RE: [PATCH v4 6/7] x86/vdso: Introduce CPU number helper functions

From: Bae, Chang Seok
Date: Fri Jun 22 2018 - 14:46:39 EST


On Friday, 22 Jun 2018, Thomas Gleixner wrote:
> On Wed, 20 Jun 2018, Chang S. Bae wrote:
> > CPU number initialization in vDSO is now a bit cleaned up by
> > the new helper functions. The helper functions will take
> > care of combing CPU and node number and reading each from

> s/combing/combining/ please

Will fix.

> > @@ -18,9 +18,9 @@ __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
> > p = __getcpu();

> While we are touching this, can we please as a first step change __getcpu()
> to something else? I've tripped over this several times in the past and
> confused it with a (nonexisting) variant of get_cpu().

How about __vdso_get_cpudata()?

> > #ifdef CONFIG_NUMA
> > node = cpu_to_node(cpu);
> > #endif

> While at it please get rid of the ifdeffery. If CONFIG_NUMA=n then
> cpu_to_node(cpu) resolves to (0).

Okay, will fix this.


> >
> > if (cpu)
> > - *cpu = p & VGETCPU_CPU_MASK;
> > + *cpu = lsl_tscp_to_cpu(p);
> >
> > if (node)
> > - *node = p >> 12;
> > + *node = lsl_tscp_to_node(p);
>
> Are these new helpers going to be used at some other place than this? If
> not, then there is really no point at all. Then just go and make this:
>
> __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
> {
> vdso_read_cpu_and_node(cpu, node);
> return 0;
> }

> > @@ -340,19 +340,19 @@ static void vgetcpu_cpu_init(void *arg)
> > int cpu = smp_processor_id();
> > struct desc_struct d = { };
> > unsigned long node = 0;
> > + unsigned long cpu_number = 0;
>
> That's hardly a CPU number. It's encoded CPU and node information.
>
> > + cpu_number = make_lsl_tscp(cpu, node);
>
> So the whole thing can be reduced to:
>
> u64 cpudata = vdso_encode_cpu_and_node(cpu, cpu_to_node(cpu));
>
> Or some other sensible function name.

Now, for these helper function renaming, I would like to check it from Andy.

Thanks,
Chang