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 <tglx@linutronix.de> Reviewed-by: Ingo Molnar <mingo@kernel.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20191106224556.240518241@linutronix.de
This commit is contained in:
parent
3d4775df0a
commit
4610ba7ad8
|
@ -1015,7 +1015,7 @@ static int exec_mmap(struct mm_struct *mm)
|
||||||
/* Notify parent that we're no longer interested in the old VM */
|
/* Notify parent that we're no longer interested in the old VM */
|
||||||
tsk = current;
|
tsk = current;
|
||||||
old_mm = current->mm;
|
old_mm = current->mm;
|
||||||
mm_release(tsk, old_mm);
|
exec_mm_release(tsk, old_mm);
|
||||||
|
|
||||||
if (old_mm) {
|
if (old_mm) {
|
||||||
sync_mm_rss(old_mm);
|
sync_mm_rss(old_mm);
|
||||||
|
|
|
@ -117,8 +117,10 @@ extern struct mm_struct *get_task_mm(struct task_struct *task);
|
||||||
* succeeds.
|
* succeeds.
|
||||||
*/
|
*/
|
||||||
extern struct mm_struct *mm_access(struct task_struct *task, unsigned int mode);
|
extern struct mm_struct *mm_access(struct task_struct *task, unsigned int mode);
|
||||||
/* Remove the current tasks stale references to the old mm_struct */
|
/* Remove the current tasks stale references to the old mm_struct on exit() */
|
||||||
extern void mm_release(struct task_struct *, struct mm_struct *);
|
extern void exit_mm_release(struct task_struct *, struct mm_struct *);
|
||||||
|
/* Remove the current tasks stale references to the old mm_struct on exec() */
|
||||||
|
extern void exec_mm_release(struct task_struct *, struct mm_struct *);
|
||||||
|
|
||||||
#ifdef CONFIG_MEMCG
|
#ifdef CONFIG_MEMCG
|
||||||
extern void mm_update_next_owner(struct mm_struct *mm);
|
extern void mm_update_next_owner(struct mm_struct *mm);
|
||||||
|
|
|
@ -437,7 +437,7 @@ static void exit_mm(void)
|
||||||
struct mm_struct *mm = current->mm;
|
struct mm_struct *mm = current->mm;
|
||||||
struct core_state *core_state;
|
struct core_state *core_state;
|
||||||
|
|
||||||
mm_release(current, mm);
|
exit_mm_release(current, mm);
|
||||||
if (!mm)
|
if (!mm)
|
||||||
return;
|
return;
|
||||||
sync_mm_rss(mm);
|
sync_mm_rss(mm);
|
||||||
|
|
|
@ -1283,7 +1283,7 @@ static int wait_for_vfork_done(struct task_struct *child,
|
||||||
* restoring the old one. . .
|
* restoring the old one. . .
|
||||||
* Eric Biederman 10 January 1998
|
* Eric Biederman 10 January 1998
|
||||||
*/
|
*/
|
||||||
void mm_release(struct task_struct *tsk, struct mm_struct *mm)
|
static void mm_release(struct task_struct *tsk, struct mm_struct *mm)
|
||||||
{
|
{
|
||||||
/* Get rid of any futexes when releasing the mm */
|
/* Get rid of any futexes when releasing the mm */
|
||||||
futex_mm_release(tsk);
|
futex_mm_release(tsk);
|
||||||
|
@ -1320,6 +1320,16 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
|
||||||
complete_vfork_done(tsk);
|
complete_vfork_done(tsk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void exit_mm_release(struct task_struct *tsk, struct mm_struct *mm)
|
||||||
|
{
|
||||||
|
mm_release(tsk, mm);
|
||||||
|
}
|
||||||
|
|
||||||
|
void exec_mm_release(struct task_struct *tsk, struct mm_struct *mm)
|
||||||
|
{
|
||||||
|
mm_release(tsk, mm);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dup_mm() - duplicates an existing mm structure
|
* dup_mm() - duplicates an existing mm structure
|
||||||
* @tsk: the task_struct with which the new mm will be associated.
|
* @tsk: the task_struct with which the new mm will be associated.
|
||||||
|
|
Loading…
Reference in New Issue