From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D13032E681; Tue, 21 Oct 2025 11:44:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761047071; cv=none; b=EZVbKbrLcAmADx3hEUUjR9g7qHraYGKCETqI+JXWt0JocBd2bIt4QK5NFWukr2GeHhQl/N8Vy4GyhtidBSl1DX87QTe64HEsCoOIWgh7L6/f7hJp6Bn3zu+p2E6Far75ZylqkK0sA9xTxxRDdbx9ZpNQKzpYlyyE1S9dBCMVVoY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761047071; c=relaxed/simple; bh=QM8oyzyJ0QczVJ0uxGx22MIzfw44XMMyED0mCYHZDF8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AtidW1vXL5CPs3kXBr1itUj5X9xYNcChOB0U23OxzSKwT9ZflowXb9IGfXBFHv5nQbLqXOOrKL8PN8S+/Ls/r87j/Q8y29vLCQ8JOwjEAzNV+DD5dL6wHyHiqb2Nv9LYifuDSwbCMqslyJDnkBpHlpdNZz/SGFN+zXb/so+VF14= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cA/9qQlH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cA/9qQlH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0DA8C4CEF5; Tue, 21 Oct 2025 11:44:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761047071; bh=QM8oyzyJ0QczVJ0uxGx22MIzfw44XMMyED0mCYHZDF8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cA/9qQlHtIWh32Oj2GkiV31uJUcLZnvqPPbzP7HjxHdvFwaKyMvmRbq1TJY/3PMME 4iDtkxaydcVE/CuDSRfLnwHFjQ29ci4IGsjzGonwFh4dht4YqhB/ypdSeVjD9An7lT guOvWv5gojtOfmdQzGgMiQb04NnjlIyQ1iBTWhtV1BaN55kim7fctPswjLIUCK4pio txcBLLOQiq19FWdHh06rznzNV9BVXYCMKT9CH9+Hnt5a56QZKaXmg4/JCEiHDBRkFn O5b1B+nlCreiTLS86pyncRSw0sgbHVvWHC+cmrTGAxA3OPoPG4Wo4JRib151PS+4cf RcjiqSukZFrxQ== From: Christian Brauner Date: Tue, 21 Oct 2025 13:43:14 +0200 Subject: [PATCH RFC DRAFT 08/50] ns: add __ns_ref_read() Precedence: bulk X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20251021-work-namespace-nstree-listns-v1-8-ad44261a8a5b@kernel.org> References: <20251021-work-namespace-nstree-listns-v1-0-ad44261a8a5b@kernel.org> In-Reply-To: <20251021-work-namespace-nstree-listns-v1-0-ad44261a8a5b@kernel.org> To: linux-fsdevel@vger.kernel.org, Josef Bacik , Jeff Layton Cc: Jann Horn , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Amir Goldstein , Tejun Heo , Johannes Weiner , Thomas Gleixner , Alexander Viro , Jan Kara , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, bpf@vger.kernel.org, Eric Dumazet , Jakub Kicinski , netdev@vger.kernel.org, Arnd Bergmann , Christian Brauner X-Mailer: b4 0.15-dev-96507 X-Developer-Signature: v=1; a=openpgp-sha256; l=1108; i=brauner@kernel.org; h=from:subject:message-id; bh=QM8oyzyJ0QczVJ0uxGx22MIzfw44XMMyED0mCYHZDF8=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWR8L3zTmVHMyWo8zSs1f3PELLeo5smC3zprHBbulWP+f iIz1PhXRykLgxgXg6yYIotDu0m43HKeis1GmRowc1iZQIYwcHEKwEQsUhn+2W/IML2/dgmTwkWn rRdEo7MC8qpzN/gcYp696OFJzo6034wM07WmCgv6enbvMlyXzDxrp+736R89jOa/N5H4URvE3m7 HCQA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Implement ns_ref_read() the same way as ns_ref_{get,put}(). No point in making that any more special or different from the other helpers. Signed-off-by: Christian Brauner --- include/linux/ns_common.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h index f5b68b8abb54..32114d5698dc 100644 --- a/include/linux/ns_common.h +++ b/include/linux/ns_common.h @@ -143,7 +143,12 @@ static __always_inline __must_check bool __ns_ref_get(struct ns_common *ns) return refcount_inc_not_zero(&ns->__ns_ref); } -#define ns_ref_read(__ns) refcount_read(&to_ns_common((__ns))->__ns_ref) +static __always_inline __must_check int __ns_ref_read(const struct ns_common *ns) +{ + return refcount_read(&ns->__ns_ref); +} + +#define ns_ref_read(__ns) __ns_ref_read(to_ns_common((__ns))) #define ns_ref_inc(__ns) refcount_inc(&to_ns_common((__ns))->__ns_ref) #define ns_ref_get(__ns) __ns_ref_get(to_ns_common((__ns))) #define ns_ref_put(__ns) __ns_ref_put(to_ns_common((__ns))) -- 2.47.3