Skip to content

Commit 4610ba7

Browse files
committed
exit/exec: Seperate mm_release()
mm_release() contains the futex exit handling. mm_release() is called from do_exit()->exit_mm() and from exec()->exec_mm(). In the exit_mm() case PF_EXITING and the futex state is updated. In the exec_mm() case these states are not touched. As the futex exit code needs further protections against exit races, this needs to be split into two functions. Preparatory only, no functional change. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 3d4775d commit 4610ba7

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

fs/exec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ static int exec_mmap(struct mm_struct *mm)
10151015
/* Notify parent that we're no longer interested in the old VM */
10161016
tsk = current;
10171017
old_mm = current->mm;
1018-
mm_release(tsk, old_mm);
1018+
exec_mm_release(tsk, old_mm);
10191019

10201020
if (old_mm) {
10211021
sync_mm_rss(old_mm);

include/linux/sched/mm.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ extern struct mm_struct *get_task_mm(struct task_struct *task);
117117
* succeeds.
118118
*/
119119
extern struct mm_struct *mm_access(struct task_struct *task, unsigned int mode);
120-
/* Remove the current tasks stale references to the old mm_struct */
121-
extern void mm_release(struct task_struct *, struct mm_struct *);
120+
/* Remove the current tasks stale references to the old mm_struct on exit() */
121+
extern void exit_mm_release(struct task_struct *, struct mm_struct *);
122+
/* Remove the current tasks stale references to the old mm_struct on exec() */
123+
extern void exec_mm_release(struct task_struct *, struct mm_struct *);
122124

123125
#ifdef CONFIG_MEMCG
124126
extern void mm_update_next_owner(struct mm_struct *mm);

kernel/exit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ static void exit_mm(void)
437437
struct mm_struct *mm = current->mm;
438438
struct core_state *core_state;
439439

440-
mm_release(current, mm);
440+
exit_mm_release(current, mm);
441441
if (!mm)
442442
return;
443443
sync_mm_rss(mm);

kernel/fork.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ static int wait_for_vfork_done(struct task_struct *child,
12831283
* restoring the old one. . .
12841284
* Eric Biederman 10 January 1998
12851285
*/
1286-
void mm_release(struct task_struct *tsk, struct mm_struct *mm)
1286+
static void mm_release(struct task_struct *tsk, struct mm_struct *mm)
12871287
{
12881288
/* Get rid of any futexes when releasing the mm */
12891289
futex_mm_release(tsk);
@@ -1320,6 +1320,16 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
13201320
complete_vfork_done(tsk);
13211321
}
13221322

1323+
void exit_mm_release(struct task_struct *tsk, struct mm_struct *mm)
1324+
{
1325+
mm_release(tsk, mm);
1326+
}
1327+
1328+
void exec_mm_release(struct task_struct *tsk, struct mm_struct *mm)
1329+
{
1330+
mm_release(tsk, mm);
1331+
}
1332+
13231333
/**
13241334
* dup_mm() - duplicates an existing mm structure
13251335
* @tsk: the task_struct with which the new mm will be associated.

0 commit comments

Comments
 (0)