Skip to contentSkip to conversation

set_cpus_allowed_ptr

DISCUSSION Peter Zijlstra 2 participants 4 messages Mar 26, 2010

lore
Share & tools
lore
#0 lore raw

Hi,

Would it make sense to clean up the set_cpus_allowed() vs set_cpus_allowed_ptr() mess using the semantic patch tool?

I guess it would be three patches:
1) converting the current remaining set_cpus_allowed() users into

    set_cpus_allowed_ptr().

2) remove set_cpus_allowed().
3) rename set_cpus_allowed_ptr() to set_cpus_allowed()

#1 lore raw
Quoted 10 lines · Peter Zijlstra

Hi,

Would it make sense to clean up the set_cpus_allowed() vs set_cpus_allowed_ptr() mess using the semantic patch tool?

I guess it would be three patches:
1) converting the current remaining set_cpus_allowed() users into

    set_cpus_allowed_ptr().

2) remove set_cpus_allowed().
3) rename set_cpus_allowed_ptr() to set_cpus_allowed()

Perhaps a subtlety is that set_cpus_allowed is creating a new variable, whose address it sends to set_cpus_allowed_ptr?

julia

#2 lore raw
Quoted 7 lines · Julia Lawall
Quoted 5 lines · Peter Zijlstra

Hi,

Would it make sense to clean up the set_cpus_allowed() vs set_cpus_allowed_ptr() mess using the semantic patch tool?

Quoted 8 lines
Quoted 5 lines

I guess it would be three patches:
1) converting the current remaining set_cpus_allowed() users into

    set_cpus_allowed_ptr().

2) remove set_cpus_allowed().
3) rename set_cpus_allowed_ptr() to set_cpus_allowed()

Perhaps a subtlety is that set_cpus_allowed is creating a new variable, whose address it sends to set_cpus_allowed_ptr?

Yes it does that, but I don't think that actually matters, set_cpus_allowed_ptr()'s arg is const, so making that temporary copy shouldn't have any side effects.

#3 lore raw
In reply to Peter Zijlstra

I tried the following semantic patch:

@@
expression E1,E2;
@@

- set_cpus_allowed(E1, cpumask_of_cpu(E2))
+ set_cpus_allowed_ptr(E1, cpumask_of(E2))

@@
expression E;
identifier I;
@@

- set_cpus_allowed(E, I)
+ set_cpus_allowed_ptr(E, &I)

@@
@@

+BAD(
set_cpus_allowed(...)
+ )

I didn't get any occurrences of BAD in the output, so there seem to be only calls to cpumask_of_cpu and identifiers. Looking at the result of grepping for set_cpus_allowed suggested the same. Am I missing anything?

julia