All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	aherrmann@suse.com, jencce.kernel@gmail.com,
	Rui Huang <ray.huang@amd.com>
Subject: Re: [PATCH 2/3] x86/topology: Fix AMD core count
Date: Sun, 20 Mar 2016 14:09:26 +0100	[thread overview]
Message-ID: <20160320130925.GC4230@pd.tnic> (raw)
In-Reply-To: <20160320124629.GY6375@twins.programming.kicks-ass.net>

On Sun, Mar 20, 2016 at 01:46:29PM +0100, Peter Zijlstra wrote:
> On Sun, Mar 20, 2016 at 01:32:25PM +0100, Peter Zijlstra wrote:
> > Yes, but IIRC the F15h driver doesn't use the NB constraints, as they
> > moved all the NB events to their own set of MSRs, which has
> > events/amd/uncore.c.
> > 
> > So all the NB cruft in the core pmu is only relevant to F10h.
> > 
> > So F15h also calling and allocating NB cruft in the core PMU driver is
> > entirely pointless.
> 
> Something like so.

Perhaps. Some minor notes below.

First a question about the big picture: why is amd/core.c even
dealing with NB counters? Especially if NB has its own initcall
amd_uncore_init()?

IOW, what I'm trying to say is, can we untangle uncore.c from core.c or
is there some dependency in the modelling I'm not aware of... which is
very likely, btw.

> ---
>  arch/x86/events/amd/core.c   | 21 ++++++++++++++++++---
>  arch/x86/events/perf_event.h |  5 +++++
>  2 files changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
> index 049ada8d4e9c..62026a79a930 100644
> --- a/arch/x86/events/amd/core.c
> +++ b/arch/x86/events/amd/core.c
> @@ -369,7 +369,7 @@ static int amd_pmu_cpu_prepare(int cpu)
>  
>  	WARN_ON_ONCE(cpuc->amd_nb);
>  
> -	if (boot_cpu_data.x86_max_cores < 2)
> +	if (!x86_pmu.amd_nb)

Yeah, except there's cpuc->amd_nb and now pmu->amd_nb. Can we
differentiate a bit more with the naming?

