From nobody Mon Dec 1 21:30:05 2025 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (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 6017D33985 for ; Mon, 1 Dec 2025 08:32:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764577957; cv=none; b=pwxRGB11T5Vvw73B1JLo8LUrLnuEk0vwv3m1ubFXf170y1tMUOkkOxC2WKBiyqt0yl5Cn4OlsWfPE/gyGHuxuyzIZbCgR/KCL2gcMiU+bVjWQANRw2qXzUnOZwW0J70nHs7+NfrRA/rYUEqzv5km1MsXP3asCgAzaQpQhu6E3wI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764577957; c=relaxed/simple; bh=WouL/gXxoaw+fgKLIDXK8/ULsHp1Pa0MmL1z6JvimiA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=oGryjf8fR9hLPPsMQZ9tQ9Wn3T2nrkDAwqU6ZWu7d7NhXT0tDeBywbzwqWLxPkS2VHviUbsmOAKtQkNrgz8fjVpOPO/LJr821p8OJsVowDN+mFm3Z0enpX3g0AY6crN47lmOAi7vCA2l/bU7n69ifv8qqYWhn+htNeGIbVd/80o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hFjKoQ82; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hFjKoQ82" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-645a13e2b17so145834a12.2 for ; Mon, 01 Dec 2025 00:32:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764577954; x=1765182754; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=agur13uatpBfTbiWy9CXQ832nKs/hmYFvcnvXcVIbzE=; b=hFjKoQ82PBlRP7uARebQtTKyzrr4gIcwZhUY6riLp+1o3ZKvh3MS03G1e8FRY5Ijbb q9WHhVp+ftCC+jZ97RLvcftOw1J5ckd86VZPbH2z+XHs0umjzsvwB2qFQc55AInqAHim 3TjnVMw9XOJeUy0KPBZuwexjPqeFcdyOTWbtlP332p02EjsjWCVlUNM/XiOXxF0Jfpii QePVZDjwf7pmSOaRpVZ5HZZ/B+OcM3gfiw/hiZnAm3jaMAfV75Lye/jlDwcIXRMjzwOe aRJfK5tpQpIKSyfB6X/kYX1B5I9MwiuGdWbMxA9mQmIWQAkRcl/42ccoF3PqxS4p/w+m SA4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764577954; x=1765182754; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=agur13uatpBfTbiWy9CXQ832nKs/hmYFvcnvXcVIbzE=; b=KbeJgvmtTbC+8Rugluplv/kdwqtz9PBosVu8bCc6T3zyb6ptwu0/wL87cL2oUmMp9P GXNuYADzz+Osz3lDtdZL8/JESfiucn3dciVN9wmXOSIBlp+vEu57DsWKa0LuqqrWd8qG halm4jRZ/kLBGW+lAj0wCwTSm3MUyBzvhMveLll6A1OEdRLZFc/bbdw7NmCa4frm+98/ YH7fL9ymyrD5BEbvEB+QvMSGPOJMCrP3GeGUe/mhecGnHJovGqyKhYuhj76B2fb3H2Mr 6iLTPlMQNVHHc86uIEt9ZCsD4mnUzfSn0sU+XS/62MPMRoOKt56+xjWlxzbNIf1NwrlB 5HLQ== X-Forwarded-Encrypted: i=1; AJvYcCUyt5/RHspSU5tXXY9Tb0WbDlJ1nLkkmJQBmlBxHi8rZ68kwS8vCLxjbIJoyBAjJq+RSB+azp1+cWR7cZ0=@vger.kernel.org X-Gm-Message-State: AOJu0YzJNWUQv22tAdp7mpVJv89t0cHN+W5IFafqn0KqKjZ67YksmSOY KN43tfPcHMLIkenbgjMkyZNlqiI4Am4uWaEfg/omLd9WViY/Gfd3vrQlVoG27A== X-Gm-Gg: ASbGncskI4WtuuUX5OvxDAnEV/EKMFYRJMEG/bNE3Oz7uUNGMJbswHaJP4YYM3sKl6h aORyDxEhjBEUDex55Jh/K8mVgHqtIV9u2q0RBbEi93rM33nyu8NzCL3rg8Ipbfj5vvsGYdjVSbt RlzbbRuoZDWit0SsAn/qAE0aqQqmnENFKrYtt095JAeAGRGbcnzgDFepBuJFIzvax66O1pbh+5A 6gfH1AplxEAy2fiJbrGl5J7s0OVXyOxPqZ0CyckG3W9KxM/U/a0Rn3oP/242HoOe93mgPygJL/3 uFSuVYA/nImS+D/VhYI5orsZqey6lxp/vG21QtE2zQdkEsM4h8h9IvG05Ctx/uXp+IxhZxluEJk Z15622Gmirpi6uSTC/lLrjqDaIAfVjdUaegKULz5Frfs9KxXPn04ZAY9MwkmbmXdjfMJI4El57w 4HqsFa7oIPLzvO+1IkpknQgy8f01YHmOvHUdJM1m8hOTzybkQD7eTxAnLias4= X-Google-Smtp-Source: AGHT+IFkO0hcC2MDPwV3l3Gu5TfNfGl5BIcxQ6u4IdLB8tg7tP4Nx4BvTYET2NVBhKoWf3cisrJZQQ== X-Received: by 2002:a05:6402:3594:b0:63c:3c63:75ed with SMTP id 4fb4d7f45d1cf-645eb2a83b2mr22977341a12.22.1764577953520; Mon, 01 Dec 2025 00:32:33 -0800 (PST) Received: from f.. (cst-prg-14-82.cust.vodafone.cz. [46.135.14.82]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-64750a90d14sm11947696a12.10.2025.12.01.00.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Dec 2025 00:32:32 -0800 (PST) From: Mateusz Guzik To: viro@zeniv.linux.org.uk Cc: brauner@kernel.org, jack@suse.cz, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Mateusz Guzik Subject: [PATCH v2] fs: hide names_cache behind runtime const machinery Date: Mon, 1 Dec 2025 09:32:26 +0100 Message-ID: <20251201083226.268846-1-mjguzik@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" s/names_cachep/names_cache/ for consistency with dentry cache. Signed-off-by: Mateusz Guzik --- v2: - rebased on top of work.filename-refcnt ACHTUNG: there is a change queued for 6.19 merge window which treats dentry cache the same way: commit 21b561dab1406e63740ebe240c7b69f19e1bcf58 Author: Mateusz Guzik Date: Wed Nov 5 16:36:22 2025 +0100 fs: hide dentry_cache behind runtime const machinery which would result in a merge conflict in vmlinux.lds.h. thus I cherry-picked before generating the diff to avoid the issue for later. fs/namei.c | 16 ++++++++++------ include/asm-generic/vmlinux.lds.h | 3 ++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index d6eac90084e1..eff4cbffe241 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -41,6 +41,8 @@ #include #include =20 +#include + #include "internal.h" #include "mount.h" =20 @@ -124,23 +126,25 @@ */ =20 /* SLAB cache for struct filename instances */ -static struct kmem_cache *names_cachep __ro_after_init; +static struct kmem_cache *__names_cache __ro_after_init; +#define names_cache runtime_const_ptr(__names_cache) =20 void __init filename_init(void) { - names_cachep =3D kmem_cache_create_usercopy("names_cache", sizeof(struct = filename), 0, - SLAB_HWCACHE_ALIGN|SLAB_PANIC, offsetof(struct filename, iname), - EMBEDDED_NAME_MAX, NULL); + __names_cache =3D kmem_cache_create_usercopy("names_cache", sizeof(struct= filename), 0, + SLAB_HWCACHE_ALIGN|SLAB_PANIC, offsetof(struct filename, iname), + EMBEDDED_NAME_MAX, NULL); + runtime_const_init(ptr, __names_cache); } =20 static inline struct filename *alloc_filename(void) { - return kmem_cache_alloc(names_cachep, GFP_KERNEL); + return kmem_cache_alloc(names_cache, GFP_KERNEL); } =20 static inline void free_filename(struct filename *p) { - kmem_cache_free(names_cachep, p); + kmem_cache_free(names_cache, p); } =20 static inline void initname(struct filename *name) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinu= x.lds.h index 20939d2445e7..3abd76ac723a 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -956,7 +956,8 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELL= ER_CLANG) #define RUNTIME_CONST_VARIABLES \ RUNTIME_CONST(shift, d_hash_shift) \ RUNTIME_CONST(ptr, dentry_hashtable) \ - RUNTIME_CONST(ptr, __dentry_cache) + RUNTIME_CONST(ptr, __dentry_cache) \ + RUNTIME_CONST(ptr, __names_cache) =20 /* Alignment must be consistent with (kunit_suite *) in include/kunit/test= .h */ #define KUNIT_TABLE() \ --=20 2.48.1