Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2379506pxb; Mon, 20 Sep 2021 20:46:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0rTFFnc+sMQtbrTPib9iWHjuCmuT9cvoyHq6qnYu53AaJgqN5utsKOLUnH4JXth1m6Qiq X-Received: by 2002:a17:907:7803:: with SMTP id la3mr20151847ejc.235.1632196008313; Mon, 20 Sep 2021 20:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632196008; cv=none; d=google.com; s=arc-20160816; b=YQNCBrGN5uZGU+Fm5Ycb+cU6MCOMl3RmUPW6UPIVN4vnPALgn9LSEjV174an/QVvHw kS9H38w1tFFRQWimI3ERg1HURa/brvJ8csXyMAItJNQT4BxIpiaVY+zjebQGOVgkLJci +/RVEXcv3iZpCmZ3//aHzPCV/omCBcQSFXy0s2pyS4EdsVFlMRjQgBEwgfkQKlR5i0mq tdHTbiowtzpYsIsQ4sD0At7avEy0iHQ70FYUFGU8LUba/VavGA6n3VUodpenlVFMle1f NgL8222hKNSQBPO7urU5e2x28V3OyuSH/Mfb/XXwokRjQHsNjRyt25n1gqYKMkWiXYnF rSTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=WDR8rd0yeY+WwyoUfkNID7NmGWHu0FjMPIrB2wt75VE=; b=Zfhf1vpbdzLUHEJtYkzbRttvMqKtv7lOD9xroFKyWnhTMhZKoES+K0ilMfQGumilb3 KFEaXlhYdMdk3/UF8yVO1zWnpCpwe76uSivOH/avCe641IP4Vyp4bvPcQEHVxCMuZIYU WLtYpXXexGCco0c54WWH5f7dU4ddZBhIrWKejtJn3iVdb1dimvNFMKspXFdSCmsH1FO1 64ZzWBX8TC0pW5mt8o3gpMqxl4IdCsL2Mo/mmTAsgvODHgll8WNUM0U2xskHhhj2Lmuj 7lX1ZhjuSU4WU38lARTPDpDPTTa7VkIW8QYH7/rTYJn9RBTRhF4FJI8qjCuAAP957Hj9 E8Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=chupZgMQ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=D5EiDX5I; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yl16si18383211ejb.382.2021.09.20.20.46.24; Mon, 20 Sep 2021 20:46:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=chupZgMQ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=D5EiDX5I; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239996AbhITXvt (ORCPT + 99 others); Mon, 20 Sep 2021 19:51:49 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:46288 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236315AbhITXts (ORCPT ); Mon, 20 Sep 2021 19:49:48 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E0B25220C9; Mon, 20 Sep 2021 23:48:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1632181698; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WDR8rd0yeY+WwyoUfkNID7NmGWHu0FjMPIrB2wt75VE=; b=chupZgMQPOxHEij3AQE2fQ2gSjEBexoIhCfHuOMAHmdvWRbUCZ3gF+k/9vweTWz5Vta7u7 mQNBvpOGiocqZ8S2DLOKWCj1DnMxDgqu+pm+lZ995Bqs12YFbnoaxjNRQ+fsjkM3Y2EJf6 IcYOJqc0DX/D4NVZVgH8EEpAAkJy30I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1632181698; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WDR8rd0yeY+WwyoUfkNID7NmGWHu0FjMPIrB2wt75VE=; b=D5EiDX5Iks4DL7NrQNDrrqwivNtaz8nkcu8GToJ6VdTOfRtsYDcTPgMQNgtEz/8W0CdMf5 geVHQgv+cPcW2OAg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 40BED13B3F; Mon, 20 Sep 2021 23:48:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 5j12O70dSWH0bgAAMHmgww (envelope-from ); Mon, 20 Sep 2021 23:48:13 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: "Mel Gorman" Cc: "Andrew Morton" , "Theodore Ts'o" , "Andreas Dilger" , "Darrick J. Wong" , "Matthew Wilcox" , "Michal Hocko" , "Jesper Dangaard Brouer" , "Dave Chinner" , "Jonathan Corbet" , linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH 1/6] MM: Support __GFP_NOFAIL in alloc_pages_bulk_*() and improve doco In-reply-to: <20210917144233.GD3891@suse.de> References: <163184698512.29351.4735492251524335974.stgit@noble.brown>, <163184741776.29351.3565418361661850328.stgit@noble.brown>, <20210917144233.GD3891@suse.de> Date: Tue, 21 Sep 2021 09:48:11 +1000 Message-id: <163218169134.3992.18152143151159846850@noble.neil.brown.name> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Sat, 18 Sep 2021, Mel Gorman wrote: > I'm top-posting to cc Jesper with full context of the patch. I don't > have a problem with this patch other than the Fixes: being a bit > marginal, I should have acked as Mel Gorman and the > @gfp in the comment should have been @gfp_mask. >=20 > However, an assumption the API design made was that it should fail fast > if memory is not quickly available but have at least one page in the > array. I don't think the network use case cares about the situation where > the array is already populated but I'd like Jesper to have the opportunity > to think about it. It's possible he would prefer it's explicit and the > check becomes > (!nr_populated || ((gfp_mask & __GFP_NOFAIL) && !nr_account)) to > state that __GFP_NOFAIL users are willing to take a potential latency > penalty if the array is already partially populated but !__GFP_NOFAIL > users would prefer fail-fast behaviour. I'm on the fence because while > I wrote the implementation, it was based on other peoples requirements. I can see that it could be desirable to not try too hard when we already have pages allocated, but maybe the best way to achieve that is for the called to clear __GFP_RECLAIM in that case. Alternately, callers that really want the __GFP_RECLAIM and __GFP_NOFAIL flags to be honoured could ensure that the array passed in is empty. That wouldn't be difficult (for current callers). In either case, the documentation should make it clear which flags are honoured when. Let's see what Jesper has to say. Thanks, NeilBrown >=20 > On Fri, Sep 17, 2021 at 12:56:57PM +1000, NeilBrown wrote: > > When alloc_pages_bulk_array() is called on an array that is partially > > allocated, the level of effort to get a single page is less than when > > the array was completely unallocated. This behaviour is inconsistent, > > but now fixed. One effect if this is that __GFP_NOFAIL will not ensure > > at least one page is allocated. > >=20 > > Also clarify the expected success rate. __alloc_pages_bulk() will > > allocated one page according to @gfp, and may allocate more if that can > > be done cheaply. It is assumed that the caller values cheap allocation > > where possible and may decide to use what it has got, or to call again > > to get more. > >=20 > > Acked-by: Mel Gorman > > Fixes: 0f87d9d30f21 ("mm/page_alloc: add an array-based interface to the = bulk page allocator") > > Signed-off-by: NeilBrown > > --- > > mm/page_alloc.c | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > >=20 > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index b37435c274cf..aa51016e49c5 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -5191,6 +5191,11 @@ static inline bool prepare_alloc_pages(gfp_t gfp_m= ask, unsigned int order, > > * is the maximum number of pages that will be stored in the array. > > * > > * Returns the number of pages on the list or array. > > + * > > + * At least one page will be allocated if that is possible while > > + * remaining consistent with @gfp. Extra pages up to the requested > > + * total will be allocated opportunistically when doing so is > > + * significantly cheaper than having the caller repeat the request. > > */ > > unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, > > nodemask_t *nodemask, int nr_pages, > > @@ -5292,7 +5297,7 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int pre= ferred_nid, > > pcp, pcp_list); > > if (unlikely(!page)) { > > /* Try and get at least one page */ > > - if (!nr_populated) > > + if (!nr_account) > > goto failed_irq; > > break; > > } > >=20 > >=20 >=20 >=20