bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] xdp: Handle device unregister for devmap_hash map type
@ 2019-10-16 13:28 Toke Høiland-Jørgensen
  2019-10-16 16:24 ` Martin Lau
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Toke Høiland-Jørgensen @ 2019-10-16 13:28 UTC (permalink / raw)
  To: daniel, ast; +Cc: Toke Høiland-Jørgensen, bpf, netdev, Tetsuo Handa

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>
---
 kernel/bpf/devmap.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index d27f3b60ff6d..deb9416341e9 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -719,6 +719,35 @@ 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)
+{
+	int i;
+
+	for (i = 0; i < dtab->n_buckets; i++) {
+		struct bpf_dtab_netdev *dev, *odev;
+		struct hlist_head *head;
+
+		head = dev_map_index_hash(dtab, i);
+		dev = hlist_entry_safe(rcu_dereference_raw(hlist_first_rcu(head)),
+				       struct bpf_dtab_netdev,
+				       index_hlist);
+
+		while (dev) {
+			odev = (netdev == dev->dev) ? dev : NULL;
+			dev = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(&dev->index_hlist)),
+					       struct bpf_dtab_netdev,
+					       index_hlist);
+
+			if (odev) {
+				hlist_del_rcu(&odev->index_hlist);
+				call_rcu(&odev->rcu,
+					 __dev_map_entry_free);
+			}
+		}
+	}
+}
+
 static int dev_map_notification(struct notifier_block *notifier,
 				ulong event, void *ptr)
 {
@@ -735,6 +764,11 @@ static int dev_map_notification(struct notifier_block *notifier,
 		 */
 		rcu_read_lock();
 		list_for_each_entry_rcu(dtab, &dev_map_list, list) {
+			if (dtab->map.map_type == BPF_MAP_TYPE_DEVMAP_HASH) {
+				dev_map_hash_remove_netdev(dtab, netdev);
+				continue;
+			}
+
 			for (i = 0; i < dtab->map.max_entries; i++) {
 				struct bpf_dtab_netdev *dev, *odev;
 
-- 
2.23.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf] xdp: Handle device unregister for devmap_hash map type
  2019-10-16 13:28 [PATCH bpf] xdp: Handle device unregister for devmap_hash map type Toke Høiland-Jørgensen
@ 2019-10-16 16:24 ` Martin Lau
  2019-10-17 10:27   ` Toke Høiland-Jørgensen
  2019-10-16 20:09 ` Tetsuo Handa
  2019-10-17 19:17 ` Andrii Nakryiko
  2 siblings, 1 reply; 10+ messages in thread
From: Martin Lau @ 2019-10-16 16:24 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: daniel, Alexei Starovoitov, bpf, netdev, Tetsuo Handa

On Wed, Oct 16, 2019 at 03:28:02PM +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>
> ---
>  kernel/bpf/devmap.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
> index d27f3b60ff6d..deb9416341e9 100644
> --- a/kernel/bpf/devmap.c
> +++ b/kernel/bpf/devmap.c
> @@ -719,6 +719,35 @@ 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)
> +{
> +	int i;
> +
> +	for (i = 0; i < dtab->n_buckets; i++) {
> +		struct bpf_dtab_netdev *dev, *odev;
> +		struct hlist_head *head;
> +
> +		head = dev_map_index_hash(dtab, i);
> +		dev = hlist_entry_safe(rcu_dereference_raw(hlist_first_rcu(head)),
> +				       struct bpf_dtab_netdev,
> +				       index_hlist);
> +
> +		while (dev) {
> +			odev = (netdev == dev->dev) ? dev : NULL;
> +			dev = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(&dev->index_hlist)),
> +					       struct bpf_dtab_netdev,
> +					       index_hlist);
> +
> +			if (odev) {
> +				hlist_del_rcu(&odev->index_hlist);
Would it race with the dev_map_hash's update/delete side?

> +				call_rcu(&odev->rcu,
> +					 __dev_map_entry_free);
> +			}
> +		}
> +	}
> +}
> +
>  static int dev_map_notification(struct notifier_block *notifier,
>  				ulong event, void *ptr)
>  {
> @@ -735,6 +764,11 @@ static int dev_map_notification(struct notifier_block *notifier,
>  		 */
>  		rcu_read_lock();
>  		list_for_each_entry_rcu(dtab, &dev_map_list, list) {
> +			if (dtab->map.map_type == BPF_MAP_TYPE_DEVMAP_HASH) {
> +				dev_map_hash_remove_netdev(dtab, netdev);
> +				continue;
> +			}
> +
>  			for (i = 0; i < dtab->map.max_entries; i++) {
>  				struct bpf_dtab_netdev *dev, *odev;
>  
> -- 
> 2.23.0
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf] xdp: Handle device unregister for devmap_hash map type
  2019-10-16 13:28 [PATCH bpf] xdp: Handle device unregister for devmap_hash map type Toke Høiland-Jørgensen
  2019-10-16 16:24 ` Martin Lau
