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>
Subject: Re: [PATCH bpf v2] xdp: fix hang while unregistering device bound to xdp socket
Date: Mon, 10 Jun 2019 19:17:37 +0300 [thread overview]
Message-ID: <06eee1e3-283a-d665-904b-f0bc89b73232@samsung.com> (raw)
In-Reply-To: <d8b2bc92-3b7e-dfe7-35ee-61a68d46ff02@samsung.com>
On 10.06.2019 11:05, Ilya Maximets wrote:
> On 08.06.2019 2:31, Jakub Kicinski wrote:
>> On Fri, 7 Jun 2019 20:31:43 +0300, Ilya Maximets wrote:
>>> +static int xsk_notifier(struct notifier_block *this,
>>> + unsigned long msg, void *ptr)
>>> +{
>>> + struct sock *sk;
>>> + struct net_device *dev = netdev_notifier_info_to_dev(ptr);
>>> + struct net *net = dev_net(dev);
>>> + int i, unregister_count = 0;
>>
>> Please order the var declaration lines longest to shortest.
>> (reverse christmas tree)
>
> Hi.
> I'm not a fan of mixing 'struct's with bare types in the declarations.
> Moving the 'sk' to the third place will make a hole like this:
>
> struct net_device *dev = netdev_notifier_info_to_dev(ptr);
> struct net *net = dev_net(dev);
> struct sock *sk;
> int i, unregister_count = 0;
>
> Which is not looking good.
> Moving to the 4th place:
>
> struct net_device *dev = netdev_notifier_info_to_dev(ptr);
> struct net *net = dev_net(dev);
> int i, unregister_count = 0;
> struct sock *sk;
I've sent v3 with this variant and with moved msg check to the top level.
>
> This variant doesn't look good for me because of mixing 'struct's with
> bare integers.
>
> Do you think I need to use one of above variants?
>
>>
>>> + mutex_lock(&net->xdp.lock);
>>> + sk_for_each(sk, &net->xdp.list) {
>>> + struct xdp_sock *xs = xdp_sk(sk);
>>> +
>>> + mutex_lock(&xs->mutex);
>>> + switch (msg) {
>>> + case NETDEV_UNREGISTER:
>>
>> You should probably check the msg type earlier and not take all the
>> locks and iterate for other types..
>
> Yeah. I thought about it too. Will fix in the next version.
>
> Best regards, Ilya Maximets.
>
prev parent reply other threads:[~2019-06-10 16:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20190607173149eucas1p1d2ebedcab469ebd66acfe7c7dcd18d7e@eucas1p1.samsung.com>
2019-06-07 17:31 ` [PATCH bpf v2] xdp: fix hang while unregistering device bound to xdp socket Ilya Maximets
2019-06-07 23:31 ` Jakub Kicinski
2019-06-10 8:05 ` Ilya Maximets
2019-06-10 16:17 ` 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=06eee1e3-283a-d665-904b-f0bc89b73232@samsung.com \
--to=i.maximets@samsung.com \
--cc=bjorn.topel@intel.com \
--cc=bpf@vger.kernel.org \
--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).