Skip to content

Commit

Permalink
x86/mm: Use mm_alloc() in poking_init()
Browse files Browse the repository at this point in the history
Instead of duplicating init_mm, allocate a fresh mm. The advantage is
that mm_alloc() has much simpler dependencies. Additionally it makes
more conceptual sense, init_mm has no (and must not have) user state
to duplicate.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20221025201057.816175235@infradead.org
  • Loading branch information
Peter Zijlstra authored and Dave Hansen committed Dec 15, 2022
1 parent af80602 commit 3f4c821
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 7 deletions.
2 changes: 1 addition & 1 deletion arch/x86/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ void __init poking_init(void)
spinlock_t *ptl;
pte_t *ptep;

poking_mm = copy_init_mm();
poking_mm = mm_alloc();
BUG_ON(!poking_mm);

/*
Expand Down
1 change: 0 additions & 1 deletion include/linux/sched/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ extern void exit_itimers(struct task_struct *);
extern pid_t kernel_clone(struct kernel_clone_args *kargs);
struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node);
struct task_struct *fork_idle(int);
struct mm_struct *copy_init_mm(void);
extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
extern pid_t user_mode_thread(int (*fn)(void *), void *arg, unsigned long flags);
extern long kernel_wait4(pid_t, int __user *, int, struct rusage *);
Expand Down
5 changes: 0 additions & 5 deletions kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -2592,11 +2592,6 @@ struct task_struct * __init fork_idle(int cpu)
return task;
}

struct mm_struct *copy_init_mm(void)
{
return dup_mm(NULL, &init_mm);
}

/*
* This is like kernel_clone(), but shaved down and tailored to just
* creating io_uring workers. It returns a created task, or an error pointer.
Expand Down

0 comments on commit 3f4c821

Please sign in to comment.