netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: [PATCH 9/9] netfilter: nft_set_pipapo: Don't abuse unlikely() in pipapo_refill()
Date: Tue, 18 Feb 2020 23:21:01 +0100	[thread overview]
Message-ID: <20200218222101.635808-10-pablo@netfilter.org> (raw)
In-Reply-To: <20200218222101.635808-1-pablo@netfilter.org>

From: Stefano Brivio <sbrivio@redhat.com>

I originally used unlikely() in the if (match_only) clause, which
we hit on the mapping table for the last field in a set, to ensure
we avoid branching to the rest of for loop body, which is executed
more frequently.

However, Pablo reports, this is confusing as it gives the impression
that this is not a common case, and it's actually not the intended
usage of unlikely().

I couldn't observe any statistical difference in matching rates on
x864_64 and aarch64 without it, so just drop it.

Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
Fixes: 3c4287f62044 ("nf_tables: Add set type for arbitrary concatenation of ranges")
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 net/netfilter/nft_set_pipapo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/netfilter/nft_set_pipapo.c b/net/netfilter/nft_set_pipapo.c
index 579600b39f39..feac8553f6d9 100644
--- a/net/netfilter/nft_set_pipapo.c
+++ b/net/netfilter/nft_set_pipapo.c
@@ -503,7 +503,7 @@ static int pipapo_refill(unsigned long *map, int len, int rules,
 				return -1;
 			}
 
-			if (unlikely(match_only)) {
+			if (match_only) {
 				bitmap_clear(map, i, 1);
 				return i;
 			}
-- 
2.11.0


  parent reply	other threads:[~2020-02-18 22:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18 22:20 [PATCH 0/9] Netfilter fixes for net Pablo Neira Ayuso
2020-02-18 22:20 ` [PATCH 1/9] netfilter: xt_hashlimit: reduce hashlimit_mutex scope for htable_put() Pablo Neira Ayuso
2020-02-18 22:20 ` [PATCH 2/9] netfilter: xt_hashlimit: limit the max size of hashtable Pablo Neira Ayuso
2020-02-18 22:20 ` [PATCH 3/9] netfilter: flowtable: skip offload setup if disabled Pablo Neira Ayuso
2020-02-18 22:20 ` [PATCH 4/9] netfilter: conntrack: remove two args from resolve_clash Pablo Neira Ayuso
2020-02-18 22:20 ` [PATCH 5/9] netfilter: conntrack: place confirm-bit setting in a helper Pablo Neira Ayuso
2020-02-18 22:20 ` [PATCH 6/9] netfilter: conntrack: split resolve_clash function Pablo Neira Ayuso
2020-02-18 22:20 ` [PATCH 7/9] netfilter: conntrack: allow insertion of clashing entries Pablo Neira Ayuso
2020-02-18 22:21 ` [PATCH 8/9] netfilter: nft_set_pipapo: Fix mapping table example in comments Pablo Neira Ayuso
2020-02-18 22:21 ` Pablo Neira Ayuso [this message]
2020-02-18 23:45 ` [PATCH 0/9] Netfilter fixes for net David Miller

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=20200218222101.635808-10-pablo@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@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).