From patchwork Mon Jun 28 17:15:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 12348357 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=-13.8 required=3.0 tests=BAYES_00, 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 59352C2B9F4 for ; Mon, 28 Jun 2021 17:15:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 23D1161466 for ; Mon, 28 Jun 2021 17:15:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23D1161466 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5D5358D0066; Mon, 28 Jun 2021 13:15:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5857F8D0016; Mon, 28 Jun 2021 13:15:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44BAA8D0066; Mon, 28 Jun 2021 13:15:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0009.hostedemail.com [216.40.44.9]) by kanga.kvack.org (Postfix) with ESMTP id 19E268D0016 for ; Mon, 28 Jun 2021 13:15:18 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4F824824999B for ; Mon, 28 Jun 2021 17:15:17 +0000 (UTC) X-FDA: 78303783474.14.D534C1B Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf18.hostedemail.com (Postfix) with ESMTP id EC64320010AC for ; Mon, 28 Jun 2021 17:15:16 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id CD9AE61C49; Mon, 28 Jun 2021 17:15:15 +0000 (UTC) Subject: [PATCH] mm/page_alloc: Return nr_populated when the array is full From: Chuck Lever To: mgorman@techsingularity.net Cc: linux-nfs@vger.kernel.org, linux-mm@kvack.org Date: Mon, 28 Jun 2021 13:15:15 -0400 Message-ID: <162490051493.1165.8122675403341013520.stgit@klimt.1015granger.net> User-Agent: StGit/1.1 MIME-Version: 1.0 Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of "SRS0=UD0C=LW=oracle.com=chuck.lever@kernel.org" designates 198.145.29.99 as permitted sender) smtp.mailfrom="SRS0=UD0C=LW=oracle.com=chuck.lever@kernel.org"; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=oracle.com (policy=none) X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: EC64320010AC X-Stat-Signature: ueptbmq3d1qna96fmtthdbej1q4nqghi X-HE-Tag: 1624900516-2093 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 SUNRPC consumer of __alloc_bulk_pages() legitimately calls it with a full array sometimes. In that case, the correct return code, according to the API contract, is to return the number of requested pages. Fixes: b3b64ebd3822 ("mm/page_alloc: do bulk array bounds check after checking populated elements") Signed-off-by: Chuck Lever --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ef2265f86b91..79f88c4ae372 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5058,7 +5058,7 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, /* Already populated array? */ if (unlikely(page_array && nr_pages - nr_populated == 0)) - return 0; + return nr_pages; /* Use the single page allocator for one page. */ if (nr_pages - nr_populated == 1)