All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Martin Lau <kafai@fb.com>
Cc: "daniel\@iogearbox.net" <daniel@iogearbox.net>,
	Alexei Starovoitov <ast@fb.com>,
	"bpf\@vger.kernel.org" <bpf@vger.kernel.org>,
	"netdev\@vger.kernel.org" <netdev@vger.kernel.org>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Subject: Re: [PATCH bpf v3] xdp: Handle device unregister for devmap_hash map type
Date: Sat, 19 Oct 2019 13:16:23 +0200	[thread overview]
Message-ID: <87lfthc7eg.fsf@toke.dk> (raw)
In-Reply-To: <20191018211818.5e6gfdjwq4zefnez@kafai-mbp>

Martin Lau <kafai@fb.com> writes:

> On Fri, Oct 18, 2019 at 09:44:18PM +0200, Toke Høiland-Jørgensen wrote:
>> It seems I forgot to add handling of devmap_hash type maps to the device
>> unregister hook for devmaps. This omission causes devices to not be
>> properly released, which causes hangs.
>> 
>> Fix this by adding the missing handler.
>> 
>> Fixes: 6f9d451ab1a3 ("xdp: Add devmap_hash map type for looking up devices by hashed index")
>> Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
>> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
>> ---
>> v3:
>>   - Use u32 for loop iterator variable
>>   - Since we're holding the lock we can just iterate with hlist_for_each_entry_safe()
>> v2:
>>   - Grab the update lock while walking the map and removing entries.
>> 
>>  kernel/bpf/devmap.c | 30 ++++++++++++++++++++++++++++++
>>  1 file changed, 30 insertions(+)
>> 
>> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
>> index c0a48f336997..012dbfb0f54b 100644
>> --- a/kernel/bpf/devmap.c
>> +++ b/kernel/bpf/devmap.c
>> @@ -719,6 +719,31 @@ const struct bpf_map_ops dev_map_hash_ops = {
>>  	.map_check_btf = map_check_no_btf,
>>  };
>>  
>> +static void dev_map_hash_remove_netdev(struct bpf_dtab *dtab,
>> +				       struct net_device *netdev)
>> +{
>> +	unsigned long flags;
>> +	u32 i;
>> +
>> +	spin_lock_irqsave(&dtab->index_lock, flags);
>> +	for (i = 0; i < dtab->n_buckets; i++) {
>> +		struct bpf_dtab_netdev *dev;
>> +		struct hlist_head *head;
>> +		struct hlist_node *next;
>> +
>> +		head = dev_map_index_hash(dtab, i);
>> +
>> +		hlist_for_each_entry_safe(dev, next, head, index_hlist) {
>> +			if (netdev != dev->dev)
>> +				continue;
>> +
>> +			hlist_del_rcu(&dev->index_hlist);
> There is another issue...
> "dtab->items--;"

Right, of course. Thanks for your diligence in spotting my silly
mistakes! Will send a v4 :)

-Toke


      reply	other threads:[~2019-10-19 11:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18 19:44 [PATCH bpf v3] xdp: Handle device unregister for devmap_hash map type Toke Høiland-Jørgensen
2019-10-18 21:18 ` Martin Lau
2019-10-19 11:16   ` Toke Høiland-Jørgensen [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=87lfthc7eg.fsf@toke.dk \
    --to=toke@redhat.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    /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 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.