* [PATCH net-next] bpf: netdev is never null in __dev_map_flush
@ 2017-08-24 1:20 Daniel Borkmann
2017-08-24 1:25 ` Alexei Starovoitov
2017-08-24 5:43 ` David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Daniel Borkmann @ 2017-08-24 1:20 UTC (permalink / raw)
To: davem; +Cc: ast, john.fastabend, netdev, Daniel Borkmann
No need to test for it in fast-path, every dev in bpf_dtab_netdev
is guaranteed to be non-NULL, otherwise dev_map_update_elem() will
fail in the first place.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
kernel/bpf/devmap.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index bfecabf..ecf9f99 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -226,12 +226,10 @@ void __dev_map_flush(struct bpf_map *map)
if (unlikely(!dev))
continue;
- netdev = dev->dev;
__clear_bit(bit, bitmap);
- if (unlikely(!netdev || !netdev->netdev_ops->ndo_xdp_flush))
- continue;
-
- netdev->netdev_ops->ndo_xdp_flush(netdev);
+ netdev = dev->dev;
+ if (likely(netdev->netdev_ops->ndo_xdp_flush))
+ netdev->netdev_ops->ndo_xdp_flush(netdev);
}
}
--
1.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] bpf: netdev is never null in __dev_map_flush
2017-08-24 1:20 [PATCH net-next] bpf: netdev is never null in __dev_map_flush Daniel Borkmann
@ 2017-08-24 1:25 ` Alexei Starovoitov
2017-08-24 3:10 ` John Fastabend
2017-08-24 5:43 ` David Miller
1 sibling, 1 reply; 5+ messages in thread
From: Alexei Starovoitov @ 2017-08-24 1:25 UTC (permalink / raw)
To: Daniel Borkmann, davem; +Cc: john.fastabend, netdev
On 8/23/17 6:20 PM, Daniel Borkmann wrote:
> No need to test for it in fast-path, every dev in bpf_dtab_netdev
> is guaranteed to be non-NULL, otherwise dev_map_update_elem() will
> fail in the first place.
>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
wow. interesting. I'm surprised you see a difference from
such micro-optimization.
Acked-by: Alexei Starovoitov <ast@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] bpf: netdev is never null in __dev_map_flush
2017-08-24 1:25 ` Alexei Starovoitov
@ 2017-08-24 3:10 ` John Fastabend
2017-08-24 8:34 ` Daniel Borkmann
0 siblings, 1 reply; 5+ messages in thread
From: John Fastabend @ 2017-08-24 3:10 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, davem; +Cc: netdev
On 08/23/2017 06:25 PM, Alexei Starovoitov wrote:
> On 8/23/17 6:20 PM, Daniel Borkmann wrote:
>> No need to test for it in fast-path, every dev in bpf_dtab_netdev
>> is guaranteed to be non-NULL, otherwise dev_map_update_elem() will
>> fail in the first place.
>>
>> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
>
> wow. interesting. I'm surprised you see a difference from
> such micro-optimization.
> Acked-by: Alexei Starovoitov <ast@kernel.org>
>
>
Thanks for the clean up, I was a bit over paranoid here as well. Is
this actually noticeable in pps benchmark or just making the code
cleaner? Just curious.
Acked-by: John Fastabend <john.fastabend@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] bpf: netdev is never null in __dev_map_flush
2017-08-24 1:20 [PATCH net-next] bpf: netdev is never null in __dev_map_flush Daniel Borkmann
2017-08-24 1:25 ` Alexei Starovoitov
@ 2017-08-24 5:43 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2017-08-24 5:43 UTC (permalink / raw)
To: daniel; +Cc: ast, john.fastabend, netdev
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Thu, 24 Aug 2017 03:20:11 +0200
> No need to test for it in fast-path, every dev in bpf_dtab_netdev
> is guaranteed to be non-NULL, otherwise dev_map_update_elem() will
> fail in the first place.
>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] bpf: netdev is never null in __dev_map_flush
2017-08-24 3:10 ` John Fastabend
@ 2017-08-24 8:34 ` Daniel Borkmann
0 siblings, 0 replies; 5+ messages in thread
From: Daniel Borkmann @ 2017-08-24 8:34 UTC (permalink / raw)
To: John Fastabend, Alexei Starovoitov, davem; +Cc: netdev
On 08/24/2017 05:10 AM, John Fastabend wrote:
> On 08/23/2017 06:25 PM, Alexei Starovoitov wrote:
>> On 8/23/17 6:20 PM, Daniel Borkmann wrote:
>>> No need to test for it in fast-path, every dev in bpf_dtab_netdev
>>> is guaranteed to be non-NULL, otherwise dev_map_update_elem() will
>>> fail in the first place.
>>>
>>> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
>>
>> wow. interesting. I'm surprised you see a difference from
>> such micro-optimization.
>> Acked-by: Alexei Starovoitov <ast@kernel.org>
>
> Thanks for the clean up, I was a bit over paranoid here as well. Is
> this actually noticeable in pps benchmark or just making the code
> cleaner? Just curious.
No, just from going over the code wondering why it could be
null here but not elsewhere.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-08-24 8:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-24 1:20 [PATCH net-next] bpf: netdev is never null in __dev_map_flush Daniel Borkmann
2017-08-24 1:25 ` Alexei Starovoitov
2017-08-24 3:10 ` John Fastabend
2017-08-24 8:34 ` Daniel Borkmann
2017-08-24 5:43 ` David Miller
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).