netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Jiri Pirko <jiri@resnulli.us>
Cc: netdev@vger.kernel.org, pabeni@redhat.com, davem@davemloft.net,
	edumazet@google.com, gal@nvidia.com
Subject: Re: [patch net-next] devlink: don't take instance lock for nested handle put
Date: Thu, 5 Oct 2023 18:30:29 -0700	[thread overview]
Message-ID: <20231005183029.32987349@kernel.org> (raw)
In-Reply-To: <20231003074349.1435667-1-jiri@resnulli.us>

On Tue,  3 Oct 2023 09:43:49 +0200 Jiri Pirko wrote:
> To fix this, don't take the devlink instance lock when putting nested
> handle. Instead, rely on devlink reference to access relevant pointers
> within devlink structure. Also, make sure that the device does

struct device ?

> not disappear by taking a reference in devlink_alloc_ns().

> @@ -310,6 +299,7 @@ static void devlink_release(struct work_struct *work)
>  
>  	mutex_destroy(&devlink->lock);
>  	lockdep_unregister_key(&devlink->lock_key);
> +	put_device(devlink->dev);

IDK.. holding references until all references are gone may lead 
to reference cycles :(

>  	kfree(devlink);
>  }

> @@ -92,9 +93,8 @@ int devlink_nl_put_nested_handle(struct sk_buff *msg, struct net *net,
>  		return -EMSGSIZE;
>  	if (devlink_nl_put_handle(msg, devlink))
>  		goto nla_put_failure;
> -	if (!net_eq(net, devlink_net(devlink))) {
> -		int id = peernet2id_alloc(net, devlink_net(devlink),
> -					  GFP_KERNEL);
> +	if (!net_eq(net, devl_net)) {
> +		int id = peernet2id_alloc(net, devl_net, GFP_KERNEL);
>  
>  		if (nla_put_s32(msg, DEVLINK_ATTR_NETNS_ID, id))
>  			return -EMSGSIZE;

Looks like pure refactoring. But are you sure that the netns can't
disappear? We're not holding the lock, the instance may get moved.

Overall I feel like recording the references on the objects will be
an endless source of locking pain. Would it be insane if we held 
the relationships as independent objects? Not as attributes of either
side? 

  reply	other threads:[~2023-10-06  1:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-03  7:43 [patch net-next] devlink: don't take instance lock for nested handle put Jiri Pirko
2023-10-06  1:30 ` Jakub Kicinski [this message]
2023-10-06  7:22   ` Jiri Pirko
2023-10-06 14:48     ` Jakub Kicinski
2023-10-06 17:07       ` Jiri Pirko
2023-10-06 22:14         ` Jakub Kicinski
2023-10-07 10:17           ` Jiri Pirko
2023-10-09 15:15             ` Jakub Kicinski
2023-10-09 15:37               ` Jiri Pirko
2023-10-09 16:31                 ` Jakub Kicinski
2023-10-10  7:31                   ` Jiri Pirko
2023-10-10 14:52                     ` Jakub Kicinski
2023-10-10 15:56                       ` Jiri Pirko
2023-10-10 18:16                         ` Jakub Kicinski
2023-10-11 13:34                           ` Jiri Pirko
2023-10-12  0:20                             ` Jakub Kicinski
2023-10-12  6:14                               ` Jiri Pirko
2023-10-13 15:39                                 ` Jakub Kicinski
2023-10-13 17:07                                   ` Jiri Pirko
2023-10-13 20:01                                     ` Jakub Kicinski
2023-10-15 11:12                                       ` Jiri Pirko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231005183029.32987349@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).