Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756770AbdLPLdl (ORCPT ); Sat, 16 Dec 2017 06:33:41 -0500 Received: from mx2.suse.de ([195.135.220.15]:44319 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753124AbdLPLdj (ORCPT ); Sat, 16 Dec 2017 06:33:39 -0500 Date: Sat, 16 Dec 2017 12:33:29 +0100 From: Michal Hocko To: Tetsuo Handa Cc: David Rientjes , Andrew Morton , Andrea Arcangeli , Benjamin Herrenschmidt , Paul Mackerras , Oded Gabbay , Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , David Airlie , Joerg Roedel , Doug Ledford , Jani Nikula , Mike Marciniszyn , Sean Hefty , Dimitri Sivanich , Boris Ostrovsky , =?iso-8859-1?B?Suly9G1l?= Glisse , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [patch v2 1/2] mm, mmu_notifier: annotate mmu notifiers with blockable invalidate callbacks Message-ID: <20171216113329.GF16951@dhcp22.suse.cz> References: <20171215162534.GA16951@dhcp22.suse.cz> <0c555671-9214-5cb9-0121-5da04faf5329@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0c555671-9214-5cb9-0121-5da04faf5329@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1739 Lines: 46 On Sat 16-12-17 15:21:51, Tetsuo Handa wrote: > On 2017/12/16 1:25, Michal Hocko wrote: > >> struct mmu_notifier_ops { > >> + /* > >> + * Flags to specify behavior of callbacks for this MMU notifier. > >> + * Used to determine which context an operation may be called. > >> + * > >> + * MMU_INVALIDATE_DOES_NOT_BLOCK: invalidate_{start,end} does not > >> + * block > >> + */ > >> + int flags; > > > > This should be more specific IMHO. What do you think about the following > > wording? > > > > invalidate_{start,end,range} doesn't block on any locks which depend > > directly or indirectly (via lock chain or resources e.g. worker context) > > on a memory allocation. > > I disagree. It needlessly complicates validating the correctness. But it makes it clear what is the actual semantic. > What if the invalidate_{start,end} calls schedule_timeout_idle(10 * HZ) ? Let's talk seriously about a real code. Any mmu notifier doing this is just crazy and should be fixed. > schedule_timeout_idle() will not block on any locks which depend directly or > indirectly on a memory allocation, but we are already blocking other memory > allocating threads at mutex_trylock(&oom_lock) in __alloc_pages_may_oom(). Then the reaper will block and progress would be slower. > This is essentially same with "sleeping forever due to schedule_timeout_killable(1) by > SCHED_IDLE thread with oom_lock held" versus "looping due to mutex_trylock(&oom_lock) > by all other allocating threads" lockup problem. The OOM reaper does not want to get > blocked for so long. Yes, it absolutely doesn't want to do that. MMu notifiers should be reasonable because they are called from performance sensitive call paths. -- Michal Hocko SUSE Labs