>  		return NOTIFY_OK;
>  
>  	cpuc->amd_nb = amd_alloc_nb(cpu);
> @@ -388,7 +388,7 @@ static void amd_pmu_cpu_starting(int cpu)
>  
>  	cpuc->perf_ctr_virt_mask = AMD64_EVENTSEL_HOSTONLY;
>  
> -	if (boot_cpu_data.x86_max_cores < 2)
> +	if (!x86_pmu.amd_nb)
>  		return;
>  
>  	nb_id = amd_get_nb_id(cpu);
> @@ -414,7 +414,7 @@ static void amd_pmu_cpu_dead(int cpu)
>  {
>  	struct cpu_hw_events *cpuhw;
>  
> -	if (boot_cpu_data.x86_max_cores < 2)
> +	if (!x86_pmu.amd_nb)
>  		return;
>  
>  	cpuhw = &per_cpu(cpu_hw_events, cpu);
> @@ -648,6 +648,8 @@ static __initconst const struct x86_pmu amd_pmu = {
>  	.cpu_prepare		= amd_pmu_cpu_prepare,
>  	.cpu_starting		= amd_pmu_cpu_starting,
>  	.cpu_dead		= amd_pmu_cpu_dead,
> +
> +	.amd_nb			= 1;

s/;/,/

>  };
>  
>  static int __init amd_core_pmu_init(void)
> @@ -674,6 +676,11 @@ static int __init amd_core_pmu_init(void)
>  	x86_pmu.eventsel	= MSR_F15H_PERF_CTL;
>  	x86_pmu.perfctr		= MSR_F15H_PERF_CTR;
>  	x86_pmu.num_counters	= AMD64_NUM_COUNTERS_CORE;
> +	/*
> +	 * AMD Core perfctr has separate MSRs for the NB events, see
> +	 * the amd/uncore.c driver.
> +	 */
> +	x86_pmu.amd_nb		= 0;
>  
>  	pr_cont("core perfctr, ");
>  	return 0;
> @@ -693,6 +700,14 @@ __init int amd_pmu_init(void)
>  	if (ret)
>  		return ret;
>  
> +	if (num_possible_cpus() == 1) {
> +		/*
> +		 * No point in allocating data structures to serialize
> +		 * against other CPUs, when there is only the one CPU.
> +		 */
> +		x86_pmu.amd_nb = 0;
> +	}
> +
>  	/* Events are common for all AMDs */
>  	memcpy(hw_cache_event_ids, amd_hw_cache_event_ids,
>  	       sizeof(hw_cache_event_ids));
> diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
> index ba6ef18528c9..46d2ece10a7b 100644
> --- a/arch/x86/events/perf_event.h
> +++ b/arch/x86/events/perf_event.h
> @@ -608,6 +608,11 @@ struct x86_pmu {
>  	atomic_t	lbr_exclusive[x86_lbr_exclusive_max];
>  
>  	/*
> +	 * AMD bits
> +	 */
> +	unsigned int	amd_nb	: 1;
> +
> +	/*
>  	 * Extra registers for events
>  	 */
>  	struct extra_reg *extra_regs;
> 

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

  reply	other threads:[~2016-03-20 13:09 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-18 15:03 [PATCH 0/3] x86 topology fixes Peter Zijlstra
2016-03-18 15:03 ` [PATCH 1/3] x86/topology: Fix logical pkg mapping Peter Zijlstra
2016-03-19  9:30   ` [tip:x86/urgent] x86/topology: Fix logical package mapping tip-bot for Peter Zijlstra
2016-03-18 15:03 ` [PATCH 2/3] x86/topology: Fix AMD core count Peter Zijlstra
2016-03-18 16:41   ` Borislav Petkov
2016-03-21  3:07     ` Huang Rui
2016-03-21  3:46       ` Huang Rui
2016-03-21  8:26         ` Borislav Petkov
2016-03-21  9:18           ` Huang Rui
2016-03-21  8:56         ` Thomas Gleixner
2016-03-21  8:21       ` Peter Zijlstra
2016-03-21  9:46         ` Huang Rui
2016-03-21 13:57           ` Borislav Petkov
2016-03-22  8:10             ` Sherry Hurwitz
2016-03-22 11:22               ` Borislav Petkov
2016-03-21  8:23       ` Borislav Petkov
2016-03-21 10:05         ` Huang Rui
2016-03-21 10:23           ` Borislav Petkov
2016-03-19  9:24   ` Thomas Gleixner
2016-03-19 15:56     ` Borislav Petkov
2016-03-20 10:39     ` Peter Zijlstra
2016-03-20 11:04       ` Borislav Petkov
2016-03-20 12:32         ` Peter Zijlstra
2016-03-20 12:46           ` Peter Zijlstra
2016-03-20 13:09             ` Borislav Petkov [this message]
2016-03-20 17:08               ` Peter Zijlstra
2016-03-20 18:46                 ` Borislav Petkov
2016-03-29  8:49             ` [tip:x86/urgent] perf/x86/amd: Cleanup Fam10h NB event constraints tip-bot for Peter Zijlstra
2016-03-22  7:56   ` [PATCH 2/3] x86/topology: Fix AMD core count Huang Rui
2016-03-18 15:03 ` [PATCH 3/3] x86/topology: Fix Intel HT disable Peter Zijlstra
2016-03-19  9:31   ` [tip:x86/urgent] " tip-bot for Peter Zijlstra
  -- strict thread matches above, loose matches on Subject: below --
2016-03-16  6:48 4.5.0+ panic when setup loop device Xiong Zhou
2016-03-16 15:26 ` Thomas Gleixner
2016-03-17  1:56   ` Xiong Zhou
2016-03-17  9:52     ` Peter Zijlstra
2016-03-17  9:56       ` Peter Zijlstra
2016-03-17 10:21       ` Thomas Gleixner
2016-03-17 10:26         ` Peter Zijlstra
2016-03-17 11:39           ` Thomas Gleixner
2016-03-17 11:51             ` Peter Zijlstra
2016-03-17 11:57               ` Borislav Petkov
2016-03-17 12:01               ` Thomas Gleixner
2016-03-17 16:42                 ` Jens Axboe
2016-03-17 18:26                   ` Jens Axboe
2016-03-17 20:20                     ` Thomas Gleixner
2016-03-17 20:23                       ` Jens Axboe
2016-03-17 20:30                         ` Thomas Gleixner
2016-03-17 20:41                           ` Jens Axboe
2016-03-18  2:31             ` Xiong Zhou
2016-03-18  4:11       ` Mike Galbraith
2016-03-18  7:51         ` Peter Zijlstra
2016-03-18 10:15         ` Peter Zijlstra
2016-03-18 12:39           ` Mike Galbraith
2016-03-18 13:32             ` Peter Zijlstra
2016-03-18 14:07               ` Mike Galbraith
2016-03-18 11:55         ` Thomas Gleixner
2016-03-18 12:39           ` Mike Galbraith
2016-03-19  9:31           ` [tip:x86/urgent] x86/topology: Use total_cpus not nr_cpu_ids for logical packages tip-bot for Thomas Gleixner
2016-03-29  8:48       ` [tip:x86/urgent] x86/topology: Fix AMD core count tip-bot for Peter Zijlstra

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=20160320130925.GC4230@pd.tnic \
    --to=bp@alien8.de \
    --cc=aherrmann@suse.com \
    --cc=jencce.kernel@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=ray.huang@amd.com \
    --cc=tglx@linutronix.de \
    /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.