From: Peter Zijlstra <peterz@infradead.org>
To: Kuba Piecuch <jpiecuch@google.com>
Cc: mingo@redhat.com, vincent.guittot@linaro.org,
dietmar.eggemann@arm.com, joshdon@google.com,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 0/3] sched: add ability to throttle sched_yield() calls to reduce contention
Date: Mon, 11 Aug 2025 10:36:09 +0200 [thread overview]
Message-ID: <20250811083609.GB1613200@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20250808200250.2016584-1-jpiecuch@google.com>
On Fri, Aug 08, 2025 at 08:02:47PM +0000, Kuba Piecuch wrote:
> Problem statement
> =================
>
> Calls to sched_yield() can touch data shared with other threads.
> Because of this, userspace threads could generate high levels of contention
> by calling sched_yield() in a tight loop from multiple cores.
>
> For example, if cputimer is enabled for a process (e.g. through
> setitimer(ITIMER_PROF, ...)), all threads of that process
> will do an atomic add on the per-process field
> p->signal->cputimer->cputime_atomic.sum_exec_runtime inside
> account_group_exec_runtime(), which is called inside update_curr().
>
> Currently, calling sched_yield() will always call update_curr() at least
> once in schedule(), and potentially one more time in yield_task_fair().
> Thus, userspace threads can generate quite a lot of contention for the
> cacheline containing cputime_atomic.sum_exec_runtime if multiple threads of
> a process call sched_yield() in a tight loop.
>
> At Google, we suspect that this contention led to a full machine lockup in
> at least one instance, with ~50% of CPU cycles spent in the atomic add
> inside account_group_exec_runtime() according to
> `perf record -a -e cycles`.
I've gotta ask, WTH is your userspace calling yield() so much?
next prev parent reply other threads:[~2025-08-11 8:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-08 20:02 Kuba Piecuch
2025-08-08 20:02 ` [RFC PATCH 1/3] sched: add bool return value to sched_class::yield_task() Kuba Piecuch
2025-08-08 20:02 ` [RFC PATCH 2/3] sched/fair: don't schedule() in yield if nr_running == 1 Kuba Piecuch
2025-08-08 20:02 ` [RFC PATCH 3/3] sched/fair: add debugfs knob for yield throttling Kuba Piecuch
2025-08-11 8:36 ` Peter Zijlstra [this message]
2025-08-11 13:35 ` [RFC PATCH 0/3] sched: add ability to throttle sched_yield() calls to reduce contention Kuba Piecuch
2025-08-14 14:53 ` Peter Zijlstra
2025-08-17 14:29 ` David Laight
2025-08-19 14:08 ` Kuba Piecuch
2025-08-20 15:49 ` Kuba Piecuch
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=20250811083609.GB1613200@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=dietmar.eggemann@arm.com \
--cc=joshdon@google.com \
--cc=jpiecuch@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--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
all inboxes | Powered by JetHome®