Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp596149lqp; Thu, 21 Mar 2024 09:47:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpG6bUC6vRKsfH6ol2RheAQYjZZlNS4PepPBjQl2evZVK+G2ymEsgGp0vPqdV6grMo1WV0ZVuxUgBLKy35uaIIFlxLbKpVTUIaTOKa4w== X-Google-Smtp-Source: AGHT+IHtavyaiwHIdKJuv5phCxEns+XHypwokJ639v82ekoC2rSWx9rt4H+EbTWMLHLs2y13qGit X-Received: by 2002:a17:907:7643:b0:a46:2100:da56 with SMTP id kj3-20020a170907764300b00a462100da56mr4180001ejc.55.1711039638296; Thu, 21 Mar 2024 09:47:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711039638; cv=pass; d=google.com; s=arc-20160816; b=Pbd4fZZAIzqvLfr2XZ6C8wL6vbN6ztD+9VcbNRf5qoePrLmnwrEpeyAavP5meVjqDS U2bmAmbnIYeHk2G5NWUUcUhfFzNNwuAj4rKxCsksGZ1jC3cNmllwCOiZlKQ2LOdKw0L1 sutjaxwW4ivSi9duqEMNheUr1UwpZ4ERWJAa0lkXUEY+7fwWSA234wIGx4B3Db4aRkKp zND4I7V12sXW4+nQuVDhMeQkpM9T7qX9XkJkK9C7fspvETA61Sl78lkDIB6pE3m9M33M oKCSGZmJ2g5tr/e9QpYXxaOlMsSSLMA3+YFwX+VvMXGHGoh371bD9EqaaGl1WMe/ox/p 8lIQ== 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=WOYiJPoOo6EZ1v2aVMfBUZhNa7dlHF73f/fDRlekI3w=; fh=gfBJshRLP4o2NfNcj0iy2ICEFhNORuNSDpzG6oELbiM=; b=kIgLHnG2bPL8PiuJ5Mh9EekILXD2aBrhZENhIEg3//gyqWFZ2UwaAL5BKW8UMfIMww o6tguu0UcEayc4vVtOXuWekDOtmncjdPp/AoedkTV9l3KYN9s8xZpSgAqbHhijV01Alw nPKXodoBGzByIHXKp08gjbD+NT0lhuC6pwRpR08QOKJbqZL3IOZkI8N3LrVNLDghO9PV OZIIXwwgMu7zbdhMFSx1WhqHq+Ulachyq/ufgm8Khkzzy3JxJXn6P/o0x6KH6ZfCKair MjVpqzbTJ5km5sEKpE2G6jryvaf6BYvA1zXx3Rq4mlcrSMBL7HX6U6TF4IWyg/DMUsCp 5sVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="XbIJR/q8"; 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-110361-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110361-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 w13-20020a1709062f8d00b00a46f27d20d9si80603eji.973.2024.03.21.09.47.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 09:47:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110361-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="XbIJR/q8"; 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-110361-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110361-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 E7D961F24BA0 for ; Thu, 21 Mar 2024 16:40:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C133E1353E2; Thu, 21 Mar 2024 16:37:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XbIJR/q8" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 5DA6B134751 for ; Thu, 21 Mar 2024 16:37:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039048; cv=none; b=Lqd4VNT0RIDYjTrmmOZcebZtQxS+oQ2iKUsG1YRpJiiu4L0fVeHx57Y1SAlez8i3NftR0ewIvY3EcHFdMY20bTm8QKimpEKor+OA9pxF+Y6CUy9WxN15fboTjF2ieI0TORbDNWGs6wMJuoBep1NUCZVbxASt4Z9M5YHAjfKXUXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039048; c=relaxed/simple; bh=FTfpkMz7knxr9PqAm/DqbYAED2rQQG3uETEf+9W7BLc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=r98bUnccqnogpvq+m625KMTrQOz92UwawRNQQFROa1cIzjXrq8Qh/lpfkpkE/GtAsU+MQXDTWUrvLaqb0HwR3wZI7lwgKX8HgdEnQpDO1/AB3evEFEldbbLIiFwrI/VbnkaJzOPZgzWsUWXjOavZpnCiC4rQZTgKZTLU9Z9M1Rg= 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=XbIJR/q8; arc=none smtp.client-ip=209.85.128.201 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-yw1-f201.google.com with SMTP id 00721157ae682-610c23abd1fso22995787b3.0 for ; Thu, 21 Mar 2024 09:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711039045; x=1711643845; 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=WOYiJPoOo6EZ1v2aVMfBUZhNa7dlHF73f/fDRlekI3w=; b=XbIJR/q88u883eJMWJlL9qorr4Q5+ewvfriJb0VMGeF91tlbGowBNb/0+1qYjCsaFF GjQ/MBJsA+YbgJWQhVVmylNbzrEAwwcZzyh+C9Cp0pDfWCCw9cU4ktJ74FB4gbKpJqPL EaGfYdjXMbCQLtCLafzicbvOrWPi7ka5REbzp4QNgHVgHcNsGGvLLOK69BKx1WzGa8Nr gslz3I5UqWwSoXkMzMUTn4kR7O7ySZ2RdxMleVSUijvDybPWHSCz7Y6xQaziC6PJFhL5 H7jBpKmIXFO22iUk/EMazdQodpUDTDVRh4VsiMfy1/sRqq0xAnSONI9oCUzeWH+ocbZC 1i1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711039045; x=1711643845; 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=WOYiJPoOo6EZ1v2aVMfBUZhNa7dlHF73f/fDRlekI3w=; b=bUpCb7k+jTv5oydKYugpXg0LRtAgfF7nldaITd/poOJzohbghn9p9dqOsgiuvbQrPR o6F+1DHZQ0PY8OGvwpOOm6RDK3YvpM+2TdZ/BwyOLLbCMqelrLdplQuHnikKy93bvo3U A0LT2dxgUtLPMvP148bOQ0ZSGbaYEXeDpEWahEY8/xLjJ1vxBA7+QCJ3T6ds5Vue7Rt4 g9tCNVwqMCP2fjKod0dzmgBqv5/cLnVt2luxWKQVrsorcqnygZ7sXklgvh6lubFgDF9T pteqKK7nOIh624S2oSwfBrWr1iilvQu8jk33um/uC0ikMdcMitJTVA3gTG/c8HGYf3yn j8SQ== X-Forwarded-Encrypted: i=1; AJvYcCWrA+NPbRRXPoGaSLtJVSth7AYIl8vpH5t08wDgP/x8KNksy7T8Wyolmwn6aWeiJTmcI3J9Qb2uPObY8AloS0iC/XbAJbUEkmt2dHjG X-Gm-Message-State: AOJu0YxNm05q8uVwcbK8zDAAM7OB7pwG3xof5WCbY90aD5M9XDh0lZc/ i+VXBqUbLX3QylWsC2usO0G7TdsbonRq2W5Ndt8/VVMeJ+qdjaqJ3YNywOXotWhisZYfDpIwK4c Hvg== 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:72f:b0:dc6:eea0:1578 with SMTP id l15-20020a056902072f00b00dc6eea01578mr2412289ybt.13.1711039045315; Thu, 21 Mar 2024 09:37:25 -0700 (PDT) Date: Thu, 21 Mar 2024 09:36:29 -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-8-surenb@google.com> Subject: [PATCH v6 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, 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 5c896c76812d..2cb53642a091 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1889,6 +1889,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.291.gc1ea87d7ee-goog