rseq: Eliminate useless task_work on execve
Subsystems (3)
RFC PATCH 1/1 rseq: Eliminate useless task_work on execve
Eliminate a useless task_work on execve by moving the call to rseq_set_notify_resume() from sched_mm_cid_after_execve() to the error path of bprm_execve(),
The call to rseq_set_notify_resume() from sched_mm_cid_after_execve() is pointless in the success case, because rseq_execve() will clear the rseq pointer before returning to userspace.
sched_mm_cid_after_execve() is called from both the success and error paths of bprm_execve(). The call to rseq_set_notify_resume() is needed on error because the mm_cid may have changed.
--- fs/exec.c | 3 ++- kernel/sched/core.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-)
fs/exec.c +2 -1
@@ -1861,10 +1861,10 @@ static int bprm_execve(struct linux_binprm *bprm) goto out;sched_mm_cid_after_execve (current); +rseq_execve (current);/* execve succeeded */ current->fs->in_exec =0 ; current->in_execve =0 ; -rseq_execve (current);user_events_execve (current);acct_update_integrals (current);task_numa_free (current, false);
@@ -1881,6 +1881,7 @@ static int bprm_execve(struct linux_binprm *bprm)force_fatal_sig (SIGSEGV );sched_mm_cid_after_execve (current); +rseq_set_notify_resume (t); current->fs->in_exec =0 ; current->in_execve =0 ;
kernel/sched/core.c +0 -1
@@ -10652,7 +10652,6 @@ void sched_mm_cid_after_execve(struct task_struct *t)smp_mb (); t->last_mm_cid = t->mm_cid =mm_cid_get (rq, t, mm); } -rseq_set_notify_resume (t); }void sched_mm_cid_fork (struct task_struct *t)
Signature · 1 line
2.39.5
Quoted 42 lines · Mathieu Desnoyers
Eliminate a useless
task_workon execve by moving the call torseq_set_notify_resume()fromsched_mm_cid_after_execve()to the error path ofbprm_execve(),The call to
rseq_set_notify_resume()fromsched_mm_cid_after_execve()is pointless in the success case, becauserseq_execve()will clear the rseq pointer before returning to userspace.
sched_mm_cid_after_execve()is called from both the success and error paths ofbprm_execve(). The call torseq_set_notify_resume()is needed on error because themm_cidmay have changed.Reported-by Mateusz Guzik <[email protected]>Signed-off-by Mathieu Desnoyers <[email protected]>Cc Ingo Molnar <[email protected]>Cc Peter Zijlstra (Intel) <[email protected]>Cc "Paul E. McKenney" <[email protected]>Cc Boqun Feng <[email protected]>Cc Michael Jeanson <[email protected]>Cc Mateusz Guzik <[email protected]>--- fs/exec.c | 3 ++- kernel/sched/core.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-)fs/exec.c +1
-1@@ -1861,10 +1861,10 @@ static int bprm_execve(struct linux_binprm *bprm) goto out;sched_mm_cid_after_execve (current); +rseq_execve (current);/* execve succeeded */ current->fs->in_exec =0 ; current->in_execve =0 ; -rseq_execve (current);user_events_execve (current);acct_update_integrals (current);task_numa_free (current, false);
fs/exec.c static int bprm_execve(struct linux_binprm *bprm) · line 1884
Quoted 4 lines
fs/exec.c +1
-0@@ -1881,6 +1881,7 @@ static int bprm_execve(struct linux_binprm *bprm)force_fatal_sig (SIGSEGV );sched_mm_cid_after_execve (current); +rseq_set_notify_resume (t);
t -> current. will send a v2.
Quoted 15 lines
fs/exec.c +0
-0current->fs->in_exec =0 ; current->in_execve =0 ;kernel/sched/core.c +0
-1@@ -10652,7 +10652,6 @@ void sched_mm_cid_after_execve(struct task_struct *t)smp_mb (); t->last_mm_cid = t->mm_cid =mm_cid_get (rq, t, mm); } -rseq_set_notify_resume (t); }void sched_mm_cid_fork (struct task_struct *t)
Signature · 3 lines
Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com