Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp596239lqp; Thu, 21 Mar 2024 09:47:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpsHmliJfWU0AhbqgSQx0IVxkjpH/MdCNnQ0pY8sgZb4bMxXbkZGY7jJ3+c/4Cr2g51GNlrjs/8rXaqQZxjlLWRaKQSn91TcHM9mVr0w== X-Google-Smtp-Source: AGHT+IGFOhxPAVKAwEJF3hg+rnDblSP4UU40qXe2jhB7kOVPj3/9UvA4tkyeAz7bwnZUrzsA5bVa X-Received: by 2002:a17:906:ae56:b0:a46:bbc9:a8c7 with SMTP id lf22-20020a170906ae5600b00a46bbc9a8c7mr7703142ejb.71.1711039647342; Thu, 21 Mar 2024 09:47:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711039647; cv=pass; d=google.com; s=arc-20160816; b=ugAlnQsfvJEfTNnfYWo9dmymUd7ZgZa6KZr2kTzBWUkFW8N8ZNFWxNptqzFUmZCgq5 UVQOPP4R8LSfvhBl4tRnTF8jLEKEIJmQEQx/kC3HCVqBeWPiCndPINQiipzF0BcX5btW B0dco5N/88eDRGaNcnIyIQq4ZyGXro4iyIP3ahZAqYW/YkfmI+zae01MTf5CKgxDJZU1 TsOQfwezYSFO1H/ubcBTFJ/cMqY1ZkQ8MMTX3V+NaY4rHXRFT69MxFHQjH74yQVH2zLB l1MxLTOOft6yXYHXIqUIa9LZiydOKhXHRgzEGoG/rE7R1oV07Im6QwaIhYY7VRejr1F7 C+rQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=dkdT2DGL8QlDQh+VA6yRS9pNWPbAmDPXuEOr3/wpZDQ=; fh=G+m/bGw3GcapipaSqIFJdN5ETQqRAFC8lp9stEEQWoc=; b=dnMqOVHrQJKKfquq7rcoGKzZc+WgWGg/cuO6no+oBx0PCs7AhG/7BA/MADdnMl4Cpq +xQFTh67rWynjQfZNd9QMmVkRTIZ3atWsnjH7E8aS7m5oKFcaR27f2oO4+vl3w8Dejvh ShVrc1W8x3/dZSUwJxBqr00jY9HOYQ/45T5hpsazz0m0LTAqsOQDJzNDLKXZCJYZxNvQ jUqsp/HT/8jtQDKUW16azc0qnHLuq6K4bPA+NlklKJ9Nqk8fswgK6pWFVmDZzNU5bXdW hdZls387IrRov4wUPSlkhMXRRVk35MHPnf5QmyqbPXJeVGcuUBIZMuUs80+dWt9PvpnW Yeew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DcAtFesw; arc=pass (i=1 spf=pass spfdomain=flex--surenb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-110363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110363-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 11-20020a170906318b00b00a46698c7a22si90567ejy.53.2024.03.21.09.47.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 09:47:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=DcAtFesw; arc=pass (i=1 spf=pass spfdomain=flex--surenb.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-110363-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110363-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7EA351F2538D for ; Thu, 21 Mar 2024 16:41:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F273136643; Thu, 21 Mar 2024 16:37:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DcAtFesw" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DABD856768 for ; Thu, 21 Mar 2024 16:37:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039053; cv=none; b=hTh5YfA8sqxMwJbLE1wrI0HiGnQsGaeVT+PVMv3PEKGX+yjEDCILxwKgCueuQX8FCDptLAaLKsLUvBU25f1ja53y2eQ+rT2/wcx3HlX65talTNLZgKBpgq6IC4oYZEbLRbP3n5X0B5fPcveJWfRj9OvbWVm1O6TOfroVDJO+3Hs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039053; c=relaxed/simple; bh=BaI5FwltZ9MPYvqrYfL7z73ZIdY4QTxEvqI1wYv8mLU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lsZPSFjAL1YvZUhfNNgeYoo35mfus67QspH/tQnEYRNPWKxXcq5pS0PsJLbOzlXLxs4w0QCyiFrdisHV7tRs0Xnz419F5fLWyV5jAGEWtjcyorc4gVy4T5/a/6u1xRkZ7MUGYrVXtvl0RgRf6z2bPtuZ3VGrhvPcoBBTO4EHbZM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=DcAtFesw; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dcbee93a3e1so1860053276.3 for ; Thu, 21 Mar 2024 09:37:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711039049; x=1711643849; darn=vger.kernel.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=dkdT2DGL8QlDQh+VA6yRS9pNWPbAmDPXuEOr3/wpZDQ=; b=DcAtFesw71UXE3lr9IlZBtpLtEzuHyz5aUpIPKFe6f8JVqo4CPCuFKUihddRW+ZivM Ny4kO9AGh+6hAboG6t/qY6/DyTCgR3WOIvxDf8/posbWuxaC9mtZ0YvhglF+ThvphRMS ReGz30Dfi2fWtnUnN4gKZwKJnRTRFztJsZ4kfxwGUlC7bQgaJgHKpgkrKA0AZ0HlQTBC kAz1lGdegfcFp7ZUZwJsq/XYF6FX7oF8G1V840rd/WK1FdSz0DYdeTWmXZz6431AgRgT i8NfZMVttyhYFCSW8Ts3jItBoHQcG1z4fIBUILJECwxL0gK3yTTuTZUNyNp2LRjg/Boh g8+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711039049; x=1711643849; 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=dkdT2DGL8QlDQh+VA6yRS9pNWPbAmDPXuEOr3/wpZDQ=; b=LZCcMbIuUC8wAho8zXQh0Q94ee2m/wZjcRzC6t20p9w+SGmk8kqMrklMEOIDCkgy1c clhq2OO2vXmirqnAIqdzFb7Z9tgEOpxKSBjEfFttturLjVqcHUKRpjGPKxnh6hK+BrJ8 hRe83IqAZ9RkqGfitpMoBGR5+wDSXz+E2tDPWXx8RWLZOo1dDJT4OodsCtYvDsLBhJGB //0XyALeHB1e7Xh7qL7OFEytZXe9uooZJLuCxb8kvGiFJEgCPBolcu4gWLfcw6iwaghX OrhLThPeaYKuXXkqZQyqNJiYZ06ro+itTKd4ibmQ/2gK2cxqpJiFzlYEFf62fDZBKOiU 45YQ== X-Forwarded-Encrypted: i=1; AJvYcCX+e1zJhKeXTfmdX6jl/bZIzpUZKE0XLVI0c08d6GHEAqibTHR/EAiXP0Px1gsf5lKRsrHQSsdkaXqMhtfG3xcmRT96biBENbC01HjN X-Gm-Message-State: AOJu0Yyg7DfdhTc0NCBcWw2AhkSD4H4UJPz+Cd1UFEvoN58gBjT3GgHX pYuqzI+3sYL89TXsA/GA8/5Tf1z7kWXsjRx1TIZs5ypamgVarxr4QBnBAVsvtBN2Tlhb/FAWZdC B1g== X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:a489:6433:be5d:e639]) (user=surenb job=sendgmr) by 2002:a05:6902:188f:b0:dcf:f526:4cc6 with SMTP id cj15-20020a056902188f00b00dcff5264cc6mr1142116ybb.11.1711039049407; Thu, 21 Mar 2024 09:37:29 -0700 (PDT) Date: Thu, 21 Mar 2024 09:36:31 -0700 In-Reply-To: <20240321163705.3067592-1-surenb@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240321163705.3067592-1-surenb@google.com> X-Mailer: git-send-email 2.44.0.291.gc1ea87d7ee-goog Message-ID: <20240321163705.3067592-10-surenb@google.com> Subject: [PATCH v6 09/37] 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, penguin-kernel@i-love.sakura.ne.jp, 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, jhubbard@nvidia.com, 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, songmuchun@bytedance.com, jbaron@akamai.com, aliceryhl@google.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 Content-Type: text/plain; charset="UTF-8" Introduce objext_flags to store additional objext flags unrelated to memcg. Signed-off-by: Suren Baghdasaryan Reviewed-by: Kees Cook Reviewed-by: Pasha Tatashin Reviewed-by: Vlastimil Babka --- include/linux/memcontrol.h | 29 ++++++++++++++++++++++------- mm/slab.h | 5 +---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 99f423742324..12afc2647cf0 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -357,7 +357,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); @@ -391,7 +406,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); } /* @@ -412,7 +427,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); } /* @@ -469,11 +484,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); } /* @@ -512,11 +527,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 1c16dc8344fa..65db525e93af 100644 --- a/mm/slab.h +++ b/mm/slab.h @@ -554,11 +554,8 @@ static inline struct slabobj_ext *slab_obj_exts(struct slab *slab) VM_BUG_ON_PAGE(obj_exts && !(obj_exts & MEMCG_DATA_OBJEXTS), 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); } #else /* CONFIG_SLAB_OBJ_EXT */ -- 2.44.0.291.gc1ea87d7ee-goog