include/linux/sched/mm.h: uninline mmdrop_async(), etc
Subsystems (3)
[email protected]
maintainerPATCH 30/119 include/linux/sched/mm.h: uninline mmdrop_async(), etc
From: Andrew Morton <[email protected]>
Subject: include/linux/sched/mm.h: uninline mmdrop_async(), etc
mmdrop_async() is only used in fork.c. Move that and its support functions into fork.c, uninline it all.
Quite a lot of code gets moved around to avoid forward declarations.
---
include/linux/sched/mm.h | 24 - kernel/fork.c | 448 +++++++++++++++++++------------------ 2 files changed, 238 insertions(+), 234 deletions(-)
include/linux/sched/mm.h renamed from include/linux/sched/mm.h~include-linux-sched-mmh-uninline-mmdrop_async-etc +2 -22
@@ -11,7 +11,7 @@/* * Routines for handling mm_structs */ -extern struct mm_struct *mm_alloc (void ); +extern struct mm_struct *mm_alloc (void );/** * mmgrab() - Pin a &struct mm_struct.
@@ -35,27 +35,7 @@ static inline void mmgrab(struct mm_struatomic_inc (&mm->mm_count); } -/* mmdrop drops the mm and the page tables */ -extern void __mmdrop (struct mm_struct *); -static inline void mmdrop (struct mm_struct *mm) -{ -if (unlikely (atomic_dec_and_test (&mm->mm_count))) -__mmdrop (mm); -} - -static inline void mmdrop_async_fn (struct work_struct *work) -{ - struct mm_struct *mm = container_of(work, struct mm_struct, async_put_work); -__mmdrop (mm); -} - -static inline void mmdrop_async (struct mm_struct *mm) -{ -if (unlikely (atomic_dec_and_test (&mm->mm_count))) { -INIT_WORK (&mm->async_put_work, mmdrop_async_fn); -schedule_work (&mm->async_put_work); - } -} +extern void mmdrop (struct mm_struct *mm);/** * mmget() - Pin the address space associated with a &struct mm_struct.
kernel/fork.c renamed from kernel/fork.c~include-linux-sched-mmh-uninline-mmdrop_async-etc +236 -211
476 lines not on this page · raw message
A message that is not in the archive (sent off-list or not yet received): [email protected]
Andrew Morton
maintainerQuoted 9 lines · On Thu, 1 Feb 2018 10:40:30 +0100 Peter Zijlstra <[email protected]> wrote:
Review
Quoted 5 lines · On Wed, Jan 31, 2018 at 04:15:51PM -0800, [email protected] wrote:
(quoted diff) +0
-5-static inline void mmdrop(struct mm_struct *mm) -{ - if (unlikely(atomic_dec_and_test(&mm->mm_count))) - __mmdrop(mm); -}I would prefer to keep that inline. Doing a CALL+RET for just the decrement is a bit silly methinks.
Good point. I'll let this bake for a while:
From: Andrew Morton <[email protected]>
Subject: include/linux/sched/mm.h: re-inline mmdrop()
As Peter points out, Doing a CALL+RET for just the decrement is a bit silly.
---
include/linux/sched/mm.h | 8 +++++++- kernel/fork.c | 10 ++-------- 2 files changed, 9 insertions(+), 9 deletions(-)
include/linux/sched/mm.h renamed from include/linux/sched/mm.h~a +7 -1
@@ -35,7 +35,13 @@ static inline void mmgrab(struct mm_struatomic_inc (&mm->mm_count); } -extern void mmdrop (struct mm_struct *mm); +extern void __mmdrop (struct mm_struct *mm); + +static inline void mmdrop (struct mm_struct *mm) +{ +if (unlikely (atomic_dec_and_test (&mm->mm_count))) +__mmdrop (mm); +}/** * mmget() - Pin the address space associated with a &struct mm_struct.
kernel/fork.c renamed from kernel/fork.c~a +1 -1
@@ -591,7 +591,7 @@ static void check_mm(struct mm_struct *m* is dropped: either by a lazy thread or by * mmput. Free the page directory and the mm. */ -static void __mmdrop (struct mm_struct *mm) +void __mmdrop (struct mm_struct *mm) {BUG_ON (mm == &init_mm);mm_free_pgd (mm);
@@ -602,13 +602,7 @@ static void __mmdrop(struct mm_struct *mput_user_ns (mm->user_ns);free_mm (mm); }