From patchwork Fri Jul 9 10:28:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xu, Yanfei" X-Patchwork-Id: 12367093 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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 34759C07E99 for ; Fri, 9 Jul 2021 10:29:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AE102613C9 for ; Fri, 9 Jul 2021 10:29:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE102613C9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=windriver.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8881E6B0071; Fri, 9 Jul 2021 06:29:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8381B6B0072; Fri, 9 Jul 2021 06:29:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 663736B0073; Fri, 9 Jul 2021 06:29:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id 3BC466B0071 for ; Fri, 9 Jul 2021 06:29:23 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 703EA181CA34D for ; Fri, 9 Jul 2021 10:29:22 +0000 (UTC) X-FDA: 78342677364.38.9A930A6 Received: from mx0a-0064b401.pphosted.com (mx0a-0064b401.pphosted.com [205.220.166.238]) by imf08.hostedemail.com (Postfix) with ESMTP id 7917530000A8 for ; Fri, 9 Jul 2021 10:29:21 +0000 (UTC) Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 169AMME9020730; Fri, 9 Jul 2021 03:29:20 -0700 Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2040.outbound.protection.outlook.com [104.47.51.40]) by mx0a-0064b401.pphosted.com with ESMTP id 39pk1vg214-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Jul 2021 03:29:19 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AhCJShCw9PbhamPSGleyVEWb3rwpamU+QsM3q21OxLzgtVoziM+wMfRXb4ZDTNFMUqnkHdEHq1ExAW6hrh6abTBbpP5o9zAQzlR3OlrO6WW3exiJlXR9n8RDLZWAaHug1N51rucKBMYpst3fAlSwQtl8PePe/n24IbVnvibMUcW3ctrYWJ2XoPElFxiFTw6XpC5lW6q5QUYhfh69socprmprCcAyxFSc9aXdOt5qGSlX2hCv5eCtAd12xMGYANWxSdJ3B5cC2YUajjDrtlNAGV49Pe7dylihNex85A1prvwLktWhoXsvDMW/mGI+JDxqscChG84VblgCRnssnidT3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6CMClUKfUseqhvni4N9tIiaU+3Yt4Zgc5LUUiu/wgHY=; b=RzQn0BMzTmeSDaTcSaOQMTBpIfSEe/JEcwmIDzuSLweID22uvAC1fwD2FPe+SvBEcmbf5OHt1CTowPpsl5UbZQy353WpFwBFpcfMzhm9KGHZ5YhLGNdRWIK9LCBRKh4xDUKY6qoT35N7KbGxuIXSuYiNtmEdLcgIsnHAQdS5DnIgP8Kj0Hae+OWSsQbkOAK/hkAoRr80GcyvK90CY2QUkWG3I4bxqRq3q4dsF5mcMqUuiqlSbR1zroDGgxDojacJ8RZptdQX3fgnK/u27sU6tK+J2Ip+2MaMAoOMG5gc3YTfsAZ4zAbJRpH7VEI/2cdkE5ub3cdcLFwTRml5PUbDNw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6CMClUKfUseqhvni4N9tIiaU+3Yt4Zgc5LUUiu/wgHY=; b=PIWO/R5HwqNGbmfnK/wR4pS1sBoOBYzGvJZzFMMw/yIrYJffbjPS4Mv5HDOYjs2v0p9k+3wbQum+AfK8xhH3Gvo7niYFVquPrNtN0K6z4XqQnsC9BwGvTlTN6Te65m71JHkx89XUOl57MsXjuCyuJu5IDwcOSwjB9zp53oKONPU= Received: from DM8PR11MB5734.namprd11.prod.outlook.com (2603:10b6:8:31::22) by DM6PR11MB3147.namprd11.prod.outlook.com (2603:10b6:5:64::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21; Fri, 9 Jul 2021 10:29:18 +0000 Received: from DM8PR11MB5734.namprd11.prod.outlook.com ([fe80::bce8:81f7:f5a1:af19]) by DM8PR11MB5734.namprd11.prod.outlook.com ([fe80::bce8:81f7:f5a1:af19%8]) with mapi id 15.20.4308.023; Fri, 9 Jul 2021 10:29:17 +0000 From: Yanfei Xu To: akpm@linux-foundation.org, mgorman@techsingularity.net Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mm/page_alloc: correct return value when failing at preparing Date: Fri, 9 Jul 2021 18:28:54 +0800 Message-Id: <20210709102855.55058-1-yanfei.xu@windriver.com> X-Mailer: git-send-email 2.27.0 X-ClientProxiedBy: HK2PR06CA0022.apcprd06.prod.outlook.com (2603:1096:202:2e::34) To DM8PR11MB5734.namprd11.prod.outlook.com (2603:10b6:8:31::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pek-lpggp1.wrs.com (60.247.85.82) by HK2PR06CA0022.apcprd06.prod.outlook.com (2603:1096:202:2e::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20 via Frontend Transport; Fri, 9 Jul 2021 10:29:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d4b4ae5f-186d-49b6-03cb-08d942c467ec X-MS-TrafficTypeDiagnostic: DM6PR11MB3147: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fZX5tUCZZPDtDBLrX3arnOewaJEzyHiMf9lSFMr4TLD0WoAmOpFwMy+C36UNvBD+LWrXtBaPQPAsqy+IS11yKCGf8fuk7UC76lPWV0Q3d57CzpbJ8v2Qj1NqnnlhNNCPz+wwv4LeuxmUajCAgUDr8bxUB/iJH2RgbwnwuAlcnA2+z8VaP4XYiV3q7ek8GDK1btQcRXAHWIYPkSErNLLWba3wUsk/d1OcoUi7WmqcFNz1CzwyP+YX0xFfH26zHYyGjU0Qf2X+gBw1pVfiJfuORfWTImFGvGAaPIG8BWx02tZf3CvweifDSaDeV6AYlWhqGtf21R+T3/s+PlqtcrbqAJg9ALLYRrBth9HlolNNxgNMOH41YSNyZe/an8n8DshefWnBYg9v0a4I5EQ0gXOG0KWEvw4Kd4MqdNHi/Qu+WPSguQfkSFUKL8geq7IKd1y7Lu/ZSoaoRD0SG9FPOp1w95if+gN43qAKTQAk7LAeKv3ZcHRJGaVAkHZxuKbjy4ig42mRSw6bquABAmc4eJLKLla4YtdWM8yWBQdqHzVYyEiRYqOSKfZ0sefhVBSf4o5xwQdCW4QpuIcFd6BFMFhyWeHJfdauyBMat8G8sQ6UXbkKieuTCSMjAomis6uUVLCZMqY2tXYRdSSJK6qtHMwDrqoE4+cWNafO9kVX6ey0HIiIC0B+eVg4oQ4db0VuIGQckYYpF2aGocP+kEno6jhn4g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM8PR11MB5734.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(136003)(346002)(39840400004)(376002)(366004)(26005)(186003)(2906002)(44832011)(6666004)(6506007)(38350700002)(5660300002)(86362001)(83380400001)(36756003)(1076003)(38100700002)(66946007)(2616005)(6512007)(6486002)(52116002)(4326008)(8936002)(8676002)(4744005)(956004)(478600001)(66476007)(316002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 132XRGzc1aDqVSFea2O/MAgUiHQJhswhtV2ZdW2ooqmRsV2ZsdRCibt7DPRH7BdjZpbNtfxrN1vfzkeTs8P6xlPEQ5LigPWqpcHNROkK9XySYcslMCXsQiXhH4R1xH3eOZGSG7tlIE/qznW1/jpyKUPw/fdiK6kUzPsBvlmDTuEdVWo3TwiHgyFsp1qp3KL2VNa2VfL1lgk8ssu8cu4vszzdgDiOgqUYjuWm5l2Q9VIn1bj5Ain59IenuR30/RXU1GJ6r//XcOFNgpJnSAQlgfqxrS09XX2e/542GCWDNBDCdF6IHmy5ll339YZFDPNOd8PnOIWCaxKEfW//fPDsWULMc/OLbvFExmdtHtBsny5h7A9IDqqaBXz0OY0f+W5RQpm+bT72qXqi5IvDykAKOlF0yGIrSez+tBeTJiMHTNrkhUtV34cmWiGlenyRcOj/HVhBuWJulFP74FUlUED8a816q7RqEDYlfGhoDtHnuU/pYkHtVQy1N1U11MGYKPsHGt2KaMjMdM2EtXSnJ0vr3V7bKeXuuusg716M6gG049KxbHral8avMv6uT/v66Q6DHRqISIuopf1XfNH8BMmZx2GzbZPNhXRriPgw9RQFNRGwycNegn70002+ZCobu2iqTqlrKLHd+D6ZxiY6X8wrEgRZqZgjK8NznK86EEja2p8c3Rb48VIyyrf9uUOD4b16IPYpXlOdZuBHYFAjhG87xr+2S21FgCVRO7LKFTWdSGwhRO1MvhEJu7F79N7Wj0/yXdrNuvXEOpKHYUaR2iuL3V5R+ZSg+WwMYCocFT5Xm9MVYVWP2JE1vUwnDdDTOC9bSq9dboKj1s+sbKSeVL6RTZYZX7o07e4jSmjz2Hq3RcYyC28lMsJsUqsDsFjBYE/QjbzAPsw0n3ztOZ0FImZy9uxVJp4y0xM6Gv8d1XKulkn+UsZliJah76OoSmaCgooa1DCw26SblsiE3hKMsJS2KTdMZy7NH9Okx4G3fyk8diA+hIioRJs2ieDECtYlSsy69TI56fl9fYHHnLwI5JvoZPM6QQedrtxzfky+fYETJ4FM+yF+hhH98j4bx0OuLL6Vj08aowMw+M7+2yUj6AAfPTPN5k0YZla2MTPeCrfRJQchIwl0dUed7Mwi+ffw5LOB2/k3Glb85aOPSoWU/1n4tXdf5Ie094Cu0sRkhs8KyOP1c3lR4jxIJvuphKmnbVJ0IAAYd6OhIgH08adlJ9vBrdt/8JHDjk8CAjvH91m1aZTewVK0tXRUmGrCTH0NpehZRDVc9F57fHCBgeR66NqNU1IY6O6pCkcoIo+zHvgbgJTvjabGHvMLkj2KP4OYG33I X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: d4b4ae5f-186d-49b6-03cb-08d942c467ec X-MS-Exchange-CrossTenant-AuthSource: DM8PR11MB5734.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2021 10:29:17.7425 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: b0qr/A6y4svKADR8ue3mvcohVLDynLxPJW81VroKmlbEe6J2Y1o3K3qRAG4GfW8Qy6Wiab3t+sBddl/WqYiDNg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3147 X-Proofpoint-ORIG-GUID: TVvUoJg1LepXaoOFWGYRTlu3VauxHFeI X-Proofpoint-GUID: TVvUoJg1LepXaoOFWGYRTlu3VauxHFeI X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-07-09_04:2021-07-09,2021-07-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxscore=0 priorityscore=1501 impostorscore=0 suspectscore=0 bulkscore=0 mlxlogscore=798 adultscore=7 clxscore=1011 lowpriorityscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107090053 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=windriversystems.onmicrosoft.com header.s=selector2-windriversystems-onmicrosoft-com header.b="PIWO/R5H"; dmarc=pass (policy=none) header.from=windriver.com; spf=pass (imf08.hostedemail.com: domain of "prvs=282436cc89=yanfei.xu@windriver.com" designates 205.220.166.238 as permitted sender) smtp.mailfrom="prvs=282436cc89=yanfei.xu@windriver.com" X-Stat-Signature: m71ep7unm636p3am4fe9cu7qayoaa4ba X-Rspamd-Queue-Id: 7917530000A8 X-Rspamd-Server: rspam05 X-HE-Tag: 1625826561-377563 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: If the array passed in is already partially populated, we should return "nr_populated" even failing at preparing arguments stage. Signed-off-by: Yanfei Xu --- 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 d6e94cc8066c..e9fd57ca4c1c 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5254,7 +5254,7 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, gfp &= gfp_allowed_mask; alloc_gfp = gfp; if (!prepare_alloc_pages(gfp, 0, preferred_nid, nodemask, &ac, &alloc_gfp, &alloc_flags)) - return 0; + return nr_populated; gfp = alloc_gfp; /* Find an allowed local zone that meets the low watermark. */ From patchwork Fri Jul 9 10:28:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xu, Yanfei" X-Patchwork-Id: 12367095 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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 3C2A6C07E9B for ; Fri, 9 Jul 2021 10:29:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D2A5261248 for ; Fri, 9 Jul 2021 10:29:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2A5261248 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=windriver.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E56986B0072; Fri, 9 Jul 2021 06:29:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E05416B0073; Fri, 9 Jul 2021 06:29:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C57DF6B0074; Fri, 9 Jul 2021 06:29:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id A1DB26B0073 for ; Fri, 9 Jul 2021 06:29:23 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D54EE2AEE5 for ; Fri, 9 Jul 2021 10:29:22 +0000 (UTC) X-FDA: 78342677364.06.32E9F83 Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) by imf08.hostedemail.com (Postfix) with ESMTP id AB73530000A5 for ; Fri, 9 Jul 2021 10:29:21 +0000 (UTC) Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 169AMHio008376; Fri, 9 Jul 2021 10:29:20 GMT Received: from nam02-bn1-obe.outbound.protection.outlook.com (mail-bn1nam07lp2042.outbound.protection.outlook.com [104.47.51.42]) by mx0a-0064b401.pphosted.com with ESMTP id 39pjyhr27j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Jul 2021 10:29:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z9YFJNsOn4sNH4F6jBCAibhVOPd/rRSzm9wIWdpI3OTEXJ7aUsJp2DzzisowEudch2CsWZfGkUhXoyfETs/q5zZNbAcHN2D0GodmIMiStCCRFVGXNxgyEEHcNiUtZJvW613i8Bd1Inx0WQuzB6wM6PMi6eOSlclr0k4eB63hQO0EifrtprzP7Pd491cyLhxfvb6ox3/vSh4eVE92EJ0XlyYyDJ4/13IzdPEzSsChmrm2U67MlgGpVJMyjql/veCgIor0/MmLZib8GoGvWvxpyhUIFV2BZmXzBSxoUmLdDI47QV43V06h9W84YAQPunz513Pa9QVV4P+dvLQLR1TkQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oxrVu3VaR9lStAi1dxSWnhqWOgJP5GNx041on9xydYM=; b=R07+1lUlc7gwgOPaWaEkWAPJXsAnGzAnaxYRP5n/sbhMgozgcIrfL9G/5DUJGofSVSbs4/u/Cu33OSWFum6IkK1Z4jnoQTN3LYGLfdIGwKIGfiL9YgrD3th8XE8cVNsukAJxnhD7Ex8zcP57mVf2KEMaj7GHhb0KoggvWktXvpS5/pxN/VuuQmT4mElifiupDrTZhhkAnb6TVkTCQEcioZsL1u3NwXwHZ0iMHOGn5fYOtjJLQfxd33qHLuQ75m14PzHeYI+lk9d2QG0QhvNseB7AOZh8OaENEEwM06HAVjUCrpHt/KD0C18jBprjuLfeGyZHEKU+CB8Tc9BzEKlhbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oxrVu3VaR9lStAi1dxSWnhqWOgJP5GNx041on9xydYM=; b=ZOtHA+ocTnt1WME9ucvwfzMwXXnGgr39OvBX32weOL6rsLKvBgJjAwhSiN0HHX87f3NvnoHxpfJA4+1FRVxj2YpM0rkd7rqSu9xEwuQaphe5vPHOACz1R6Dlv16xsQVBJuMx/rZLXUyAP8JIzxGhhXOufNso0WueRBrqDnXkalg= Received: from DM8PR11MB5734.namprd11.prod.outlook.com (2603:10b6:8:31::22) by DM6PR11MB3147.namprd11.prod.outlook.com (2603:10b6:5:64::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21; Fri, 9 Jul 2021 10:29:19 +0000 Received: from DM8PR11MB5734.namprd11.prod.outlook.com ([fe80::bce8:81f7:f5a1:af19]) by DM8PR11MB5734.namprd11.prod.outlook.com ([fe80::bce8:81f7:f5a1:af19%8]) with mapi id 15.20.4308.023; Fri, 9 Jul 2021 10:29:19 +0000 From: Yanfei Xu To: akpm@linux-foundation.org, mgorman@techsingularity.net Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mm/page_alloc: avoid counting event if no successful allocation Date: Fri, 9 Jul 2021 18:28:55 +0800 Message-Id: <20210709102855.55058-2-yanfei.xu@windriver.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210709102855.55058-1-yanfei.xu@windriver.com> References: <20210709102855.55058-1-yanfei.xu@windriver.com> X-ClientProxiedBy: HK2PR06CA0022.apcprd06.prod.outlook.com (2603:1096:202:2e::34) To DM8PR11MB5734.namprd11.prod.outlook.com (2603:10b6:8:31::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pek-lpggp1.wrs.com (60.247.85.82) by HK2PR06CA0022.apcprd06.prod.outlook.com (2603:1096:202:2e::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20 via Frontend Transport; Fri, 9 Jul 2021 10:29:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d89ec5d2-f7e2-4a3f-b815-08d942c46938 X-MS-TrafficTypeDiagnostic: DM6PR11MB3147: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1388; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WtzqEroO1+mVGZ+HO3ielSlnhqiq4/oYFYSNdcyUPxYFHuAs5iiqTizqHnuu/DE+v2bRsml1nDlVD+vhDcMzcuMpmraLWf/yb4bxeOEoJIrL80/3Ct2V/KLnSUxFCfBm5tcMhnjE8hb8eOkcXANeQg3DFHLBxwvSHD6Qpjr3ilow03RQM/rkU6Vi1ZZHVT4v1fFJcXfgiQj2xHMxSGJDLRPm+jQL0ZPxIqY4ozRBBPEXebu5OlS8rdkvYq+1XZlk2v6vmYvoyscG5HJQQTFGeXdL1SztP6h4tzZy/F3CpnTj+JBPT8zXHJNcZYWBr9pMJ9hjcPSwYV/2ysO6W9djOY/joGMcGgeOlInX7nuBJsDsem9gB8YO6Ojs1/OVmPYgl9J+pOJUl2xGcOe/PcCYTchSPEFrubqmQ1ayjMy3cwFCA+dielYFz1ywMRecLEaqZG8wgsU31D/aPwxajMmUPzonPFtwKWrykfaDmQZnyNkom/gF5V2PkOnGuk+cmCTRBZnYA9TNbDWugZUPv+KZYUEesK30seIcX3N7Sqtw45mwZrSBlbrvrXFiAK3jRbB6Un2sMM2yeyQFawrKJq/5+N4Richm61BG5qvBP10leCIZlmOMZym9ij8qmnu6gQXXfAlvvB1tjJbQreBagWyJ96wfzkffxSh+mNdI1a29JFPjH7Fp7H/ft9QyzCReIOlLA7kojmTHAEcuI0mmigktTA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM8PR11MB5734.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(396003)(136003)(346002)(39840400004)(376002)(366004)(26005)(186003)(2906002)(44832011)(6666004)(6506007)(38350700002)(5660300002)(86362001)(83380400001)(36756003)(1076003)(38100700002)(66946007)(2616005)(6512007)(6486002)(52116002)(4326008)(8936002)(8676002)(956004)(478600001)(66476007)(316002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yitEsd44nkZpngd/M4xnl30C4USsTmoimwV5SvLzhLwfI0OCBBez3sV5g+ssUuDGjMoXR1YDFJRNdHI125kFitefTY9EpkG9gXiKAZISWtW1IxjREgH7Cl2ELF5jmicOU75lE919jWBpu6G72kGlWSSNOPF2xUmoHjHIV/MUuw6PKTmzjhSMzx3B1Y43GGb4tBqBzlTZyuobjwxLZRGpAsvg8VtPI0L/t0iYGh+Y7kfgHPynWxnYhktG2l4Nnp6yXMbKI3iv3lzP622aarO13nyo3rolgYuQSk62Q6QSf6+hjbLRj1bXsyAnEsHiNEjhp0Lb5SZyIBn1hKz4fBuE1ckgi1gYmq76+fyqJWWbl2veJmd5KWkqKcKhMW2u8A8UN5YY7+DGe66RdHpaCelPj+GmZYVB0OaauCVvcv6y6+Vi3AzuqXRu5c4N8IJDS+f5OmC++9qUG4nVsncca1fkQquqU4EuNHmINhjdgWJrp7XwyK0a6VrZB2SVJUgMQbhNFBS5PZDDFwjNl+iAk+X3Y2sxg0DFCaSXU+QfVO2FMZz9Loiyt+KgrcSVXRxcrD1LBNO9NCd1VN7j+z8QeetllIpXxxQry6ZecgE0+zYW9U68D4rk6qUKvwfLIhPUJTk/wZB46T1z/bQRY2tO1J159F1IxDj1X+yuPyPQAlf4hZmTjdWuQEKUXtTg6rg5ZiWyJz5b4fq298NYd8IO5NT9hgUMvKk5B8ROZUp4Z2Yz1/ZLnA16mEdl+iE3c8WN1ElWLn4wLUuY+6jyJPXM8wVWt5hMAY1EUAz7GQtROkidDiYbbZA/jjw2rXwt8V2Yg/3VHbCgcVRy7sDFsenYH5281ckE61nR2grWDH5wttv1ieY+gAlUmbMV+Am8fHdZReXy1zt6ptxq7G12Ems4sXQFHnMIfJOoMW5v1zUz9aOhDQSQ0vpDXmWXS0i1ToVeNRTAaQm5IcpTY1vw/wDESw9JdkVAcl2ZlXehOleiO0eiE4jYutsH6cQ8Nb05TFpk6RYst8Q0JPkO8hrGAdkpiz585A73q6I5LWxexyeb3rxCtxGdr95SJSePUrhMuoklpsNdQClrmNv/z5ibPWXTYaIy/UYx6IvY9fOHyLxOR1iz+nJmyRMyvnbHPKcd0Mj/J6D5vvJ5Txfw84rVutT0RUK/0CxG5vk0Gl5suuWgsZGfaQ9wgcEmCr4VMOkUncstfBCkSRjaIHBUGDHhFuz9kh6gBvqcL/NI02r8oBYCcu72S9f1nQU153Z5db+OZQzTDM6zpZNBAOGHa3lqqNRxu0SU5t5TM/ZRUD5QJ5V1nX5CvYcQ0fOZu4PLwTdYEio8MTE6 X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: d89ec5d2-f7e2-4a3f-b815-08d942c46938 X-MS-Exchange-CrossTenant-AuthSource: DM8PR11MB5734.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jul 2021 10:29:19.7507 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hIknUM0mzfy2HORmBBhAJIasBd5GblKqeQs4gUUzEexsB2UlF2N4CCg/XIuIXsEYBorgxJw/VIP38KZv78e6GA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3147 X-Proofpoint-GUID: t-dZj-zkOs2_dc1oq8vjjsu829anhyJz X-Proofpoint-ORIG-GUID: t-dZj-zkOs2_dc1oq8vjjsu829anhyJz X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-07-09_04:2021-07-09,2021-07-09 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 adultscore=0 phishscore=0 lowpriorityscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 clxscore=1015 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107090053 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=windriversystems.onmicrosoft.com header.s=selector2-windriversystems-onmicrosoft-com header.b=ZOtHA+oc; dmarc=pass (policy=none) header.from=windriver.com; spf=pass (imf08.hostedemail.com: domain of "prvs=282436cc89=yanfei.xu@windriver.com" designates 205.220.178.238 as permitted sender) smtp.mailfrom="prvs=282436cc89=yanfei.xu@windriver.com" X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: AB73530000A5 X-Stat-Signature: hwqy1p5bdf96gdmptcjodog1o14uoknc X-HE-Tag: 1625826561-26057 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: While the nr_populated is non-zero, however the nr_account might be zero if allocating fails. In this case, not to count event can save some cycles. And this commit extract the check of "page_array" from a while statement to avoid unnecessary checks for it. Signed-off-by: Yanfei Xu --- mm/page_alloc.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e9fd57ca4c1c..e25d508b85e9 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5235,16 +5235,18 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, if (unlikely(nr_pages <= 0)) return 0; - /* - * Skip populated array elements to determine if any pages need - * to be allocated before disabling IRQs. - */ - while (page_array && nr_populated < nr_pages && page_array[nr_populated]) - nr_populated++; + if (page_array) { + /* + * Skip populated array elements to determine if any pages need + * to be allocated before disabling IRQs. + */ + while (nr_populated < nr_pages && page_array[nr_populated]) + nr_populated++; - /* Already populated array? */ - if (unlikely(page_array && nr_pages - nr_populated == 0)) - return nr_populated; + /* Already populated array? */ + if (unlikely(nr_pages - nr_populated == 0)) + return nr_populated; + } /* Use the single page allocator for one page. */ if (nr_pages - nr_populated == 1) @@ -5319,9 +5321,10 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid, local_unlock_irqrestore(&pagesets.lock, flags); - __count_zid_vm_events(PGALLOC, zone_idx(zone), nr_account); - zone_statistics(ac.preferred_zoneref->zone, zone, nr_account); - + if (likely(nr_account)) { + __count_zid_vm_events(PGALLOC, zone_idx(zone), nr_account); + zone_statistics(ac.preferred_zoneref->zone, zone, nr_account); + } return nr_populated; failed_irq: