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=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 25728C55178 for ; Tue, 27 Oct 2020 14:31:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A2278206DC for ; Tue, 27 Oct 2020 14:31:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="QScZCtVJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2278206DC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 343F96B0070; Tue, 27 Oct 2020 10:31:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 319566B0071; Tue, 27 Oct 2020 10:31:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 256D86B0072; Tue, 27 Oct 2020 10:31:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id ED52D6B0070 for ; Tue, 27 Oct 2020 10:31:48 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 66A21180AD806 for ; Tue, 27 Oct 2020 14:31:48 +0000 (UTC) X-FDA: 77417944296.22.moon42_3c0003e2727c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 3607418038E68 for ; Tue, 27 Oct 2020 14:31:48 +0000 (UTC) X-HE-Tag: moon42_3c0003e2727c X-Filterd-Recvd-Size: 4768 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Tue, 27 Oct 2020 14:31:47 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1603809106; h=from:from:reply-to:subject:subject: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=uuw37CmdGgaUF2rTsLXZIxdwBi56keqYJAASysIsH4U=; b=QScZCtVJ88Ft10nSiaAM31z9hd30tvg7sm0uLaSV0xvsBBwNiIAiXthx+uw5HdJDHCO2gL /LScYs8N/+/Y/g1sEzi3bViteDVWpDr9u5cLVN927E+Y2dug78ERP+RSXwlnzu8X2JnfZ0 dPK7a+yMSWEJqpmUm9TGElUUj2fhHV4= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1F098AC1F; Tue, 27 Oct 2020 14:31:46 +0000 (UTC) Date: Tue, 27 Oct 2020 15:31:41 +0100 From: Michal Hocko To: Muchun Song Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , Shakeel Butt , Roman Gushchin , Joonsoo Kim , laoar.shao@gmail.com, Chris Down , Christian Brauner , Peter Zijlstra , Ingo Molnar , Kees Cook , Thomas Gleixner , esyr@redhat.com, Suren Baghdasaryan , areber@redhat.com, Marco Elver , LKML , Cgroups , Linux Memory Management List Subject: Re: [External] Re: [PATCH 5/5] mm: memcontrol: Simplify the mem_cgroup_page_lruvec Message-ID: <20201027143141.GX20500@dhcp22.suse.cz> References: <20201027080256.76497-1-songmuchun@bytedance.com> <20201027080256.76497-6-songmuchun@bytedance.com> <20201027133639.GT20500@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Tue 27-10-20 22:15:16, Muchun Song wrote: > On Tue, Oct 27, 2020 at 9:36 PM Michal Hocko wrote: > > > > On Tue 27-10-20 16:02:56, Muchun Song wrote: > > > We can reuse the code of mem_cgroup_lruvec() to simplify the code > > > of the mem_cgroup_page_lruvec(). > > > > yes, removing the code duplication is reasonable. But ... > > > > > > > > Signed-off-by: Muchun Song > > > --- > > > include/linux/memcontrol.h | 44 +++++++++++++++++++++++++++----------- > > > mm/memcontrol.c | 40 ---------------------------------- > > > 2 files changed, 32 insertions(+), 52 deletions(-) > > > > > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > > > index 95807bf6be64..5e8480e54cd8 100644 > > > --- a/include/linux/memcontrol.h > > > +++ b/include/linux/memcontrol.h > > > @@ -451,16 +451,9 @@ mem_cgroup_nodeinfo(struct mem_cgroup *memcg, int nid) > > > return memcg->nodeinfo[nid]; > > > } > > > > > > -/** > > > - * mem_cgroup_lruvec - get the lru list vector for a memcg & node > > > - * @memcg: memcg of the wanted lruvec > > > - * > > > - * Returns the lru list vector holding pages for a given @memcg & > > > - * @node combination. This can be the node lruvec, if the memory > > > - * controller is disabled. > > > - */ > > > -static inline struct lruvec *mem_cgroup_lruvec(struct mem_cgroup *memcg, > > > - struct pglist_data *pgdat) > > > +static inline struct lruvec *mem_cgroup_node_lruvec(struct mem_cgroup *memcg, > > > + struct pglist_data *pgdat, > > > + int nid) > > > > This is just wrong interface. Either take nid or pgdat. You do not want > > both because that just begs for wrong usage. > > If we want to avoid abuse of mem_cgroup_node_lruvec. We can move > those functions to the memcontrol.c. And add the "static" attribute to the > mem_cgroup_node_lruvec. Just export mem_cgroup_lruvec and > mem_cgroup_page_lruvec. Is this OK? Sorry, I was probably not clear enough. I am not against the function per se. I just do not think we want to make it trickier to use than necessary. That means either use pgdat or nid argument. Not both because they should always be in sync and you can trivially get from one to the other and vice versa. -- Michal Hocko SUSE Labs