Re: [PATCH 5/7] workqueue: Automatically mark CPU-hogging work items CPU_INTENSIVE

From: Tejun Heo
Date: Thu May 11 2023 - 18:48:25 EST


On Thu, May 11, 2023 at 11:23:58PM +0200, Peter Zijlstra wrote:
> > * Even when detection is working, the 10ms detection delays can add up if
> > many CPU-hogging work items are queued at the same time.
> HZ=100 assumption there :-) My HZs are bigger 'n yours etc.

Oh, I was referring to the default threshold, but yeah, lower HZ can
definitely be a factor.

> > However, in vast majority of cases, this should be able to detect violations
> > reliably and provide reasonable protection with a small increase in code
> > complexity.
> >
> > If some work items trigger this condition repeatedly, the bigger problem
> > likely is the CPU being saturated with such per-cpu work items and the
> > solution would be making them UNBOUND. The next patch will add a debug
> > mechanism to help spot such cases.
> >
> > v3: Switch to use wq_worker_tick() instead of hooking into preemptions as
> > suggested by Peter.
> >
> > v2: Lai pointed out that wq_worker_stopping() also needs to be called from
> > preemption and rtlock paths and an earlier patch was updated
> > accordingly. This patch adds a comment describing the risk of infinte
> > recursions and how they're avoided.
> I tend to prefer these changelog-changelogs to go below the --- so that
> they go away on applying, they're not really relevant when reading the
> patch in a year's time when trying to figure out wtf this patch did.

I tried that and promptly lost the version logs while iterating / posting
cuz that involved going through git commits. But yeah, the above version
logs aren't useful. I'll drop them when applying.

> Anyway, this seems entirely reasonable.
> Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>