Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3905809pxy; Tue, 4 May 2021 12:39:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5cC9kTRdVHPWMkqjIlkD2kknR/tfsWxcirReecF9nZO5Vi8kCCQb0IzmyTqWRwCh3i03s X-Received: by 2002:a17:906:3a45:: with SMTP id a5mr24286711ejf.288.1620157174598; Tue, 04 May 2021 12:39:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620157174; cv=none; d=google.com; s=arc-20160816; b=yu4lUxcmKLaIJwRFku34c53peAQyFZMdYH2+bU1H1fuRIFOOcfco6/5EY8d4fNTnAn yVBiILV7a7PNVBygRImzBDy+Uz+BXVBFtYDDf8qWTx7fsM4LaQTWKt39wYsyeacTwWTP /CtZmesA6UpWlhjQFjHW450SGRZDB0ZnLeRaZFNPtIMGllUmxW414x1LTHjajlHjdc9l WLE7ZO8qqkUDMoN4X1jvTWK/YADYVrRYoRCS9w656y6uFjAl/nGmxhbE6gqIb0MXXyQ5 n3QLrBErnsBHRLdAtBzcJdQJL05hpU/CC5J8/a/xqSoaB0GzHYjDx37bRn6c/dBY3RfU zTJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=btYsPAMNSGmXffsSk7+VR60HmUlYSHIt+oz7jjLh4E8=; b=G+MhoumpDdx9bZRQKabZHrOWmRNTODwSnmLWUe7fk5Pb6E/UhjOVS4GBrf4EjYm73u joiYwAuV9GNd9ItDwChu2pgvJgA4RrdZh02ZkYPKcVyv/IeFiyIbwcj5RXxnWNANSL8e XlvhAhCUhUe3lCOxIbCVqX5zpwcySvU2XKZPY/Lk29VysUMmbNNzH6ELARIM1ysfhAhQ 0x/qFyNzXMLHeNhQcdjPIVIJdPT+hElRc7BiMxGKajRAnZHzAUQJKrRwNYrTo/QaKuyh JCSdJDRspE3rDfsRc3fNM+MZTBcaqPLNRIjAONpY1HUUowcsvhh6svwro/zP4aK6oEbo fw2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=qm3h49sU; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a42si14743647edf.188.2021.05.04.12.39.09; Tue, 04 May 2021 12:39:34 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=qm3h49sU; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232181AbhEDTi1 (ORCPT + 99 others); Tue, 4 May 2021 15:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232153AbhEDTi0 (ORCPT ); Tue, 4 May 2021 15:38:26 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79BD9C061574 for ; Tue, 4 May 2021 12:37:31 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id z9so10526213lfu.8 for ; Tue, 04 May 2021 12:37:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=btYsPAMNSGmXffsSk7+VR60HmUlYSHIt+oz7jjLh4E8=; b=qm3h49sUOH2s6tvF7KNhGDE1XdJRjRppqoGSbXNvcIvjPgsmygPRL+Huz/bo6LwJJk /0FRs5hMe3DuFnhdCHSW6+PF81z+rW7Yt1/7pBaFsY8xruoFVGCDcCF3ric6+eGNMf26 QJi7EdjlGvaBNdL89o5778YfWQd2Lkstsx85AT0wSngk1QGxewfEqdZBOCTYlqRsu9jH X9EGZsayyWCKd39XPQumXqjjs0V/gicwgCK+mb4TGO6nhk+gLJK9zX6SjCWoDh5tJOWU viTvPxRimjGbUel53oqUg7BoKFeJM8s4RDOXTvYSemwmre0bTiaM5Gf4FCkfmH0nKTmb m5Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=btYsPAMNSGmXffsSk7+VR60HmUlYSHIt+oz7jjLh4E8=; b=TbNusL7PO7JN5pyK8RT2m0N3Cx0iRo5Fvl8IWxImwRfu+cPuoYW5AAs0FPksPEfe6Z 10rSXBEQsFpwRwbxRp160u8rfQjxJWEVaMBTtg92o3if0cRwG4VN+M4M1HnT2IZTCptE nMqxvsGt8igmG//w1s0mYE2X0IjpgzFSs7uZMlPid/8wamPnCtLchrro6wHYC9bqhItJ TWtpzOs7DA1NeFtXrl23Bm4UHmuP56jFVHdpa+Yo5VgM9awJNT4tlQhav9S1k7ML+OsK YzmiYpuHjbYFr1efpY5eLYwlyK7QtHVU/AMqCk0K+pC5/5UQiBabxAfPJwTKIl9bSQlE br5g== X-Gm-Message-State: AOAM530LAN1SIS7KPK8Y5EPfYjTNbqxZksl4UHkxXTXI4winTydTETVA L4l73RGs+avUuhI/ImVkrfOREL//8X4O8C1J/x4Q8g== X-Received: by 2002:a05:6512:acd:: with SMTP id n13mr17648346lfu.432.1620157049746; Tue, 04 May 2021 12:37:29 -0700 (PDT) MIME-Version: 1.0 References: <20210504132350.4693-1-longman@redhat.com> <20210504132350.4693-2-longman@redhat.com> In-Reply-To: <20210504132350.4693-2-longman@redhat.com> From: Shakeel Butt Date: Tue, 4 May 2021 12:37:18 -0700 Message-ID: Subject: Re: [PATCH v2 1/2] mm: memcg/slab: Properly set up gfp flags for objcg pointer array To: Waiman Long Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , LKML , Cgroups , Linux MM Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 4, 2021 at 6:24 AM 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 > --- > 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) What about __GFP_DMA32? Does it matter? It seems like DMA32 requests go to normal caches. > + > 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]); > -- > 2.18.1 >