netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ilya Maximets <i.maximets@samsung.com>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	bpf@vger.kernel.org, xdp-newbies@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	"Björn Töpel" <bjorn.topel@intel.com>,
	"Magnus Karlsson" <magnus.karlsson@intel.com>,
	"Jonathan Lemon" <jonathan.lemon@gmail.com>,
	"Daniel Borkmann" <daniel@iogearbox.net>
Subject: Re: [PATCH bpf v4 2/2] xdp: fix hang while unregistering device bound to xdp socket
Date: Thu, 27 Jun 2019 10:23:27 +0300	[thread overview]
Message-ID: <30d4e214-f53b-ac2d-e7f7-99bbd7b96b8f@samsung.com> (raw)
In-Reply-To: <20190626113427.761cc845@cakuba.netronome.com>

On 26.06.2019 21:34, Jakub Kicinski wrote:
> On Wed, 26 Jun 2019 21:15:15 +0300, Ilya Maximets wrote:
>> diff --git a/net/xdp/xdp_umem.c b/net/xdp/xdp_umem.c
>> index 267b82a4cbcf..56729e74cbea 100644
>> --- a/net/xdp/xdp_umem.c
>> +++ b/net/xdp/xdp_umem.c
>> @@ -140,34 +140,38 @@ int xdp_umem_assign_dev(struct xdp_umem *umem, struct net_device *dev,
>>  	return err;
>>  }
>>  
>> -static void xdp_umem_clear_dev(struct xdp_umem *umem)
>> +void xdp_umem_clear_dev(struct xdp_umem *umem)
>>  {
>> +	bool lock = rtnl_is_locked();
> 
> How do you know it's not just locked by someone else?  You need to pass
> the locked state in if this is called from different paths, some of
> which already hold rtnl.

Oh. That's a shame. I need more sleep.

Thanks for spotting. I'll re-work this part.

Best regards, Ilya Maximets.

> 
> Preferably factor the code which needs the lock out into a separate
> function like this:
> 
> void __function()
> {
> 	do();
> 	the();
> 	things();
> 	under();
> 	the();
> 	lock();
> }
> 
> void function()
> {
> 	rtnl_lock();
> 	__function();
> 	rtnl_unlock();
> }
> 
>>  	struct netdev_bpf bpf;
>>  	int err;
>>  
>> +	if (!lock)
>> +		rtnl_lock();
> 
> 
> 

      reply	other threads:[~2019-06-27  7:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190626181520eucas1p1817d31d958b8755600f0745e92edef5a@eucas1p1.samsung.com>
2019-06-26 18:15 ` [PATCH bpf v4 0/2] xdp: fix hang while unregistering device bound to xdp socket Ilya Maximets
     [not found]   ` <CGME20190626181525eucas1p2d0f467c8ba7504b7dcc639712575032e@eucas1p2.samsung.com>
2019-06-26 18:15     ` [PATCH bpf v4 1/2] xdp: hold device for umem regardless of zero-copy mode Ilya Maximets
     [not found]   ` <CGME20190626181528eucas1p190f20427a1d2a64f2efa6cedcfac0826@eucas1p1.samsung.com>
2019-06-26 18:15     ` [PATCH bpf v4 2/2] xdp: fix hang while unregistering device bound to xdp socket Ilya Maximets
2019-06-26 18:34       ` Jakub Kicinski
2019-06-27  7:23         ` Ilya Maximets [this message]

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=30d4e214-f53b-ac2d-e7f7-99bbd7b96b8f@samsung.com \
    --to=i.maximets@samsung.com \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=jonathan.lemon@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=xdp-newbies@vger.kernel.org \
    /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).