Skip to content

Commit

Permalink
tracehook: clear TIF_NOTIFY_RESUME in tracehook_notify_resume()
Browse files Browse the repository at this point in the history
All the callers currently do this, clean it up and move the clearing
into tracehook_notify_resume() instead.

Reviewed-by: Oleg Nesterov <[email protected]>
Reviewed-by: Thomas Gleixner <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Oct 17, 2020
1 parent 324bcf5 commit 3c53279
Show file tree
Hide file tree
Showing 27 changed files with 18 additions and 46 deletions.
1 change: 0 additions & 1 deletion arch/alpha/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ do_work_pending(struct pt_regs *regs, unsigned long thread_flags,
do_signal(regs, r0, r19);
r0 = 0;
} else {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
}
}
Expand Down
2 changes: 1 addition & 1 deletion arch/arc/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,6 @@ void do_notify_resume(struct pt_regs *regs)
* ASM glue gaurantees that this is only called when returning to
* user mode
*/
if (test_and_clear_thread_flag(TIF_NOTIFY_RESUME))
if (test_thread_flag(TIF_NOTIFY_RESUME))
tracehook_notify_resume(regs);
}
1 change: 0 additions & 1 deletion arch/arm/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,6 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
} else if (thread_flags & _TIF_UPROBE) {
uprobe_notify_resume(regs);
} else {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
rseq_handle_notify_resume(NULL, regs);
}
Expand Down
1 change: 0 additions & 1 deletion arch/arm64/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,6 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
do_signal(regs);

if (thread_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
rseq_handle_notify_resume(NULL, regs);
}
Expand Down
4 changes: 1 addition & 3 deletions arch/c6x/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,6 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, u32 thread_info_flags,
if (thread_info_flags & (1 << TIF_SIGPENDING))
do_signal(regs, syscall);

if (thread_info_flags & (1 << TIF_NOTIFY_RESUME)) {
clear_thread_flag(TIF_NOTIFY_RESUME);
if (thread_info_flags & (1 << TIF_NOTIFY_RESUME))
tracehook_notify_resume(regs);
}
}
1 change: 0 additions & 1 deletion arch/csky/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
do_signal(regs);

if (thread_info_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
rseq_handle_notify_resume(NULL, regs);
}
Expand Down
4 changes: 1 addition & 3 deletions arch/h8300/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,6 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, u32 thread_info_flags)
if (thread_info_flags & _TIF_SIGPENDING)
do_signal(regs);

if (thread_info_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
if (thread_info_flags & _TIF_NOTIFY_RESUME)
tracehook_notify_resume(regs);
}
}
1 change: 0 additions & 1 deletion arch/hexagon/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ int do_work_pending(struct pt_regs *regs, u32 thread_info_flags)
}

if (thread_info_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ do_notify_resume_user(sigset_t *unused, struct sigscratch *scr, long in_syscall)
ia64_do_signal(scr, in_syscall);
}

if (test_and_clear_thread_flag(TIF_NOTIFY_RESUME)) {
if (test_thread_flag(TIF_NOTIFY_RESUME)) {
local_irq_enable(); /* force interrupt enable */
tracehook_notify_resume(&scr->pt);
}
Expand Down
2 changes: 1 addition & 1 deletion arch/m68k/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,6 @@ void do_notify_resume(struct pt_regs *regs)
if (test_thread_flag(TIF_SIGPENDING))
do_signal(regs);

if (test_and_clear_thread_flag(TIF_NOTIFY_RESUME))
if (test_thread_flag(TIF_NOTIFY_RESUME))
tracehook_notify_resume(regs);
}
2 changes: 1 addition & 1 deletion arch/microblaze/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,6 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, int in_syscall)
if (test_thread_flag(TIF_SIGPENDING))
do_signal(regs, in_syscall);

if (test_and_clear_thread_flag(TIF_NOTIFY_RESUME))
if (test_thread_flag(TIF_NOTIFY_RESUME))
tracehook_notify_resume(regs);
}
1 change: 0 additions & 1 deletion arch/mips/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,6 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused,
do_signal(regs);

if (thread_info_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
rseq_handle_notify_resume(NULL, regs);
}
Expand Down
4 changes: 1 addition & 3 deletions arch/nds32/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,6 @@ do_notify_resume(struct pt_regs *regs, unsigned int thread_flags)
if (thread_flags & _TIF_SIGPENDING)
do_signal(regs);

if (thread_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
if (thread_flags & _TIF_NOTIFY_RESUME)
tracehook_notify_resume(regs);
}
}
2 changes: 1 addition & 1 deletion arch/nios2/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ asmlinkage int do_notify_resume(struct pt_regs *regs)
*/
return restart;
}
} else if (test_and_clear_thread_flag(TIF_NOTIFY_RESUME))
} else if (test_thread_flag(TIF_NOTIFY_RESUME))
tracehook_notify_resume(regs);