@ 2019-10-16 20:09 ` Tetsuo Handa
  2019-10-17 10:28   ` Toke Høiland-Jørgensen
  2019-10-17 19:17 ` Andrii Nakryiko
  2 siblings, 1 reply; 10+ messages in thread
From: Tetsuo Handa @ 2019-10-16 20:09 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen; +Cc: daniel, ast, bpf, netdev

On 2019/10/16 22:28, 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>

Well, regarding 6f9d451ab1a3, I think that we want explicit "(u64)" cast

@@ -97,6 +123,14 @@ static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr)
        cost = (u64) dtab->map.max_entries * sizeof(struct bpf_dtab_netdev *);
        cost += sizeof(struct list_head) * num_possible_cpus();

+       if (attr->map_type == BPF_MAP_TYPE_DEVMAP_HASH) {
+               dtab->n_buckets = roundup_pow_of_two(dtab->map.max_entries);
+
+               if (!dtab->n_buckets) /* Overflow check */
+                       return -EINVAL;
+               cost += sizeof(struct hlist_head) * dtab->n_buckets;

                                                    ^here

+       }
+
        /* if map size is larger than memlock limit, reject it */
        err = bpf_map_charge_init(&dtab->map.memory, cost);
        if (err)

like "(u64) dtab->map.max_entries * sizeof(struct bpf_dtab_netdev *)" does.
Otherwise, on 32bits build, "sizeof(struct hlist_head) * dtab->n_buckets" can become 0.

----------
#include <stdio.h>
#include <linux/types.h>

int main(int argc, char *argv[])
{
        volatile __u32 i = 4294967296ULL / sizeof(unsigned long *);
        volatile __u64 cost = sizeof(unsigned long *) * i;

        printf("cost=%llu\n", (unsigned long long) cost);
        return 0;
}
----------

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf] xdp: Handle device unregister for devmap_hash map type
  2019-10-16 16:24 ` Martin Lau
@ 2019-10-17 10:27   ` Toke Høiland-Jørgensen
  0 siblings, 0 replies; 10+ messages in thread
From: Toke Høiland-Jørgensen @ 2019-10-17 10:27 UTC (permalink / raw)
  To: Martin Lau; +Cc: daniel, Alexei Starovoitov, bpf, netdev, Tetsuo Handa

Martin Lau <kafai@fb.com> writes:

> On Wed, Oct 16, 2019 at 03:28:02PM +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>
>> ---
>>  kernel/bpf/devmap.c | 34 ++++++++++++++++++++++++++++++++++
>>  1 file changed, 34 insertions(+)
>> 
>> diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
>> index d27f3b60ff6d..deb9416341e9 100644
>> --- a/kernel/bpf/devmap.c
>> +++ b/kernel/bpf/devmap.c
>> @@ -719,6 +719,35 @@ 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)
>> +{
>> +	int i;
>> +
>> +	for (i = 0; i < dtab->n_buckets; i++) {
>> +		struct bpf_dtab_netdev *dev, *odev;
>> +		struct hlist_head *head;
>> +
>> +		head = dev_map_index_hash(dtab, i);
>> +		dev = hlist_entry_safe(rcu_dereference_raw(hlist_first_rcu(head)),
>> +				       struct bpf_dtab_netdev,
>> +				       index_hlist);
>> +
>> +		while (dev) {
>> +			odev = (netdev == dev->dev) ? dev : NULL;
>> +			dev = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(&dev->index_hlist)),
>> +					       struct bpf_dtab_netdev,
>> +					       index_hlist);
>> +
>> +			if (odev) {
>> +				hlist_del_rcu(&odev->index_hlist);
> Would it race with the dev_map_hash's update/delete side?

Oh, right, seems I forgot to grab the lock; will send a v2!

-Toke


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf] xdp: Handle device unregister for devmap_hash map type
  2019-10-16 20:09 ` Tetsuo Handa
