From: Jens Axboe Date: Mon, 9 Nov 2020 14:19:32 +0000 (-0700) Subject: Merge tag 'core-entry-notify-signal' of git://git.kernel.org/pub/scm/linux/kernel... X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=29701d69b98d0a132abd63fe2e51125f478fbc53;p=linux.git Merge tag 'core-entry-notify-signal' of git://git./linux/kernel/git/tip/tip into tif-task_work.arch Core changes to support TASK_NOTIFY_SIGNAL * tag 'core-entry-notify-signal' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: task_work: Use TIF_NOTIFY_SIGNAL if available entry: Add support for TIF_NOTIFY_SIGNAL signal: Add task_sigpending() helper --- 29701d69b98d0a132abd63fe2e51125f478fbc53 diff --cc include/linux/entry-common.h index 474f29638d2c9,c7bfac45f9516..b9711e813ec2d --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@@ -37,8 -37,12 +37,12 @@@ # define _TIF_UPROBE (0) #endif + #ifndef _TIF_NOTIFY_SIGNAL + # define _TIF_NOTIFY_SIGNAL (0) + #endif + /* - * TIF flags handled in syscall_enter_from_usermode() + * TIF flags handled in syscall_enter_from_user_mode() */ #ifndef ARCH_SYSCALL_ENTER_WORK # define ARCH_SYSCALL_ENTER_WORK (0) diff --cc kernel/entry/common.c index e9e2df3f3f9ee,42eff115c4269..33bb5f9f399cd --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@@ -157,10 -139,11 +165,10 @@@ static unsigned long exit_to_user_mode_ if (ti_work & _TIF_PATCH_PENDING) klp_update_patch_state(current); - if (ti_work & _TIF_SIGPENDING) - arch_do_signal(regs); + if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) + handle_signal_work(regs, ti_work); if (ti_work & _TIF_NOTIFY_RESUME) { - clear_thread_flag(TIF_NOTIFY_RESUME); tracehook_notify_resume(regs); rseq_handle_notify_resume(NULL, regs); } diff --cc kernel/task_work.c index 8d6e1217c451c,ae058893913ce..15b087286bea4 --- a/kernel/task_work.c +++ b/kernel/task_work.c @@@ -29,11 -52,10 +57,10 @@@ static void task_work_notify_signal(str * RETURNS: * 0 if succeeds or -ESRCH. */ -int -task_work_add(struct task_struct *task, struct callback_head *work, int notify) +int task_work_add(struct task_struct *task, struct callback_head *work, + enum task_work_notify_mode notify) { struct callback_head *head; - unsigned long flags; do { head = READ_ONCE(task->task_works); @@@ -49,21 -69,8 +76,11 @@@ set_notify_resume(task); break; case TWA_SIGNAL: - /* - * Only grab the sighand lock if we don't already have some - * task_work pending. This pairs with the smp_store_mb() - * in get_signal(), see comment there. - */ - if (!(READ_ONCE(task->jobctl) & JOBCTL_TASK_WORK) && - lock_task_sighand(task, &flags)) { - task->jobctl |= JOBCTL_TASK_WORK; - signal_wake_up(task, 0); - unlock_task_sighand(task, &flags); - } + task_work_notify_signal(task); break; + default: + WARN_ON_ONCE(1); + break; } return 0;