From patchwork Mon May 1 16:54:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13227648 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 BE9C0C77B61 for ; Mon, 1 May 2023 16:55:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 57BF990000F; Mon, 1 May 2023 12:55:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52C16900002; Mon, 1 May 2023 12:55:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F5FA90000F; Mon, 1 May 2023 12:55:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2A2D0900002 for ; Mon, 1 May 2023 12:55:39 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EACC316073E for ; Mon, 1 May 2023 16:55:38 +0000 (UTC) X-FDA: 80742287556.13.BE512FA Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) by imf04.hostedemail.com (Postfix) with ESMTP id 2E4BF40007 for ; Mon, 1 May 2023 16:55:36 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=lxWpRSi2; spf=pass (imf04.hostedemail.com: domain of 3B-9PZAYKCE48A7u3rw44w1u.s421y3AD-220Bqs0.47w@flex--surenb.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3B-9PZAYKCE48A7u3rw44w1u.s421y3AD-220Bqs0.47w@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682960137; a=rsa-sha256; cv=none; b=kwKQl2D05zlcBrJ43VYXiS1sDxcJ8fnaMVO5dTNU06Y1kzKVvAvj3KFJ1zcWhvSM55hUY8 MW+d7whasHUajp/ZkyftTT97eihH/PXg93g8ADG2upof+LVBDR4pv5yq7HZ6tboyjcGcS2 yCq4azn6byQdeyuLyAnIX1Nmld+50hI= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=lxWpRSi2; spf=pass (imf04.hostedemail.com: domain of 3B-9PZAYKCE48A7u3rw44w1u.s421y3AD-220Bqs0.47w@flex--surenb.bounces.google.com designates 209.85.216.73 as permitted sender) smtp.mailfrom=3B-9PZAYKCE48A7u3rw44w1u.s421y3AD-220Bqs0.47w@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682960137; 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=xg9JlY7/fjt8XCrAgZEcEBdLHf1ezLwh/Q099RdQeBg=; b=gSowKm8170zYHG+RbakbDBv3hOAsE3hbxSE6xeKqNhRQ8mBCwB7Cn7e3Oup8rI7Ykp9JNC Awik3JM9EqE/A3zGq2JmKujUKepwnB3qc43U+YG96/dY3M9xx1c+sEUaO/ut+XScQZdFd/ wH8Nc+Y5az8D8zWpRItHovh3gXZ+18E= Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-24df9b0ed7aso1439816a91.3 for ; Mon, 01 May 2023 09:55:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682960136; x=1685552136; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=xg9JlY7/fjt8XCrAgZEcEBdLHf1ezLwh/Q099RdQeBg=; b=lxWpRSi2RW8T5MQ6rUDBO360BpQGLeAVDuvFbZTW2oi6i0pP4Ylls+pWo4X0mmDlZ4 ZivjAV0YmO5+Csa7KFdawNwZlR87MIFCY0KvaMmh23wbSx/Zqw9mWSmtCW/DFws1pL93 HinphsKaTEMZsFj4FnMn87Gmq03vSk5t2aEjAb2xkm1oUZHHiNVFH5GCIuTzn5brrAqi 57iYlmpPjz1nsWZstv5H0Wf3fwPUmwqs17xOGhYG6xNhITzJ07bTu6Ucjsolv2WF8BDd fpFmt5mSOlDgy/NcylrZlRdpPNgsEH1oRDPs7B+h6qorwNaMNm9hhTPxfiNkqgalis48 xWGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682960136; x=1685552136; 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=xg9JlY7/fjt8XCrAgZEcEBdLHf1ezLwh/Q099RdQeBg=; b=K0XPoikrXYkI+hbKmVYhDBMgjasj4yhDP+aYAToWAIgOYYxYcRZjNRQKrxgmul2dhr ChlttfKwTgXlEzpCJPeE9OVLR958e+YL2m5vIhreCz3UzXQcERJf2bG9en5TIj7FDxRG HFJgISw/FLIKrxt6smbYOmT/dgznuxG3pKwmou0DGBc4mIi084spDl0wTeE63kHHBBEp YmX+UsWnDbafcQ5HqBU2+vXBdnLcxgztO6KhaO6oCDCDUI1EJfM1vlFTZLlHMehcBtBD z4L9KFtpBzXAr8H3k89SvXYxExqZtzTarDZEIM7CIZpKVqKVYHihnGYKFOzAXXib+c9H Srlg== X-Gm-Message-State: AC+VfDydhd9ySZIJMBU5Ed7TUxiv0gS3KCB6my19EuugSAsJ7pUR0g6A JoW5NOi9Hhwc4xq5wcrHA8llcAA27gU= X-Google-Smtp-Source: ACHHUZ6YgiTbOdoAI7RvpBgPX+gkOC970dcPRGZpFE4ZhJnSWmLnFtQB4uP9hU7pUIktNp1PkK/6Tg72Th0= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:6d24:3efd:facc:7ac4]) (user=surenb job=sendgmr) by 2002:a17:90a:2d7:b0:247:5ce:5bd7 with SMTP id d23-20020a17090a02d700b0024705ce5bd7mr3861119pjd.0.1682960135879; Mon, 01 May 2023 09:55:35 -0700 (PDT) Date: Mon, 1 May 2023 09:54:22 -0700 In-Reply-To: <20230501165450.15352-1-surenb@google.com> Mime-Version: 1.0 References: <20230501165450.15352-1-surenb@google.com> X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog Message-ID: <20230501165450.15352-13-surenb@google.com> Subject: [PATCH 12/40] 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, ldufour@linux.ibm.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, 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-Queue-Id: 2E4BF40007 X-Rspamd-Server: rspam01 X-Stat-Signature: y7r3p4ifmebi7w5zeekwzdqx9yfhyhi1 X-HE-Tag: 1682960136-793586 X-HE-Meta: U2FsdGVkX1/m2ylWhyWUvxbHm8idcWL4/9XFJD2A8EdiSwNtRhDqoCqiFufnYlDxwjHtlLldWrXtN+pV7oCIMVMH1Yf71ZpLKfJngL7ghGofAyZmQywmhbcxs7G0k8IO1ClGEjJmCZwv9rDS0jLppDYf6YyRD8nyG6HJMwBvAl+P5y36dgCg0bMPwLBBgyhwy9bA4mF/aRtxYLefsngnCd+rrq3zNwB68UTOOf5rCIvNGaD8GbcxdFV905Vd76GLMYeZStV6EhGH3se3foZZaSZB8gMiqrxRIalQCJZKuPUeVqBSPC49e1Ay28VUwq06O1hY5aMu8fp7pnJZTqUAVuhwcU6us5uyMte7UxxQ4cqBiluqWCVU5k7rIZWyUzVdf4J4QEjMckrQ6LyDdr+rV5e3ErNcd2vf8NVUINNwuatjaeD4O9fw8qWi/x61N5Z/9Iyb483+PQ/H8LVIA8ET9j1olP46PelqZj33xH3TQIMAoL6jDOknwMWGslZmSRT42zNdVM21mpDGLe144UAFMYyXWR7jqad4IWTU4KLDKdNJe6Pq00xOy1S3xDYgQC10mdCJik9DhgczuwfgeA6Qq67NK6Nhr5DwBNXsLcGwMXul/39VywaikvG/rk7XnoLfwa0VqccM08dz67+0ucGnvGPX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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: Introduce objext_flags to store additional objext flags unrelated to memcg. Signed-off-by: Suren Baghdasaryan --- 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 b9fd9732a52b..5e2da63c525f 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -347,7 +347,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); @@ -381,7 +396,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); } /* @@ -402,7 +417,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); } /* @@ -459,11 +474,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); } /* @@ -502,11 +517,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 b1c22dc87047..bec202bdcfb8 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -409,10 +409,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,