@ 2019-10-17 10:28   ` Toke Høiland-Jørgensen
  2019-10-17 15:23     ` Alexei Starovoitov
  0 siblings, 1 reply; 10+ messages in thread
From: Toke Høiland-Jørgensen @ 2019-10-17 10:28 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: daniel, ast, bpf, netdev

Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> writes:

> On 2019/10/16 22:28, 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>
>
> Well, regarding 6f9d451ab1a3, I think that we want explicit "(u64)" cast
>
> @@ -97,6 +123,14 @@ static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr)
>         cost = (u64) dtab->map.max_entries * sizeof(struct bpf_dtab_netdev *);
>         cost += sizeof(struct list_head) * num_possible_cpus();
>
> +       if (attr->map_type == BPF_MAP_TYPE_DEVMAP_HASH) {
> +               dtab->n_buckets = roundup_pow_of_two(dtab->map.max_entries);
> +
> +               if (!dtab->n_buckets) /* Overflow check */
> +                       return -EINVAL;
> +               cost += sizeof(struct hlist_head) * dtab->n_buckets;
>
>                                                     ^here
>
> +       }
> +
>         /* if map size is larger than memlock limit, reject it */
>         err = bpf_map_charge_init(&dtab->map.memory, cost);
>         if (err)
>
> like "(u64) dtab->map.max_entries * sizeof(struct bpf_dtab_netdev *)" does.
> Otherwise, on 32bits build, "sizeof(struct hlist_head) * dtab->n_buckets" can become 0.

Oh, right. I kinda assumed the compiler would be smart enough to figure
that out based on the type of the LHS; will send a separate fix for this.

-Toke


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf] xdp: Handle device unregister for devmap_hash map type
  2019-10-17 10:28   ` Toke Høiland-Jørgensen
@ 2019-10-17 15:23     ` Alexei Starovoitov
  2019-10-17 15:40       ` Toke Høiland-Jørgensen
  0 siblings, 1 reply; 10+ messages in thread
From: Alexei Starovoitov @ 2019-10-17 15:23 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, Tetsuo Handa; +Cc: daniel, bpf, netdev

On 10/17/19 3:28 AM, Toke Høiland-Jørgensen wrote:
> Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> writes:
> 
>> On 2019/10/16 22:28, 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>
>>
>> Well, regarding 6f9d451ab1a3, I think that we want explicit "(u64)" cast
>>
>> @@ -97,6 +123,14 @@ static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr)
>>          cost = (u64) dtab->map.max_entries * sizeof(struct bpf_dtab_netdev *);
>>          cost += sizeof(struct list_head) * num_possible_cpus();
>>
>> +       if (attr->map_type == BPF_MAP_TYPE_DEVMAP_HASH) {
>> +               dtab->n_buckets = roundup_pow_of_two(dtab->map.max_entries);
>> +
>> +               if (!dtab->n_buckets) /* Overflow check */
>> +                       return -EINVAL;
>> +               cost += sizeof(struct hlist_head) * dtab->n_buckets;
>>
>>                                                      ^here
>>
>> +       }
>> +
>>          /* if map size is larger than memlock limit, reject it */
>>          err = bpf_map_charge_init(&dtab->map.memory, cost);
>>          if (err)
>>
>> like "(u64) dtab->map.max_entries * sizeof(struct bpf_dtab_netdev *)" does.
>> Otherwise, on 32bits build, "sizeof(struct hlist_head) * dtab->n_buckets" can become 0.
> 
> Oh, right. I kinda assumed the compiler would be smart enough to figure
> that out based on the type of the LHS; will send a separate fix for this.

compiler smart enough?! you must be kidding.
It's a C standard. Compiler has to do 32 bit multiply because n_buckets
is u32 and sizeof is 32 bit in 32bit arches as Tetsuo explained.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf] xdp: Handle device unregister for devmap_hash map type
  2019-10-17 15:23     ` Alexei Starovoitov