return 0;
Expand Down
1 change: 0 additions & 1 deletion arch/openrisc/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
}
syscall = 0;
} else {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
}
}
Expand Down
4 changes: 1 addition & 3 deletions arch/parisc/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,6 @@ void do_notify_resume(struct pt_regs *regs, long in_syscall)
if (test_thread_flag(TIF_SIGPENDING))
do_signal(regs, in_syscall);

if (test_thread_flag(TIF_NOTIFY_RESUME)) {
clear_thread_flag(TIF_NOTIFY_RESUME);
if (test_thread_flag(TIF_NOTIFY_RESUME))
tracehook_notify_resume(regs);
}
}
1 change: 0 additions & 1 deletion arch/powerpc/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)
}

if (thread_info_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
rseq_handle_notify_resume(NULL, regs);
}
Expand Down
4 changes: 1 addition & 3 deletions arch/riscv/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,6 @@ asmlinkage __visible void do_notify_resume(struct pt_regs *regs,
if (thread_info_flags & _TIF_SIGPENDING)
do_signal(regs);

if (thread_info_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
if (thread_info_flags & _TIF_NOTIFY_RESUME)
tracehook_notify_resume(regs);
}
}
1 change: 0 additions & 1 deletion arch/s390/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,6 @@ void do_signal(struct pt_regs *regs)

void do_notify_resume(struct pt_regs *regs)
{
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
rseq_handle_notify_resume(NULL, regs);
}
4 changes: 1 addition & 3 deletions arch/sh/kernel/signal_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,6 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0,
if (thread_info_flags & _TIF_SIGPENDING)
do_signal(regs, save_r0);

if (thread_info_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
if (thread_info_flags & _TIF_NOTIFY_RESUME)
tracehook_notify_resume(regs);
}
}
4 changes: 1 addition & 3 deletions arch/sparc/kernel/signal_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,8 @@ void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0,
{
if (thread_info_flags & _TIF_SIGPENDING)
do_signal(regs, orig_i0);
if (thread_info_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
if (thread_info_flags & _TIF_NOTIFY_RESUME)
tracehook_notify_resume(regs);
}
}

asmlinkage int do_sys_sigstack(struct sigstack __user *ssptr,
Expand Down
4 changes: 1 addition & 3 deletions arch/sparc/kernel/signal_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,8 @@ void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long
uprobe_notify_resume(regs);
if (thread_info_flags & _TIF_SIGPENDING)
do_signal(regs, orig_i0);
if (thread_info_flags & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
if (thread_info_flags & _TIF_NOTIFY_RESUME)
tracehook_notify_resume(regs);
}
user_enter();
}

2 changes: 1 addition & 1 deletion arch/um/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void interrupt_end(void)
schedule();
if (test_thread_flag(TIF_SIGPENDING))
do_signal(regs);
if (test_and_clear_thread_flag(TIF_NOTIFY_RESUME))
if (test_thread_flag(TIF_NOTIFY_RESUME))
tracehook_notify_resume(regs);
}

Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,6 @@ void do_notify_resume(struct pt_regs *regs)
if (test_thread_flag(TIF_SIGPENDING))
do_signal(regs);

if (test_and_clear_thread_flag(TIF_NOTIFY_RESUME))
if (test_thread_flag(TIF_NOTIFY_RESUME))
tracehook_notify_resume(regs);
}
4 changes: 2 additions & 2 deletions include/linux/tracehook.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ static inline void set_notify_resume(struct task_struct *task)
*/
static inline void tracehook_notify_resume(struct pt_regs *regs)
{
clear_thread_flag(TIF_NOTIFY_RESUME);
/*
* The caller just cleared TIF_NOTIFY_RESUME. This barrier
* pairs with task_work_add()->set_notify_resume() after
* This barrier pairs with task_work_add()->set_notify_resume() after
* hlist_add_head(task->task_works);
*/
smp_mb__after_atomic();
Expand Down
1 change: 0 additions & 1 deletion kernel/entry/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs,
arch_do_signal(regs);

if (ti_work & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
tracehook_notify_resume(regs);
rseq_handle_notify_resume(NULL, regs);
}
Expand Down
4 changes: 1 addition & 3 deletions kernel/entry/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ static int xfer_to_guest_mode_work(struct kvm_vcpu *vcpu, unsigned long ti_work)
if (ti_work & _TIF_NEED_RESCHED)
schedule();

if (ti_work & _TIF_NOTIFY_RESUME) {
clear_thread_flag(TIF_NOTIFY_RESUME);
if (ti_work & _TIF_NOTIFY_RESUME)
tracehook_notify_resume(NULL);
}

ret = arch_xfer_to_guest_mode_handle_work(vcpu, ti_work);
if (ret)
Expand Down

0 comments on commit 3c53279

Please sign in to comment.