From patchwork Wed Feb 21 19:40:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suren Baghdasaryan X-Patchwork-Id: 13566188 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 B2EA0C48BEB for ; Wed, 21 Feb 2024 19:41:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B3F06B009A; Wed, 21 Feb 2024 14:41:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 73C6C6B009B; Wed, 21 Feb 2024 14:41:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B3D86B009C; Wed, 21 Feb 2024 14:41:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 44EA76B009A for ; Wed, 21 Feb 2024 14:41:17 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EF77A160AC1 for ; Wed, 21 Feb 2024 19:41:16 +0000 (UTC) X-FDA: 81816829752.27.21B43B2 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf14.hostedemail.com (Postfix) with ESMTP id 313F210001E for ; Wed, 21 Feb 2024 19:41:15 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Vvlw7H+n; spf=pass (imf14.hostedemail.com: domain of 32lHWZQYKCA0574r0ot11tyr.p1zyv07A-zzx8npx.14t@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=32lHWZQYKCA0574r0ot11tyr.p1zyv07A-zzx8npx.14t@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=1708544475; 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=DcVDeB20sah+c6m+q7qbj/Bohzcv0RbxXXpsl4x4Og4=; b=DP3e1Xno16zVDGH8fGwQZuCN/hxjTGKBECrwpGyaig/D36fLQ41MF+a4y91S5YHpi26WoX vxK1vxMaIdrcbyhv0EMagZ4n/FsorEiejqkKvHjZ9gs5L2JdVSFvxnUDec+TAcuayd+OM8 lSljwny/6KIfL0aYhKH6QpIxQJdPrN8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=Vvlw7H+n; spf=pass (imf14.hostedemail.com: domain of 32lHWZQYKCA0574r0ot11tyr.p1zyv07A-zzx8npx.14t@flex--surenb.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=32lHWZQYKCA0574r0ot11tyr.p1zyv07A-zzx8npx.14t@flex--surenb.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708544475; a=rsa-sha256; cv=none; b=H2x77SO8OiFKNTAkHFfj1AqGV39wH0ZRvOiXe6i3w4rlaEbsdgxCqwH+m5nt2WSnF/Ty3h tUZeiGbHGfHYd9Px4Rhl2OAjjOKnr90DgmHzi873Nt78dajvyaeHCU40gWmbbmvT+f1m4J VeIFA9WXDtMtPM6UOLxkRHt9eufIfHc= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6088fa18619so9932637b3.2 for ; Wed, 21 Feb 2024 11:41:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708544474; x=1709149274; 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=DcVDeB20sah+c6m+q7qbj/Bohzcv0RbxXXpsl4x4Og4=; b=Vvlw7H+nh6ruP/PkfuO+jWE/pGrsBhM4cpRsfvkNpvEasKOsPN7wR6LOr/X7NedzrG o2AAl4AMphoYp4c3rZc0TF8HhrKkHkKdr7+rhCvGpkStUMnYbQoVK8rFs/My9LLwY1tD yu57dggV9DeqO/i8FmvIPIy735VjWXIIeBiqrrefrYKZm6hJrqx67+WP/R/fXfedTIl/ O3ieazb8Jh1wbYvl3IXjIBGEdPyGvdVxkWA4ev+LHRDgQi3IjiL4IF9PHik9wAShDm6p aPopacDXoARL/NozCImJOjisSOycw5u1Xa9ibQosZADoZeQQcYP5f5RGjibXucpISPBJ wVDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708544474; x=1709149274; 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=DcVDeB20sah+c6m+q7qbj/Bohzcv0RbxXXpsl4x4Og4=; b=cOpb0PUgM2hpuA4QgeSxcCAaskc4++w0yqNWMlatK7s6K8/kedEUPf6awjBMYekPvx Ojtk5IB57h3Ky2Cwe52GBjZA6a+I1LY5L9N9i7N5ImVi3XZcijlEr7yWUvJU1G6J94SC hgM39SONcD5GOcGO+AAGWSN49Ju2hGKbcQTSp/obJlfveaCSzws1XhtfLlFvxsK8PYnU aBq7dIT7BWNOp1Ejfk72O50lpk6ZSaQ+NGZH6s1gEgBWD0OYCVNhPEGJPUBN3JjjGDYD qBd+RnkCT5GXj2STkT16Ndg/R8tj4gba3CUDAtxSaoPr6T5ifJ/pcy2UU0lgVqP67z3v msAg== X-Forwarded-Encrypted: i=1; AJvYcCUybi6XQLcCSQSvCkVxWdHQsgI35S54Z9JsnaFuiC+uh+AxH+MPqGLGL0RLCgzffxGw+fDsZTnpSRZn5+gDCLJNkOY= X-Gm-Message-State: AOJu0YwJ+DxjLHft1kWaFlvKMPRJmMh+c3PTDXeGMvL4h1Dkc+FwL0iG jUClwav/0k4w/OeHi53OgXrwkSXzAQ9Lz3WWGZjK6xTRm9gKcNPqGFvuoqHFtBg6R5lP4iL1vjP ZIA== X-Google-Smtp-Source: AGHT+IH75M2lZrHB2S9wjqCstmCY896frmoFhg/GjACV0w0wTBslVAISl72HA0I1QmkMPlsLusmP2hmQVrQ= X-Received: from surenb-desktop.mtv.corp.google.com ([2620:15c:211:201:953b:9a4e:1e10:3f07]) (user=surenb job=sendgmr) by 2002:a81:4ecd:0:b0:608:9561:fdbe with SMTP id c196-20020a814ecd000000b006089561fdbemr96126ywb.2.1708544474186; Wed, 21 Feb 2024 11:41:14 -0800 (PST) Date: Wed, 21 Feb 2024 11:40:21 -0800 In-Reply-To: <20240221194052.927623-1-surenb@google.com> Mime-Version: 1.0 References: <20240221194052.927623-1-surenb@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240221194052.927623-9-surenb@google.com> Subject: [PATCH v4 08/36] 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, 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-Rspamd-Queue-Id: 313F210001E X-Rspam-User: X-Stat-Signature: xcmdao7uwopdkfjdrudbai4rtdtysafc X-Rspamd-Server: rspam01 X-HE-Tag: 1708544475-209318 X-HE-Meta: U2FsdGVkX19ft1ZGXFfBMPj1C7x7gsGIrbiCMBbwHPGuBTP2svwZ+vNpI1WIqlLAGWvT43rFbomRteRIva4JQZLcOOPulHeQnJsIyKBP6MYVmV70ToSK+XaYhrDf7m2mji0GBonKF06xb959l95MlrwnOiDZxuejf9aPkifnkvzo7NfI/ypq82IU8iGJtPUAdfa4svtbYHAPYgKdV5O4HQhWL0oNE90WfX13XfRPup1jUoA8MC4ww4Is2lDbddyPHDqW3c49Fevv344WtqRr0tXJ6LjTiQzEXXHhSJOZ4w24PTS66Tbz2CLksv5X2AV5skjDhN3dn9+cXH/5rqFo9VueCi3odAZ/W9llwFxaLCPrWORBKYXBQA65KEm9zm/gxdmjEuCZuNfI29ttnx1njSUH/+bXaZtKeOtdxFmBWWxbRjKK9b4sLsJnugMAsPh1LYTUe8aNhZ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M/Z/hLbGoT+J7Ns9aHLttJ2nyED2qjYIQdKz5KC4p96NiIuv2Hsl0INPteemCRcTjG9e+emdwIS3qqeDVpwSz7pbqeOG9NRbmqPlHUBsOgTVDGz+ADq4+86XQnFSsQcge3Oz1H7l+g5ztqvodRwu8gRHT8mc7ADRAhIsie06kIzWddVwxwNM2MEMy/qegmLKCEulQvH/mby3yMxJuRIUkzor0IamkLVwsliVuzH0XYptZQ== 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 __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 76fb600fbc80..ca803b2949fc 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1899,6 +1899,8 @@ 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)