@ 2019-10-17 15:40       ` Toke Høiland-Jørgensen
  0 siblings, 0 replies; 10+ messages in thread
From: Toke Høiland-Jørgensen @ 2019-10-17 15:40 UTC (permalink / raw)
  To: Alexei Starovoitov, Tetsuo Handa; +Cc: daniel, bpf, netdev

Alexei Starovoitov <ast@fb.com> writes:

> On 10/17/19 3:28 AM, Toke Høiland-Jørgensen wrote:
>> Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> writes:
>> 
>>> On 2019/10/16 22:28, 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>
>>>
>>> Well, regarding 6f9d451ab1a3, I think that we want explicit "(u64)" cast
>>>
>>> @@ -97,6 +123,14 @@ static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr)
>>>          cost = (u64) dtab->map.max_entries * sizeof(struct bpf_dtab_netdev *);
>>>          cost += sizeof(struct list_head) * num_possible_cpus();
>>>
>>> +       if (attr->map_type == BPF_MAP_TYPE_DEVMAP_HASH) {
>>> +               dtab->n_buckets = roundup_pow_of_two(dtab->map.max_entries);
>>> +
>>> +               if (!dtab->n_buckets) /* Overflow check */
>>> +                       return -EINVAL;
>>> +               cost += sizeof(struct hlist_head) * dtab->n_buckets;
>>>
>>>                                                      ^here
>>>
>>> +       }
>>> +
>>>          /* if map size is larger than memlock limit, reject it */
>>>          err = bpf_map_charge_init(&dtab->map.memory, cost);
>>>          if (err)
>>>
>>> like "(u64) dtab->map.max_entries * sizeof(struct bpf_dtab_netdev *)" does.
>>> Otherwise, on 32bits build, "sizeof(struct hlist_head) * dtab->n_buckets" can become 0.
>> 
>> Oh, right. I kinda assumed the compiler would be smart enough to figure
>> that out based on the type of the LHS; will send a separate fix for this.
>
> compiler smart enough?! you must be kidding.
> It's a C standard. Compiler has to do 32 bit multiply because n_buckets
> is u32 and sizeof is 32 bit in 32bit arches as Tetsuo explained.

Sure, I can see that now that Tetsuo pointed it out (thanks for that,
BTW!).

I'm just saying that since it's being assigned to a u64, the fact that
the calculation is not automatically promoted to 64-bit is somewhat
unintuitive (to me), regardless of whether it's in the standard or not.

-Toke


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf] xdp: Handle device unregister for devmap_hash map type
  2019-10-16 13:28 [PATCH bpf] xdp: Handle device unregister for devmap_hash map type Toke Høiland-Jørgensen
  2019-10-16 16:24 ` Martin Lau
  2019-10-16 20:09 ` Tetsuo Handa
@ 2019-10-17 19:17 ` Andrii Nakryiko
  2019-10-18 10:31   ` Toke Høiland-Jørgensen
  2 siblings, 1 reply; 10+ messages in thread
From: Andrii Nakryiko @ 2019-10-17 19:17 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: Daniel Borkmann, Alexei Starovoitov, bpf, Networking, Tetsuo Handa

On Wed, Oct 16, 2019 at 9:07 AM Toke Høiland-Jørgensen <toke@redhat.com> 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>
> ---
>  kernel/bpf/devmap.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
>

[...]

> +
> +               while (dev) {
> +                       odev = (netdev == dev->dev) ? dev : NULL;
> +                       dev = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(&dev->index_hlist)),

Please run scripts/checkpatch.pl, this looks like a rather long line.

> +                                              struct bpf_dtab_netdev,
> +                                              index_hlist);

[...]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf] xdp: Handle device unregister for devmap_hash map type
  2019-10-17 19:17 ` Andrii Nakryiko
