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 C8F26C07E99 for ; Fri, 9 Jul 2021 12:26:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9461F6135C for ; Fri, 9 Jul 2021 12:26:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231252AbhGIM2r (ORCPT ); Fri, 9 Jul 2021 08:28:47 -0400 Received: from outbound-smtp49.blacknight.com ([46.22.136.233]:51231 "EHLO outbound-smtp49.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbhGIM2q (ORCPT ); Fri, 9 Jul 2021 08:28:46 -0400 Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp49.blacknight.com (Postfix) with ESMTPS id AD24BFB3D1 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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