From: Daniel Mack <daniel@zonque.org>
To: Craig Gallek <kraigatgoog@gmail.com>,
Alexei Starovoitov <ast@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>,
"David S . Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net-next] bpf: Optimize lpm trie delete
Date: Wed, 20 Sep 2017 18:51:53 +0200 [thread overview]
Message-ID: <47e47f0d-d04d-b52b-647a-7883aa5f3268@zonque.org> (raw)
In-Reply-To: <20170920162247.63787-1-kraigatgoog@gmail.com>
Hi Craig,
Thanks, this looks much cleaner already :)
On 09/20/2017 06:22 PM, Craig Gallek wrote:
> diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c
> index 9d58a576b2ae..b5a7d70ec8b5 100644
> --- a/kernel/bpf/lpm_trie.c
> +++ b/kernel/bpf/lpm_trie.c
> @@ -397,7 +397,7 @@ static int trie_delete_elem(struct bpf_map *map, void *_key)
> struct lpm_trie_node __rcu **trim;
> struct lpm_trie_node *node;
> unsigned long irq_flags;
> - unsigned int next_bit;
> + unsigned int next_bit = 0;
This default assignment seems wrong, and I guess you only added it to
squelch a compiler warning?
[...]
> + /* If the node has one child, we may be able to collapse the tree
> + * while removing this node if the node's child is in the same
> + * 'next bit' slot as this node was in its parent or if the node
> + * itself is the root.
> + */
> + if (trim == &trie->root) {
> + next_bit = node->child[0] ? 0 : 1;
> + rcu_assign_pointer(trie->root, node->child[next_bit]);
> + kfree_rcu(node, rcu);
I don't think you should treat this 'root' case special.
Instead, move the 'next_bit' assignment outside of the condition ...
> + } else if (rcu_access_pointer(node->child[next_bit])) {
> + rcu_assign_pointer(*trim, node->child[next_bit]);
> + kfree_rcu(node, rcu);
... and then this branch would handle the case just fine. Correct?
Otherwise, looks good to me!
Thanks,
Daniel
next prev parent reply other threads:[~2017-09-20 16:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-20 16:22 [PATCH net-next] bpf: Optimize lpm trie delete Craig Gallek
2017-09-20 16:51 ` Daniel Mack [this message]
2017-09-20 18:51 ` Craig Gallek
2017-09-20 22:56 ` Daniel Mack
2017-09-21 13:13 ` Craig Gallek
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=47e47f0d-d04d-b52b-647a-7883aa5f3268@zonque.org \
--to=daniel@zonque.org \
--cc=ast@fb.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=kraigatgoog@gmail.com \
--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