All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] SUNRPC: add some netns refcount trackers
@ 2022-01-27 20:09 Eric Dumazet
  2022-01-27 20:09 ` [PATCH net-next 1/3] SUNRPC: add netns refcount tracker to struct svc_xprt Eric Dumazet
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Eric Dumazet @ 2022-01-27 20:09 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski
  Cc: Chuck Lever, linux-nfs, netdev, Eric Dumazet, Eric Dumazet

From: Eric Dumazet <edumazet@google.com>

Effort started in linux-5.17

Our goal is to replace get_net()/put_net() pairs with
get_net_track()/put_net_track() to get instant notifications
of imbalance bugs in the future.

Patches were split from a bigger series sent one month ago.

Eric Dumazet (3):
  SUNRPC: add netns refcount tracker to struct svc_xprt
  SUNRPC: add netns refcount tracker to struct gss_auth
  SUNRPC: add netns refcount tracker to struct rpc_xprt

 include/linux/sunrpc/svc_xprt.h |  1 +
 include/linux/sunrpc/xprt.h     |  1 +
 net/sunrpc/auth_gss/auth_gss.c  | 10 ++++++----
 net/sunrpc/svc_xprt.c           |  4 ++--
 net/sunrpc/xprt.c               |  4 ++--
 5 files changed, 12 insertions(+), 8 deletions(-)

-- 
2.35.0.rc0.227.g00780c9af4-goog


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/3] SUNRPC: add netns refcount tracker to struct svc_xprt
  2022-01-27 20:09 [PATCH net-next 0/3] SUNRPC: add some netns refcount trackers Eric Dumazet
@ 2022-01-27 20:09 ` Eric Dumazet
  2022-01-27 20:25   ` Chuck Lever III
  2022-01-27 20:09 ` [PATCH net-next 2/3] SUNRPC: add netns refcount tracker to struct gss_auth Eric Dumazet
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2022-01-27 20:09 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski
  Cc: Chuck Lever, linux-nfs, netdev, Eric Dumazet, Eric Dumazet

From: Eric Dumazet <edumazet@google.com>

struct svc_xprt holds a long lived reference to a netns,
it is worth tracking it.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/linux/sunrpc/svc_xprt.h | 1 +
 net/sunrpc/svc_xprt.c           | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
index 571f605bc91ef8fa190e7fd5504efb76ec3fa89e..382af90320acc3a7b3817bf66f65fbb15447ae7d 100644
--- a/include/linux/sunrpc/svc_xprt.h
+++ b/include/linux/sunrpc/svc_xprt.h
@@ -88,6 +88,7 @@ struct svc_xprt {
 	struct list_head	xpt_users;	/* callbacks on free */
 
 	struct net		*xpt_net;
+	netns_tracker		ns_tracker;
 	const struct cred	*xpt_cred;
 	struct rpc_xprt		*xpt_bc_xprt;	/* NFSv4.1 backchannel */
 	struct rpc_xprt_switch	*xpt_bc_xps;	/* NFSv4.1 backchannel */
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index b21ad79941474685597c9c7c07b862ef7e98ad74..db878e833b672864551bc9ef884a3cd6ca6c2603 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -162,7 +162,7 @@ static void svc_xprt_free(struct kref *kref)
 	if (test_bit(XPT_CACHE_AUTH, &xprt->xpt_flags))
 		svcauth_unix_info_release(xprt);
 	put_cred(xprt->xpt_cred);
-	put_net(xprt->xpt_net);
+	put_net_track(xprt->xpt_net, &xprt->ns_tracker);
 	/* See comment on corresponding get in xs_setup_bc_tcp(): */
 	if (xprt->xpt_bc_xprt)
 		xprt_put(xprt->xpt_bc_xprt);
@@ -198,7 +198,7 @@ void svc_xprt_init(struct net *net, struct svc_xprt_class *xcl,
 	mutex_init(&xprt->xpt_mutex);
 	spin_lock_init(&xprt->xpt_lock);
 	set_bit(XPT_BUSY, &xprt->xpt_flags);
-	xprt->xpt_net = get_net(net);
+	xprt->xpt_net = get_net_track(net, &xprt->ns_tracker, GFP_ATOMIC);
 	strcpy(xprt->xpt_remotebuf, "uninitialized");
 }
 EXPORT_SYMBOL_GPL(svc_xprt_init);
-- 
2.35.0.rc0.227.g00780c9af4-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/3] SUNRPC: add netns refcount tracker to struct gss_auth
  2022-01-27 20:09 [PATCH net-next 0/3] SUNRPC: add some netns refcount trackers Eric Dumazet
  2022-01-27 20:09 ` [PATCH net-next 1/3] SUNRPC: add netns refcount tracker to struct svc_xprt Eric Dumazet
@ 2022-01-27 20:09 ` Eric Dumazet
  2022-01-27 20:09 ` [PATCH net-next 3/3] SUNRPC: add netns refcount tracker to struct rpc_xprt Eric Dumazet
  2022-01-28 15:10 ` [PATCH net-next 0/3] SUNRPC: add some netns refcount trackers patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2022-01-27 20:09 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski
  Cc: Chuck Lever, linux-nfs, netdev, Eric Dumazet, Eric Dumazet

