From: Peter Zijlstra <peterz@infradead.org>
To: Florian Westphal <fw@strlen.de>
Cc: "Li,Rongqing" <lirongqing@baidu.com>,
"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, juri.lelli@redhat.com,
vincent.guittot@linaro.org, Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH net-next] netfilter: conntrack: Reduce cond_resched frequency in gc_worker
Date: Wed, 15 Oct 2025 13:49:56 +0200 [thread overview]
Message-ID: <20251015114956.GC3419281@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <aO-ADi4UJhOFz4zr@strlen.de>
On Wed, Oct 15, 2025 at 01:06:01PM +0200, Florian Westphal wrote:
> 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...
The plan is to remove cond_resched() and friends entirely and have
PREEMPT_LAZY fully replace PREEMPT_VOLUNTARY.
But I don't think we currently have anybody actively working on this.
Ideally distros should be switching to LAZY and report performance vs
VOLUNTARY such that we can try and address things.
Perhaps the thing to do is to just disable VOLUNTARY and see what
happens :-)
prev parent reply other threads:[~2025-10-15 11:50 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
2025-10-15 11:49 ` Peter Zijlstra [this message]
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=20251015114956.GC3419281@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--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=tglx@linutronix.de \
--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