From mboxrd@z Thu Jan 1 00:00:00 1970 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=-5.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 66751C07E9C for ; Fri, 9 Jul 2021 12:26:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0F04D6135C for ; Fri, 9 Jul 2021 12:26:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F04D6135C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D8EE26B0071; Fri, 9 Jul 2021 08:26:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D3EE06B0072; Fri, 9 Jul 2021 08:26:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C07706B0073; Fri, 9 Jul 2021 08:26:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id A01656B0071 for ; Fri, 9 Jul 2021 08:26:05 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DB05B180943E3 for ; Fri, 9 Jul 2021 12:26:04 +0000 (UTC) X-FDA: 78342971448.20.3971C39 Received: from outbound-smtp17.blacknight.com (outbound-smtp17.blacknight.com [46.22.139.234]) by imf02.hostedemail.com (Postfix) with ESMTP id 5B2C17001A0A for ; Fri, 9 Jul 2021 12:26:04 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp17.blacknight.com (Postfix) with ESMTPS id ADD511C5DF2 for ; Fri, 9 Jul 2021 13:26:02 +0100 (IST) Received: (qmail 31164 invoked from network); 9 Jul 2021 12:26:02 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.17.255]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 9 Jul 2021 12:26:02 -0000 Date: Fri, 9 Jul 2021 13:26:01 +0100 From: Mel Gorman To: Yanfei Xu Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] mm/page_alloc: avoid counting event if no successful allocation Message-ID: <20210709122601.GA3840@techsingularity.net> References: <20210709102855.55058-1-yanfei.xu@windriver.com> <20210709102855.55058-2-yanfei.xu@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20210709102855.55058-2-yanfei.xu@windriver.com> User-Agent: Mutt/1.10.1 (2018-07-13) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf02.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.234 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 5B2C17001A0A X-Stat-Signature: 6ryd1juo57u4rcrgifd6ryh9q5pg6ter X-HE-Tag: 1625833564-29371 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: On Fri, Jul 09, 2021 at 06:28:55PM +0800, Yanfei Xu wrote: > 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. > The much more likely path is that nr_account is positive so we avoid a branch in the common case. > And this commit extract the check of "page_array" from a while > statement to avoid unnecessary checks for it. > I'm surprised the compiler does not catch that page_array is invariant for the loop. Did you check if gcc generates different code is page_array is explicitly checked once instead of putting it in the loop? -- Mel Gorman SUSE Labs