Skip to content

Commit 169eae7

Browse files
compudjIngo Molnar
authored andcommitted
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. Also move the rseq_execve() to right after sched_mm_cid_after_execve() in bprm_execve(). [ mingo: Merged to a recent upstream kernel, extended the changelog. ] Signed-off-by: Mathieu Desnoyers <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9757768 commit 169eae7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

fs/exec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1864,9 +1864,9 @@ static int bprm_execve(struct linux_binprm *bprm)
18641864
goto out;
18651865

18661866
sched_mm_cid_after_execve(current);
1867+
rseq_execve(current);
18671868
/* execve succeeded */
18681869
current->in_execve = 0;
1869-
rseq_execve(current);
18701870
user_events_execve(current);
18711871
acct_update_integrals(current);
18721872
task_numa_free(current, false);
@@ -1883,6 +1883,7 @@ static int bprm_execve(struct linux_binprm *bprm)
18831883
force_fatal_sig(SIGSEGV);
18841884

18851885
sched_mm_cid_after_execve(current);
1886+
rseq_set_notify_resume(current);
18861887
current->in_execve = 0;
18871888

18881889
return retval;

kernel/sched/core.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10703,7 +10703,6 @@ void sched_mm_cid_after_execve(struct task_struct *t)
1070310703
smp_mb();
1070410704
t->last_mm_cid = t->mm_cid = mm_cid_get(rq, t, mm);
1070510705
}
10706-
rseq_set_notify_resume(t);
1070710706
}
1070810707

1070910708
void sched_mm_cid_fork(struct task_struct *t)

0 commit comments

Comments
 (0)