Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp790551pxy; Wed, 5 May 2021 14:05:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLT3/b7p+yNVUpkB7AgEv+bVtTWvYajrbvt7mvLT39JYmidwtaoc2XJ3MrCuuc6WLnJZAN X-Received: by 2002:a17:906:5654:: with SMTP id v20mr708572ejr.462.1620248750283; Wed, 05 May 2021 14:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620248750; cv=none; d=google.com; s=arc-20160816; b=r3Hrs4M1ru6qSoWwfAT8gMIys2W356Wg5vOBvj/ucZ1dzzwCO+NSuJSAPmfLcN0XGC lh2bAqJmDEzpJVs/Cz5S5wcIZJHUgDQz1c4VFwA3GVU4oTdFPO8j6OHzrUnMBTZg1LNb 9yk060UsNLnYv1TjZSGU+nfsUsLKHvBBJMUvdtHYuC+7d5ulh6d7hXPpDdI6hVIZAZng 3242ETVlGBxfOdemt90SNLo21CV2yDUjjtnuyBLw3GKJTPh65cxj3wqH8Zuea3BSI5iK jMkas9l2AbXVYbnlJOXZ9tCzKxP/StDcNuA14iYCAxEgsxdLsn90ygp18j9PUxzCAQOO 8Gvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=sp6zs1ct6ZutkKpokv+nsMB40a5kSzzW57yCb7izaMY=; b=UQaj28T5y+gdZ8MXZB0n6Xo/ipyP5NFxLXLIU7MLK+9SR90+4Ir3A4KcY3O81dwoff GR/Q/fVeNKZPVkyMlVXFhuf9B5bt0pCityrWCU1nK7mf2zpLMQ5JfB+WcFjNQBv3mUMv ZYZ577hDKW2jVN/OFT1X6pCFN90J4TaKzyQXVkRgA3jXxQeOxAD4n7/3Z6SK+RgMHpNS ZlGLHpdzs/feb0zIV7hnd/aKGr9ecb/OAGKYUl3+4CESWrKt10wzuM7v4l6CRjVNOVfQ JR+eN1e88SZjN5Rgpgf1K/6RY8e+ko/niXFPLDFnazMOzWSPaDzAe3YTf2VPi4XoBO4c hL3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=beBzr20N; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f6si437567ejt.379.2021.05.05.14.05.26; Wed, 05 May 2021 14:05:50 -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=@redhat.com header.s=mimecast20190719 header.b=beBzr20N; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233775AbhEEUHl (ORCPT + 99 others); Wed, 5 May 2021 16:07:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23815 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233758AbhEEUHj (ORCPT ); Wed, 5 May 2021 16:07:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620245202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=sp6zs1ct6ZutkKpokv+nsMB40a5kSzzW57yCb7izaMY=; b=beBzr20NUfxwX7T1Tsi3oIU8SIrKkFubOw4JZoCONgPzFtLX3yeZ1skLbYZUhCe3TuXn3p Ed0LpBAOhAqQsV0UBc2ar9pvR7cuGJzihE5NeFq+LEWPCQM6b1FV8OplwIcB5NomrFLI6H T7DsXz1sgPJisZv1+VjqJHFHpLr3nZk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-144-0DTu22x2PDGISfDhzQtVdQ-1; Wed, 05 May 2021 16:06:38 -0400 X-MC-Unique: 0DTu22x2PDGISfDhzQtVdQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0C09E835DE3; Wed, 5 May 2021 20:06:37 +0000 (UTC) Received: from llong.com (ovpn-117-4.rdu2.redhat.com [10.10.117.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6219810023AB; Wed, 5 May 2021 20:06:35 +0000 (UTC) From: Waiman Long To: Johannes Weiner , Michal Hocko , Vladimir Davydov , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Shakeel Butt Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Waiman Long Subject: [PATCH v4 1/3] mm: memcg/slab: Properly set up gfp flags for objcg pointer array Date: Wed, 5 May 2021 16:06:08 -0400 Message-Id: <20210505200610.13943-2-longman@redhat.com> In-Reply-To: <20210505200610.13943-1-longman@redhat.com> References: <20210505200610.13943-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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]); -- 2.18.1