From: "Guo, Wangyang" <wangyang.guo@intel.com>
To: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org,
Benjamin Lei <benjamin.lei@intel.com>,
Tim Chen <tim.c.chen@linux.intel.com>,
Tianyou Li <tianyou.li@intel.com>, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>
Subject: Re: [PATCH] sched/fair: Avoid false sharing in nohz struct
Date: Tue, 23 Dec 2025 16:03:23 +0800 [thread overview]
Message-ID: <8445130b-7672-45a7-9c9e-512aa6029a56@intel.com> (raw)
In-Reply-To: <917c1771-5249-4c10-9ecf-699cdd323cd9@linux.ibm.com>
On 12/23/2025 3:27 PM, Shrikanth Hegde wrote:
>>>
>>> Likely in your case, nr_cpus updates are the costly ones.
>>> Try below and see if it helps to fix your issue too.
>>> https://lore.kernel.org/all/20251201183146.74443-1-
>>> sshegde@linux.ibm.com/
>>> I Should send out new version soon.
>>>
>>>> 2. Data followed by nohz still share the same cacheline and has
>>>> potential false sharing issue.
>>>>
>>>
>>> How does your patch handle this?
>>> I don't see any other struct apart from nohz being changed.
>>
>> The data follow by nohz is implicit and determined by compiler.
>> For example, this is the layout from /proc/kallsyms in my machine:
>> ffffffff88600d40 b nohz
>> ffffffff88600d68 B arch_needs_tick_broadcast
>> ffffffff88600d6c b __key.264
>> ffffffff88600d6c b __key.265
>> ffffffff88600d70 b dl_generation
>> ffffffff88600d78 b sched_clock_irqtime
>>
>> What we can do is placing read-mostly `idle_cpus_mask` pointer in a
>> new cacheline, so data followed by nohz would not be affected by nr_cpus.
>>
>
> That's a concern. If it is compiler dependent, then sometime it helps,
> sometime it wont.
This patch wants to make it compiler independent. Sometimes it maybe
sched_clock_irqtime, sometimes, it maybe baba_vars. Changing on nohz
makes sure it would not affect others, no matter whatever data followed.
> It should done other way around rather than changing the nohz.
> If there is structure which has a lot of read/updates, it should go into
> its
> own cacheline rather.
>
> i.e in your case sched_clock_irqtime should go into its own cacheline.
If that is preferred in kernel, I can resubmit the patch which only
requires alignment on sched_clock_irqtime.
> ---
> diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
> index 4f97896887ec..29f9438f9f03 100644
> --- a/kernel/sched/cputime.c
> +++ b/kernel/sched/cputime.c
> @@ -25,7 +25,7 @@
> */
> DEFINE_PER_CPU(struct irqtime, cpu_irqtime);
>
> -int sched_clock_irqtime;
> +int sched_clock_irqtime __cacheline_aligned;
>
> void enable_sched_clock_irqtime(void)
> {
>
>
BR
Wangyang
next prev parent reply other threads:[~2025-12-23 8:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 5:56 Wangyang Guo
2025-12-21 13:05 ` Shrikanth Hegde
2025-12-22 2:21 ` Guo, Wangyang
2025-12-23 7:27 ` Shrikanth Hegde
2025-12-23 8:03 ` Guo, Wangyang [this message]
2025-12-19 1:38 Shubhang Kaushik Prasanna Kumar
2025-12-19 13:56 ` Guo, Wangyang
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=8445130b-7672-45a7-9c9e-512aa6029a56@intel.com \
--to=wangyang.guo@intel.com \
--cc=benjamin.lei@intel.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sshegde@linux.ibm.com \
--cc=tianyou.li@intel.com \
--cc=tim.c.chen@linux.intel.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/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®