Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1949949pxb; Fri, 5 Mar 2021 03:54:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzdvvcICAjVBJ7V3LVCWILXem90sMQj3E9Aaq3H2aUp43nKBQqbMKxAMjWH08wrWytttP9y X-Received: by 2002:a50:fe17:: with SMTP id f23mr9000956edt.258.1614945260203; Fri, 05 Mar 2021 03:54:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614945260; cv=none; d=google.com; s=arc-20160816; b=hnafPa4sH9TSE8K+gVY61aVcvORQBN9pQch0BUOAULrei6HkykhqTTYtCUH52AqfXr KfZFOPLL1D67UEsnar8Y8ASY4Ihr3Y7Em7d2+HnWVHXf8AvAd5H33t+Xd4LPy/8tUG2i 6gp8xpzJQ7WOSQueXOVmAfsgb1KinrIGu5Dds9cRbKMGRj/PpkBktEeKFnNVEgjw8iXX 9EteGUDdnXm65tkuSjDN2ttgQv4P2GGsGhck2pGfP72mhhkE1mGQiVMLJS3jB3B4GmBm DDrg+S/vPu7PhFC5xandCPeeXxnoOwkRB18V5GLfCAgF3Xz9Udi1qZjactq++0xeWqCW 6cuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=6WeC3+MgZVHAE3bpKTnOSw5jwR/M940LyaOSeo03HC4=; b=iHP4h8+UvPl7qewJK3KrpMysYdeRw74gaKO/UOLtUa+OUG/q/5SnbxgsiONY53DjPT zR8XGVsNYa6hbMjSWP0yqoMb6xm6y1cyqDepAN3edSc58qVDIFl05zhxcSw47YVJpuzR U64NncEmQCf+niJRW7ombLwI9Ucm4eHbQ3Y1Pg2q4fJYJ1+3uvQtXhxh6AT/5ghj9hQ2 07Llir22lxeL/ldsEvDTUoec7bP3PWDg6lvUiM47c19DygxGNzVRBvpLB5y5d125UmPX 58pMBEVGGkHEJzk6p61aaHQKQ1GBUcVaj+DP+1oPonebLw+ptqsXM1lbbxwZB/aQ50Uw sLNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=qtH+XHRf; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v1si1485907edb.592.2021.03.05.03.53.57; Fri, 05 Mar 2021 03:54:20 -0800 (PST) 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; dkim=pass header.i=@suse.com header.s=susede1 header.b=qtH+XHRf; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229749AbhCELsL (ORCPT + 99 others); Fri, 5 Mar 2021 06:48:11 -0500 Received: from mx2.suse.de ([195.135.220.15]:38366 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbhCELsD (ORCPT ); Fri, 5 Mar 2021 06:48:03 -0500 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=1614944882; 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=6WeC3+MgZVHAE3bpKTnOSw5jwR/M940LyaOSeo03HC4=; b=qtH+XHRf5FIZiV19w3D+9pUe6TJ52SfBcVbFfFU5eO0+gKQJ6uYkyJY2QCUSWcvXFvbg6K DbNZeAwZ4IMiuPbxOCUmvN3tOC0Nz2IU/Z+BGzRZhkU0jMLUfuLNTs92OhL/MJ6msyiLHA 8HKN9sr1/GtRgMs2/DfxkXigJ6h1gpI= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 35CE0AC54; Fri, 5 Mar 2021 11:48:02 +0000 (UTC) Date: Fri, 5 Mar 2021 12:48:00 +0100 From: Michal Hocko To: Zhou Guanghui Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, hannes@cmpxchg.org, hughd@google.com, kirill.shutemov@linux.intel.com, npiggin@gmail.com, ziy@nvidia.com, wangkefeng.wang@huawei.com, guohanjun@huawei.com, dingtianhong@huawei.com, chenweilong@huawei.com, rui.xiang@huawei.com Subject: Re: [PATCH v2 1/2] mm/memcg: rename mem_cgroup_split_huge_fixup to split_page_memcg Message-ID: References: <20210304074053.65527-1-zhouguanghui1@huawei.com> <20210304074053.65527-2-zhouguanghui1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210304074053.65527-2-zhouguanghui1@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 04-03-21 07:40:52, Zhou Guanghui wrote: > Rename mem_cgroup_split_huge_fixup to split_page_memcg and explicitly > pass in page number argument. > > In this way, the interface name is more common and can be used by > potential users. In addition, the complete info(memcg and flag) of > the memcg needs to be set to the tail pages. I think it is good to call out the css_get -> css_get_many as a microptimization explicitly. Even though I do not expect this to be easily visible it makes sense to save rcu section for each of the tail page in general. > Signed-off-by: Zhou Guanghui Acked-by: Michal Hocko > --- > include/linux/memcontrol.h | 6 ++---- > mm/huge_memory.c | 2 +- > mm/memcontrol.c | 15 ++++++--------- > 3 files changed, 9 insertions(+), 14 deletions(-) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index e6dc793d587d..0c04d39a7967 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -1061,9 +1061,7 @@ static inline void memcg_memory_event_mm(struct mm_struct *mm, > rcu_read_unlock(); > } > > -#ifdef CONFIG_TRANSPARENT_HUGEPAGE > -void mem_cgroup_split_huge_fixup(struct page *head); > -#endif > +void split_page_memcg(struct page *head, unsigned int nr); > > #else /* CONFIG_MEMCG */ > > @@ -1400,7 +1398,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order, > return 0; > } > > -static inline void mem_cgroup_split_huge_fixup(struct page *head) > +static inline void split_page_memcg(struct page *head, unsigned int nr) > { > } > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index 395c75111d33..e7f29308ebc8 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -2471,7 +2471,7 @@ static void __split_huge_page(struct page *page, struct list_head *list, > int i; > > /* complete memcg works before add pages to LRU */ > - mem_cgroup_split_huge_fixup(head); > + split_page_memcg(head, nr); > > if (PageAnon(head) && PageSwapCache(head)) { > swp_entry_t entry = { .val = page_private(head) }; > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 845eec01ef9d..e064ac0d850a 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -3287,24 +3287,21 @@ void obj_cgroup_uncharge(struct obj_cgroup *objcg, size_t size) > > #endif /* CONFIG_MEMCG_KMEM */ > > -#ifdef CONFIG_TRANSPARENT_HUGEPAGE > /* > - * Because page_memcg(head) is not set on compound tails, set it now. > + * Because page_memcg(head) is not set on tails, set it now. > */ > -void mem_cgroup_split_huge_fixup(struct page *head) > +void split_page_memcg(struct page *head, unsigned int nr) > { > struct mem_cgroup *memcg = page_memcg(head); > int i; > > - if (mem_cgroup_disabled()) > + if (mem_cgroup_disabled() || !memcg) > return; > > - for (i = 1; i < HPAGE_PMD_NR; i++) { > - css_get(&memcg->css); > - head[i].memcg_data = (unsigned long)memcg; > - } > + for (i = 1; i < nr; i++) > + head[i].memcg_data = head->memcg_data; > + css_get_many(&memcg->css, nr - 1); > } > -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */ > > #ifdef CONFIG_MEMCG_SWAP > /** > -- > 2.25.0 > -- Michal Hocko SUSE Labs