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/t0iYG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Rxu0SU5t5TM/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: