Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2499107imm; Mon, 28 May 2018 09:13:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrLIlNneevvZlxZH/Q7QDZJwlnd819OySe2tSmTXKmOHYUI5bUKtErPQH4GXJrioh7ibttN X-Received: by 2002:a62:62c2:: with SMTP id w185-v6mr14067974pfb.78.1527524018469; Mon, 28 May 2018 09:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527524018; cv=none; d=google.com; s=arc-20160816; b=cmS1kSPclBCHGF+/Idn1dnQ7VbIFW3LVjtIchyhSBHSSrlMU4PvkRjl1QIljQBzy/s EjVJ6yiIJwZov0cT/iq85sL6gJyoz87xvrVM45mvoS16XKwAWVa6BC752SvCG7Jyu1ap SgcdDb1I37ii2W1h5kfqUriWf3uq0FOOznJFlm2eQjYAAXXTPrBvlzUMuyO8dvWtPM9B YaKWu9noOkAWbfSPSI8T03ghe2gkyTWitOePrSGNzALmBKlmBCpEkcmvOAwhITOB4NQ8 WGxA+pjmcDugMt7t5UYm7qT88Iu+Oa0VYU5HcNV/SoiMpjKinIBhFQ51UgyfbuAXOXss dLJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Zq68Cwe6iJKRZqH/PnWe6zu6DaoZNklENM1Rqtqd21s=; b=xZz4wSwEgt8PERcdEdHacKs/M9CPHJvtfC8kQwLQTaUiMmerkgkiOWk8wQLtI9yHF5 ZV14vbCqJ5G3w0QzRUrHsT9WuzVm3t4H57XcnYPjwZYQVT3qCtvBipa7T9JwGQjVBloA Z/QdTw3ucLdfkQpWQBOzb1j0Vzs/65kkuE1zalofpmd43BzmLGrTYuzcVaTmf9gQa0T+ CS8cAYr0hYplyWQVt49Mjt7S+gHmcyZe8lAWgfPl7flcHdS5kSVX6dX9RIV3c2rW9AaP ZYQHb6N69iIDXiVWzOtZPZJXKBz144dzKVl+Q34PVDbl3qt4Gev1NJGigd7Musy+o+G+ u4cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=EWLswC3n; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f19-v6si31026376plj.89.2018.05.28.09.13.23; Mon, 28 May 2018 09:13:38 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=EWLswC3n; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S939655AbeE1QK4 (ORCPT + 99 others); Mon, 28 May 2018 12:10:56 -0400 Received: from merlin.infradead.org ([205.233.59.134]:50290 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936814AbeE1QKu (ORCPT ); Mon, 28 May 2018 12:10:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Zq68Cwe6iJKRZqH/PnWe6zu6DaoZNklENM1Rqtqd21s=; b=EWLswC3nwabvOr4SKluI1lcCG9 3qELxWWfkmYTtlfZ6XYuoxbn66LpIvKLefWgltx827dtRwH8KHVtpMZ8gKmQS29d8/MR3dE6Zo9Nu +EOYcIR8yhpKUTR3VkK//NtycxTHXx6NQPtcwmfw+LVVgBHJAt2qvwayqDh3PwQqjIlUMrnsME+Ab xJ0VMiTwydG4WUhcRLdCWpHm9xhccmDVQaPYWW6cvC3kC0sKbdSIShoCFk+A3eVK3KQWgr7SKCOE7 E0j5P5Pt/1cMO78wnuesziBKIwlyk/kIcSikM0/MjTJdSsoeQSH71mzu1lpdst4zQZkNqlYLIz5Zh SyohnJXQ==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNKjN-00046U-FA; Mon, 28 May 2018 16:10:45 +0000 Subject: Re: [PATCH] doc: document scope NOFS, NOIO APIs To: Michal Hocko , Mike Rapoport Cc: Dave Chinner , Jonathan Corbet , LKML , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, "Darrick J. Wong" , David Sterba References: <20180424183536.GF30619@thunk.org> <20180524114341.1101-1-mhocko@kernel.org> <20180524221715.GY10363@dastard> <20180525081624.GH11881@dhcp22.suse.cz> <20180527124721.GA4522@rapoport-lnx> <20180528092138.GI1517@dhcp22.suse.cz> From: Randy Dunlap Message-ID: Date: Mon, 28 May 2018 09:10:43 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180528092138.GI1517@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/28/2018 02:21 AM, Michal Hocko wrote: > On Sun 27-05-18 15:47:22, Mike Rapoport wrote: >> On Fri, May 25, 2018 at 10:16:24AM +0200, Michal Hocko wrote: >>> On Fri 25-05-18 08:17:15, Dave Chinner wrote: >>>> On Thu, May 24, 2018 at 01:43:41PM +0200, Michal Hocko wrote: >>> [...] >>>>> +FS/IO code then simply calls the appropriate save function right at the >>>>> +layer where a lock taken from the reclaim context (e.g. shrinker) and >>>>> +the corresponding restore function when the lock is released. All that >>>>> +ideally along with an explanation what is the reclaim context for easier >>>>> +maintenance. >>>> >>>> This paragraph doesn't make much sense to me. I think you're trying >>>> to say that we should call the appropriate save function "before >>>> locks are taken that a reclaim context (e.g a shrinker) might >>>> require access to." >>>> >>>> I think it's also worth making a note about recursive/nested >>>> save/restore stacking, because it's not clear from this description >>>> that this is allowed and will work as long as inner save/restore >>>> calls are fully nested inside outer save/restore contexts. >>> >>> Any better? >>> >>> -FS/IO code then simply calls the appropriate save function right at the >>> -layer where a lock taken from the reclaim context (e.g. shrinker) and >>> -the corresponding restore function when the lock is released. All that >>> -ideally along with an explanation what is the reclaim context for easier >>> -maintenance. >>> +FS/IO code then simply calls the appropriate save function before any >>> +lock shared with the reclaim context is taken. The corresponding >>> +restore function when the lock is released. All that ideally along with >> >> Maybe: "The corresponding restore function is called when the lock is >> released" > > This will get rewritten some more based on comments from Dave > >>> +an explanation what is the reclaim context for easier maintenance. >>> + >>> +Please note that the proper pairing of save/restore function allows nesting >>> +so memalloc_noio_save is safe to be called from an existing NOIO or NOFS scope. >> >> so it is safe to call memalloc_noio_save from an existing NOIO or NOFS >> scope > > Here is what I have right now on top > > diff --git a/Documentation/core-api/gfp_mask-from-fs-io.rst b/Documentation/core-api/gfp_mask-from-fs-io.rst > index c0ec212d6773..0cff411693ab 100644 > --- a/Documentation/core-api/gfp_mask-from-fs-io.rst > +++ b/Documentation/core-api/gfp_mask-from-fs-io.rst > @@ -34,12 +34,15 @@ scope will inherently drop __GFP_FS respectively __GFP_IO from the given > mask so no memory allocation can recurse back in the FS/IO. > > FS/IO code then simply calls the appropriate save function before any > -lock shared with the reclaim context is taken. The corresponding > -restore function when the lock is released. All that ideally along with > -an explanation what is the reclaim context for easier maintenance. > - > -Please note that the proper pairing of save/restore function allows nesting > -so memalloc_noio_save is safe to be called from an existing NOIO or NOFS scope. > +critical section wrt. the reclaim is started - e.g. lock shared with the Please spell out "with respect to". > +reclaim context or when a transaction context nesting would be possible > +via reclaim. The corresponding restore function when the critical "The corresponding restore ... ends." << That is not a complete sentence. It's missing something. > +section ends. All that ideally along with an explanation what is > +the reclaim context for easier maintenance. > + > +Please note that the proper pairing of save/restore function allows > +nesting so it is safe to call ``memalloc_noio_save`` respectively > +``memalloc_noio_restore`` from an existing NOIO or NOFS scope. Please note that the proper pairing of save/restore functions allows nesting so it is safe to call ``memalloc_noio_save`` or ``memalloc_noio_restore`` respectively from an existing NOIO or NOFS scope. > > What about __vmalloc(GFP_NOFS) > ============================== > -- ~Randy