diff --git a/fs/aio.c b/fs/aio.c index c72b2c51b446ce5fe72fe66bd5a7238ea3f6a89d..1a78979663dca98aee2219e8818bc917e50f3f28 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1761,7 +1761,7 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync, list_del_init(&req->wait.entry); list_del(&iocb->ki_list); iocb->ki_res.res = mangle_poll(mask); - if (iocb->ki_eventfd && eventfd_signal_count()) { + if (iocb->ki_eventfd && !eventfd_signal_allowed()) { iocb = NULL; INIT_WORK(&req->work, aio_poll_put_work); schedule_work(&req->work); diff --git a/fs/eventfd.c b/fs/eventfd.c index df466ef81dddfa05c6e6b3f90eaf0a8a352b53a7..9035ca60bfcf3548ee1d48ace5e70a8b36c967ea 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -25,8 +25,6 @@ #include #include -DEFINE_PER_CPU(int, eventfd_wake_count); - static DEFINE_IDA(eventfd_ida); struct eventfd_ctx { @@ -67,21 +65,21 @@ __u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n) * Deadlock or stack overflow issues can happen if we recurse here * through waitqueue wakeup handlers. If the caller users potentially * nested waitqueues with custom wakeup handlers, then it should - * check eventfd_signal_count() before calling this function. If - * it returns true, the eventfd_signal() call should be deferred to a + * check eventfd_signal_allowed() before calling this function. If + * it returns false, the eventfd_signal() call should be deferred to a * safe context. */ - if (WARN_ON_ONCE(this_cpu_read(eventfd_wake_count))) + if (WARN_ON_ONCE(current->in_eventfd_signal)) return 0; spin_lock_irqsave(&ctx->wqh.lock, flags); - this_cpu_inc(eventfd_wake_count); + current->in_eventfd_signal = 1; if (ULLONG_MAX - ctx->count < n) n = ULLONG_MAX - ctx->count; ctx->count += n; if (waitqueue_active(&ctx->wqh)) wake_up_locked_poll(&ctx->wqh, EPOLLIN); - this_cpu_dec(eventfd_wake_count); + current->in_eventfd_signal = 0; spin_unlock_irqrestore(&ctx->wqh.lock, flags); return n; diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h index dc4fd8a6644dd62da4837ebc7e9d20a24716e59a..836b4c021a0a42f1f6c41c2e2f371f5204868a6b 100644 --- a/include/linux/eventfd.h +++ b/include/linux/eventfd.h @@ -14,6 +14,7 @@ #include #include #include +#include /* * CAREFUL: Check include/uapi/asm-generic/fcntl.h when defining @@ -42,11 +43,9 @@ __u64 eventfd_signal(struct eventfd_ctx *ctx, __u64 n); int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_entry_t *wait, __u64 *cnt); -DECLARE_PER_CPU(int, eventfd_wake_count); - -static inline bool eventfd_signal_count(void) +static inline bool eventfd_signal_allowed(void) { - return this_cpu_read(eventfd_wake_count); + return !current->in_eventfd_signal; } #else /* CONFIG_EVENTFD */ @@ -77,9 +76,9 @@ static inline int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, return -ENOSYS; } -static inline bool eventfd_signal_count(void) +static inline bool eventfd_signal_allowed(void) { - return false; + return true; } #endif diff --git a/include/linux/sched.h b/include/linux/sched.h index d59aa4f198d965e90e30fe2a186438f874d0db72..d81141fb759891134910f80e275c44bdb34b0a2d 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -836,6 +836,10 @@ struct task_struct { #ifdef CONFIG_BLK_DEV_IO_TRACE unsigned int btrace_seq; #endif +#ifdef CONFIG_EVENTFD + /* Recursion prevention for eventfd_signal() */ + unsigned in_eventfd_signal:1; +#endif unsigned int policy; int nr_cpus_allowed; diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 3356e03540134c1c1b9139e73950763d4d55eaf6..5fabcfdfcebaf81ae0b8765ad528f9352700d62a 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c @@ -2495,7 +2495,7 @@ ww_mutex_lock_interruptible(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) return ret; } -EXPORT_SYMBOL_GPL(ww_mutex_lock_interruptible); +EXPORT_SYMBOL(ww_mutex_lock_interruptible); int __sched ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) @@ -2515,7 +2515,7 @@ ww_mutex_lock(struct ww_mutex *lock, struct ww_acquire_ctx *ctx) return ret; } -EXPORT_SYMBOL_GPL(ww_mutex_lock); +EXPORT_SYMBOL(ww_mutex_lock); void __sched ww_mutex_unlock(struct ww_mutex *lock) { diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 725ee6710d259f0282d9ecc6c3c03af0e31d914b..eae5db7094e0e2fb8d1dc8214b1d9b60b4a73d16 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c @@ -51,7 +51,11 @@ static bool stop_machine_initialized = false; void print_stop_info(const char *log_lvl, struct task_struct *task) { - struct cpu_stopper *stopper = this_cpu_ptr(&cpu_stopper); + /* + * If @task is a stopper task, it cannot migrate and task_cpu() is + * stable. + */ + struct cpu_stopper *stopper = per_cpu_ptr(&cpu_stopper, task_cpu(task)); if (task != stopper->thread) return; diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c index fff2225847c40b35c2598e64ad341d9188242432..3c6229f16e81d179658305ae551916ab6a724955 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -1220,12 +1220,10 @@ stacktrace_trigger(struct event_trigger_data *data, void *rec, struct ring_buffer_event *event) { struct trace_event_file *file = data->private_data; - unsigned long flags; - if (file) { - local_save_flags(flags); - __trace_stack(file->tr, flags, STACK_SKIP); - } else + if (file) + __trace_stack(file->tr, tracing_gen_ctx(), STACK_SKIP); + else trace_dump_stack(STACK_SKIP); } diff --git a/localversion-rt b/localversion-rt index 21988f9ad53f1e18eabcac745d17451bd07f614e..e8ada8cdb471ea981dda20a3895c3ab91a68c873 100644 --- a/localversion-rt +++ b/localversion-rt @@ -1 +1 @@ --rt34 +-rt73