Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp77242lqi; Wed, 6 Mar 2024 10:27:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUL8peOotY08UJ01qY6xIlY6ZDZsjQk7jB+w70xFzE4EnxIHYD1zDRHHx4VYxXPyVv25EhMlJjxa/yOqBvoQ+Vf4sB3/JJVZNwjeu59Uw== X-Google-Smtp-Source: AGHT+IEq1n9dP+BQa9efxsjQyBx06MQe77VoItfiihR2wU5/xIqHRWRq6uwFCNznvmaD3+fXXORw X-Received: by 2002:a17:906:3bd5:b0:a3f:ac54:5aa1 with SMTP id v21-20020a1709063bd500b00a3fac545aa1mr11973042ejf.21.1709749642003; Wed, 06 Mar 2024 10:27:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709749641; cv=pass; d=google.com; s=arc-20160816; b=fUmsl/1cGQ3HUyA91BTCRiPTOQPNukUMF/EfIDEbr/m7XaetApBx7ailfzJxy6E9Q6 zwMIM9n7BV3Ilzcd1ZdWVd5wTy3qAP4nEhY2JZJmN2Z5B0GkYQsDjsSITgV3v5B22Ler FQ0eWgDONT+aNt8PuuXD79pyVcOOInnb6zsS20reh0b+mH0I789OxcdPF+8e32it+pWC 0SxUP8FrWchEkRdA830bE46FxWWNxw/M1rroENPYaDBCKkmMSYlYP8pg5Auop6DnRWmo 8vmjBl1drq4vjR/Sr78V+N0tGdiCWqer/LXlmYt0tfnURFrea5+dcWEhkvEy/oo+B6Mw RYSQ== 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=6rH9mI3mTJcaBoi8NvQC9FpkTZd7d5upxL04jrJdHuE=; fh=ZqPFscvSVPdx01cUEpUwJW/XMWT5JNM4GyTgYZaa8VU=; b=b44yTDz7BhWN/oLPDZBEM3pB97yyO8mQ1sGdjw/tyxp/4+VHFroY/IKM/sJv5JaBuT heAZZZEFsIKljnogcE31EBHPuuvhI8AuJaUmV/9lpcMQek1gAexgTmvkrX/2JDTg6NTF /d4qRGmbbzAwHGBtOrQJg6CyMrLn6SlEaxM446rlrsugxjw4BoytldKdcZ6Ue3usPPay JZ/B+4Wjn1BdcQ7GmyRYJKsemEyeCNQwne+H41RlwzYHKxrQYTVfe0wHsogwyuWFXwxn ZX569YakL4S91A5E02ss6GDhwIG+ROTFwVKSF3nVKYjDursBP0Qs564tlK9Ug0CVtQoR WriA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="z6Csgq/G"; 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-94398-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94398-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 gs16-20020a1709072d1000b00a44659dcc08si5784100ejc.992.2024.03.06.10.27.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 10:27:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94398-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="z6Csgq/G"; 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-94398-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94398-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 8BB4A1F22A4E for ; Wed, 6 Mar 2024 18:27:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E814D144023; Wed, 6 Mar 2024 18:25:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="z6Csgq/G" 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 C8E0F143746 for ; Wed, 6 Mar 2024 18:25:00 +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=1709749502; cv=none; b=OK5xxPqwD0quyKvL+JXCNlqJ5qU1vgDmCroVclVU/NhGQzglw9rqN1ieQ4WyXMi8cQJXdF5qLf1NTAcgnVmh7JEz0mDvCdxHkoRLEdanFhY0OXcfrThYviY8F556BRMkE5Uj7CpfYUqKxfD5DTtMoi1VyS4zChT/yJimN/x7+x0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709749502; c=relaxed/simple; bh=R2DVckge80A2ruR232rDSrP7/GV74FogObtaXjKjFt4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WQtHADc7TnysWGvByG+eDZwLI6bh/l8bfaHVHxce8UXZhNDO2f+zZ4jl326fziojPzqV3uMi7WOzMug9xdrKaXKt73LcAGN/XQuYiR/pQus6pxuJTHuwAPRcreeph28DvAJVFQrLF69D1rDUeCyYWA65rs2lnKSVfAeOTEvZ4/s= 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=z6Csgq/G; 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-dc64b659a9cso2344801276.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=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=6rH9mI3mTJcaBoi8NvQC9FpkTZd7d5upxL04jrJdHuE=; b=z6Csgq/GpdiAe/2EPMOGSkC2HPAWpdm6wsmaT0tXTRd1oqJ1m+W2JXkygqBzBcF8WM WtLuFAkHn6wjeSqx+vHHHzX9YJus/kVLjMfFZ5uMGWDRAG8BlsbKVphRki6kXGTA7b/2 Jn4G11pkF0ohN30bWz/KRrLyu4oeU329e/8QN9wuANcX5Q8seA4QvANEnVL7KR072tcp o2uNxsBhwPM6ACBSZ8Vb7AIhQl8h83raKw/3BfZRGDloTI394CE91N5fWgiUW7xSUkBw EbOj0f4H0BUf7T5MM73iceYQEPqAhCchgBVSM8oX/gDAFmtMKJ/F6IwqHjU1jJ+09erO R5bg== 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=EwkZaEJGSCJdlq2PqsSuzo4+YeMcUyUGM30ITejwJndFIIJp5vzC6MRZkFB5zEjoIH sbEPwLqNX9dlEq9bqRc6f1ow6eVpPydo96BN6sJHg0N4blAMFWeBOzytxquYwDpRH3Bo QSqgqW61S1rua4zx9oSh7fuNzfI9rNLRrYSChkX30N9gN5V7oLSN1ig6C1PYhFpTnetb R/xyKmTOtnigWPYK8cS6clkmQ9QU+8Y1wqZ5Ka+osI48TuUTD+pKu1z735Wh7AX5BCyt qgKcmjYkfy+Wb3lvxwP9PRt/6rVOM9/yfw0y9A3VHpnDIXE3mXazG8F6NoHhl8OmXRxS sowQ== X-Forwarded-Encrypted: i=1; AJvYcCVJGX09/BWkw/SCfVHibZMVxSKTiimZZQRDhHjUHq4Tyl559rtgCHLWQMU1lBavaEkzLT3fgFQaD+DW9CJcircGwq+poR3nXfuEbSdv X-Gm-Message-State: AOJu0YxjIwHP9nZMgRC1T8+ZKExSTXJHV5J3pbDw1kcrZzzAfZpVrldF 6VdDy3eyX15NL3kwopfjDcOJUKBXTVMiFB1AxYgD2HweW3d62rysDUhYDT1bbwv3qzgCbo9EdpW bTw== 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Content-Type: text/plain; charset="UTF-8" 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) -- 2.44.0.278.ge034bb2e1d-goog