From: Tejun Heo <tj@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: jiangshanlai@gmail.com, torvalds@linux-foundation.org,
linux-kernel@vger.kernel.org, kernel-team@meta.com,
Hillf Danton <hdanton@sina.com>
Subject: Re: [PATCH 4/6] workqueue: Automatically mark CPU-hogging work items CPU_INTENSIVE
Date: Wed, 10 May 2023 06:08:20 -1000 [thread overview]
Message-ID: <ZFvBdB9C7t8ao1PU@slm.duckdns.org> (raw)
In-Reply-To: <20230510150946.GO4253@hirez.programming.kicks-ass.net>
Hello, Peter.
On Wed, May 10, 2023 at 05:09:46PM +0200, Peter Zijlstra wrote:
> > @@ -2348,6 +2382,7 @@ __acquires(&pool->lock)
> > worker->current_work = work;
> > worker->current_func = work->func;
> > worker->current_pwq = pwq;
> > + worker->current_at = worker->task->se.sum_exec_runtime;
>
> That only gets updated at scheduling events, it's not a 'running' clock.
I think it gets updated on each tick and preemption checks, right? That
should be more than enough here. Just using jiffies should be fine on higher
HZ machines; however, when the threshold is not significantly longer than
HZ, it becomes a bit problematic. Reading highres clock separately is an
option but is a little bit more expensive. So, sum_exec_runtime seems to fit
pretty well. FWIW, it's already used outside scheduler proper too.
> > work_data = *work_data_bits(work);
> > worker->current_color = get_work_color(work_data);
> >
>
> Anyway, it occurs to me that if all you want is to measure long running
> works, then would it not be much easier to simply forward the tick?
Ah, that reminds me that I forgot to update the origin timestamp on
sleeping. It should be tracking the continuous CPU consumption between
sleeps.
> Something like the below.. Then this tick handler (which will have just
> updated ->sum_exec_runtime BTW) can do that above 'work-be-long-running'
> check.
>
> Or am I missing something? Seems simpler than hijacking preempt-out.
One advantage of doing it from preempt-out is that workqueue can immediately
release other per-cpu work items without any delay as when the violating
work item leaves CPU is the exact point for both detection and action.
That said, this mechanism doesn't have to super accurate, so simpler code
has its benefits. I'll take a stab at it.
Thanks.
--
tejun
next prev parent reply other threads:[~2023-05-10 16:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 3:07 [PATCHSET v2 wq/for-6.5] workqueue: Implement automatic CPU intensive detection and add monitoring Tejun Heo
2023-05-10 3:07 ` [PATCH 1/6] workqueue, sched: Notify workqueue of scheduling of RUNNING and preempted tasks Tejun Heo
2023-05-10 3:07 ` [PATCH 2/6] workqueue: Re-order struct worker fields Tejun Heo
2023-05-10 3:07 ` [PATCH 3/6] workqueue: Move worker_set/clr_flags() upwards Tejun Heo
2023-05-10 14:30 ` Linus Torvalds
2023-05-10 18:18 ` Tejun Heo
2023-05-10 3:07 ` [PATCH 4/6] workqueue: Automatically mark CPU-hogging work items CPU_INTENSIVE Tejun Heo
2023-05-10 15:09 ` Peter Zijlstra
2023-05-10 16:08 ` Tejun Heo [this message]
2023-05-10 3:07 ` [PATCH 5/6] workqueue: Report work funcs that trigger automatic CPU_INTENSIVE mechanism Tejun Heo
2023-05-10 3:07 ` [PATCH 6/6] workqueue: Add pwq->stats[] and a monitoring script Tejun Heo
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=ZFvBdB9C7t8ao1PU@slm.duckdns.org \
--to=tj@kernel.org \
--cc=hdanton@sina.com \
--cc=jiangshanlai@gmail.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®