From patchwork Wed Jul 10 01:56:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexs@kernel.org X-Patchwork-Id: 13728782 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EEDAC2BD09 for ; Wed, 10 Jul 2024 01:51:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5C906B008C; Tue, 9 Jul 2024 21:51:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D0C946B0095; Tue, 9 Jul 2024 21:51:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB8616B009D; Tue, 9 Jul 2024 21:51:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9D1086B008C for ; Tue, 9 Jul 2024 21:51:14 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0C8BB1216A6 for ; Wed, 10 Jul 2024 01:51:14 +0000 (UTC) X-FDA: 82322165268.06.7B93CE9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id EF0DD10000F for ; Wed, 10 Jul 2024 01:51:10 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EpAHh+3s; spf=pass (imf14.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720576240; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=JTt/ch9VyxrMUwiEXaanXSEgG75s5E9Po6FvjgX0Ubg=; b=6eR3of1hL1sEiiCT0MqE+ipruZy1gtkUDYUAmjCL9mG4xW3V+7hXL0yUI9FlJZreYk5BUe BElgBWAVYLXr47VNYcLLIhtrZ4Ji8qYnHV5vN6gpHrOytDmJ3eRqhMVSSXA1G3ev7jaWV3 IrAYZQasf9R/Z/O5knFjuRrHHo07n6Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720576240; a=rsa-sha256; cv=none; b=5vC8Ga9NC/x8S+Zg/IGEdBAfTq7y4okuvGUNl3NfA+rGgMm8ydaior8+vd8cDqSS09YBl3 6z4acoFJZXg5+zqMaY1e0mZ5FATWoCFyGP/X8r6diuWdh40L8ROy5//81egaLuVMNGQ47j CA2DweCzaNoacBjDWHXFWPUXrr/w+BY= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=EpAHh+3s; spf=pass (imf14.hostedemail.com: domain of alexs@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alexs@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B113C61692; Wed, 10 Jul 2024 01:51:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D9E6C3277B; Wed, 10 Jul 2024 01:51:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720576269; bh=ZvLp7r5qYpXgQ8FeJYMYjuwJ6F6KhsV/1xQSB21NOzY=; h=From:To:Cc:Subject:Date:From; b=EpAHh+3sKtz1m+bYgcFLVMI5KjLyu0QMXujNasDcqXOK+IGr7IQBtM+eHAk5nzRz+ tMk6XRyqPl7l5A1BVK5AqaccCektN/8Dhy752zi3rsCDh6EqrASj9AfqE06oNPkb+u RlqtaGS7nBYx58z+sPhHOPJIIsH2Q17uZDG7LEp8cyWQVUNJ++Pv1ZrgEndq4VYyKr 3nk94moYyIg8C5KVOH5nS5Y1KwoL2gN3Sp1BNDwqP0SduRUZAjhSYGlDgpfHDV4kC+ uHBbVV2EPUclEOEMkuqShJFgIeiEdgIXV25oVk93Q+IEPLqZSzJDaMOVZtzkCOODSe 6qDR8/rj6yEkQ== From: alexs@kernel.org To: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, "Gustavo A . R . Silva" , Vincent Guittot , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Petr Mladek , Masahiro Yamada , Randy Dunlap , Yoann Congal , "Alex Shi (Tencent)" , Suren Baghdasaryan Subject: [PATCH v2] mm/memcg: alignment memcg_data define condition Date: Wed, 10 Jul 2024 09:56:08 +0800 Message-ID: <20240710015608.100801-1-alexs@kernel.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: EF0DD10000F X-Stat-Signature: 1z3j5p9u6swnutg1wxabcjs9k45i3dqu X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1720576270-473982 X-HE-Meta: U2FsdGVkX1/j0kRG8q9N2UkY4hMLETG8iAkHgml24uFtFc4mMgPkzpaGffzDQ6CsPnl2l7csIeGJTnjH6hYux8WKvlktTRNcaekiiL8Mm8yuXlWYKeGqdbfhf3TEGK0XBM3C3IJxrZH90wozRt14IXLq++i9vyQZfZkcxvwHK4Q2NZzu4p+oqB01qOkXwyazH+k14vKpOQgA9IC8D0CVDWH45Q29axe3qkh9iLOSpR8u/XIx3stNJX3cOYSFUpNP+g9Et8Cdbc5ZN3uQs3dqPWB+xo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p6jJ9ucdR7mIzCtPvMjxBsIkPuQJzDox0LZpDATYp6X0ngTn5NZAUa6EMBWCmawRSa34NYdTL9M6tukLAWC+gEApHiRJgJYyFPFpxCnvQD7jYiniN5VBqoc9KyTNFwt7Q+ug== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: "Alex Shi (Tencent)" commit 21c690a349ba ("mm: introduce slabobj_ext to support slab object extensions") changed the folio/page->memcg_data define condition from MEMCG to SLAB_OBJ_EXT. And selected SLAB_OBJ_EXT for MEMCG, just for SLAB_MATCH(memcg_data, obj_exts), even no other relationship between them. Above action make memcg_data exposed and include SLAB_OBJ_EXT for !MEMCG. That's incorrect in logcial and pay on code size. So let's remove SLAB_OBJ_EXT from MEMCG and as Vlastimil Babka suggested, add _unused_slab_obj_ext for SLAB_MATCH for slab.obj_exts while !MEMCG. That could resolve the match issue, clean up the feature logical and save the unnessary code adding. Signed-off-by: Alex Shi (Tencent) Cc: Randy Dunlap Cc: Yoann Congal Cc: Masahiro Yamada Cc: Petr Mladek Cc: Suren Baghdasaryan Cc: Vlastimil Babka --- include/linux/mm_types.h | 8 ++++++-- init/Kconfig | 1 - mm/slab.h | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index ef09c4eef6d3..4ac3abc673d3 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -180,8 +180,10 @@ struct page { /* Usage count. *DO NOT USE DIRECTLY*. See page_ref.h */ atomic_t _refcount; -#ifdef CONFIG_SLAB_OBJ_EXT +#ifdef CONFIG_MEMCG unsigned long memcg_data; +#elif defined(CONFIG_SLAB_OBJ_EXT) + unsigned long _unused_slab_obj_ext; #endif /* @@ -343,8 +345,10 @@ struct folio { }; atomic_t _mapcount; atomic_t _refcount; -#ifdef CONFIG_SLAB_OBJ_EXT +#ifdef CONFIG_MEMCG unsigned long memcg_data; +#elif defined(CONFIG_SLAB_OBJ_EXT) + unsigned long _unused_slab_obj_ext; #endif #if defined(WANT_PAGE_VIRTUAL) void *virtual; diff --git a/init/Kconfig b/init/Kconfig index 26bf8bb0a7ce..61e43ac9fe75 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -965,7 +965,6 @@ config MEMCG bool "Memory controller" select PAGE_COUNTER select EVENTFD - select SLAB_OBJ_EXT help Provides control over the memory footprint of tasks in a cgroup. diff --git a/mm/slab.h b/mm/slab.h index 3586e6183224..8ffdd4f315f8 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -98,7 +98,11 @@ SLAB_MATCH(flags, __page_flags); SLAB_MATCH(compound_head, slab_cache); /* Ensure bit 0 is clear */ SLAB_MATCH(_refcount, __page_refcount); #ifdef CONFIG_SLAB_OBJ_EXT +#ifdef CONFIG_MEMCG SLAB_MATCH(memcg_data, obj_exts); +#else +SLAB_MATCH(_unused_slab_obj_ext, obj_exts); +#endif #endif #undef SLAB_MATCH static_assert(sizeof(struct slab) <= sizeof(struct page));