Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp610390pxv; Fri, 9 Jul 2021 05:31:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXRVG0QIFvjt4tSjLv3VWZaJ390r1Z+ZV91lXBKTLEKgXVmB/f0PPlQquevqBd8yWJSVWF X-Received: by 2002:a17:907:d09:: with SMTP id gn9mr34408652ejc.447.1625833861851; Fri, 09 Jul 2021 05:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625833861; cv=none; d=google.com; s=arc-20160816; b=hFEfI43hygY/QL96fbi209kZE/1ky3Lud37juiVhLvOwb78NE8tkajUWL16WpH67Ja KnmWZKgEGK1Zgm7ftMS8rsp9wDcYYOyYbuxiWBGEe103vOOGCzqcBj71MDzVdqp9+1Lh nzWfaA+3FkakrLAmqn+RClUXwPDbi5Xm0RdShgEtD2iUN2ZaE5CtchuaxESbYeaZBAqs 90MwmQfH6qhvzhuOIEN5RuS6GhOwBx57RBTA13NhEDmkL8iJ1dqKouR10R/KxkSq8Grd Y5jvZMBBp7XM9idjJdCDqmGp6qcDmCCoTI1fm5/qBmZILcGO42AV2QyQt/GCvOzrNOaN 86Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=XXoRoYNeqjOPHhf0LUpYn3rmyKmNQPmiVB2s1TmBVAk=; b=dSxCdcih03jxbVphyUXYR5s44llkvi818eZ/jQnHxbaPXI44KWSLxBYYPyw3LLXcOJ ZGZCnRwjfZl3bbngu+1goII1+wx5luFONRqwyHrQVtnGI0ltSkBSfJ/fLqBMexR1e1zY 7eYw52xHdnPBAPxg2og+Un0qmdhgoRf3KN1U0MucMlXsk4sok+rnAfhIZkL8BzsapU7O udHTYZ8Iy7oLTDg4SV/XAd22VfAWn2cgkOaTVg+jY5Y5T5fJ6+1d9gjX5Rp/AQKVRAuS 8sk6ku4kHyhSGNFFIASkmvwinj/8glafuGrzcWlFMBRXKuDCKrqcNdURLc3YM9Sjes07 q7nQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp6si8337129ejc.695.2021.07.09.05.30.27; Fri, 09 Jul 2021 05:31:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231142AbhGIM2r (ORCPT + 99 others); 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