All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mel Gorman <mgorman@suse.com>
To: lkp@lists.01.org
Subject: Re: [x86/mce] 1de08dccd3: will-it-scale.per_process_ops -14.1% regression
Date: Mon, 31 Aug 2020 09:55:17 +0100	[thread overview]
Message-ID: <20200831085516.GE2976@suse.com> (raw)
In-Reply-To: <20200831082306.GA61340@shbuild999.sh.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2412 bytes --]

On Mon, Aug 31, 2020 at 04:23:06PM +0800, Feng Tang wrote:
> On Mon, Aug 31, 2020 at 08:56:11AM +0100, Mel Gorman wrote:
> > On Mon, Aug 31, 2020 at 10:16:38AM +0800, Feng Tang wrote:
> > > > So why don't you define both variables with DEFINE_PER_CPU_ALIGNED and
> > > > check if all your bad measurements go away this way?
> > > 
> > > For 'arch_freq_scale', there are other percpu variables in the same
> > > smpboot.c: 'arch_prev_aperf' and 'arch_prev_mperf', and in hot path
> > > arch_scale_freq_tick(), these 3 variables are all accessed, so I didn't 
> > > touch it. Or maybe we can align the first of these 3 variables, so
> > > that they sit in one cacheline.
> > > 
> > > > You'd also need to check whether there's no detrimental effect from
> > > > this change on other, i.e., !KNL platforms, and I think there won't
> > > > be because both variables will be in separate cachelines then and all
> > > > should be good.
> > > 
> > > Yes, these kind of changes should be verified on other platforms.
> > > 
> > > One thing still puzzles me, that the 2 variables are per-cpu things, and
> > > there is no case of many CPU contending, why the cacheline layout matters?
> > > I doubt it is due to the contention of the same cache set, and am trying
> > > to find some way to test it.
> > > 
> > 
> > Because if you have two structures that are per-cpu and not cache-aligned
> > then a write in one can bounce the cache line in another due to
> > cache coherency protocol. It's generally called "false cache line
> > sharing". https://en.wikipedia.org/wiki/False_sharing has basic examples
> > (lets not get into whether wikipedia is a valid citation source, there
> > are books on the topic if someone really cared).
> 
> For 'arch_freq_scale' and 'tsc_adjust' percpu variable, they are only
> accessed by their own CPU, and usually no other CPU will touch them,

Read "false sharing again". Two adjacent per-CPU structures can still
interfere with each other if the structures happen to cross a cache line
boundary and are not cache aligned.

> the
> hot node path only use this_cpu_read/write/ptr. And each CPU's static
> percpu variables are all packed together in one area (256KB for one CPU on
> this test box),

If the structure is not cache aligned (probably 64KB) then there is a
boundary when cache line bounces can occur.

-- 
Mel Gorman
SUSE Labs

WARNING: multiple messages have this Message-ID (diff)
From: Mel Gorman <mgorman@suse.com>
To: Feng Tang <feng.tang@intel.com>
Cc: Borislav Petkov <bp@suse.de>, "Luck, Tony" <tony.luck@intel.com>,
	kernel test robot <rong.a.chen@intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	lkp@lists.01.org
Subject: Re: [LKP] Re: [x86/mce] 1de08dccd3: will-it-scale.per_process_ops -14.1% regression
Date: Mon, 31 Aug 2020 09:55:17 +0100	[thread overview]
Message-ID: <20200831085516.GE2976@suse.com> (raw)
In-Reply-To: <20200831082306.GA61340@shbuild999.sh.intel.com>

On Mon, Aug 31, 2020 at 04:23:06PM +0800, Feng Tang wrote:
> On Mon, Aug 31, 2020 at 08:56:11AM +0100, Mel Gorman wrote:
> > On Mon, Aug 31, 2020 at 10:16:38AM +0800, Feng Tang wrote:
> > > > So why don't you define both variables with DEFINE_PER_CPU_ALIGNED and
> > > > check if all your bad measurements go away this way?
> > > 
> > > For 'arch_freq_scale', there are other percpu variables in the same
> > > smpboot.c: 'arch_prev_aperf' and 'arch_prev_mperf', and in hot path
> > > arch_scale_freq_tick(), these 3 variables are all accessed, so I didn't 
> > > touch it. Or maybe we can align the first of these 3 variables, so
> > > that they sit in one cacheline.
> > > 
> > > > You'd also need to check whether there's no detrimental effect from
> > > > this change on other, i.e., !KNL platforms, and I think there won't
> > > > be because both variables will be in separate cachelines then and all
> > > > should be good.
> > > 
> > > Yes, these kind of changes should be verified on other platforms.
> > > 
> > > One thing still puzzles me, that the 2 variables are per-cpu things, and
> > > there is no case of many CPU contending, why the cacheline layout matters?
> > > I doubt it is due to the contention of the same cache set, and am trying
> > > to find some way to test it.
> > > 
> > 
> > Because if you have two structures that are per-cpu and not cache-aligned
> > then a write in one can bounce the cache line in another due to
> > cache coherency protocol. It's generally called "false cache line
> > sharing". https://en.wikipedia.org/wiki/False_sharing has basic examples
> > (lets not get into whether wikipedia is a valid citation source, there
> > are books on the topic if someone really cared).
> 
> For 'arch_freq_scale' and 'tsc_adjust' percpu variable, they are only
> accessed by their own CPU, and usually no other CPU will touch them,

