From patchwork Tue Oct 24 13:46:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13434580 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 68144C00A8F for ; Tue, 24 Oct 2023 13:47:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F4136B026C; Tue, 24 Oct 2023 09:47:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 37B3B6B026F; Tue, 24 Oct 2023 09:47:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17ED66B026E; Tue, 24 Oct 2023 09:47:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id EFE506B026C for ; Tue, 24 Oct 2023 09:47:08 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C84E6B5D9B for ; Tue, 24 Oct 2023 13:47:08 +0000 (UTC) X-FDA: 81380481336.01.107A8BC Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf23.hostedemail.com (Postfix) with ESMTP id C9C1D14001E for ; Tue, 24 Oct 2023 13:47:06 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=YG+eh7VH; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of 32co3ZQYKCH4uwtgpdiqqing.eqonkpwz-oomxcem.qti@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=32co3ZQYKCH4uwtgpdiqqing.eqonkpwz-oomxcem.qti@flex--surenb.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1698155226; 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=Qg2lup2zwYWRtm8BAuIZWN5zY45A/qiqWGd2wrDGPpE=; b=xBwY0Bh056u9MBfiE/D6e2pznnCqM3ASN+zRKApzVnrSKiybNm4m8iTiUF1dHUOLcHj16d g8KU2Ljn7DxyVgDKYicU1XfsCU5HAU66EqaV+LVcVP2nmn/561aM89Qqcj+TN3YAgZDTT8 0PxOV54BsOAOfBTvVcwtQI7Ywtos5hQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=YG+eh7VH; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of 32co3ZQYKCH4uwtgpdiqqing.eqonkpwz-oomxcem.qti@flex--surenb.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=32co3ZQYKCH4uwtgpdiqqing.eqonkpwz-oomxcem.qti@flex--surenb.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1698155226; a=rsa-sha256; cv=none; b=le+yXwXlDO6aQwphm6a1uAqxDXZfDIStJwl1IcKw2OrXXrRmnuiYMZuUXztLTFp0/ML+Ol fCS+lR+6fvwyzkHQ0IOkdXlad8EQNjgZzDzpap1c7980nq4baZqXwME4o2KjM9s8y/PUm+ fugUVwnQw0zHODgTYndwu7AAijkoC0Q= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5a7d1816bccso59392007b3.1 for ; Tue, 24 Oct 2023 06:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698155226; x=1698760026; 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=Qg2lup2zwYWRtm8BAuIZWN5zY45A/qiqWGd2wrDGPpE=; b=YG+eh7VHwfFk4oJ00sQcCvyufGDSixcVa833VhvSEo5aNTBk/wJ8zVPETmN6uO/9dh pA4CQKNgrS5n5JHBQqCIrME+dTuCaj78ufniauvEcYwZWEjDIZpy5NkqeeKor75KZ4f9 dhpg+sYrsgI4532lgRIklVdlXkCihSrvQglc5GwlmzDcunD3dga6zQGYuUir/USR+WzC fCwT5XTI1Mb0RyEJqCuiuFZ2VjY+ee7e7lLw/ZaTsQiDAQfbgRAEvcDaXGmhiOj/ioMV a/2V9ATOeNIrc4K30mERysrCeGaGM64wvh/bzIFeHtxQ3QbK04Ea5x23UTL6DYBO1z62 uPDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698155226; x=1698760026; 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=Qg2lup2zwYWRtm8BAuIZWN5zY45A/qiqWGd2wrDGPpE=; b=poHVSfqkSgUjYl0cmdJRwxcxeV7KUAXHBJ8+1/bwOICCtXDG7GuxjRTWthTAmSE36G HBgJsAYh2yvoUA5uFlgZxpx6T31XGUg4lkxkVSo0pLF8N0UD96zf4O5ebv1gjSAORYJU baFvE72SnT44+fwU/Kwih//q/1ZmGJnLEOfr3D0fw+3CcZ81nZRDX8RCdNAqbOn7XZXk HMfPNAFskIKtH+C80wSjQ0AZSMMR/F9Wdo6z4CZePwidlW2z6KNRisFxZet9/gcmH3lP stFHt2eI4rp/quOoEPGWN93GaVmW0b3Z5vLWz9sgQ1rOwtPs7GdLLneocbzZAOXdrbPP b4Pg== X-Gm-Message-State: AOJu0YzeCnXGwHbFAPCUjf9TJlTTZe0V58zfssjZ4PqvdK4Q6+K6R/tw VpgbddE7nQ+MUfO1LgVcG8WFCTOIXoQ= X-Google-Smtp-Source: AGHT+IFbSeYSocyqc9oNK2jC1GEj7y9HsYgl5xw/vFv8t55K0y/nslFyvoCz7IdF8OEyu7ekDQ1W6y46+34= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:45ba:3318:d7a5:336a]) (user=surenb job=sendgmr) by 2002:a0d:dd02:0:b0:579:f832:74b with SMTP id g2-20020a0ddd02000000b00579f832074bmr286214ywe.10.1698155225916; Tue, 24 Oct 2023 06:47:05 -0700 (PDT) Date: Tue, 24 Oct 2023 06:46:08 -0700 In-Reply-To: <20231024134637.3120277-1-surenb@google.com> Mime-Version: 1.0 References: <20231024134637.3120277-1-surenb@google.com> X-Mailer: git-send-email 2.42.0.758.gaed0368e0e-goog Message-ID: <20231024134637.3120277-12-surenb@google.com> Subject: [PATCH v2 11/39] 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, 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: rspam12 X-Rspamd-Queue-Id: C9C1D14001E X-Stat-Signature: iy5ny1k3ms1png53ieanyu1e63dm6uye X-HE-Tag: 1698155226-752972 X-HE-Meta: U2FsdGVkX18wOQuAb+w2FXz+Z/Tg/BaeaOefUdyb4ZCU3Lk2HLSVwawBto+teFVB6RMyVBzkRU+MxxB1b6bxNzpyCscJKoS6XlyfBpwtcL57v6AxW6xytvBu3gmJAu/TJajI/lGZl9Y4Y/fdHV6OEFYLCmRi8Iiu4BV6abnuNBBdZ/qQYklBb6+ehwlY4bi34qwUg/wtbo/u9IDogEt0tjLEwb+BNJhhpDPUfdN5LoXUecfiGeiihsthzWUlMQISe2zFPyYQrLvrqvpRlgLk0ITeZ5CjwYROHMnKdcsAiZnYgo/4L/w7KJSD/Xe7RjkG3KWn9Z08WQL6rtWKIrvzoTH1HEyS89RL2TnwDvwbk9xndF5bAne4ITiRgguQdpYHLEytvRsWBIcQ2fGJp5mABK/FZdXjNKCcn7vVBClySvzm4drAOZEPPpYJDzlo9ORi9/PfRYhZ1xBU2dVXq5fxYQy5dGN0E8Er0LdSlfRSIioN/3DaB9l9gNrC2xKaP3IQKG5KwPcC6rVW8/PZHo76kKivoaMf+h6D3HnOVQwaYa7tb12WR4wh58cpA+Qji5NOdZQcTepmndOGszxNsKbMfRv2zpSjgxdioDPE/kZHb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qrKcjfrO+fu0x4aA9vhx+q5crRMEqV+j8p2i/ 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 --- 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 4b17ebb7e723..f3ede28b6fa6 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -354,7 +354,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); @@ -388,7 +403,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); } /* @@ -409,7 +424,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); } /* @@ -466,11 +481,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); } /* @@ -509,11 +524,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 187acc593397..60417fd262ea 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -448,10 +448,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,