Skip to content

Commit d0e60d4

Browse files
committed
Merge tag 'bitmap-for-5.19-rc1' of https://github.com/norov/linux
Pull bitmap updates from Yury Norov: - bitmap: optimize bitmap_weight() usage, from me - lib/bitmap.c make bitmap_print_bitmask_to_buf parseable, from Mauro Carvalho Chehab - include/linux/find: Fix documentation, from Anna-Maria Behnsen - bitmap: fix conversion from/to fix-sized arrays, from me - bitmap: Fix return values to be unsigned, from Kees Cook It has been in linux-next for at least a week with no problems. * tag 'bitmap-for-5.19-rc1' of https://github.com/norov/linux: (31 commits) nodemask: Fix return values to be unsigned bitmap: Fix return values to be unsigned KVM: x86: hyper-v: replace bitmap_weight() with hweight64() KVM: x86: hyper-v: fix type of valid_bank_mask ia64: cleanup remove_siblinginfo() drm/amd/pm: use bitmap_{from,to}_arr32 where appropriate KVM: s390: replace bitmap_copy with bitmap_{from,to}_arr64 where appropriate lib/bitmap: add test for bitmap_{from,to}_arr64 lib: add bitmap_{from,to}_arr64 lib/bitmap: extend comment for bitmap_(from,to)_arr32() include/linux/find: Fix documentation lib/bitmap.c make bitmap_print_bitmask_to_buf parseable MAINTAINERS: add cpumask and nodemask files to BITMAP_API arch/x86: replace nodes_weight with nodes_empty where appropriate mm/vmstat: replace cpumask_weight with cpumask_empty where appropriate clocksource: replace cpumask_weight with cpumask_empty in clocksource.c genirq/affinity: replace cpumask_weight with cpumask_empty where appropriate irq: mips: replace cpumask_weight with cpumask_empty where appropriate drm/i915/pmu: replace cpumask_weight with cpumask_empty where appropriate arch/x86: replace cpumask_weight with cpumask_empty where appropriate ...
2 parents 23df9ba + 0dfe540 commit d0e60d4

File tree

27 files changed

+263
-207
lines changed

27 files changed

+263
-207
lines changed

MAINTAINERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3533,10 +3533,14 @@ R: Andy Shevchenko <[email protected]>
35333533
R: Rasmus Villemoes <[email protected]>
35343534
S: Maintained
35353535
F: include/linux/bitmap.h
3536+
F: include/linux/cpumask.h
35363537
F: include/linux/find.h
3538+
F: include/linux/nodemask.h
35373539
F: lib/bitmap.c
3540+
F: lib/cpumask.c
35383541
F: lib/find_bit.c
35393542
F: lib/find_bit_benchmark.c
3543+
F: lib/nodemask.c
35403544
F: lib/test_bitmap.c
35413545
F: tools/include/linux/bitmap.h
35423546
F: tools/include/linux/find.h

arch/alpha/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ common_shutdown_1(void *generic_ptr)
125125
/* Wait for the secondaries to halt. */
126126
set_cpu_present(boot_cpuid, false);
127127
set_cpu_possible(boot_cpuid, false);
128-
while (cpumask_weight(cpu_present_mask))
128+
while (!cpumask_empty(cpu_present_mask))
129129
barrier();
130130
#endif
131131

