[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <z5riatsc5fycrrvw4c6puqlyghsaaoefisy7osujxiu2mlnzzk@js5yxopnexcl>
Date: Mon, 15 Sep 2025 14:06:52 +0200
From: Jan Kara <jack@...e.cz>
To: Christian Brauner <brauner@...nel.org>
Cc: Jan Kara <jack@...e.cz>, Amir Goldstein <amir73il@...il.com>,
linux-fsdevel@...r.kernel.org, Josef Bacik <josef@...icpanda.com>,
Jeff Layton <jlayton@...nel.org>, Mike Yuan <me@...dnzj.com>,
Zbigniew Jędrzejewski-Szmek <zbyszek@...waw.pl>, Lennart Poettering <mzxreary@...inter.de>,
Daan De Meyer <daan.j.demeyer@...il.com>, Aleksa Sarai <cyphar@...har.com>,
Alexander Viro <viro@...iv.linux.org.uk>, Jens Axboe <axboe@...nel.dk>, Tejun Heo <tj@...nel.org>,
Johannes Weiner <hannes@...xchg.org>, Michal Koutný <mkoutny@...e.com>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Chuck Lever <chuck.lever@...cle.com>, linux-nfs@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org, cgroups@...r.kernel.org,
netdev@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH v2 23/33] time: support ns lookup
On Fri 12-09-25 13:52:46, Christian Brauner wrote:
> Support the generic ns lookup infrastructure to support file handles for
> namespaces.
>
> Reviewed-by: Thomas Gleixner <tglx@...utronix.de>
> Signed-off-by: Christian Brauner <brauner@...nel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@...e.cz>
Honza
> ---
> include/linux/time_namespace.h | 5 +++++
> init/main.c | 2 ++
> kernel/time/namespace.c | 11 ++++++++++-
> 3 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/time_namespace.h b/include/linux/time_namespace.h
> index bb2c52f4fc94..7f6af7a9771e 100644
> --- a/include/linux/time_namespace.h
> +++ b/include/linux/time_namespace.h
> @@ -33,6 +33,7 @@ struct time_namespace {
> extern struct time_namespace init_time_ns;
>
> #ifdef CONFIG_TIME_NS
> +void __init time_ns_init(void);
> extern int vdso_join_timens(struct task_struct *task,
> struct time_namespace *ns);
> extern void timens_commit(struct task_struct *tsk, struct time_namespace *ns);
> @@ -108,6 +109,10 @@ static inline ktime_t timens_ktime_to_host(clockid_t clockid, ktime_t tim)
> }
>
> #else
> +static inline void __init time_ns_init(void)
> +{
> +}
> +
> static inline int vdso_join_timens(struct task_struct *task,
> struct time_namespace *ns)
> {
> diff --git a/init/main.c b/init/main.c
> index 0ee0ee7b7c2c..e7d2c57c65a7 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -103,6 +103,7 @@
> #include <linux/randomize_kstack.h>
> #include <linux/pidfs.h>
> #include <linux/ptdump.h>
> +#include <linux/time_namespace.h>
> #include <net/net_namespace.h>
>
> #include <asm/io.h>
> @@ -1072,6 +1073,7 @@ void start_kernel(void)
> fork_init();
> proc_caches_init();
> uts_ns_init();
> + time_ns_init();
> key_init();
> security_init();
> dbg_late_init();
> diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c
> index 0be93d8f2896..408f60d0a3b6 100644
> --- a/kernel/time/namespace.c
> +++ b/kernel/time/namespace.c
> @@ -12,6 +12,7 @@
> #include <linux/seq_file.h>
> #include <linux/proc_ns.h>
> #include <linux/export.h>
> +#include <linux/nstree.h>
> #include <linux/time.h>
> #include <linux/slab.h>
> #include <linux/cred.h>
> @@ -104,6 +105,7 @@ static struct time_namespace *clone_time_ns(struct user_namespace *user_ns,
> ns->user_ns = get_user_ns(user_ns);
> ns->offsets = old_ns->offsets;
> ns->frozen_offsets = false;
> + ns_tree_add(ns);
> return ns;
>
> fail_free_page:
> @@ -250,11 +252,13 @@ static void timens_set_vvar_page(struct task_struct *task,
>
> void free_time_ns(struct time_namespace *ns)
> {
> + ns_tree_remove(ns);
> dec_time_namespaces(ns->ucounts);
> put_user_ns(ns->user_ns);
> ns_free_inum(&ns->ns);
> __free_page(ns->vvar_page);
> - kfree(ns);
> + /* Concurrent nstree traversal depends on a grace period. */
> + kfree_rcu(ns, ns.ns_rcu);
> }
>
> static struct time_namespace *to_time_ns(struct ns_common *ns)
> @@ -487,3 +491,8 @@ struct time_namespace init_time_ns = {
> .ns.ops = &timens_operations,
> .frozen_offsets = true,
> };
> +
> +void __init time_ns_init(void)
> +{
> + ns_tree_add(&init_time_ns);
> +}
>
> --
> 2.47.3
>
--
Jan Kara <jack@...e.com>
SUSE Labs, CR
Powered by blists - more mailing lists