The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Lin Ming <ming.m.lin@intel.com>
To: Stephane Eranian <eranian@google.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	"mingo@elte.hu" <mingo@elte.hu>,
	Peter Zijlstra <peterz@infradead.org>,
	"Kleen, Andi" <andi.kleen@intel.com>
Subject: Re: perf_events: questions about cpu_has_ht_siblings() and offcore support
Date: Fri, 22 Apr 2011 21:26:38 +0800	[thread overview]
Message-ID: <1303478798.2461.11.camel@localhost> (raw)
In-Reply-To: <BANLkTinNJERr_=ELO61UbrwCJjW1KAdK2A@mail.gmail.com>

On Fri, 2011-04-22 at 20:59 +0800, Stephane Eranian wrote:
> Lin,
> 
> In arch/x86/include/asm/smp.h, you added:
> 
> static inline bool cpu_has_ht_siblings(void)
> {
>        bool has_siblings = false;
> #ifdef CONFIG_SMP
>        has_siblings = cpu_has_ht && smp_num_siblings > 1;
> #endif
>        return has_siblings;
> }
> 
> I am wondering about the goal of this function.
> 
> Is it supposed to return whether or not HT is enabled?
> 
> Ht enabled != HT supported

It's used to check if HT is supported.

We had some long discussions months ago about how to check if HT is
enabled. http://marc.info/?t=129346430400004&r=1&w=2

But unfortunately, we didn't find a way to check if HT is enabled.
So I just check if HT is supported.

> 
> On my systems (NHM or SNB), its value does not change
> when I enable/disable HT.
> 
> Looking at Intel's AP-485 (CPUID documentation), they
> clearly say that none of the Leaf functions which report
> about HT or the number of logical cores, can be used to
> detect HT enabled or disabled. Seems those leaf functions
> are the basis for smp_num_siblings. The trick in Table-5.5
> for bit 28 with CPUID(1).EBX[23:16] used in detect_ht()
> is about HT supported and not HT enabled.
> 
> HT supported means multi-core or multi-thread supported.
> 
> Going back to the perf_event code, I wonder what is the
> point of using this function in intel_pmu_cpu_prepare(), then.
> 
> I suspect you wanted to know whether or not HT was enabled.
> But that's not going to work. If you want that functionality, then
> I tried:
> 
> +static inline int is_ht_enabled(void)
> +{
> +       bool has_ht = false;
> +#ifdef CONFIG_SMP
> +       int w;
> +       w = cpumask_weight(cpu_sibling_mask(smp_processor_id()));
> +       has_ht = cpu_has_ht && w > 1;
> +#endif
> +       return has_ht;
> +}
> 
> But that cannot be used in the CPU hotplug callback for prepare(),
> it is too early.
> 
> OTOH, you need some validation even in the case HT is off. No two events
> scheduled together on the same PMU can have different values for the extra
> reg. Thus, the fact that cpu_has_ht_siblings() is imune to HT state helps here,
> but then what's the point of it?

The points is to avoid the percore resource allocations(which are used
to sync between HTs) if HT is not supported.

> 
> I am preparing a patch that builds on your patch and improves
> support for those events or features which require an extra
> (shared) register. They are differences between NHM/WSM
> and SNB.



  reply	other threads:[~2011-04-22 13:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-22 12:59 perf_events: questions about cpu_has_ht_siblings() and offcore support Stephane Eranian
2011-04-22 13:26 ` Lin Ming [this message]
2011-04-22 13:46   ` Stephane Eranian
2011-04-22 14:31     ` Lin Ming
2011-04-22 14:41       ` Stephane Eranian
2011-04-22 14:47         ` Peter Zijlstra
2011-04-22 14:48           ` Stephane Eranian
2011-04-22 15:03         ` Lin Ming
2011-04-22 15:05           ` Stephane Eranian
2011-04-22 15:30             ` Lin Ming
2011-04-22 16:21               ` Stephane Eranian
2011-04-22 14:53       ` Stephane Eranian
2011-04-22 20:42     ` Peter Zijlstra
2011-04-22 22:15       ` Stephane Eranian

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=1303478798.2461.11.camel@localhost \
    --to=ming.m.lin@intel.com \
    --cc=andi.kleen@intel.com \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.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