RE: [????] Re: [PATCH net-next] netfilter: conntrack: Reduce cond_resched frequency in gc_worker
From: Li,Rongqing
Date: Tue Oct 14 2025 - 21:57:19 EST
> > The current implementation calls cond_resched() in every iteration of
> > the garbage collection loop. This creates some overhead when
> > processing large conntrack tables with billions of entries, as each
> > cond_resched() invocation involves scheduler operations.
> >
> > To reduce this overhead, implement a time-based throttling mechanism
> > that calls cond_resched() at most once per millisecond. This maintains
> > system responsiveness while minimizing scheduler contention.
> >
> > gc_worker() with hashsize=10000 shows measurable improvement:
> >
> > Before: 7114.274us
> > After: 5993.518us (15.8% reduction)
>
> I dislike this, I have never seen this pattern.
>
This patch is similar as
commit 271557de7cbfdecb08e89ae1ca74647ceb57224f
xfs: reduce the rate of cond_resched calls inside scrub
> Whole point of cond_resched() is to let scheduler decide.
>
> Maybe it would be better to move gc_worker off to its own work queue
> (create_workqueue()) instead of reusing system wq so one can tune the
> priority instead?
I am fine to move gc_worker to its own work queue
Thanks
-Li