Skip to content

Commit d34bc48

Browse files
akpm00torvalds
authored andcommitted
include/linux/sched/mm.h: re-inline mmdrop()
As Peter points out, Doing a CALL+RET for just the decrement is a bit silly. Fixes: d70f2a1 ("include/linux/sched/mm.h: uninline mmdrop_async(), etc") Acked-by: Peter Zijlstra (Intel) <peterz@infraded.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7ed1c19 commit d34bc48

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

include/linux/sched/mm.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,18 @@ static inline void mmgrab(struct mm_struct *mm)
3636
atomic_inc(&mm->mm_count);
3737
}
3838

39-
extern void mmdrop(struct mm_struct *mm);
39+
extern void __mmdrop(struct mm_struct *mm);
40+
41+
static inline void mmdrop(struct mm_struct *mm)
42+
{
43+
/*
44+
* The implicit full barrier implied by atomic_dec_and_test() is
45+
* required by the membarrier system call before returning to
46+
* user-space, after storing to rq->curr.
47+
*/
48+
if (unlikely(atomic_dec_and_test(&mm->mm_count)))
49+
__mmdrop(mm);
50+
}
4051

4152
/**
4253
* mmget() - Pin the address space associated with a &struct mm_struct.

kernel/fork.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ static void check_mm(struct mm_struct *mm)
592592
* is dropped: either by a lazy thread or by
593593
* mmput. Free the page directory and the mm.
594594
*/
595-
static void __mmdrop(struct mm_struct *mm)
595+
void __mmdrop(struct mm_struct *mm)
596596
{
597597
BUG_ON(mm == &init_mm);
598598
mm_free_pgd(mm);
@@ -603,18 +603,7 @@ static void __mmdrop(struct mm_struct *mm)
603603
put_user_ns(mm->user_ns);
604604
free_mm(mm);
605605
}
606-
607-
void mmdrop(struct mm_struct *mm)
608-
{
609-
/*
610-
* The implicit full barrier implied by atomic_dec_and_test() is
611-
* required by the membarrier system call before returning to
612-
* user-space, after storing to rq->curr.
613-
*/
614-
if (unlikely(atomic_dec_and_test(&mm->mm_count)))
615-
__mmdrop(mm);
616-
}
617-
EXPORT_SYMBOL_GPL(mmdrop);
606+
EXPORT_SYMBOL_GPL(__mmdrop);
618607

619608
static void mmdrop_async_fn(struct work_struct *work)
620609
{

0 commit comments

Comments
 (0)