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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90041C433EF for ; Mon, 28 Mar 2022 12:01:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242164AbiC1MDS (ORCPT ); Mon, 28 Mar 2022 08:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242154AbiC1MDP (ORCPT ); Mon, 28 Mar 2022 08:03:15 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBAB1767C; Mon, 28 Mar 2022 05:01:34 -0700 (PDT) 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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