Re: [PATCH 01/10] x86: Add topology_max_smt_threads()

From: Thomas Gleixner
Date: Fri May 06 2016 - 06:49:21 EST


On Fri, 6 May 2016, Peter Zijlstra wrote:
> On Thu, May 05, 2016 at 04:03:58PM -0700, Andi Kleen wrote:
> >
> > extern unsigned int __max_logical_packages;
> > #define topology_max_packages() (__max_logical_packages)
> > +
> > +extern int max_smt_threads;

Please follow the above convention and prepend it with underscores. That way
it's clear that the variable should not be touched outside of the core which
initializes it.

> > +#define topology_max_smt_threads() max_smt_threads
> > +

> > static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip)
> > {
> > unsigned long flags;
> > @@ -489,6 +492,7 @@ void set_cpu_sibling_map(int cpu)
> > struct cpuinfo_x86 *c = &cpu_data(cpu);
> > struct cpuinfo_x86 *o;
> > int i;
> > + int threads;

int i, threads;

Please

> >
> > cpumask_set_cpu(cpu, cpu_sibling_setup_mask);
> >
> > @@ -545,6 +549,10 @@ void set_cpu_sibling_map(int cpu)
> > if (match_die(c, o) && !topology_same_node(c, o))
> > primarily_use_numa_for_topology();
> > }
> > +
> > + threads = cpumask_weight(topology_sibling_cpumask(cpu));
> > + if (threads > max_smt_threads)
> > + max_smt_threads = threads;
> > }
> >
> > /* maps the cpu to the sched domain representing multi-core */
> > @@ -1436,6 +1444,21 @@ __init void prefill_possible_map(void)
> >
> > #ifdef CONFIG_HOTPLUG_CPU
> >
> > +/* Recompute SMT state for all CPUs on offline */
> > +static void recompute_smt_state(void)
> > +{
> > + int max_threads;
> > + int cpu;

Ditto

> > +
> > + max_threads = 0;
> > + for_each_online_cpu (cpu) {
> > + int threads = cpumask_weight(topology_sibling_cpumask(cpu));

Missing newline.

Otherwise that looks good.

Thanks,

tglx