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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 3561AC433E0 for ; Tue, 26 Jan 2021 16:25:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D0D2522210 for ; Tue, 26 Jan 2021 16:25:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D0D2522210 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 39E688D00F1; Tue, 26 Jan 2021 11:25:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 326448D00B0; Tue, 26 Jan 2021 11:25:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1EE988D00F1; Tue, 26 Jan 2021 11:25:07 -0500 (EST) 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 04C568D00B0 for ; Tue, 26 Jan 2021 11:25:07 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BBE74181AEF30 for ; Tue, 26 Jan 2021 16:25:06 +0000 (UTC) X-FDA: 77748450612.18.angle91_20112b62758f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 9837D100ED9DE for ; Tue, 26 Jan 2021 16:25:06 +0000 (UTC) X-HE-Tag: angle91_20112b62758f X-Filterd-Recvd-Size: 2231 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Tue, 26 Jan 2021 16:24:58 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id EE0D9ACF5; Tue, 26 Jan 2021 16:24:57 +0000 (UTC) Subject: Re: [PATCH] mm/workingset.c: avoid unnecessary max_nodes estimation in count_shadow_nodes() To: Miaohe Lin , akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210123073825.46709-1-linmiaohe@huawei.com> From: Vlastimil Babka Message-ID: <8dea8eff-3100-4f57-5d61-e532803d256f@suse.cz> Date: Tue, 26 Jan 2021 17:24:57 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210123073825.46709-1-linmiaohe@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 1/23/21 8:38 AM, Miaohe Lin wrote: > If list_lru_shrink_count is 0, we always return SHRINK_EMPTY regardless of > the value of max_nodes. So we can return early if nodes == 0 to save some > cpu cycles of approximating a reasonable limit for the nodes. > > Signed-off-by: Miaohe Lin Acked-by: Vlastimil Babka > --- > mm/workingset.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/mm/workingset.c b/mm/workingset.c > index 10e96de945b3..7db8f3dad13c 100644 > --- a/mm/workingset.c > +++ b/mm/workingset.c > @@ -461,6 +461,8 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker, > unsigned long pages; > > nodes = list_lru_shrink_count(&shadow_nodes, sc); > + if (!nodes) > + return SHRINK_EMPTY; > > /* > * Approximate a reasonable limit for the nodes > @@ -503,9 +505,6 @@ static unsigned long count_shadow_nodes(struct shrinker *shrinker, > > max_nodes = pages >> (XA_CHUNK_SHIFT - 3); > > - if (!nodes) > - return SHRINK_EMPTY; > - > if (nodes <= max_nodes) > return 0; > return nodes - max_nodes; >