2015-05-26 20:45:07

by Tony Luck

[permalink] [raw]
Subject: Re: [PATCH 06/16] ia64: fix up obsolete cpu function usage.

On Mon, Mar 2, 2015 at 3:35 AM, Rusty Russell <[email protected]> wrote:
> Thanks to spatch, then a sweep for for_each_cpu_mask => for_each_cpu.
>
> Signed-off-by: Rusty Russell <[email protected]>

I'm seeing a bunch of warnings building the ia64 tree:

arch/ia64/kernel/smpboot.c:437: warning: passing argument 2 of
'cpumask_set_cpu' discards qualifiers from pointer target type
arch/ia64/kernel/smpboot.c:478: warning: passing argument 2 of
'cpumask_test_cpu' discards qualifiers from pointer target type
arch/ia64/kernel/smpboot.c:484: warning: passing argument 2 of
'cpumask_test_cpu' discards qualifiers from pointer target type
arch/ia64/kernel/smpboot.c:544: warning: passing argument 2 of
'cpumask_set_cpu' discards qualifiers from pointer target type
arch/ia64/kernel/smpboot.c:568: warning: passing argument 2 of
'cpumask_set_cpu' discards qualifiers from pointer target type
arch/ia64/kernel/smpboot.c:676: warning: passing argument 2 of
'cpumask_clear_cpu' discards qualifiers from pointer target type
arch/ia64/kernel/smpboot.c:747: warning: passing argument 2 of
'cpumask_test_cpu' discards qualifiers from pointer target type

which track back to these lines from this commit:

$ git show 5d2068da8d339e4dff8f9b9a1246e6a79e2949d8 | grep cpu_callin_map
- cpu_set(cpuid, cpu_callin_map);
+ cpumask_set_cpu(cpuid, &cpu_callin_map);
- if (cpu_isset(cpu, cpu_callin_map))
+ if (cpumask_test_cpu(cpu, &cpu_callin_map))
- if (!cpu_isset(cpu, cpu_callin_map)) {
+ if (!cpumask_test_cpu(cpu, &cpu_callin_map)) {
- cpu_set(0, cpu_callin_map);
+ cpumask_set_cpu(0, &cpu_callin_map);
- cpu_set(smp_processor_id(), cpu_callin_map);
+ cpumask_set_cpu(smp_processor_id(), &cpu_callin_map);
- cpu_clear(cpu, cpu_callin_map);
+ cpumask_clear_cpu(cpu, &cpu_callin_map);
- if (cpu_isset(cpu, cpu_callin_map))
+ if (cpumask_test_cpu(cpu, &cpu_callin_map))

The problem being that cpu_callin_map is declared volatile,
which matched the arg type in the declarations for
cpu_set() and cpu_clear() ... but doesn't match the new
fangled cpumask_set_cpu() etc.

Now the new functions do go on to call set_bit()
etc. ... which *do* expect a volatile second argument.

Should cpumask_set_cpu() and friends specify a volatile argument???

-Tony


2015-05-27 01:20:10

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH 06/16] ia64: fix up obsolete cpu function usage.

Tony Luck <[email protected]> writes:
> On Mon, Mar 2, 2015 at 3:35 AM, Rusty Russell <[email protected]> wrote:
>> Thanks to spatch, then a sweep for for_each_cpu_mask => for_each_cpu.
>>
>> Signed-off-by: Rusty Russell <[email protected]>
>
> I'm seeing a bunch of warnings building the ia64 tree:

Indeed, here's the forgotten fix sitting in my patch collection.

> Should cpumask_set_cpu() and friends specify a volatile argument???

It's weird, but it turns out hardly anyone wants that.

Cheers,
Rusty.

ia64: make cpu_callin_map non-volatile.

cpumask_test_cpu() doesn't take volatile, unlike the obsoleted
cpu_isset. The only place ia64 really cares is the spin waiting for a
bit; udelay() is probably a barrier but insert rmb() to be sure.

Signed-off-by: Rusty Russell <[email protected]>

diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index 15051e9c2c6f..629975b56608 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -127,7 +127,7 @@ int smp_num_siblings = 1;
volatile int ia64_cpu_to_sapicid[NR_CPUS];
EXPORT_SYMBOL(ia64_cpu_to_sapicid);

-static volatile cpumask_t cpu_callin_map;
+static cpumask_t cpu_callin_map;

struct smp_boot_data smp_boot_data __initdata;

@@ -477,6 +477,7 @@ do_boot_cpu (int sapicid, int cpu, struct task_struct *idle)
for (timeout = 0; timeout < 100000; timeout++) {
if (cpumask_test_cpu(cpu, &cpu_callin_map))
break; /* It has booted */
+ rmb(); /* Make sure we re-read cpu_callin_map */
udelay(100);
}
Dprintk("\n");