From: Eric Dumazet <edumazet@google.com>

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/sunrpc/auth_gss/auth_gss.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 5f42aa5fc612850b526c160ab5e5c75416862676..8eb7e8544815a8bc20a79b21b01e3ba110fc6b47 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -72,7 +72,8 @@ struct gss_auth {
 	struct gss_api_mech *mech;
 	enum rpc_gss_svc service;
 	struct rpc_clnt *client;
-	struct net *net;
+	struct net	*net;
+	netns_tracker	ns_tracker;
 	/*
 	 * There are two upcall pipes; dentry[1], named "gssd", is used
 	 * for the new text-based upcall; dentry[0] is named after the
@@ -1013,7 +1014,8 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt)
 			goto err_free;
 	}
 	gss_auth->client = clnt;
-	gss_auth->net = get_net(rpc_net_ns(clnt));
+	gss_auth->net = get_net_track(rpc_net_ns(clnt), &gss_auth->ns_tracker,
+				      GFP_KERNEL);
 	err = -EINVAL;
 	gss_auth->mech = gss_mech_get_by_pseudoflavor(flavor);
 	if (!gss_auth->mech)
@@ -1068,7 +1070,7 @@ gss_create_new(const struct rpc_auth_create_args *args, struct rpc_clnt *clnt)
 err_put_mech:
 	gss_mech_put(gss_auth->mech);
 err_put_net:
-	put_net(gss_auth->net);
+	put_net_track(gss_auth->net, &gss_auth->ns_tracker);
 err_free:
 	kfree(gss_auth->target_name);
 	kfree(gss_auth);
@@ -1084,7 +1086,7 @@ gss_free(struct gss_auth *gss_auth)
 	gss_pipe_free(gss_auth->gss_pipe[0]);
 	gss_pipe_free(gss_auth->gss_pipe[1]);
 	gss_mech_put(gss_auth->mech);
-	put_net(gss_auth->net);
+	put_net_track(gss_auth->net, &gss_auth->ns_tracker);
 	kfree(gss_auth->target_name);
 
 	kfree(gss_auth);
-- 
2.35.0.rc0.227.g00780c9af4-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 3/3] SUNRPC: add netns refcount tracker to struct rpc_xprt
  2022-01-27 20:09 [PATCH net-next 0/3] SUNRPC: add some netns refcount trackers Eric Dumazet
  2022-01-27 20:09 ` [PATCH net-next 1/3] SUNRPC: add netns refcount tracker to struct svc_xprt Eric Dumazet
  2022-01-27 20:09 ` [PATCH net-next 2/3] SUNRPC: add netns refcount tracker to struct gss_auth Eric Dumazet
@ 2022-01-27 20:09 ` Eric Dumazet
  2022-01-28 15:10 ` [PATCH net-next 0/3] SUNRPC: add some netns refcount trackers patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: Eric Dumazet @ 2022-01-27 20:09 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski
  Cc: Chuck Lever, linux-nfs, netdev, Eric Dumazet, Eric Dumazet

From: Eric Dumazet <edumazet@google.com>

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/linux/sunrpc/xprt.h | 1 +
 net/sunrpc/xprt.c           | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index 955ea4d7af0b2fea1300a46fad963df35f25810c..3cdc8d878d81122e3318447df4770100500403e4 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -284,6 +284,7 @@ struct rpc_xprt {
 	} stat;
 
 	struct net		*xprt_net;
+	netns_tracker		ns_tracker;
 	const char		*servername;
 	const char		*address_strings[RPC_DISPLAY_MAX];
 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index a02de2bddb28b48bb6798327c0814e769314621b..5af484d6ba5e8bfb871768122009ee330c708c04 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -1835,7 +1835,7 @@ EXPORT_SYMBOL_GPL(xprt_alloc);
 
 void xprt_free(struct rpc_xprt *xprt)
 {
-	put_net(xprt->xprt_net);
+	put_net_track(xprt->xprt_net, &xprt->ns_tracker);
 	xprt_free_all_slots(xprt);
 	xprt_free_id(xprt);
 	rpc_sysfs_xprt_destroy(xprt);
@@ -2027,7 +2027,7 @@ static void xprt_init(struct rpc_xprt *xprt, struct net *net)
 
 	xprt_init_xid(xprt);
 
-	xprt->xprt_net = get_net(net);
+	xprt->xprt_net = get_net_track(net, &xprt->ns_tracker, GFP_KERNEL);
 }
 
 /**
-- 
2.35.0.rc0.227.g00780c9af4-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 1/3] SUNRPC: add netns refcount tracker to struct svc_xprt
  2022-01-27 20:09 ` [PATCH net-next 1/3] SUNRPC: add netns refcount tracker to struct svc_xprt Eric Dumazet
@ 2022-01-27 20:25   ` Chuck Lever III
  0 siblings, 0 replies; 6+ messages in thread
From: Chuck Lever III @ 2022-01-27 20:25 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, Jakub Kicinski, Linux NFS Mailing List, netdev,
	Eric Dumazet



> On Jan 27, 2022, at 3:09 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> 
> From: Eric Dumazet <edumazet@google.com>
> 
> struct svc_xprt holds a long lived reference to a netns,
> it is worth tracking it.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

I haven't followed the requirements for the extended tracking,
but I have no objection to this change.

Acked-by: Chuck Lever <chuck.lever@oracle.com>


> ---
> include/linux/sunrpc/svc_xprt.h | 1 +
> net/sunrpc/svc_xprt.c           | 4 ++--
> 2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
> index 571f605bc91ef8fa190e7fd5504efb76ec3fa89e..382af90320acc3a7b3817bf66f65fbb15447ae7d 100644
> --- a/include/linux/sunrpc/svc_xprt.h
> +++ b/include/linux/sunrpc/svc_xprt.h
> @@ -88,6 +88,7 @@ struct svc_xprt {
> 	struct list_head	xpt_users;	/* callbacks on free */
> 
> 	struct net		*xpt_net;
> +	netns_tracker		ns_tracker;
> 	const struct cred	*xpt_cred;
> 	struct rpc_xprt		*xpt_bc_xprt;	/* NFSv4.1 backchannel */
> 	struct rpc_xprt_switch	*xpt_bc_xps;	/* NFSv4.1 backchannel */
> diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
> index b21ad79941474685597c9c7c07b862ef7e98ad74..db878e833b672864551bc9ef884a3cd6ca6c2603 100644
> --- a/net/sunrpc/svc_xprt.c
> +++ b/net/sunrpc/svc_xprt.c
> @@ -162,7 +162,7 @@ static void svc_xprt_free(struct kref *kref)
> 	if (test_bit(XPT_CACHE_AUTH, &xprt->xpt_flags))
> 		svcauth_unix_info_release(xprt);
> 	put_cred(xprt->xpt_cred);
> -	put_net(xprt->xpt_net);
> +	put_net_track(xprt->xpt_net, &xprt->ns_tracker);
> 	/* See comment on corresponding get in xs_setup_bc_tcp(): */
> 	if (xprt->xpt_bc_xprt)
> 		xprt_put(xprt->xpt_bc_xprt);
> @@ -198,7 +198,7 @@ void svc_xprt_init(struct net *net, struct svc_xprt_class *xcl,
> 	mutex_init(&xprt->xpt_mutex);
> 	spin_lock_init(&xprt->xpt_lock);
> 	set_bit(XPT_BUSY, &xprt->xpt_flags);
> -	xprt->xpt_net = get_net(net);
> +	xprt->xpt_net = get_net_track(net, &xprt->ns_tracker, GFP_ATOMIC);
> 	strcpy(xprt->xpt_remotebuf, "uninitialized");
> }
> EXPORT_SYMBOL_GPL(svc_xprt_init);
> -- 
> 2.35.0.rc0.227.g00780c9af4-goog
> 

--
Chuck Lever




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 0/3] SUNRPC: add some netns refcount trackers
  2022-01-27 20:09 [PATCH net-next 0/3] SUNRPC: add some netns refcount trackers Eric Dumazet
                   ` (2 preceding siblings ...)
  2022-01-27 20:09 ` [PATCH net-next 3/3] SUNRPC: add netns refcount tracker to struct rpc_xprt Eric Dumazet