arch/ia64/kernel/setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ setup_arch (char **cmdline_p)
572572
#ifdef CONFIG_ACPI_HOTPLUG_CPU
573573
prefill_possible_map();
574574
#endif
575-
per_cpu_scan_finalize((cpumask_weight(&early_cpu_possible_map) == 0 ?
575+
per_cpu_scan_finalize((cpumask_empty(&early_cpu_possible_map) ?
576576
32 : cpumask_weight(&early_cpu_possible_map)),
577577
additional_cpus > 0 ? additional_cpus : 0);
578578
#endif /* CONFIG_ACPI_NUMA */

arch/ia64/kernel/smpboot.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,17 +576,13 @@ clear_cpu_sibling_map(int cpu)
576576
static void
577577
remove_siblinginfo(int cpu)
578578
{
579-
int last = 0;
580-
581579
if (cpu_data(cpu)->threads_per_core == 1 &&
582580
cpu_data(cpu)->cores_per_socket == 1) {
583581
cpumask_clear_cpu(cpu, &cpu_core_map[cpu]);
584582
cpumask_clear_cpu(cpu, &per_cpu(cpu_sibling_map, cpu));
585583
return;
586584
}
587585

588-
last = (cpumask_weight(&cpu_core_map[cpu]) == 1 ? 1 : 0);
589-
590586
/* remove it from all sibling map's */
591587
clear_cpu_sibling_map(cpu);
592588
}

arch/riscv/kernel/cpufeature.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,10 @@ void __init riscv_fill_hwcap(void)
213213
else
214214
elf_hwcap = this_hwcap;
215215

216-
if (bitmap_weight(riscv_isa, RISCV_ISA_EXT_MAX))
217-
bitmap_and(riscv_isa, riscv_isa, this_isa, RISCV_ISA_EXT_MAX);
218-
else
216+
if (bitmap_empty(riscv_isa, RISCV_ISA_EXT_MAX))
219217
bitmap_copy(riscv_isa, this_isa, RISCV_ISA_EXT_MAX);
220-
218+
else
219+
bitmap_and(riscv_isa, riscv_isa, this_isa, RISCV_ISA_EXT_MAX);
221220
}
222221

223222
/* We don't support systems with F but without D, so mask those out

arch/s390/kvm/kvm-s390.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,8 +1332,7 @@ static int kvm_s390_set_processor_feat(struct kvm *kvm,
13321332
mutex_unlock(&kvm->lock);
13331333
return -EBUSY;
13341334
}
1335-
bitmap_copy(kvm->arch.cpu_feat, (unsigned long *) data.feat,
1336-
KVM_S390_VM_CPU_FEAT_NR_BITS);
1335+
bitmap_from_arr64(kvm->arch.cpu_feat, data.feat, KVM_S390_VM_CPU_FEAT_NR_BITS);
13371336
mutex_unlock(&kvm->lock);
13381337
VM_EVENT(kvm, 3, "SET: guest feat: 0x%16.16llx.0x%16.16llx.0x%16.16llx",
13391338
data.feat[0],
@@ -1504,8 +1503,7 @@ static int kvm_s390_get_processor_feat(struct kvm *kvm,
15041503
{
15051504
struct kvm_s390_vm_cpu_feat data;
15061505

1507-
bitmap_copy((unsigned long *) data.feat, kvm->arch.cpu_feat,
1508-
KVM_S390_VM_CPU_FEAT_NR_BITS);
1506+
bitmap_to_arr64(data.feat, kvm->arch.cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS);
15091507
if (copy_to_user((void __user *)attr->addr, &data, sizeof(data)))
15101508
return -EFAULT;
15111509
VM_EVENT(kvm, 3, "GET: guest feat: 0x%16.16llx.0x%16.16llx.0x%16.16llx",
@@ -1520,9 +1518,7 @@ static int kvm_s390_get_machine_feat(struct kvm *kvm,
15201518
{
15211519
struct kvm_s390_vm_cpu_feat data;
15221520

1523-
bitmap_copy((unsigned long *) data.feat,
1524-
kvm_s390_available_cpu_feat,
1525-
KVM_S390_VM_CPU_FEAT_NR_BITS);
1521+
bitmap_to_arr64(data.feat, kvm_s390_available_cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS);
15261522
if (copy_to_user((void __user *)attr->addr, &data, sizeof(data)))
15271523
return -EFAULT;
15281524
VM_EVENT(kvm, 3, "GET: host feat: 0x%16.16llx.0x%16.16llx.0x%16.16llx",

arch/x86/kvm/hyperv.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static void synic_update_vector(struct kvm_vcpu_hv_synic *synic,
9090
{
9191
struct kvm_vcpu *vcpu = hv_synic_to_vcpu(synic);
9292
struct kvm_hv *hv = to_kvm_hv(vcpu->kvm);
93-
int auto_eoi_old, auto_eoi_new;
93+
bool auto_eoi_old, auto_eoi_new;
9494

9595
if (vector < HV_SYNIC_FIRST_VALID_VECTOR)
9696
return;
@@ -100,16 +100,16 @@ static void synic_update_vector(struct kvm_vcpu_hv_synic *synic,
100100
else
101101
__clear_bit(vector, synic->vec_bitmap);
102102

103-
auto_eoi_old = bitmap_weight(synic->auto_eoi_bitmap, 256);
103+
auto_eoi_old = !bitmap_empty(synic->auto_eoi_bitmap, 256);
104104

105105
if (synic_has_vector_auto_eoi(synic, vector))
106106
__set_bit(vector, synic->auto_eoi_bitmap);
107107
else
108108
__clear_bit(vector, synic->auto_eoi_bitmap);
109109

110-
auto_eoi_new = bitmap_weight(synic->auto_eoi_bitmap, 256);
110+
auto_eoi_new = !bitmap_empty(synic->auto_eoi_bitmap, 256);
111111

112-
if (!!auto_eoi_old == !!auto_eoi_new)
112+
if (auto_eoi_old == auto_eoi_new)
113113
return;
114114

115115
if (!enable_apicv)
@@ -1855,7 +1855,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
18551855
all_cpus = flush_ex.hv_vp_set.format !=
18561856
HV_GENERIC_SET_SPARSE_4K;
18571857

1858-
if (hc->var_cnt != bitmap_weight((unsigned long *)&valid_bank_mask, 64))
1858+
if (hc->var_cnt != hweight64(valid_bank_mask))
18591859
return HV_STATUS_INVALID_HYPERCALL_INPUT;
18601860

18611861
if (all_cpus)
@@ -1956,7 +1956,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
19561956
valid_bank_mask = send_ipi_ex.vp_set.valid_bank_mask;
19571957
all_cpus = send_ipi_ex.vp_set.format == HV_GENERIC_SET_ALL;
19581958

1959-
if (hc->var_cnt != bitmap_weight((unsigned long *)&valid_bank_mask, 64))
1959+
if (hc->var_cnt != hweight64(valid_bank_mask))
19601960
return HV_STATUS_INVALID_HYPERCALL_INPUT;
19611961

19621962
if (all_cpus)

drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ int smu_v11_0_set_allowed_mask(struct smu_context *smu)
781781
goto failed;
782782
}
783783

784-
bitmap_copy((unsigned long *)feature_mask, feature->allowed, 64);
784+
bitmap_to_arr32(feature_mask, feature->allowed, 64);
785785

786786
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetAllowedFeaturesMaskHigh,
787787
feature_mask[1], NULL);

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ int smu_v13_0_set_allowed_mask(struct smu_context *smu)
837837
feature->feature_num < 64)
838838
return -EINVAL;
839839

840-
bitmap_copy((unsigned long *)feature_mask, feature->allowed, 64);
840+
bitmap_to_arr32(feature_mask, feature->allowed, 64);
841841

842842
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetAllowedFeaturesMaskHigh,
843843
feature_mask[1], NULL);

drivers/gpu/drm/i915/i915_pmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ static int i915_pmu_cpu_online(unsigned int cpu, struct hlist_node *node)
10471047
GEM_BUG_ON(!pmu->base.event_init);
10481048

10491049
/* Select the first online CPU as a designated reader. */
1050-
if (!cpumask_weight(&i915_pmu_cpumask))
1050+
if (cpumask_empty(&i915_pmu_cpumask))
10511051
cpumask_set_cpu(cpu, &i915_pmu_cpumask);
10521052

10531053
return 0;

0 commit comments

Comments
 (0)