@ 2019-10-18 10:31   ` Toke Høiland-Jørgensen
  2019-10-18 16:28     ` Andrii Nakryiko
  0 siblings, 1 reply; 10+ messages in thread
From: Toke Høiland-Jørgensen @ 2019-10-18 10:31 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Daniel Borkmann, Alexei Starovoitov, bpf, Networking, Tetsuo Handa

Andrii Nakryiko <andrii.nakryiko@gmail.com> writes:

> On Wed, Oct 16, 2019 at 9:07 AM Toke Høiland-Jørgensen <toke@redhat.com> 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>
>> ---
>>  kernel/bpf/devmap.c | 34 ++++++++++++++++++++++++++++++++++
>>  1 file changed, 34 insertions(+)
>>
>
> [...]
>
>> +
>> +               while (dev) {
>> +                       odev = (netdev == dev->dev) ? dev : NULL;
>> +                       dev = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(&dev->index_hlist)),
>
> Please run scripts/checkpatch.pl, this looks like a rather long line.

That was a deliberate departure from the usual line length, actually. I
don't think it helps readability to split that into three lines just to
adhere to a strict line length requirement...

-Toke


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf] xdp: Handle device unregister for devmap_hash map type
  2019-10-18 10:31   ` Toke Høiland-Jørgensen
@ 2019-10-18 16:28     ` Andrii Nakryiko
  0 siblings, 0 replies; 10+ messages in thread
From: Andrii Nakryiko @ 2019-10-18 16:28 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: Daniel Borkmann, Alexei Starovoitov, bpf, Networking, Tetsuo Handa

On Fri, Oct 18, 2019 at 3:31 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>
> Andrii Nakryiko <andrii.nakryiko@gmail.com> writes:
>
> > On Wed, Oct 16, 2019 at 9:07 AM Toke Høiland-Jørgensen <toke@redhat.com> 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>
> >> ---
> >>  kernel/bpf/devmap.c | 34 ++++++++++++++++++++++++++++++++++
> >>  1 file changed, 34 insertions(+)
> >>
> >
> > [...]
> >
> >> +
> >> +               while (dev) {
> >> +                       odev = (netdev == dev->dev) ? dev : NULL;
> >> +                       dev = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(&dev->index_hlist)),
> >
> > Please run scripts/checkpatch.pl, this looks like a rather long line.
>
> That was a deliberate departure from the usual line length, actually. I
> don't think it helps readability to split that into three lines just to
> adhere to a strict line length requirement...

Wouldn't local variable make it even more readable?

>
> -Toke
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-10-18 16:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16 13:28 [PATCH bpf] xdp: Handle device unregister for devmap_hash map type Toke Høiland-Jørgensen
2019-10-16 16:24 ` Martin Lau
2019-10-17 10:27   ` Toke Høiland-Jørgensen
2019-10-16 20:09 ` Tetsuo Handa
2019-10-17 10:28   ` Toke Høiland-Jørgensen
2019-10-17 15:23     ` Alexei Starovoitov
2019-10-17 15:40       ` Toke Høiland-Jørgensen
2019-10-17 19:17 ` Andrii Nakryiko
2019-10-18 10:31   ` Toke Høiland-Jørgensen
2019-10-18 16:28     ` Andrii Nakryiko

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).