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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62215C433F5 for ; Mon, 28 Mar 2022 12:01:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B01E98D0002; Mon, 28 Mar 2022 08:01:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A881C8D0001; Mon, 28 Mar 2022 08:01:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 902588D0002; Mon, 28 Mar 2022 08:01:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 7C7C18D0001 for ; Mon, 28 Mar 2022 08:01:46 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 44A8E121374 for ; Mon, 28 Mar 2022 12:01:46 +0000 (UTC) X-FDA: 79293655812.08.1FDBB1C Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf21.hostedemail.com (Postfix) with ESMTP id 3ABE81C0044 for ; Mon, 28 Mar 2022 12:01:41 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 7A2AD210EB; Mon, 28 Mar 2022 12:01:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1648468893; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c6Z5kgi2wB4asWItH9cY1KuHpvBDFVgytOlK7MLeiuA=; b=Gog9U0tdKPz+Wl+YHWZ8KNw1A2fwCjwtYp9Q+XJJJNcvkWmFWqyrbmiUHjSlgjYzBI9y0J R6gzG0GJ2Tj4tUSrSMqZkjJvpYL2NKDYqOXZGRaD8Eiof5wjPpJUf7xPAYYbI/9EWoEXpI 4Y/n/ZiTuszwootYfN1QRb8I1uNjI4s= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 18364A3B82; Mon, 28 Mar 2022 12:01:33 +0000 (UTC) Date: Mon, 28 Mar 2022 14:01:32 +0200 From: Michal Hocko To: Miaohe Lin Cc: hannes@cmpxchg.org, roman.gushchin@linux.dev, shakeelb@google.com, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/memcg: remove unneeded nr_scanned Message-ID: References: <20220328114144.53389-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220328114144.53389-1-linmiaohe@huawei.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 3ABE81C0044 X-Stat-Signature: 3aoorwoaeyhc7p89t1m98147rzmzgiwm X-Rspam-User: Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=Gog9U0td; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf21.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com X-HE-Tag: 1648468901-428548 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 Mon 28-03-22 19:41:44, Miaohe Lin wrote: > The local variable nr_scanned is unneeded as mem_cgroup_soft_reclaim always > does *total_scanned += nr_scanned. So we can pass total_scanned directly to > the mem_cgroup_soft_reclaim to simplify the code and save some cpu cycles > of adding nr_scanned to total_scanned. Maybe the compiler could be clever enough to generate a good code. mem_cgroup_soft_reclaim doesn't have other caller so it could be inlined. But I do agree that the change makes sense because it makes the code more consistent as mem_cgroup_soft_limit_reclaim already uses total_scanned this way. > Signed-off-by: Miaohe Lin Acked-by: Michal Hocko Thanks > --- > mm/memcontrol.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index b686ec4f42c6..79341365ec90 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -3384,7 +3384,6 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, > int loop = 0; > struct mem_cgroup_tree_per_node *mctz; > unsigned long excess; > - unsigned long nr_scanned; > > if (order > 0) > return 0; > @@ -3412,11 +3411,9 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, > if (!mz) > break; > > - nr_scanned = 0; > reclaimed = mem_cgroup_soft_reclaim(mz->memcg, pgdat, > - gfp_mask, &nr_scanned); > + gfp_mask, total_scanned); > nr_reclaimed += reclaimed; > - *total_scanned += nr_scanned; > spin_lock_irq(&mctz->lock); > __mem_cgroup_remove_exceeded(mz, mctz); > > -- > 2.23.0 -- Michal Hocko SUSE Labs