From patchwork Wed Mar 6 18:24:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13584417 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 24565C5475B for ; Wed, 6 Mar 2024 18:25:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C01C6B0093; Wed, 6 Mar 2024 13:25:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 41E8A6B0095; Wed, 6 Mar 2024 13:25:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FAA06B0096; Wed, 6 Mar 2024 13:25:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 09E4A6B0093 for ; Wed, 6 Mar 2024 13:25:03 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DA9F21C11B5 for ; Wed, 6 Mar 2024 18:25:02 +0000 (UTC) X-FDA: 81867440844.21.198A15E Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf01.hostedemail.com (Postfix) with ESMTP id 10D8940005 for ; Wed, 6 Mar 2024 18:25:00 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="UYFf/gz8"; spf=pass (imf01.hostedemail.com: domain of 3-7ToZQYKCD4xzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3-7ToZQYKCD4xzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709749501; a=rsa-sha256; cv=none; b=7nscL/nOcN8tn6Qo1VJpLjhbk/mW88hcRR8/lT8vZPgCScBh0yenrZYk0ytRN3HwdfM61q oVET1QAjeZ0UKeYhkfQ5WYGXc2GCMPDP8o/Nzer8WgbEYR8r7lkr4iWOPg34bgMBWeb+Is gx20r10EdEQEGk1nZa1QD8e+iVrJZN8= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b="UYFf/gz8"; spf=pass (imf01.hostedemail.com: domain of 3-7ToZQYKCD4xzwjsglttlqj.htrqnsz2-rrp0fhp.twl@flex--surenb.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3-7ToZQYKCD4xzwjsglttlqj.htrqnsz2-rrp0fhp.twl@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=1709749501; 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=6rH9mI3mTJcaBoi8NvQC9FpkTZd7d5upxL04jrJdHuE=; b=xa93/cCsE02vfKSyD9YmIY3ZSIXAKNTEqiTWDNJ78nuB03yjLIOYWHBz8csvNpA3omRBpD t7XaC/flZrb6hl3pYKbfyuzlhePM5E0RnFil+q/c73tGbD+5bikuYmtBqS6EeP41Wi8yIO dzn4Wq9tC2LIZmMNMzxSaq1dr6urai0= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc64b659a9cso2344800276.3 for ; Wed, 06 Mar 2024 10:25:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709749500; x=1710354300; 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=6rH9mI3mTJcaBoi8NvQC9FpkTZd7d5upxL04jrJdHuE=; b=UYFf/gz8dWKsmLbdZzs4JLdws5uAdWZHdrP/gU/NOnE9xtQhjm/xtXHibFX80O5LoH QJIORDu+GouyfiBtEEn8bVld9/P+5WiGfSXReA3ti+4Dungb4j84+lF0QcgR3rkN2muK dDdIE2Itbi5sOcMxl+wfFBLklbX6eXCI+mjKb+DS3RTbfsoU2vzHYA5nqRtDnO/vBIFj uZ/GaPWlAgPmZw+iuATXebFEyG6Z+J3fQaRLyI3RMwTcdAonIYrQyHkZm2IO/ZzeKbit CVPqo/UJkl0ea+luX48Ag62MkxrRup11BqXO3gWu1O+496WLXwFczZoKa8o8Z92zj5Oq XFPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709749500; x=1710354300; 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=6rH9mI3mTJcaBoi8NvQC9FpkTZd7d5upxL04jrJdHuE=; b=FB4EzoShdrY8ZYDoU2lTJRFoiYGu9g5BAVTpysdSGqSWwD3MRMJ7P9kDwxemwZ2KCR XSn2RpseW94IDYlFtUlKp+hFbGRoQbsONELg8JFbCkzbfhP+XkicL3msI+NfQJbeC23R OuP8wwQ2ZMFZbsT35butIssOzJtVVHXvEKI7TZbgx4Zm/EXfHIbkBINoIENIEd3HLLmB Di1668n1dZ1lSyJhVTOZ2NfyHPWcO3rSkszDDoc/aR1IHpRjfDOPB0KEa7tVIzyQ/+fh c9nJ2iNuagXva4SM7Xyo42tYemzm8HdexzBW6z1UdTodbBHWG89oYB9Tsne+e8/Fx6rD EZBQ== X-Forwarded-Encrypted: i=1; AJvYcCXWbr75Gz7LYq4vWNJ8QeNME0U+nVh4BLR03Ig68Pu275eaf7grpWbL+x2aWx0Y0RxwYfcTHOKXpUGHM8IL07p4kgs= X-Gm-Message-State: AOJu0YwJw642HemTYQo3yxcTPO6D+yrXt7E3F0rb9uGBP+ESTM6G/25M ypODmEeVrsc6VAqdol4PFkFSAxpQZrCq4Ahat6vS9W5+kTzRVcdAaVWdiKpVE8t4rHU+3dHYTFC HUw== X-Google-Smtp-Source: AGHT+IHxR0olBWteUpSeEtMuXDZWp8I1meqV0Icf5ps5DXZSQPpSTLoMw3+arJQFndTmnzLC9JieP9mTFwI= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:85f0:e3db:db05:85e2]) (user=surenb job=sendgmr) by 2002:a05:6902:1885:b0:dc6:207e:e8b1 with SMTP id cj5-20020a056902188500b00dc6207ee8b1mr3919663ybb.2.1709749499865; Wed, 06 Mar 2024 10:24:59 -0800 (PST) Date: Wed, 6 Mar 2024 10:24:05 -0800 In-Reply-To: <20240306182440.2003814-1-surenb@google.com> Mime-Version: 1.0 References: <20240306182440.2003814-1-surenb@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240306182440.2003814-8-surenb@google.com> Subject: [PATCH v5 07/37] mm: introduce __GFP_NO_OBJ_EXT flag to selectively prevent slabobj_ext creation 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, shakeelb@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 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 10D8940005 X-Stat-Signature: dcskr4f5dgspc1wkfzmd9eu614wydzx8 X-Rspam-User: X-HE-Tag: 1709749500-638338 X-HE-Meta: U2FsdGVkX1+glY4SVOLmZ76BXlExz3nXqZfUxSnugpyQhI0r1wZmFFmmtMs5FDt+mnm/myVDWW/axLqSWSDg7UjVPVwBTbdcdaEhOHt9TPEbM88A/VgNjS28X9VO7yhiyL1VmDJ9DPkZ6GY508NqqrciFK+oE2jet/TlwhhbLIm3UW4n7I+xO4tPpQFGPIwxt5bnS0Voayj8HcaZMAT5oGeVyTJlE/oLyWFN/4axqX9T9iwkQefeAuU/JECu/6jag498+gnZmUGcrDr/R1OqGRmG6SbGHnMAwHLxkHANECw2lHSGK0YlJ9pQRptT6i8qtKW2sExdOE/he5zJlmqTka0LpKNLMW0rw7dKsMuu6J2D1wDl43kbpyFnNnWLSMPytWdeoo1bbXO0KW1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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 __GFP_NO_OBJ_EXT flag in order to prevent recursive allocations when allocating slabobj_ext on a slab. Signed-off-by: Suren Baghdasaryan Reviewed-by: Kees Cook Reviewed-by: Pasha Tatashin Reviewed-by: Vlastimil Babka --- include/linux/gfp_types.h | 11 +++++++++++ mm/slub.c | 2 ++ 2 files changed, 13 insertions(+) diff --git a/include/linux/gfp_types.h b/include/linux/gfp_types.h index 868c8fb1bbc1..e36e168d8cfd 100644 --- a/include/linux/gfp_types.h +++ b/include/linux/gfp_types.h @@ -52,6 +52,9 @@ enum { #endif #ifdef CONFIG_LOCKDEP ___GFP_NOLOCKDEP_BIT, +#endif +#ifdef CONFIG_SLAB_OBJ_EXT + ___GFP_NO_OBJ_EXT_BIT, #endif ___GFP_LAST_BIT }; @@ -93,6 +96,11 @@ enum { #else #define ___GFP_NOLOCKDEP 0 #endif +#ifdef CONFIG_SLAB_OBJ_EXT +#define ___GFP_NO_OBJ_EXT BIT(___GFP_NO_OBJ_EXT_BIT) +#else +#define ___GFP_NO_OBJ_EXT 0 +#endif /* * Physical address zone modifiers (see linux/mmzone.h - low four bits) @@ -133,12 +141,15 @@ enum { * node with no fallbacks or placement policy enforcements. * * %__GFP_ACCOUNT causes the allocation to be accounted to kmemcg. + * + * %__GFP_NO_OBJ_EXT causes slab allocation to have no object extension. */ #define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE) #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) #define __GFP_HARDWALL ((__force gfp_t)___GFP_HARDWALL) #define __GFP_THISNODE ((__force gfp_t)___GFP_THISNODE) #define __GFP_ACCOUNT ((__force gfp_t)___GFP_ACCOUNT) +#define __GFP_NO_OBJ_EXT ((__force gfp_t)___GFP_NO_OBJ_EXT) /** * DOC: Watermark modifiers diff --git a/mm/slub.c b/mm/slub.c index 6ab9f8f38ac5..2ba5d7b2711d 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1899,6 +1899,8 @@ static int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s, void *vec; gfp &= ~OBJCGS_CLEAR_MASK; + /* Prevent recursive extension vector allocation */ + gfp |= __GFP_NO_OBJ_EXT; vec = kcalloc_node(objects, sizeof(struct slabobj_ext), gfp, slab_nid(slab)); if (!vec)