Read "false sharing again". Two adjacent per-CPU structures can still
interfere with each other if the structures happen to cross a cache line
boundary and are not cache aligned.

> the
> hot node path only use this_cpu_read/write/ptr. And each CPU's static
> percpu variables are all packed together in one area (256KB for one CPU on
> this test box),

If the structure is not cache aligned (probably 64KB) then there is a
boundary when cache line bounces can occur.

-- 
Mel Gorman
SUSE Labs

  reply	other threads:[~2020-08-31  8:55 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-25 11:44 [x86/mce] 1de08dccd3: will-it-scale.per_process_ops -14.1% regression kernel test robot
2020-04-25 11:44 ` kernel test robot
2020-04-25 13:01 ` Borislav Petkov
2020-04-25 13:01   ` Borislav Petkov
2020-08-18  8:29   ` Feng Tang
2020-08-18  8:29     ` [LKP] " Feng Tang
2020-08-18 20:06     ` Luck, Tony
2020-08-18 20:06       ` [LKP] " Luck, Tony
2020-08-19  2:04       ` Feng Tang
2020-08-19  2:04         ` [LKP] " Feng Tang
2020-08-19  2:23         ` Luck, Tony
2020-08-19  2:23           ` [LKP] " Luck, Tony
2020-08-19  3:04           ` Feng Tang
2020-08-19  3:04             ` [LKP] " Feng Tang
2020-08-19  3:15           ` Feng Tang
2020-08-19  3:15             ` [LKP] " Feng Tang
2020-08-21  2:02         ` Feng Tang
2020-08-21  2:02           ` [LKP] " Feng Tang
2020-08-24 15:14           ` Borislav Petkov
2020-08-24 15:14             ` [LKP] " Borislav Petkov
2020-08-24 15:33             ` Feng Tang
2020-08-24 15:33               ` [LKP] " Feng Tang
2020-08-24 15:38               ` Luck, Tony
2020-08-24 15:38                 ` [LKP] " Luck, Tony
2020-08-24 15:48                 ` Feng Tang
2020-08-24 15:48                   ` [LKP] " Feng Tang
2020-08-24 16:12               ` Borislav Petkov
2020-08-24 16:12                 ` [LKP] " Borislav Petkov
2020-08-24 16:56                 ` Mel Gorman
2020-08-24 16:56                   ` [LKP] " Mel Gorman
2020-08-25  6:49                   ` Feng Tang
2020-08-25  6:49                     ` [LKP] " Feng Tang
2020-08-25  6:23                 ` Feng Tang
2020-08-25  6:23                   ` [LKP] " Feng Tang
2020-08-25 16:44                   ` Luck, Tony
2020-08-25 16:44                     ` [LKP] " Luck, Tony
2020-08-26  1:45                     ` Feng Tang
2020-08-26  1:45                       ` [LKP] " Feng Tang
2020-08-28 17:48                   ` Borislav Petkov
2020-08-28 17:48                     ` [LKP] " Borislav Petkov
2020-08-31  2:16                     ` Feng Tang
2020-08-31  2:16                       ` [LKP] " Feng Tang
2020-08-31  7:56                       ` Mel Gorman
2020-08-31  7:56                         ` [LKP] " Mel Gorman
2020-08-31  8:23                         ` Feng Tang
2020-08-31  8:23                           ` [LKP] " Feng Tang
2020-08-31  8:55                           ` Mel Gorman [this message]
2020-08-31  8:55                             ` Mel Gorman
2020-08-31 12:53                             ` Feng Tang
2020-08-31 12:53                               ` [LKP] " Feng Tang

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=20200831085516.GE2976@suse.com \
    --to=mgorman@suse.com \
    --cc=lkp@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.