Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751452AbdINITd (ORCPT ); Thu, 14 Sep 2017 04:19:33 -0400 Received: from mx2.suse.de ([195.135.220.15]:35239 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751188AbdINITc (ORCPT ); Thu, 14 Sep 2017 04:19:32 -0400 Date: Thu, 14 Sep 2017 10:19:29 +0200 From: Michal Hocko To: Sherry Yang Cc: linux-kernel@vger.kernel.org, tkjos@google.com, maco@google.com, arve@android.com, gregkh@linuxfoundation.org, Ingo Molnar , Andrew Morton , Vlastimil Babka , David Rientjes , Andrea Arcangeli , Peter Zijlstra , Thomas Gleixner , Andy Lutomirski , Oleg Nesterov , Hoeun Ryu , Christoph Lameter , Vegard Nossum , Frederic Weisbecker Subject: Re: [PATCH] mm: Restore mmput_async Message-ID: <20170914081929.um7lszeqtkesdtx3@dhcp22.suse.cz> References: <20170908223934.67442-1-sherryy@android.com> <20170913215932.86846-1-sherryy@android.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170913215932.86846-1-sherryy@android.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2324 Lines: 76 On Wed 13-09-17 17:59:27, Sherry Yang wrote: > Restore asynchronous mmput, allowing mmput_async to be called > from an atomic context in Android binder shrinker callback. > > mmput_async was initially introduced in ec8d7c14e > ("mm, oom_reaper: do not mmput synchronously from the > oom reaper context"), and was removed in 212925802 > ("mm: oom: let oom_reap_task and exit_mmap run concurrently") > > Signed-off-by: Sherry Yang I would just fold this into https://lkml.org/lkml/2017/9/8/785. The patch is simple enough to take this in one go and it will be clear who and why needs to restore the api. No objections otherwise. Acked-by: Michal Hocko > --- > include/linux/sched/mm.h | 6 ++++++ > kernel/fork.c | 18 ++++++++++++++++++ > 2 files changed, 24 insertions(+) > > diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h > index 3a19c253bdb1..ae53e413fb13 100644 > --- a/include/linux/sched/mm.h > +++ b/include/linux/sched/mm.h > @@ -84,6 +84,12 @@ static inline bool mmget_not_zero(struct mm_struct *mm) > > /* mmput gets rid of the mappings and all user-space */ > extern void mmput(struct mm_struct *); > +#ifdef CONFIG_MMU > +/* same as above but performs the slow path from the async context. Can > + * be called from the atomic context as well > + */ > +void mmput_async(struct mm_struct *); > +#endif > > /* Grab a reference to a task's mm, if it is not already going away */ > extern struct mm_struct *get_task_mm(struct task_struct *task); > diff --git a/kernel/fork.c b/kernel/fork.c > index 10646182440f..e702cb9ffbd8 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -946,6 +946,24 @@ void mmput(struct mm_struct *mm) > } > EXPORT_SYMBOL_GPL(mmput); > > +#ifdef CONFIG_MMU > +static void mmput_async_fn(struct work_struct *work) > +{ > + struct mm_struct *mm = container_of(work, struct mm_struct, > + async_put_work); > + > + __mmput(mm); > +} > + > +void mmput_async(struct mm_struct *mm) > +{ > + if (atomic_dec_and_test(&mm->mm_users)) { > + INIT_WORK(&mm->async_put_work, mmput_async_fn); > + schedule_work(&mm->async_put_work); > + } > +} > +#endif > + > /** > * set_mm_exe_file - change a reference to the mm's executable file > * > -- > 2.11.0 (Apple Git-81) > -- Michal Hocko SUSE Labs