From patchwork Mon Feb 12 21:38:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13554047 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 1E1DDC4829D for ; Mon, 12 Feb 2024 21:40:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15F556B008A; Mon, 12 Feb 2024 16:39:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C2736B0092; Mon, 12 Feb 2024 16:39:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2BB06B008C; Mon, 12 Feb 2024 16:39:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CC5F36B0089 for ; Mon, 12 Feb 2024 16:39:55 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A2FFC802C7 for ; Mon, 12 Feb 2024 21:39:55 +0000 (UTC) X-FDA: 81784469550.29.E2E1B3A Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf21.hostedemail.com (Postfix) with ESMTP id DE35D1C000A for ; Mon, 12 Feb 2024 21:39:52 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=TMFpdhCX; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf21.hostedemail.com: domain of 3KJDKZQYKCKcZbYLUINVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3KJDKZQYKCKcZbYLUINVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707773992; a=rsa-sha256; cv=none; b=Pjzt3ORKfBWirFGokHdCe9NZHhSbeHbmsLNIWqFRgcYanh7Fq44XbAYuyuxZYvE4A31Rqc FqQ/FYc5jCajZsii7apOVxA8K/MeCmRmRSHrDgDsNAQLb8OQdr8ODJ0WP2tvnWIfroAv9L hBchOdrUDCCgBVghAHNEA4udRLtAsnU= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=TMFpdhCX; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf21.hostedemail.com: domain of 3KJDKZQYKCKcZbYLUINVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3KJDKZQYKCKcZbYLUINVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707773992; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Wy0D/wmUn3AGzRHJaKJZBS4cvr5irQ3tEAXEefF/wd0=; b=0L/fq/eF3JPcshHh7lAa6SG8jCBSLO8610TDhEHJM/OQ3cE1d6kfCSyzshIdU2C/DwGXpA HWvkvN2zgnBgcKKujj632FoYOMpdfKkIUAhpjF0piDl/ZrhP87Bk8a/RRFLGoNfMLsVVjt sSJIh98lAKruZEFBOEYXgFAonY4O4O4= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-604ac3c75ebso68375527b3.0 for ; Mon, 12 Feb 2024 13:39:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707773992; x=1708378792; darn=kvack.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Wy0D/wmUn3AGzRHJaKJZBS4cvr5irQ3tEAXEefF/wd0=; b=TMFpdhCX3j1xquLdGUtOzMbfpai69IciqRQUbvKfxf6ZiE6oQvA3nICX3B1gwKLwgu X65dSIEclKcQGNRpsItziEdPHZ+ASQ1HWfoFt9DcCyOc8SKrbI89H1k5TveZ+xPTj4nX 8bnElEZWHGshNpPrxl+ZsTegYwANWHEujMJpQFSWRmJSLIlDuGW/KtllLVx9Vkxe7NiE biB+Z+6unBBoWPq+ySGqDgVGY49Sg10dHIi0mCgU8/sfkeUuF2TNfqY9ChYSjASP948o GcG3/W/ZulWyw3aqwUFPxIdFHzJago8Kn2X3DU4aSq4bq5hpmZjxqhWrBFs2wPrYEE/f xKIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707773992; x=1708378792; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Wy0D/wmUn3AGzRHJaKJZBS4cvr5irQ3tEAXEefF/wd0=; b=DTcNoT9PGh/0POFkSDmUYDUVx7fvCBb0H0LWkw9VHzddchcv/Pl1ZPE35lBaK5p+BN cyObUURYSAKvs8exBjhYhGsIA9t9wtPUFoU6AEn0ZnqQ8iazIGbbvbwHEhvXIu8lgxSI IfP5FNnItpGmd+RQHB4lB7aPkZrXrow1M/vwgtPBMn6EfMpeTPsxyPe3xwPG/UmiN5r2 Tur4T/S0w/aWrswg0W2tXai6QM48HyDuz5+xJyCf5z0IN0NnHEuzDH/uuYNl1mkiRfcA aHoA4fiC4PvtpnNUzp7nbvNxsoDQokc1IA88ElFfcVJmPWImKLGxoPXs07cNOYU+bmZg AUdA== X-Gm-Message-State: AOJu0YyLBTQX24i1YW1YKsYf9Ek16rORriIOmLPAlAam/hUUqaMAGlbu KX4eoGuFd1ME0CxGFlb660OdQ5Rf2Jo/TBfWl9BTRqBNkDzrjwsZEtSNS5+sos4bx40/kNQDBeP HBg== X-Google-Smtp-Source: AGHT+IGJNldcJg1nJudvCE1Sp9g/6sTQwYzeBOB4AMRF5kjsz9nHiwJOvFtrkpc6PJTXjQSExrbdy8gvy1w= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:b848:2b3f:be49:9cbc]) (user=surenb job=sendgmr) by 2002:a0d:cc91:0:b0:607:7bca:e8d5 with SMTP id o139-20020a0dcc91000000b006077bcae8d5mr286452ywd.0.1707773992000; Mon, 12 Feb 2024 13:39:52 -0800 (PST) Date: Mon, 12 Feb 2024 13:38:55 -0800 In-Reply-To: <20240212213922.783301-1-surenb@google.com> Mime-Version: 1.0 References: <20240212213922.783301-1-surenb@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240212213922.783301-10-surenb@google.com> Subject: [PATCH v3 09/35] slab: objext: introduce objext_flags as extension to page_memcg_data_flags From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, mhocko@suse.com, vbabka@suse.cz, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, corbet@lwn.net, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, dennis@kernel.org, tj@kernel.org, muchun.song@linux.dev, rppt@kernel.org, paulmck@kernel.org, pasha.tatashin@soleen.com, yosryahmed@google.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, andreyknvl@gmail.com, keescook@chromium.org, ndesaulniers@google.com, vvvvvv@google.com, gregkh@linuxfoundation.org, ebiggers@google.com, ytcoode@gmail.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, 42.hyeyoo@gmail.com, glider@google.com, elver@google.com, dvyukov@google.com, shakeelb@google.com, songmuchun@bytedance.com, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, surenb@google.com, kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kasan-dev@googlegroups.com, cgroups@vger.kernel.org X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: DE35D1C000A X-Stat-Signature: 54uorr6d8psoeia4ostos7btipk5crx3 X-HE-Tag: 1707773992-935615 X-HE-Meta: U2FsdGVkX19XlDQskdneA9kfneltdsmjP75f7Q8cCuOnTK9QildkI+RL5kU4G6T40vZl+vNZeqUKw6MP/7FAX6lzXmWUXWXcN40MKees77V0w8E5KW0dt9M7JuVLfwF9VDWr8fGeglzDHKEIftLSgl8nzE3X9SFh8tzI3h/XiIwQG4+13ESsu25bPYjbDyjEAhvxR98wVVkecgcvR72GGvh3zHZ8+zYCXLkrTC5GGkjTzPewq7SzqQpQcEJhKYQJM4DlQD103v3E0+34cuFhk22a3WCyW/vBg4P/Fr8lwQ2qVH0fjLy7uLGEteofizE5yc7HpQ9qyBIYy4uR3bact94FGN2IAV03hJZJeX3EBy1VLqP1zcjo01DjOnKFnZuGkRJvgDnt9mAc0GU7Nfjb0HB5MW1o1woW9A6156XH16kCjyRERx2ZbH+c4Q20kC23+9l11nG74ecBttt8lwPKD3ZkxJz1Uxb4RvargghiQ7ASTYK0awhW4qYbr3HxLY24C+at4eIgM4F1Wfkm/m6Fim+otmo9M1TkTsQzIky4paHBAVhQYMQjybL1z4g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cRYblAwpByAqqUBs9C2zf8kWIdktTFlBIUdqKvQd/GDifs8PXxVdSyOojvzmyks 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: Introduce objext_flags to store additional objext flags unrelated to memcg. Signed-off-by: Suren Baghdasaryan Reviewed-by: Kees Cook --- include/linux/memcontrol.h | 29 ++++++++++++++++++++++------- mm/slab.h | 4 +--- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index eb1dc181e412..f3584e98b640 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -356,7 +356,22 @@ enum page_memcg_data_flags { __NR_MEMCG_DATA_FLAGS = (1UL << 2), }; -#define MEMCG_DATA_FLAGS_MASK (__NR_MEMCG_DATA_FLAGS - 1) +#define __FIRST_OBJEXT_FLAG __NR_MEMCG_DATA_FLAGS + +#else /* CONFIG_MEMCG */ + +#define __FIRST_OBJEXT_FLAG (1UL << 0) + +#endif /* CONFIG_MEMCG */ + +enum objext_flags { + /* the next bit after the last actual flag */ + __NR_OBJEXTS_FLAGS = __FIRST_OBJEXT_FLAG, +}; + +#define OBJEXTS_FLAGS_MASK (__NR_OBJEXTS_FLAGS - 1) + +#ifdef CONFIG_MEMCG static inline bool folio_memcg_kmem(struct folio *folio); @@ -390,7 +405,7 @@ static inline struct mem_cgroup *__folio_memcg(struct folio *folio) VM_BUG_ON_FOLIO(memcg_data & MEMCG_DATA_OBJEXTS, folio); VM_BUG_ON_FOLIO(memcg_data & MEMCG_DATA_KMEM, folio); - return (struct mem_cgroup *)(memcg_data & ~MEMCG_DATA_FLAGS_MASK); + return (struct mem_cgroup *)(memcg_data & ~OBJEXTS_FLAGS_MASK); } /* @@ -411,7 +426,7 @@ static inline struct obj_cgroup *__folio_objcg(struct folio *folio) VM_BUG_ON_FOLIO(memcg_data & MEMCG_DATA_OBJEXTS, folio); VM_BUG_ON_FOLIO(!(memcg_data & MEMCG_DATA_KMEM), folio); - return (struct obj_cgroup *)(memcg_data & ~MEMCG_DATA_FLAGS_MASK); + return (struct obj_cgroup *)(memcg_data & ~OBJEXTS_FLAGS_MASK); } /* @@ -468,11 +483,11 @@ static inline struct mem_cgroup *folio_memcg_rcu(struct folio *folio) if (memcg_data & MEMCG_DATA_KMEM) { struct obj_cgroup *objcg; - objcg = (void *)(memcg_data & ~MEMCG_DATA_FLAGS_MASK); + objcg = (void *)(memcg_data & ~OBJEXTS_FLAGS_MASK); return obj_cgroup_memcg(objcg); } - return (struct mem_cgroup *)(memcg_data & ~MEMCG_DATA_FLAGS_MASK); + return (struct mem_cgroup *)(memcg_data & ~OBJEXTS_FLAGS_MASK); } /* @@ -511,11 +526,11 @@ static inline struct mem_cgroup *folio_memcg_check(struct folio *folio) if (memcg_data & MEMCG_DATA_KMEM) { struct obj_cgroup *objcg; - objcg = (void *)(memcg_data & ~MEMCG_DATA_FLAGS_MASK); + objcg = (void *)(memcg_data & ~OBJEXTS_FLAGS_MASK); return obj_cgroup_memcg(objcg); } - return (struct mem_cgroup *)(memcg_data & ~MEMCG_DATA_FLAGS_MASK); + return (struct mem_cgroup *)(memcg_data & ~OBJEXTS_FLAGS_MASK); } static inline struct mem_cgroup *page_memcg_check(struct page *page) diff --git a/mm/slab.h b/mm/slab.h index f4ff635091e4..77cf7474fe46 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -560,10 +560,8 @@ static inline struct slabobj_ext *slab_obj_exts(struct slab *slab) slab_page(slab)); VM_BUG_ON_PAGE(obj_exts & MEMCG_DATA_KMEM, slab_page(slab)); - return (struct slabobj_ext *)(obj_exts & ~MEMCG_DATA_FLAGS_MASK); -#else - return (struct slabobj_ext *)obj_exts; #endif + return (struct slabobj_ext *)(obj_exts & ~OBJEXTS_FLAGS_MASK); } int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s,