netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: "Li,Rongqing" <lirongqing@baidu.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	"netfilter-devel@vger.kernel.org"
	<netfilter-devel@vger.kernel.org>,
	"coreteam@netfilter.org" <coreteam@netfilter.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org
Subject: Re: [PATCH net-next] netfilter: conntrack: Reduce cond_resched frequency in gc_worker
Date: Wed, 15 Oct 2025 13:06:01 +0200	[thread overview]
Message-ID: <aO-ADi4UJhOFz4zr@strlen.de> (raw)
In-Reply-To: <13de94827815469193e10d6fb0c0d45b@baidu.com>

Li,Rongqing <lirongqing@baidu.com> wrote:

[ CC scheduler experts & drop netfilter maintainers ]

Context: proposed patch
(https://patchwork.ozlabs.org/project/netfilter-devel/patch/20251014115103.2678-1-lirongqing@baidu.com/)
does:

-		cond_resched();
+		if (jiffies - resched_time > msecs_to_jiffies(1)) {
+			cond_resched();
+			resched_time = jiffies;
+		}

... and my knee-jerk reaction was "reject".

But author pointed me at:
commit 271557de7cbfdecb08e89ae1ca74647ceb57224f
xfs: reduce the rate of cond_resched calls inside scrub

So:

Is calling cond_resched() unconditionally while walking hashtable/tree etc.
really discouraged?  I see a truckload of cond_resched() calls in similar
walkers all over networking. I find it hard to believe that conntrack is
somehow special and should call it only once per ms.

If cond_resched() is really so expensive even just for *checking*
(retval 0), then maybe we should only call it for every n-th hash slot?
(every L1_CACHE_BYTES?).

But even in that case it would be good to have a comment or documentation
entry about recommended usage, or better yet, make a variant of
xchk_maybe_relax() available via sched.h...

  reply	other threads:[~2025-10-15 11:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-14 11:51 [PATCH net-next] netfilter: conntrack: Reduce cond_resched frequency in gc_worker lirongqing
2025-10-14 13:06 ` Florian Westphal
2025-10-15  1:56   ` [????] " Li,Rongqing
2025-10-15 11:06     ` Florian Westphal [this message]
2025-10-15 11:49       ` Peter Zijlstra

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=aO-ADi4UJhOFz4zr@strlen.de \
    --to=fw@strlen.de \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=juri.lelli@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lirongqing@baidu.com \
    --cc=mingo@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=peterz@infradead.org \
    --cc=vincent.guittot@linaro.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).