nf_conncount_gc_list() takes list_lock first and only then finds out, in __nf_conncount_gc_list(), that gc already ran during this jiffy and there is nothing to do. The trylock still writes to the lock, so every caller contends on it even though at most one of them per jiffy does any work.
This matters on the count-only path of nf_conncount_count_skb(), where the lookup itself is lockless: when many cpus query the same list at once, the gc attempt is the only thing they serialize on. Read last_gc before the trylock and leave early. The check under the lock stays, as it is the one that decides when two cpus race for the same jiffy. Signed-off-by: Vladimir Vdovin <[email protected]> --- net/netfilter/nf_conncount.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/netfilter/nf_conncount.c b/net/netfilter/nf_conncount.c index 84290e363245..be9e395e25b6 100644 --- a/net/netfilter/nf_conncount.c +++ b/net/netfilter/nf_conncount.c @@ -382,6 +382,10 @@ bool nf_conncount_gc_list(struct net *net, { bool ret; + /* don't bother if we just did GC */ + if ((u32)jiffies == READ_ONCE(list->last_gc)) + return false; + /* don't bother if other cpu is already doing GC */ if (!spin_trylock_bh(&list->list_lock)) return false; -- 2.56.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