@ 2022-01-28 15:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-01-28 15:10 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: davem, kuba, chuck.lever, linux-nfs, netdev, edumazet

Hello:

This series was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu, 27 Jan 2022 12:09:34 -0800 you wrote:
> From: Eric Dumazet <edumazet@google.com>
> 
> Effort started in linux-5.17
> 
> Our goal is to replace get_net()/put_net() pairs with
> get_net_track()/put_net_track() to get instant notifications
> of imbalance bugs in the future.
> 
> [...]

Here is the summary with links:
  - [net-next,1/3] SUNRPC: add netns refcount tracker to struct svc_xprt
    https://git.kernel.org/netdev/net-next/c/6cdef8a6ee74
  - [net-next,2/3] SUNRPC: add netns refcount tracker to struct gss_auth
    https://git.kernel.org/netdev/net-next/c/9b1831e56c7f
  - [net-next,3/3] SUNRPC: add netns refcount tracker to struct rpc_xprt
    https://git.kernel.org/netdev/net-next/c/b9a0d6d143ec

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-28 15:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27 20:09 [PATCH net-next 0/3] SUNRPC: add some netns refcount trackers Eric Dumazet
2022-01-27 20:09 ` [PATCH net-next 1/3] SUNRPC: add netns refcount tracker to struct svc_xprt Eric Dumazet
2022-01-27 20:25   ` Chuck Lever III
2022-01-27 20:09 ` [PATCH net-next 2/3] SUNRPC: add netns refcount tracker to struct gss_auth Eric Dumazet
2022-01-27 20:09 ` [PATCH net-next 3/3] SUNRPC: add netns refcount tracker to struct rpc_xprt Eric Dumazet
2022-01-28 15:10 ` [PATCH net-next 0/3] SUNRPC: add some netns refcount trackers patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.