Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2086962ybl; Thu, 15 Aug 2019 06:23:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxs46tTnxVlCu2QhjsrYPOy/jy9YJigiZpaljyLxOcqCvmPXR0pfp7Usz4v+lwAjzEFDn8h X-Received: by 2002:a63:1341:: with SMTP id 1mr3593365pgt.48.1565875381055; Thu, 15 Aug 2019 06:23:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565875381; cv=none; d=google.com; s=arc-20160816; b=cuj1+raZHsQcB7kNTol3h9o8vH9p5BZcwmAB+g1a9bAtU9hCqFxbpxLDCi4sOFQpyp nSheM+VFAESHctH3TvyTe0c72z3CAOM/zeaIw0aQloKV6lVRtWcT4bWBy7NwAV2rj51z WKJZLbBNaR1WXvcSNRxaB5ZBf4ASZ6iy1ADGPDPyjLw98fGm94fv9MApIu9oWT1JN9s6 BUVTaPuphZ4gwliylaAJnqFtVpQi7NU/8ctHy4WlRquK4yofr8UOG10hrR4dBXF1eqP0 F0aYLGXg9t4263v1xko9/QaR/+e40fzvDlrkGDfOEP271xckA+rZoC7iD54DyX3NGRmD +yFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=JKFh+/Vz3qmbK3PTtwelfLmB/D/WxqDIyBdqe0obP2k=; b=l22hhMIywDPT2uG7g6E7tzs29qD7r/jUc3HFZufqKyjt9lm8xDDqprOX5v2X1ifwhZ nB2I+d6PGE1IEP1wCG9gXTlm1+gjz/KPv8hiVXq7klOs8Tx2fgcUUBkAsCLriJ07H4vQ 7Zw50IeuLlMwekGPQUsgYRWM0ua6iZ962LwVlM1u8fh2glE93H/duVRLf1y5pKhAWPyW sUc6XGw2JuDePp3+B9bxfdVC60iA1CRpnDFIn40rdK64cof+jiLZUxODqUe459TYSMlw XpbJlg56OzFhp1WlOHsXeZeDunLhjfusC5uM4lhRZ0qg3KOamgwKnxuHA+enFquRvCVs LcWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c11si1823724pga.118.2019.08.15.06.22.44; Thu, 15 Aug 2019 06:23:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732245AbfHONVb (ORCPT + 99 others); Thu, 15 Aug 2019 09:21:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:42698 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731822AbfHONVa (ORCPT ); Thu, 15 Aug 2019 09:21:30 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6BF77AF2D; Thu, 15 Aug 2019 13:21:28 +0000 (UTC) Date: Thu, 15 Aug 2019 15:21:27 +0200 From: Michal Hocko To: Jason Gunthorpe Cc: LKML , linux-mm@kvack.org, DRI Development , Intel Graphics Development , Peter Zijlstra , Ingo Molnar , Andrew Morton , David Rientjes , Christian =?iso-8859-1?Q?K=F6nig?= , =?iso-8859-1?B?Suly9G1l?= Glisse , Masahiro Yamada , Wei Wang , Andy Shevchenko , Thomas Gleixner , Jann Horn , Feng Tang , Kees Cook , Randy Dunlap , Daniel Vetter Subject: Re: [PATCH 2/5] kernel.h: Add non_block_start/end() Message-ID: <20190815132127.GI9477@dhcp22.suse.cz> References: <20190814202027.18735-1-daniel.vetter@ffwll.ch> <20190814202027.18735-3-daniel.vetter@ffwll.ch> <20190814235805.GB11200@ziepe.ca> <20190815065829.GA7444@phenom.ffwll.local> <20190815122344.GA21596@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190815122344.GA21596@ziepe.ca> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 15-08-19 09:23:44, Jason Gunthorpe wrote: > On Thu, Aug 15, 2019 at 08:58:29AM +0200, Daniel Vetter wrote: > > On Wed, Aug 14, 2019 at 08:58:05PM -0300, Jason Gunthorpe wrote: > > > On Wed, Aug 14, 2019 at 10:20:24PM +0200, Daniel Vetter wrote: > > > > In some special cases we must not block, but there's not a > > > > spinlock, preempt-off, irqs-off or similar critical section already > > > > that arms the might_sleep() debug checks. Add a non_block_start/end() > > > > pair to annotate these. > > > > > > > > This will be used in the oom paths of mmu-notifiers, where blocking is > > > > not allowed to make sure there's forward progress. Quoting Michal: > > > > > > > > "The notifier is called from quite a restricted context - oom_reaper - > > > > which shouldn't depend on any locks or sleepable conditionals. The code > > > > should be swift as well but we mostly do care about it to make a forward > > > > progress. Checking for sleepable context is the best thing we could come > > > > up with that would describe these demands at least partially." > > > > > > But this describes fs_reclaim_acquire() - is there some reason we are > > > conflating fs_reclaim with non-sleeping? > > > > No idea why you tie this into fs_reclaim. We can definitly sleep in there, > > and for e.g. kswapd (which also wraps everything in fs_reclaim) we're > > event supposed to I thought. To make sure we can get at the last bit of > > memory by flushing all the queues and waiting for everything to be cleaned > > out. > > AFAIK the point of fs_reclaim is to prevent "indirect dependency upon > the page allocator" ie a justification that was given this !blockable > stuff. > > For instance: > > fs_reclaim_acquire() > kmalloc(GFP_KERNEL) <- lock dep assertion > > And further, Michal's concern about indirectness through locks is also > handled by lockdep: > > CPU0 CPU1 > mutex_lock() > kmalloc(GFP_KERNEL) > mutex_unlock() > fs_reclaim_acquire() > mutex_lock() <- lock dep assertion > > In other words, to prevent recursion into the page allocator you use > fs_reclaim_acquire(), and lockdep verfies it in its usual robust way. fs_reclaim_acquire is about FS/IO recursions IIUC. We are talking about any !GFP_NOWAIT allocation context here and any {in}direct dependency on it. Whether fs_reclaim_acquire can be reused for that I do not know because I am not familiar with the lockdep machinery enough > I asked Tejun about this once in regards to WQ_MEM_RECLAIM and he > explained that it means you can't call the allocator functions in a > way that would recurse into reclaim (ie instead use instead GFP_ATOMIC, or > tolerate allocation failure, or various other things). > > So, the reason I bring it up is half the justifications you posted for > blockable had to do with not recursing into reclaim and deadlocking, > and didn't seem to have much to do with blocking. > > I'm asking if *non-blocking* is really the requirement or if this is > just the usual 'do not deadlock on the allocator' thing reclaim paths > alread have? No, non-blocking is a very coarse approximation of what we really need. But it should give us even a stronger condition. Essentially any sleep other than a preemption shouldn't be allowed in that context. -- Michal Hocko SUSE Labs