Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2210697pxb; Fri, 17 Sep 2021 05:00:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLiE7ZJvyOTMYkWEXh09TGE5x6HjpFFQEvNNSwvZa2Rf6rVFre65FxmldW5H7UUS1RdTpn X-Received: by 2002:a17:906:d287:: with SMTP id ay7mr11650914ejb.402.1631880038620; Fri, 17 Sep 2021 05:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631880038; cv=none; d=google.com; s=arc-20160816; b=hBpss1kzY1XlWVU6avnqlCEcrUXbzUzt1mG40naSbrpkx0MJD0xFH+VTqlaGMClgBX vbakXed7y4T/9wzgT6e467YjcKQgudPveP4ZNI6uWNwaRAnZ/aKwilvrAA9dpXFN3jzl kDtAy0o81OBWOVV/EZsYkoIolZPArA5+Q5cI6ik9qLegATJ/NK5CpaugrYJmcCcMxV6g sZ1Vy5g+Xkuah4Nu9Aswe0GeWez+FcI6w2Qo08d2fm+3QPsAQGJqghw/kvSVym3VOtFa x8C8Eb/s0+93yoTksQ7DgopAIYOFiD8r74ldci9yX+OV9Soz6qbXDIxQs7mst+SQs7Ic n4CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature:dkim-signature; bh=PhO+AMBCn5CF5KJqwHi2NRgoifLeDG6tBD6IhB9YLqI=; b=s7Yn0dxRo3VCkWq4yWlgq1QEQVKx0NlWClDovDctACLm1iIPAbhh2LW+bUGRKyzpm7 6pMeDahEG6T0Xy/DkiLZ2AUoowLYwVl09wvu7LgkbxEcv7QWS/x3/f+ZErc2MCjE6stX XDX7mI4N9R0w9WlDjpg40xzpsw1wIdX+QhRkJsi8sUxEf9cZny8KcV3aV+sXsWWlYcls 20kbZLvk5P11rGcVgXn/XNcfKThyetKn/WqwyJD+PfwQKuHjXcccYcBxV9i+7UP9S/MW I/WZlDuYBnrR5uTL6lFLoBDutAA8GwzbQz2sffMKm1fBrTkcxhn1GBVETWyFf784K5ww XySw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vThorR8a; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 m12si6417413edd.470.2021.09.17.05.00.15; Fri, 17 Sep 2021 05:00:38 -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=vThorR8a; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 S243049AbhIQDAx (ORCPT + 99 others); Thu, 16 Sep 2021 23:00:53 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:41390 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243248AbhIQDAw (ORCPT ); Thu, 16 Sep 2021 23:00:52 -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-out2.suse.de (Postfix) with ESMTPS id ABA7D2007B; Fri, 17 Sep 2021 02:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1631847569; 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=PhO+AMBCn5CF5KJqwHi2NRgoifLeDG6tBD6IhB9YLqI=; b=vThorR8aWQ88Y2GmJEKKlzu9235Z/ZeCUkMr1tu37GhRXPpZfoOnsprc1JRFJTuXWRqbYo OrwNdG+winpkkSlgaBUSLsVjiQSK1WiUbcsFBMP1c4iGoCvNYpDkYEriFSvFrODR8idE2j Tlusg86Y9/ATaenPc/okC73RyP3RPU0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1631847569; 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=PhO+AMBCn5CF5KJqwHi2NRgoifLeDG6tBD6IhB9YLqI=; b=PdD7iVhth5i0uczJ3IGRe4R+iuVLNQA6JKSOCFB6xykfVbdQIAbKb0z9L556d52BZHWlwR comcujPIZxeGDSBw== 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 4A36E13D0B; Fri, 17 Sep 2021 02:59:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id v4HZAo0ERGFmMwAAMHmgww (envelope-from ); Fri, 17 Sep 2021 02:59:25 +0000 Subject: [PATCH 1/6] MM: Support __GFP_NOFAIL in alloc_pages_bulk_*() and improve doco From: NeilBrown To: Andrew Morton , Theodore Ts'o , Andreas Dilger , "Darrick J. Wong" , Matthew Wilcox , Mel Gorman , Michal Hocko , ". Dave Chinner" , Jonathan Corbet Cc: 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 Date: Fri, 17 Sep 2021 12:56:57 +1000 Message-ID: <163184741776.29351.3565418361661850328.stgit@noble.brown> In-Reply-To: <163184698512.29351.4735492251524335974.stgit@noble.brown> References: <163184698512.29351.4735492251524335974.stgit@noble.brown> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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. 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. 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(-) 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_mask, 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 preferred_nid, pcp, pcp_list); if (unlikely(!page)) { /* Try and get at least one page */ - if (!nr_populated) + if (!nr_account) goto failed_irq; break; }