Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1786554pxy; Thu, 6 May 2021 16:15:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfeubIZnf+4cgtI6KDDnwQohC8LN0k/KTIvbw5WH7+liHED5Q+ZPgFGKkeeBJF5VT6Uz/U X-Received: by 2002:a17:902:bf46:b029:ee:b949:bd0 with SMTP id u6-20020a170902bf46b02900eeb9490bd0mr7418606pls.14.1620342952344; Thu, 06 May 2021 16:15:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620342952; cv=none; d=google.com; s=arc-20160816; b=fH9X2MNKfZIWOxOMwdRfQ+AJUNbG+21NOBVZhTcKeC/P0WQjoP5ikKl45D6Z2Ham11 BO1g7qcDrKrcaRiGPjSaOA2h0nNIIrHQwBlkmWXSRmGoMcIUab0yUNRjHhuGmCBPWKnB DOC5T5zvRHSNVSCg/8PsgD5vgYZ0FwxnRZHxIUjHjbc6zYWfoGvnnzK6GjnHhptzffiA 8EbcOGzPHqx8b+MLGXQWDqOPA9M0EfNKySgLMv3L4/0gAFqyjkWuvIlaqd2m0hvb3Le3 tJarHdIyZaY5xvpDva0x0eKTseob4uzuAnXkXbxBCdOZXAg/MnJ+ZwjGYVkDHdt1vWpJ 8gFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=pHP9HLTJIhCrMzIQWVYkS7GWe2KXtSI4OPyyJcqcyX0=; b=C0rdvf+huk1Sj6qI2aZDf6e2tHtavMGcEEoTOYUB67llK5usfRnZJ7B/YS2uqeYUAx IkbfpogSUxfTvNPlYQ8oSEQJ+1tJDA3eoA0IXyhfaoL+qBW9ITHA8/82XpszgXM10HAF dIAJmDJODJolqPdrWsBpK+byxnwgJLdehZssl3axP4/tMJR+1ZZ22zk0UPCOzjLLmbog KgBzwbDM/WcA9CegriEec0r+1vZnUk4TIyz0xIxvfpSKpTeXMnBCiC4aWDjkei9FWHjK VgMK6xHflpTixCthmfZT3khYlZUn4vPLAJoguREMm8ERdpnxKyed/QFhHuEgSKvrnp8a v9uQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a6si4795054pgm.17.2021.05.06.16.15.39; Thu, 06 May 2021 16:15:52 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235761AbhEFPj6 (ORCPT + 99 others); Thu, 6 May 2021 11:39:58 -0400 Received: from mx2.suse.de ([195.135.220.15]:41890 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236172AbhEFPiY (ORCPT ); Thu, 6 May 2021 11:38:24 -0400 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 45852B207; Thu, 6 May 2021 15:37:25 +0000 (UTC) Subject: Re: [PATCH v4 1/3] mm: memcg/slab: Properly set up gfp flags for objcg pointer array To: Waiman Long , Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Roman Gushchin , Shakeel Butt Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org References: <20210505200610.13943-1-longman@redhat.com> <20210505200610.13943-2-longman@redhat.com> From: Vlastimil Babka Message-ID: <46fb83c8-d875-9f85-da2c-ac2ba4847c07@suse.cz> Date: Thu, 6 May 2021 17:37:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210505200610.13943-2-longman@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/5/21 10:06 PM, Waiman Long wrote: > Since the merging of the new slab memory controller in v5.9, the page > structure may store a pointer to obj_cgroup pointer array for slab pages. > Currently, only the __GFP_ACCOUNT bit is masked off. However, the array > is not readily reclaimable and doesn't need to come from the DMA buffer. > So those GFP bits should be masked off as well. > > Do the flag bit clearing at memcg_alloc_page_obj_cgroups() to make sure > that it is consistently applied no matter where it is called. > > Fixes: 286e04b8ed7a ("mm: memcg/slab: allocate obj_cgroups for non-root slab pages") > Signed-off-by: Waiman Long > Reviewed-by: Shakeel Butt Reviewed-by: Vlastimil Babka > --- > mm/memcontrol.c | 8 ++++++++ > mm/slab.h | 1 - > 2 files changed, 8 insertions(+), 1 deletion(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index c100265dc393..5e3b4f23b830 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -2863,6 +2863,13 @@ static struct mem_cgroup *get_mem_cgroup_from_objcg(struct obj_cgroup *objcg) > } > > #ifdef CONFIG_MEMCG_KMEM > +/* > + * The allocated objcg pointers array is not accounted directly. > + * Moreover, it should not come from DMA buffer and is not readily > + * reclaimable. So those GFP bits should be masked off. > + */ > +#define OBJCGS_CLEAR_MASK (__GFP_DMA | __GFP_RECLAIMABLE | __GFP_ACCOUNT) > + > int memcg_alloc_page_obj_cgroups(struct page *page, struct kmem_cache *s, > gfp_t gfp, bool new_page) > { > @@ -2870,6 +2877,7 @@ int memcg_alloc_page_obj_cgroups(struct page *page, struct kmem_cache *s, > unsigned long memcg_data; > void *vec; > > + gfp &= ~OBJCGS_CLEAR_MASK; > vec = kcalloc_node(objects, sizeof(struct obj_cgroup *), gfp, > page_to_nid(page)); > if (!vec) > diff --git a/mm/slab.h b/mm/slab.h > index 18c1927cd196..b3294712a686 100644 > --- a/mm/slab.h > +++ b/mm/slab.h > @@ -309,7 +309,6 @@ static inline void memcg_slab_post_alloc_hook(struct kmem_cache *s, > if (!memcg_kmem_enabled() || !objcg) > return; > > - flags &= ~__GFP_ACCOUNT; > for (i = 0; i < size; i++) { > if (likely(p[i])) { > page = virt_to_head_page(p[i]); >