From: John Fastabend <john.fastabend@gmail.com>
To: davem@davemloft.net, daniel@iogearbox.net, alexander.levin@verizon.com
Cc: netdev@vger.kernel.org
Subject: Re: [net-next PATCH] net: devmap fix mutex in rcu critical section
Date: Fri, 04 Aug 2017 14:58:15 -0700 [thread overview]
Message-ID: <5984EDF7.3060808@gmail.com> (raw)
In-Reply-To: <20170804212132.7678.11425.stgit@john-Precision-Tower-5810>
On 08/04/2017 02:21 PM, John Fastabend wrote:
> Originally we used a mutex to protect concurrent devmap update
> and delete operations from racing with netdev unregister notifier
> callbacks.
>
[...]
> }
> @@ -396,22 +385,20 @@ static int dev_map_notification(struct notifier_block *notifier,
>
Daniel reminds me this is not in a rcu_read_lock/unlock() section as
needed, so v2 on its way. Thanks!
> switch (event) {
> case NETDEV_UNREGISTER:
> - mutex_lock(&dev_map_list_mutex);
rcu_read_lock();
> list_for_each_entry(dtab, &dev_map_list, list) {
> for (i = 0; i < dtab->map.max_entries; i++) {
> - struct bpf_dtab_netdev *dev;
> + struct bpf_dtab_netdev *dev, *odev;
>
> - dev = dtab->netdev_map[i];
> + dev = READ_ONCE(dtab->netdev_map[i]);
> if (!dev ||
> dev->dev->ifindex != netdev->ifindex)
> continue;
> - dev = xchg(&dtab->netdev_map[i], NULL);
> - if (dev)
> + odev = cmpxchg(&dtab->netdev_map[i], dev, NULL);
> + if (dev == odev)
> call_rcu(&dev->rcu,
> __dev_map_entry_free);
> }
> }
rcu_read_unlock();
> - mutex_unlock(&dev_map_list_mutex);
> break;
> default:
> break;
>
prev parent reply other threads:[~2017-08-04 21:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-04 21:21 [net-next PATCH] net: devmap fix mutex in rcu critical section John Fastabend
2017-08-04 21:58 ` John Fastabend [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=5984EDF7.3060808@gmail.com \
--to=john.fastabend@gmail.com \
--cc=alexander.levin@verizon.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=netdev@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).