Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+6 -34
+6 -34
include/linux/cpumask.h
··· 1083 1083 void init_cpu_possible(const struct cpumask *src); 1084 1084 void init_cpu_online(const struct cpumask *src); 1085 1085 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)) 1094 1088 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)) 1103 1093 1104 1094 void set_cpu_online(unsigned int cpu, bool online); 1105 - 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 1095 1124 1096 /** 1125 1097 * to_cpumask - convert a NR_CPUS bitmap to a struct cpumask *