Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3618216pxy; Tue, 4 May 2021 06:25:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOim1iYBS5G93YxmeoHznk1PVbFz/Fl/6KZq3vBxvfa2CuSz7ydOe0CzMDNFiVl5Se2doD X-Received: by 2002:a17:902:7683:b029:ec:a434:1921 with SMTP id m3-20020a1709027683b02900eca4341921mr25621444pll.67.1620134739590; Tue, 04 May 2021 06:25:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620134739; cv=none; d=google.com; s=arc-20160816; b=P14FI7hjzltL+Nm9H+JG99OOmf7Hp4NDIFGy5LuND8p3kqC+iHgpkh0MKzncleN/SJ v8x8NswU/fybVGsgUW2zlW4zLolcExwpnZbgEzxTKzuisst7Aq3As6g9bx4rVxBFd3zC 8HOLCWen8nYeGLQH45/Yweatgs4o+YO0W+/jDnQLXD2y56VhV+6Tn+AgvPjyOMOuGwyu PEq2Ur+4tuCUFmdgLQCJkeEBySc7bKskLIMmRAlJGD0q/N6lbsKigjt7UCQwXjlW5Zxz 9wkTA2HvOSihQxaRLUfkmXqtysLlV12eyuxp0JkYjyKprlCHXOfgbu2bwM3sWWx3nev9 4fSg== 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=UYxtPKpE548sgyGm/1fmGwS+oSULE1eFSrQRq98f+o4=; b=xQeUfFZE0igvUSwk+0Q19akZPNjm96+ejGGchgvm80lQMl3hTsLyT7+sTmtG7XMXVk gEB/ZI9fKu076eJSc2ImbyYhrBEh8vYSQYJXZF1bxEqEbJtNJsh8L5872ZFoshKiDRR7 HCrlUPG/qnVYBQnGYBqE0txsUZ26sE29tnIrzvKgXrAIgMomtyOCZcFXU2OLcniIL2B4 SORt0DaW1gRULlOdyJagvdLa1jhXqo2yWrjFzKc4Zsx5Hj0FKwmZQzCZCyZIj8ImsIEx bY/6MwHtTaeiImZlquMv73K1GxeDxh+jPyicviA6gi7FnGKXU8bTQ0OysCa8W41z1esI u4eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UfPGcj9c; 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 z11si3720802pgj.89.2021.05.04.06.25.23; Tue, 04 May 2021 06:25:39 -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=UfPGcj9c; 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 S231195AbhEDNZk (ORCPT + 99 others); Tue, 4 May 2021 09:25:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30180 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231179AbhEDNZj (ORCPT ); Tue, 4 May 2021 09:25:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620134684; 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=UYxtPKpE548sgyGm/1fmGwS+oSULE1eFSrQRq98f+o4=; b=UfPGcj9cHZEQY9/NXWraYBTOkuW9hP/7lyrFn6rK0LUHQK6ck5h0Y5pv9cjKJqtYcLqF/1 V2p+VzP4dA3tEj9FuII7pZud+MlBC0XNZNKuplgXvWeFE1j7UEE5CL7YGpt6zVt3cHzcPb cI+5UF8+g1k8O6TYqjwvE2P9tFeRy4Q= 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-278-nkQpdF6LPIiH6RVXqqhTJQ-1; Tue, 04 May 2021 09:24:40 -0400 X-MC-Unique: nkQpdF6LPIiH6RVXqqhTJQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A5496835DE2; Tue, 4 May 2021 13:24:38 +0000 (UTC) Received: from llong.com (ovpn-115-230.rdu2.redhat.com [10.10.115.230]) by smtp.corp.redhat.com (Postfix) with ESMTP id 335D4608BA; Tue, 4 May 2021 13:24:37 +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 v2 1/2] mm: memcg/slab: Properly set up gfp flags for objcg pointer array Date: Tue, 4 May 2021 09:23:49 -0400 Message-Id: <20210504132350.4693-2-longman@redhat.com> In-Reply-To: <20210504132350.4693-1-longman@redhat.com> References: <20210504132350.4693-1-longman@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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 --- 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