From patchwork Sun Aug 29 22:28:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 12464363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3398C432BE for ; Sun, 29 Aug 2021 22:28:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 501E760E77 for ; Sun, 29 Aug 2021 22:28:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 501E760E77 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 681076B006C; Sun, 29 Aug 2021 18:28:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 631856B0071; Sun, 29 Aug 2021 18:28:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F8398D0001; Sun, 29 Aug 2021 18:28:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0200.hostedemail.com [216.40.44.200]) by kanga.kvack.org (Postfix) with ESMTP id 3CD2F6B006C for ; Sun, 29 Aug 2021 18:28:22 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B0FD3231C0 for ; Sun, 29 Aug 2021 22:28:21 +0000 (UTC) X-FDA: 78529558002.15.ABDDB26 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf18.hostedemail.com (Postfix) with ESMTP id 462F04002088 for ; Sun, 29 Aug 2021 22:28:21 +0000 (UTC) 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 C43912002F; Sun, 29 Aug 2021 22:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1630276099; 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=hMSpzXqPdpIAPWSYH1xsfxIi/YSds781FIsUXyeTRYY=; b=bYRoN0hksTXqqxt+3d7cH4US/4njd/btdAI16cFABh+BXiBy5/PzuXN/1qwj3zCuGgLc1S L3Xawk0YEHCIpjWcMs1ZoPQmeiEQLX6CjR5l//p/Fe2v507jDUu2HZWYG1aNKYF5X17ojk 0xEZM72f5i8QWSuPwsCf8ZMfa1jxFNI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1630276099; 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=hMSpzXqPdpIAPWSYH1xsfxIi/YSds781FIsUXyeTRYY=; b=eOykAVDqYGtlzq2Ffpp5k51Nm9+45WjVJE5ox+US7sbUrUv3tK1t32pYDCTm1xI1hoKkD6 DtrO/jeCF7LE8PDA== 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 3344513216; Sun, 29 Aug 2021 22:28:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id VplmOAEKLGGlRAAAMHmgww (envelope-from ); Sun, 29 Aug 2021 22:28:17 +0000 MIME-Version: 1.0 From: "NeilBrown" To: "Chuck Lever III" , "Mel Gorman" , Cc: "Mike Javorski" , "Linux NFS Mailing List" , linux-mm@kvack.org Subject: [PATCH] MM: clarify effort used in alloc_pages_bulk_*() In-reply-to: <12B831AA-4A4E-4102-ADA3-97B6FA0B119E@oracle.com> References: , <162846730406.22632.14734595494457390936@noble.neil.brown.name>, , , <162855893202.12431.3423894387218130632@noble.neil.brown.name>, , <162882238416.1695.4958036322575947783@noble.neil.brown.name>, , , <162907681945.1695.10796003189432247877@noble.neil.brown.name>, <87777C39-BDDA-4E1E-83FA-5B46918A66D3@oracle.com>, , <162915491276.9892.7049267765583701172@noble.neil.brown.name>, <162941948235.9892.6790956894845282568@noble.neil.brown.name>, , , <162960371884.9892.13803244995043191094@noble.neil.brown.name>, , <162966962721.9892.5962616727949224286@noble.neil.brown.name>, , <163001427749.7591.7281634750945934559@noble.neil.brown.name>, , <163004202961.7591.12633163545286005205@noble.neil.brown.name>, , <163004848514.7591.2757618782251492498@noble.neil.brown.name>, <6CC9C852-CEE3-4657-86AD-9D5759E2BE1C@oracle.com>, , , <416268C9-BEAC-483C-9392-8139340BC849@oracle.com>, , <12B831AA-4A4E-4102-ADA3-97B6FA0B119E@oracle.com> Date: Mon, 30 Aug 2021 08:28:15 +1000 Message-id: <163027609524.7591.4987241695872857175@noble.neil.brown.name> Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=bYRoN0hk; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=eOykAVDq; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf18.hostedemail.com: domain of neilb@suse.de designates 195.135.220.29 as permitted sender) smtp.mailfrom=neilb@suse.de X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 462F04002088 X-Stat-Signature: 7qooy3c7jmchierg8buwax6wg6o1rsez X-HE-Tag: 1630276101-674938 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The alloc_pages_bulk_*() interfaces do not make it clear what degree of success can be expected. The code appears to allocate at least one page with the same effort as alloc_page() when used with the same GFP flags, and then to allocate any more only opportunistically. So a caller should not *expect* to get a full allocation, but should not be *surprised* by one either. Add text to the comment clarifying this. Also fix a bug. 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. Fixes: 0f87d9d30f21 ("mm/page_alloc: add an array-based interface to the bulk page allocator") Signed-off-by: NeilBrown Acked-by: Mel Gorman --- 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 eeb3a9cb36bb..083316c45964 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5206,6 +5206,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, @@ -5307,7 +5312,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; }