Skip to content

Commit 5c563ee

Browse files
committed
cpumask: introduce assign_cpu() macro
Now that assign_bit() is a thin macro wrapper around set_bit() and clear_bit(), we can use it in cpumask API and drop duplicating implementations of set_cpu_xxx() helpers with no additional overhead. Bloat-o-meter reports almost 2k less of generated code for allyesconfig, mostly in kernel/cpu.c: add/remove: 2/4 grow/shrink: 3/4 up/down: 498/-2228 (-1730) Reviewed-by: Alexander Lobakin <aleksander.lobakin@intel.com> Signed-off-by: Yury Norov <yury.norov@gmail.com>
1 parent 46d1907 commit 5c563ee

1 file changed

Lines changed: 6 additions & 34 deletions

File tree

include/linux/cpumask.h

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,44 +1083,16 @@ void init_cpu_present(const struct cpumask *src);
10831083
void init_cpu_possible(const struct cpumask *src);
10841084
void init_cpu_online(const struct cpumask *src);
10851085

1086-
static inline void
1087-
set_cpu_possible(unsigned int cpu, bool possible)
1088-
{
1089-
if (possible)
1090-
cpumask_set_cpu(cpu, &__cpu_possible_mask);
1091-
else
1092-
cpumask_clear_cpu(cpu, &__cpu_possible_mask);
1093-
}
1086+
#define assign_cpu(cpu, mask, val) \
1087+
assign_bit(cpumask_check(cpu), cpumask_bits(mask), (val))
10941088

1095-
static inline void
1096-
set_cpu_present(unsigned int cpu, bool present)
1097-
{
1098-
if (present)
1099-
cpumask_set_cpu(cpu, &__cpu_present_mask);
1100-
else
1101-
cpumask_clear_cpu(cpu, &__cpu_present_mask);
1102-
}
1089+
#define set_cpu_possible(cpu, possible) assign_cpu((cpu), &__cpu_possible_mask, (possible))
1090+
#define set_cpu_present(cpu, present) assign_cpu((cpu), &__cpu_present_mask, (present))
1091+
#define set_cpu_active(cpu, active) assign_cpu((cpu), &__cpu_active_mask, (active))
1092+
#define set_cpu_dying(cpu, dying) assign_cpu((cpu), &__cpu_dying_mask, (dying))
11031093

11041094
void set_cpu_online(unsigned int cpu, bool online);
11051095

1106-
static inline void
1107-
set_cpu_active(unsigned int cpu, bool active)
1108-
{
1109-
if (active)
1110-
cpumask_set_cpu(cpu, &__cpu_active_mask);
1111-
else
1112-
cpumask_clear_cpu(cpu, &__cpu_active_mask);
1113-
}
1114-
1115-
static inline void
1116-
set_cpu_dying(unsigned int cpu, bool dying)
1117-
{
1118-
if (dying)
1119-
cpumask_set_cpu(cpu, &__cpu_dying_mask);
1120-
else
1121-
cpumask_clear_cpu(cpu, &__cpu_dying_mask);
1122-
}
1123-
11241096
/**
11251097
* to_cpumask - convert a NR_CPUS bitmap to a struct cpumask *
11261098
* @bitmap: the bitmap

0 commit comments

Comments
 (0)