From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932104AbcELIHj (ORCPT ); Thu, 12 May 2016 04:07:39 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33831 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932079AbcELIH3 (ORCPT ); Thu, 12 May 2016 04:07:29 -0400 Date: Thu, 12 May 2016 10:07:24 +0200 From: Ingo Molnar To: Andi Kleen Cc: Thomas Gleixner , Peter Zijlstra , acme@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen , x86@kernel.org Subject: Re: [UPDATED PATCH 01/10] x86: Add topology_max_smt_threads() Message-ID: <20160512080724.GB20497@gmail.com> References: <1462489447-31832-1-git-send-email-andi@firstfloor.org> <1462489447-31832-2-git-send-email-andi@firstfloor.org> <20160506101318.GV3430@twins.programming.kicks-ass.net> <20160506172426.GW13997@two.firstfloor.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160506172426.GW13997@two.firstfloor.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Andi Kleen wrote: > For SMT specific workarounds it is useful to know if SMT is active > on any online CPU in the system. This currently requires a loop > over all online CPUs. > > Add a global variable that is updated with the maximum number > of smt threads on any CPU on online/offline, and use it for > topology_max_smt_threads() > > The single call is easier to use than a loop. > > Not exported to user space because user space already can use > the existing sibling interfaces to find this out. > > v2: Code formatting changes and use __ for variable name > Cc: tglx@linutronix.de > Signed-off-by: Andi Kleen > > diff --git a/arch/x86/include/asm/topology.h b/arch/x86/include/asm/topology.h > index 7f991bd5031b..f79181c03561 100644 > --- a/arch/x86/include/asm/topology.h > +++ b/arch/x86/include/asm/topology.h > @@ -129,6 +129,10 @@ extern const struct cpumask *cpu_coregroup_mask(int cpu); > > extern unsigned int __max_logical_packages; > #define topology_max_packages() (__max_logical_packages) > + > +extern int __max_smt_threads; > +#define topology_max_smt_threads() __max_smt_threads > + > int topology_update_package_map(unsigned int apicid, unsigned int cpu); > extern int topology_phys_to_logical_pkg(unsigned int pkg); > #else > @@ -136,6 +140,7 @@ extern int topology_phys_to_logical_pkg(unsigned int pkg); > static inline int > topology_update_package_map(unsigned int apicid, unsigned int cpu) { return 0; } > static inline int topology_phys_to_logical_pkg(unsigned int pkg) { return 0; } > +#define topology_max_smt_threads() 1 Is there a good reason why this is a CPP macro instead of an inline function like the code above it uses? > +/* Recompute SMT state for all CPUs on offline */ s/when a CPU gets offlined/ Thanks, Ingo