mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-13 07:44:00 +08:00
Bitmap patches for 5.19-rc1
This series includes the following patchsets: - bitmap: optimize bitmap_weight() usage(w/o bitmap_weight_cmp), 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. -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEi8GdvG6xMhdgpu/4sUSA/TofvsgFAmKaEzYACgkQsUSA/Tof vsiGKwv8Dgr3G0mLbSfmHZqdFMIsmSmwhxlEH6eBNtX6vjQbGafe/Buhj/1oSY8N NYC4+5Br6s7MmMRth3Kp6UECdl94TS3Ka06T+lVBKkG+C+B1w1/svqUMM2ZCQF3e Z5R/HhR6av9X9Qb2mWSasWLkWp629NjdtRsJSDWiVt1emVVwh+iwxQnMH9VuE+ao z3mvaQfSRhe4h+xCZOiohzFP+0jZb1EnPrQAIVzNUjigo7mglpNvVyO7p/8LU7gD dIjfGmSbtsHU72J+/0lotRqjhjORl1F/EILf8pIzx5Ga7ExUGhOzGWAj7/3uZxfA Cp1Z/QV271MGwv/sNdSPwCCJHf51eOmsbyOyUScjb3gFRwIStEa1jB4hKwLhS5wF 3kh4kqu3WGuIQAdxkUpDBsy3CQjAPDkvtRJorwyWGbjwa9xUETESAgH7XCCTsgWc 0sIuldWWaxC581+fAP1Dzmo8uuWBURTaOrVmRMILQHMTw54zoFyLY+VI9gEAT9aV gnPr3M4F =U7DN -----END PGP SIGNATURE----- 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 ...
This commit is contained in:
commit
d0e60d46bc
@ -3533,10 +3533,14 @@ R: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
|
||||
R: Rasmus Villemoes <linux@rasmusvillemoes.dk>
|
||||
S: Maintained
|
||||
F: include/linux/bitmap.h
|
||||
F: include/linux/cpumask.h
|
||||
F: include/linux/find.h
|
||||
F: include/linux/nodemask.h
|
||||
F: lib/bitmap.c
|
||||
F: lib/cpumask.c
|
||||
F: lib/find_bit.c
|
||||
F: lib/find_bit_benchmark.c
|
||||
F: lib/nodemask.c
|
||||
F: lib/test_bitmap.c
|
||||
F: tools/include/linux/bitmap.h
|
||||
F: tools/include/linux/find.h
|
||||
|
@ -125,7 +125,7 @@ common_shutdown_1(void *generic_ptr)
|
||||
/* Wait for the secondaries to halt. */
|
||||
set_cpu_present(boot_cpuid, false);
|
||||
set_cpu_possible(boot_cpuid, false);
|
||||
while (cpumask_weight(cpu_present_mask))
|
||||
while (!cpumask_empty(cpu_present_mask))
|
||||
barrier();
|
||||
#endif
|
||||
|
||||
|
@ -572,7 +572,7 @@ setup_arch (char **cmdline_p)
|
||||
#ifdef CONFIG_ACPI_HOTPLUG_CPU
|
||||
prefill_possible_map();
|
||||
#endif
|
||||
per_cpu_scan_finalize((cpumask_weight(&early_cpu_possible_map) == 0 ?
|
||||
per_cpu_scan_finalize((cpumask_empty(&early_cpu_possible_map) ?
|
||||
32 : cpumask_weight(&early_cpu_possible_map)),
|
||||
additional_cpus > 0 ? additional_cpus : 0);
|
||||
#endif /* CONFIG_ACPI_NUMA */
|
||||
|
@ -576,8 +576,6 @@ clear_cpu_sibling_map(int cpu)
|
||||
static void
|
||||
remove_siblinginfo(int cpu)
|
||||
{
|
||||
int last = 0;
|
||||
|
||||
if (cpu_data(cpu)->threads_per_core == 1 &&
|
||||
cpu_data(cpu)->cores_per_socket == 1) {
|
||||
cpumask_clear_cpu(cpu, &cpu_core_map[cpu]);
|
||||
@ -585,8 +583,6 @@ remove_siblinginfo(int cpu)
|
||||
return;
|
||||
}
|
||||
|
||||
last = (cpumask_weight(&cpu_core_map[cpu]) == 1 ? 1 : 0);
|
||||
|
||||
/* remove it from all sibling map's */
|
||||
clear_cpu_sibling_map(cpu);
|
||||
}
|
||||
|
@ -213,11 +213,10 @@ void __init riscv_fill_hwcap(void)
|
||||
else
|
||||
elf_hwcap = this_hwcap;
|
||||
|
||||
if (bitmap_weight(riscv_isa, RISCV_ISA_EXT_MAX))
|
||||
bitmap_and(riscv_isa, riscv_isa, this_isa, RISCV_ISA_EXT_MAX);
|
||||
else
|
||||
if (bitmap_empty(riscv_isa, RISCV_ISA_EXT_MAX))
|
||||
bitmap_copy(riscv_isa, this_isa, RISCV_ISA_EXT_MAX);
|
||||
|
||||
else
|
||||
bitmap_and(riscv_isa, riscv_isa, this_isa, RISCV_ISA_EXT_MAX);
|
||||
}
|
||||
|
||||
/* We don't support systems with F but without D, so mask those out
|
||||
|
@ -1332,8 +1332,7 @@ static int kvm_s390_set_processor_feat(struct kvm *kvm,
|
||||
mutex_unlock(&kvm->lock);
|
||||
return -EBUSY;
|
||||
}
|
||||
bitmap_copy(kvm->arch.cpu_feat, (unsigned long *) data.feat,
|
||||
KVM_S390_VM_CPU_FEAT_NR_BITS);
|
||||
bitmap_from_arr64(kvm->arch.cpu_feat, data.feat, KVM_S390_VM_CPU_FEAT_NR_BITS);
|
||||
mutex_unlock(&kvm->lock);
|
||||
VM_EVENT(kvm, 3, "SET: guest feat: 0x%16.16llx.0x%16.16llx.0x%16.16llx",
|
||||
data.feat[0],
|
||||
@ -1504,8 +1503,7 @@ static int kvm_s390_get_processor_feat(struct kvm *kvm,
|
||||
{
|
||||
struct kvm_s390_vm_cpu_feat data;
|
||||
|
||||
bitmap_copy((unsigned long *) data.feat, kvm->arch.cpu_feat,
|
||||
KVM_S390_VM_CPU_FEAT_NR_BITS);
|
||||
bitmap_to_arr64(data.feat, kvm->arch.cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS);
|
||||
if (copy_to_user((void __user *)attr->addr, &data, sizeof(data)))
|
||||
return -EFAULT;
|
||||
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,
|
||||
{
|
||||
struct kvm_s390_vm_cpu_feat data;
|
||||
|
||||
bitmap_copy((unsigned long *) data.feat,
|
||||
kvm_s390_available_cpu_feat,
|
||||
KVM_S390_VM_CPU_FEAT_NR_BITS);
|
||||
bitmap_to_arr64(data.feat, kvm_s390_available_cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS);
|
||||
if (copy_to_user((void __user *)attr->addr, &data, sizeof(data)))
|
||||
return -EFAULT;
|
||||
VM_EVENT(kvm, 3, "GET: host feat: 0x%16.16llx.0x%16.16llx.0x%16.16llx",
|
||||
|
@ -90,7 +90,7 @@ static void synic_update_vector(struct kvm_vcpu_hv_synic *synic,
|
||||
{
|
||||
struct kvm_vcpu *vcpu = hv_synic_to_vcpu(synic);
|
||||
struct kvm_hv *hv = to_kvm_hv(vcpu->kvm);
|
||||
int auto_eoi_old, auto_eoi_new;
|
||||
bool auto_eoi_old, auto_eoi_new;
|
||||
|
||||
if (vector < HV_SYNIC_FIRST_VALID_VECTOR)
|
||||
return;
|
||||
@ -100,16 +100,16 @@ static void synic_update_vector(struct kvm_vcpu_hv_synic *synic,
|
||||
else
|
||||
__clear_bit(vector, synic->vec_bitmap);
|
||||
|
||||
auto_eoi_old = bitmap_weight(synic->auto_eoi_bitmap, 256);
|
||||
auto_eoi_old = !bitmap_empty(synic->auto_eoi_bitmap, 256);
|
||||
|
||||
if (synic_has_vector_auto_eoi(synic, vector))
|
||||
__set_bit(vector, synic->auto_eoi_bitmap);
|
||||
else
|
||||
__clear_bit(vector, synic->auto_eoi_bitmap);
|
||||
|
||||
auto_eoi_new = bitmap_weight(synic->auto_eoi_bitmap, 256);
|
||||
auto_eoi_new = !bitmap_empty(synic->auto_eoi_bitmap, 256);
|
||||
|
||||
if (!!auto_eoi_old == !!auto_eoi_new)
|
||||
if (auto_eoi_old == auto_eoi_new)
|
||||
return;
|
||||
|
||||
if (!enable_apicv)
|
||||
@ -1855,7 +1855,7 @@ static u64 kvm_hv_flush_tlb(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
|
||||
all_cpus = flush_ex.hv_vp_set.format !=
|
||||
HV_GENERIC_SET_SPARSE_4K;
|
||||
|
||||
if (hc->var_cnt != bitmap_weight((unsigned long *)&valid_bank_mask, 64))
|
||||
if (hc->var_cnt != hweight64(valid_bank_mask))
|
||||
return HV_STATUS_INVALID_HYPERCALL_INPUT;
|
||||
|
||||
if (all_cpus)
|
||||
@ -1956,7 +1956,7 @@ static u64 kvm_hv_send_ipi(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hc)
|
||||
valid_bank_mask = send_ipi_ex.vp_set.valid_bank_mask;
|
||||
all_cpus = send_ipi_ex.vp_set.format == HV_GENERIC_SET_ALL;
|
||||
|
||||
if (hc->var_cnt != bitmap_weight((unsigned long *)&valid_bank_mask, 64))
|
||||
if (hc->var_cnt != hweight64(valid_bank_mask))
|
||||
return HV_STATUS_INVALID_HYPERCALL_INPUT;
|
||||
|
||||
if (all_cpus)
|
||||
|
@ -781,7 +781,7 @@ int smu_v11_0_set_allowed_mask(struct smu_context *smu)
|
||||
goto failed;
|
||||
}
|
||||
|
||||
bitmap_copy((unsigned long *)feature_mask, feature->allowed, 64);
|
||||
bitmap_to_arr32(feature_mask, feature->allowed, 64);
|
||||
|
||||
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetAllowedFeaturesMaskHigh,
|
||||
feature_mask[1], NULL);
|
||||
|
@ -837,7 +837,7 @@ int smu_v13_0_set_allowed_mask(struct smu_context *smu)
|
||||
feature->feature_num < 64)
|
||||
return -EINVAL;
|
||||
|
||||
bitmap_copy((unsigned long *)feature_mask, feature->allowed, 64);
|
||||
bitmap_to_arr32(feature_mask, feature->allowed, 64);
|
||||
|
||||
ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetAllowedFeaturesMaskHigh,
|
||||
feature_mask[1], NULL);
|
||||
|
@ -1047,7 +1047,7 @@ static int i915_pmu_cpu_online(unsigned int cpu, struct hlist_node *node)
|
||||
GEM_BUG_ON(!pmu->base.event_init);
|
||||
|
||||
/* Select the first online CPU as a designated reader. */
|
||||
if (!cpumask_weight(&i915_pmu_cpumask))
|
||||
if (cpumask_empty(&i915_pmu_cpumask))
|
||||
cpumask_set_cpu(cpu, &i915_pmu_cpumask);
|
||||
|
||||
return 0;
|
||||
|
@ -45,41 +45,31 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
|
||||
{
|
||||
struct iio_poll_func *pf = p;
|
||||
struct iio_dev *indio_dev = pf->indio_dev;
|
||||
int i = 0, j;
|
||||
u16 *data;
|
||||
|
||||
data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
|
||||
if (!data)
|
||||
goto done;
|
||||
|
||||
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) {
|
||||
/*
|
||||
* Three common options here:
|
||||
* hardware scans: certain combinations of channels make
|
||||
* up a fast read. The capture will consist of all of them.
|
||||
* Hence we just call the grab data function and fill the
|
||||
* buffer without processing.
|
||||
* software scans: can be considered to be random access
|
||||
* so efficient reading is just a case of minimal bus
|
||||
* transactions.
|
||||
* software culled hardware scans:
|
||||
* occasionally a driver may process the nearest hardware
|
||||
* scan to avoid storing elements that are not desired. This
|
||||
* is the fiddliest option by far.
|
||||
* Here let's pretend we have random access. And the values are
|
||||
* in the constant table fakedata.
|
||||
*/
|
||||
int i, j;
|
||||
|
||||
for (i = 0, j = 0;
|
||||
i < bitmap_weight(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength);
|
||||
i++, j++) {
|
||||
j = find_next_bit(indio_dev->active_scan_mask,
|
||||
indio_dev->masklength, j);
|
||||
/* random access read from the 'device' */
|
||||
data[i] = fakedata[j];
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Three common options here:
|
||||
* hardware scans:
|
||||
* certain combinations of channels make up a fast read. The capture
|
||||
* will consist of all of them. Hence we just call the grab data
|
||||
* function and fill the buffer without processing.
|
||||
* software scans:
|
||||
* can be considered to be random access so efficient reading is just
|
||||
* a case of minimal bus transactions.
|
||||
* software culled hardware scans:
|
||||
* occasionally a driver may process the nearest hardware scan to avoid
|
||||
* storing elements that are not desired. This is the fiddliest option
|
||||
* by far.
|
||||
* Here let's pretend we have random access. And the values are in the
|
||||
* constant table fakedata.
|
||||
*/
|
||||
for_each_set_bit(j, indio_dev->active_scan_mask, indio_dev->masklength)
|
||||
data[i++] = fakedata[j];
|
||||
|
||||
iio_push_to_buffers_with_timestamp(indio_dev, data,
|
||||
iio_get_time_ns(indio_dev));
|
||||
|
@ -1603,12 +1603,8 @@ static int b53_arl_read(struct b53_device *dev, u64 mac,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bitmap_weight(free_bins, dev->num_arl_bins) == 0)
|
||||
return -ENOSPC;
|
||||
|
||||
*idx = find_first_bit(free_bins, dev->num_arl_bins);
|
||||
|
||||
return -ENOENT;
|
||||
return *idx >= dev->num_arl_bins ? -ENOSPC : -ENOENT;
|
||||
}
|
||||
|
||||
static int b53_arl_op(struct b53_device *dev, int op, int port,
|
||||
|
@ -2180,13 +2180,9 @@ static int bcm_sysport_rule_set(struct bcm_sysport_priv *priv,
|
||||
if (nfc->fs.ring_cookie != RX_CLS_FLOW_WAKE)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
/* All filters are already in use, we cannot match more rules */
|
||||
if (bitmap_weight(priv->filters, RXCHK_BRCM_TAG_MAX) ==
|
||||
RXCHK_BRCM_TAG_MAX)
|
||||
return -ENOSPC;
|
||||
|
||||
index = find_first_zero_bit(priv->filters, RXCHK_BRCM_TAG_MAX);
|
||||
if (index >= RXCHK_BRCM_TAG_MAX)
|
||||
/* All filters are already in use, we cannot match more rules */
|
||||
return -ENOSPC;
|
||||
|
||||
/* Location is the classification ID, and index is the position
|
||||
|
@ -355,7 +355,7 @@ int otx2_add_macfilter(struct net_device *netdev, const u8 *mac)
|
||||
{
|
||||
struct otx2_nic *pf = netdev_priv(netdev);
|
||||
|
||||
if (bitmap_weight(&pf->flow_cfg->dmacflt_bmap,
|
||||
if (!bitmap_empty(&pf->flow_cfg->dmacflt_bmap,
|
||||
pf->flow_cfg->dmacflt_max_flows))
|
||||
netdev_warn(netdev,
|
||||
"Add %pM to CGX/RPM DMAC filters list as well\n",
|
||||
@ -438,7 +438,7 @@ int otx2_get_maxflows(struct otx2_flow_config *flow_cfg)
|
||||
return 0;
|
||||
|
||||
if (flow_cfg->nr_flows == flow_cfg->max_flows ||
|
||||
bitmap_weight(&flow_cfg->dmacflt_bmap,
|
||||
!bitmap_empty(&flow_cfg->dmacflt_bmap,
|
||||
flow_cfg->dmacflt_max_flows))
|
||||
return flow_cfg->max_flows + flow_cfg->dmacflt_max_flows;
|
||||
else
|
||||
|
@ -1120,7 +1120,7 @@ static int otx2_cgx_config_loopback(struct otx2_nic *pf, bool enable)
|
||||
struct msg_req *msg;
|
||||
int err;
|
||||
|
||||
if (enable && bitmap_weight(&pf->flow_cfg->dmacflt_bmap,
|
||||
if (enable && !bitmap_empty(&pf->flow_cfg->dmacflt_bmap,
|
||||
pf->flow_cfg->dmacflt_max_flows))
|
||||
netdev_warn(pf->netdev,
|
||||
"CGX/RPM internal loopback might not work as DMAC filters are active\n");
|
||||
|
@ -1994,21 +1994,16 @@ static void mlx4_allocate_port_vpps(struct mlx4_dev *dev, int port)
|
||||
|
||||
static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int slave)
|
||||
{
|
||||
int port, err;
|
||||
int p, port, err;
|
||||
struct mlx4_vport_state *vp_admin;
|
||||
struct mlx4_vport_oper_state *vp_oper;
|
||||
struct mlx4_slave_state *slave_state =
|
||||
&priv->mfunc.master.slave_state[slave];
|
||||
struct mlx4_active_ports actv_ports = mlx4_get_active_ports(
|
||||
&priv->dev, slave);
|
||||
int min_port = find_first_bit(actv_ports.ports,
|
||||
priv->dev.caps.num_ports) + 1;
|
||||
int max_port = min_port - 1 +
|
||||
bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports);
|
||||
|
||||
for (port = min_port; port <= max_port; port++) {
|
||||
if (!test_bit(port - 1, actv_ports.ports))
|
||||
continue;
|
||||
for_each_set_bit(p, actv_ports.ports, priv->dev.caps.num_ports) {
|
||||
port = p + 1;
|
||||
priv->mfunc.master.vf_oper[slave].smi_enabled[port] =
|
||||
priv->mfunc.master.vf_admin[slave].enable_smi[port];
|
||||
vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port];
|
||||
@ -2063,19 +2058,13 @@ static int mlx4_master_activate_admin_state(struct mlx4_priv *priv, int slave)
|
||||
|
||||
static void mlx4_master_deactivate_admin_state(struct mlx4_priv *priv, int slave)
|
||||
{
|
||||
int port;
|
||||
int p, port;
|
||||
struct mlx4_vport_oper_state *vp_oper;
|
||||
struct mlx4_active_ports actv_ports = mlx4_get_active_ports(
|
||||
&priv->dev, slave);
|
||||
int min_port = find_first_bit(actv_ports.ports,
|
||||
priv->dev.caps.num_ports) + 1;
|
||||
int max_port = min_port - 1 +
|
||||
bitmap_weight(actv_ports.ports, priv->dev.caps.num_ports);
|
||||
|
||||
|
||||
for (port = min_port; port <= max_port; port++) {
|
||||
if (!test_bit(port - 1, actv_ports.ports))
|
||||
continue;
|
||||
for_each_set_bit(p, actv_ports.ports, priv->dev.caps.num_ports) {
|
||||
port = p + 1;
|
||||
priv->mfunc.master.vf_oper[slave].smi_enabled[port] =
|
||||
MLX4_VF_SMI_DISABLED;
|
||||
vp_oper = &priv->mfunc.master.vf_oper[slave].vport[port];
|
||||
|
@ -319,44 +319,27 @@ free_rdma_dev:
|
||||
void qed_rdma_bmap_free(struct qed_hwfn *p_hwfn,
|
||||
struct qed_bmap *bmap, bool check)
|
||||
{
|
||||
int weight = bitmap_weight(bmap->bitmap, bmap->max_count);
|
||||
int last_line = bmap->max_count / (64 * 8);
|
||||
int last_item = last_line * 8 +
|
||||
DIV_ROUND_UP(bmap->max_count % (64 * 8), 64);
|
||||
u64 *pmap = (u64 *)bmap->bitmap;
|
||||
int line, item, offset;
|
||||
u8 str_last_line[200] = { 0 };
|
||||
unsigned int bit, weight, nbits;
|
||||
unsigned long *b;
|
||||
|
||||
if (!weight || !check)
|
||||
if (!check)
|
||||
goto end;
|
||||
|
||||
weight = bitmap_weight(bmap->bitmap, bmap->max_count);
|
||||
if (!weight)
|
||||
goto end;
|
||||
|
||||
DP_NOTICE(p_hwfn,
|
||||
"%s bitmap not free - size=%d, weight=%d, 512 bits per line\n",
|
||||
bmap->name, bmap->max_count, weight);
|
||||
|
||||
/* print aligned non-zero lines, if any */
|
||||
for (item = 0, line = 0; line < last_line; line++, item += 8)
|
||||
if (bitmap_weight((unsigned long *)&pmap[item], 64 * 8))
|
||||
DP_NOTICE(p_hwfn,
|
||||
"line 0x%04x: 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx 0x%016llx\n",
|
||||
line,
|
||||
pmap[item],
|
||||
pmap[item + 1],
|
||||
pmap[item + 2],
|
||||
pmap[item + 3],
|
||||
pmap[item + 4],
|
||||
pmap[item + 5],
|
||||
pmap[item + 6], pmap[item + 7]);
|
||||
for (bit = 0; bit < bmap->max_count; bit += 512) {
|
||||
b = bmap->bitmap + BITS_TO_LONGS(bit);
|
||||
nbits = min(bmap->max_count - bit, 512U);
|
||||
|
||||
/* print last unaligned non-zero line, if any */
|
||||
if ((bmap->max_count % (64 * 8)) &&
|
||||
(bitmap_weight((unsigned long *)&pmap[item],
|
||||
bmap->max_count - item * 64))) {
|
||||
offset = sprintf(str_last_line, "line 0x%04x: ", line);
|
||||
for (; item < last_item; item++)
|
||||
offset += sprintf(str_last_line + offset,
|
||||
"0x%016llx ", pmap[item]);
|
||||
DP_NOTICE(p_hwfn, "%s\n", str_last_line);
|
||||
if (!bitmap_empty(b, nbits))
|
||||
DP_NOTICE(p_hwfn,
|
||||
"line 0x%04x: %*pb\n", bit / 512, nbits, b);
|
||||
}
|
||||
|
||||
end:
|
||||
|
@ -76,7 +76,7 @@ void qed_roce_stop(struct qed_hwfn *p_hwfn)
|
||||
* We delay for a short while if an async destroy QP is still expected.
|
||||
* Beyond the added delay we clear the bitmap anyway.
|
||||
*/
|
||||
while (bitmap_weight(rcid_map->bitmap, rcid_map->max_count)) {
|
||||
while (!bitmap_empty(rcid_map->bitmap, rcid_map->max_count)) {
|
||||
/* If the HW device is during recovery, all resources are
|
||||
* immediately reset without receiving a per-cid indication
|
||||
* from HW. In this case we don't expect the cid bitmap to be
|
||||
|
@ -72,6 +72,8 @@ struct device;
|
||||
* bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region
|
||||
* bitmap_from_arr32(dst, buf, nbits) Copy nbits from u32[] buf to dst
|
||||
* bitmap_to_arr32(buf, src, nbits) Copy nbits from buf to u32[] dst
|
||||
* bitmap_to_arr64(buf, src, nbits) Copy nbits from buf to u64[] dst
|
||||
* bitmap_to_arr64(buf, src, nbits) Copy nbits from buf to u64[] dst
|
||||
* bitmap_get_value8(map, start) Get 8bit value from map at start
|
||||
* bitmap_set_value8(map, value, start) Set 8bit value to map at start
|
||||
*
|
||||
@ -132,8 +134,8 @@ unsigned long *devm_bitmap_zalloc(struct device *dev,
|
||||
* lib/bitmap.c provides these functions:
|
||||
*/
|
||||
|
||||
int __bitmap_equal(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int nbits);
|
||||
bool __bitmap_equal(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int nbits);
|
||||
bool __pure __bitmap_or_equal(const unsigned long *src1,
|
||||
const unsigned long *src2,
|
||||
const unsigned long *src3,
|
||||
@ -157,10 +159,10 @@ int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
|
||||
void __bitmap_replace(unsigned long *dst,
|
||||
const unsigned long *old, const unsigned long *new,
|
||||
const unsigned long *mask, unsigned int nbits);
|
||||
int __bitmap_intersects(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int nbits);
|
||||
int __bitmap_subset(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int nbits);
|
||||
bool __bitmap_intersects(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int nbits);
|
||||
bool __bitmap_subset(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int nbits);
|
||||
int __bitmap_weight(const unsigned long *bitmap, unsigned int nbits);
|
||||
void __bitmap_set(unsigned long *map, unsigned int start, int len);
|
||||
void __bitmap_clear(unsigned long *map, unsigned int start, int len);
|
||||
@ -264,8 +266,12 @@ static inline void bitmap_copy_clear_tail(unsigned long *dst,
|
||||
}
|
||||
|
||||
/*
|
||||
* On 32-bit systems bitmaps are represented as u32 arrays internally, and
|
||||
* therefore conversion is not needed when copying data from/to arrays of u32.
|
||||
* On 32-bit systems bitmaps are represented as u32 arrays internally. On LE64
|
||||
* machines the order of hi and lo parts of numbers match the bitmap structure.
|
||||
* In both cases conversion is not needed when copying data from/to arrays of
|
||||
* u32. But in LE64 case, typecast in bitmap_copy_clear_tail() may lead
|
||||
* to out-of-bound access. To avoid that, both LE and BE variants of 64-bit
|
||||
* architectures are not using bitmap_copy_clear_tail().
|
||||
*/
|
||||
#if BITS_PER_LONG == 64
|
||||
void bitmap_from_arr32(unsigned long *bitmap, const u32 *buf,
|
||||
@ -281,6 +287,22 @@ void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap,
|
||||
(const unsigned long *) (bitmap), (nbits))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* On 64-bit systems bitmaps are represented as u64 arrays internally. On LE32
|
||||
* machines the order of hi and lo parts of numbers match the bitmap structure.
|
||||
* In both cases conversion is not needed when copying data from/to arrays of
|
||||
* u64.
|
||||
*/
|
||||
#if (BITS_PER_LONG == 32) && defined(__BIG_ENDIAN)
|
||||
void bitmap_from_arr64(unsigned long *bitmap, const u64 *buf, unsigned int nbits);
|
||||
void bitmap_to_arr64(u64 *buf, const unsigned long *bitmap, unsigned int nbits);
|
||||
#else
|
||||
#define bitmap_from_arr64(bitmap, buf, nbits) \
|
||||
bitmap_copy_clear_tail((unsigned long *)(bitmap), (const unsigned long *)(buf), (nbits))
|
||||
#define bitmap_to_arr64(buf, bitmap, nbits) \
|
||||
bitmap_copy_clear_tail((unsigned long *)(buf), (const unsigned long *)(bitmap), (nbits))
|
||||
#endif
|
||||
|
||||
static inline int bitmap_and(unsigned long *dst, const unsigned long *src1,
|
||||
const unsigned long *src2, unsigned int nbits)
|
||||
{
|
||||
@ -331,8 +353,8 @@ static inline void bitmap_complement(unsigned long *dst, const unsigned long *sr
|
||||
#endif
|
||||
#define BITMAP_MEM_MASK (BITMAP_MEM_ALIGNMENT - 1)
|
||||
|
||||
static inline int bitmap_equal(const unsigned long *src1,
|
||||
const unsigned long *src2, unsigned int nbits)
|
||||
static inline bool bitmap_equal(const unsigned long *src1,
|
||||
const unsigned long *src2, unsigned int nbits)
|
||||
{
|
||||
if (small_const_nbits(nbits))
|
||||
return !((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits));
|
||||
@ -362,8 +384,9 @@ static inline bool bitmap_or_equal(const unsigned long *src1,
|
||||
return !(((*src1 | *src2) ^ *src3) & BITMAP_LAST_WORD_MASK(nbits));
|
||||
}
|
||||
|
||||
static inline int bitmap_intersects(const unsigned long *src1,
|
||||
const unsigned long *src2, unsigned int nbits)
|
||||
static inline bool bitmap_intersects(const unsigned long *src1,
|
||||
const unsigned long *src2,
|
||||
unsigned int nbits)
|
||||
{
|
||||
if (small_const_nbits(nbits))
|
||||
return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0;
|
||||
@ -371,8 +394,8 @@ static inline int bitmap_intersects(const unsigned long *src1,
|
||||
return __bitmap_intersects(src1, src2, nbits);
|
||||
}
|
||||
|
||||
static inline int bitmap_subset(const unsigned long *src1,
|
||||
const unsigned long *src2, unsigned int nbits)
|
||||
static inline bool bitmap_subset(const unsigned long *src1,
|
||||
const unsigned long *src2, unsigned int nbits)
|
||||
{
|
||||
if (small_const_nbits(nbits))
|
||||
return ! ((*src1 & ~(*src2)) & BITMAP_LAST_WORD_MASK(nbits));
|
||||
@ -514,10 +537,7 @@ static inline void bitmap_next_set_region(unsigned long *bitmap,
|
||||
*/
|
||||
static inline void bitmap_from_u64(unsigned long *dst, u64 mask)
|
||||
{
|
||||
dst[0] = mask & ULONG_MAX;
|
||||
|
||||
if (sizeof(mask) > sizeof(unsigned long))
|
||||
dst[1] = mask >> 32;
|
||||
bitmap_from_arr64(dst, &mask, 64);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,8 +21,8 @@ extern unsigned long _find_last_bit(const unsigned long *addr, unsigned long siz
|
||||
/**
|
||||
* find_next_bit - find the next set bit in a memory region
|
||||
* @addr: The address to base the search on
|
||||
* @offset: The bitnumber to start searching at
|
||||
* @size: The bitmap size in bits
|
||||
* @offset: The bitnumber to start searching at
|
||||
*
|
||||
* Returns the bit number for the next set bit
|
||||
* If no bits are set, returns @size.
|
||||
@ -50,8 +50,8 @@ unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
|
||||
* find_next_and_bit - find the next set bit in both memory regions
|
||||
* @addr1: The first address to base the search on
|
||||
* @addr2: The second address to base the search on
|
||||
* @offset: The bitnumber to start searching at
|
||||
* @size: The bitmap size in bits
|
||||
* @offset: The bitnumber to start searching at
|
||||
*
|
||||
* Returns the bit number for the next set bit
|
||||
* If no bits are set, returns @size.
|
||||
@ -79,8 +79,8 @@ unsigned long find_next_and_bit(const unsigned long *addr1,
|
||||
/**
|
||||
* find_next_zero_bit - find the next cleared bit in a memory region
|
||||
* @addr: The address to base the search on
|
||||
* @offset: The bitnumber to start searching at
|
||||
* @size: The bitmap size in bits
|
||||
* @offset: The bitnumber to start searching at
|
||||
*
|
||||
* Returns the bit number of the next zero bit
|
||||
* If no bits are zero, returns @size.
|
||||
|
@ -42,11 +42,11 @@
|
||||
* void nodes_shift_right(dst, src, n) Shift right
|
||||
* void nodes_shift_left(dst, src, n) Shift left
|
||||
*
|
||||
* int first_node(mask) Number lowest set bit, or MAX_NUMNODES
|
||||
* int next_node(node, mask) Next node past 'node', or MAX_NUMNODES
|
||||
* int next_node_in(node, mask) Next node past 'node', or wrap to first,
|
||||
* unsigned int first_node(mask) Number lowest set bit, or MAX_NUMNODES
|
||||
* unsigend int next_node(node, mask) Next node past 'node', or MAX_NUMNODES
|
||||
* unsigned int next_node_in(node, mask) Next node past 'node', or wrap to first,
|
||||
* or MAX_NUMNODES
|
||||
* int first_unset_node(mask) First node not set in mask, or
|
||||
* unsigned int first_unset_node(mask) First node not set in mask, or
|
||||
* MAX_NUMNODES
|
||||
*
|
||||
* nodemask_t nodemask_of_node(node) Return nodemask with bit 'node' set
|
||||
@ -153,7 +153,7 @@ static inline void __nodes_clear(nodemask_t *dstp, unsigned int nbits)
|
||||
|
||||
#define node_test_and_set(node, nodemask) \
|
||||
__node_test_and_set((node), &(nodemask))
|
||||
static inline int __node_test_and_set(int node, nodemask_t *addr)
|
||||
static inline bool __node_test_and_set(int node, nodemask_t *addr)
|
||||
{
|
||||
return test_and_set_bit(node, addr->bits);
|
||||
}
|
||||
@ -200,7 +200,7 @@ static inline void __nodes_complement(nodemask_t *dstp,
|
||||
|
||||
#define nodes_equal(src1, src2) \
|
||||
__nodes_equal(&(src1), &(src2), MAX_NUMNODES)
|
||||
static inline int __nodes_equal(const nodemask_t *src1p,
|
||||
static inline bool __nodes_equal(const nodemask_t *src1p,
|
||||
const nodemask_t *src2p, unsigned int nbits)
|
||||
{
|
||||
return bitmap_equal(src1p->bits, src2p->bits, nbits);
|
||||
@ -208,7 +208,7 @@ static inline int __nodes_equal(const nodemask_t *src1p,
|
||||
|
||||
#define nodes_intersects(src1, src2) \
|
||||
__nodes_intersects(&(src1), &(src2), MAX_NUMNODES)
|
||||
static inline int __nodes_intersects(const nodemask_t *src1p,
|
||||
static inline bool __nodes_intersects(const nodemask_t *src1p,
|
||||
const nodemask_t *src2p, unsigned int nbits)
|
||||
{
|
||||
return bitmap_intersects(src1p->bits, src2p->bits, nbits);
|
||||
@ -216,20 +216,20 @@ static inline int __nodes_intersects(const nodemask_t *src1p,
|
||||
|
||||
#define nodes_subset(src1, src2) \
|
||||
__nodes_subset(&(src1), &(src2), MAX_NUMNODES)
|
||||
static inline int __nodes_subset(const nodemask_t *src1p,
|
||||
static inline bool __nodes_subset(const nodemask_t *src1p,
|
||||
const nodemask_t *src2p, unsigned int nbits)
|
||||
{
|
||||
return bitmap_subset(src1p->bits, src2p->bits, nbits);
|
||||
}
|
||||
|
||||
#define nodes_empty(src) __nodes_empty(&(src), MAX_NUMNODES)
|
||||
static inline int __nodes_empty(const nodemask_t *srcp, unsigned int nbits)
|
||||
static inline bool __nodes_empty(const nodemask_t *srcp, unsigned int nbits)
|
||||
{
|
||||
return bitmap_empty(srcp->bits, nbits);
|
||||
}
|
||||
|
||||
#define nodes_full(nodemask) __nodes_full(&(nodemask), MAX_NUMNODES)
|
||||
static inline int __nodes_full(const nodemask_t *srcp, unsigned int nbits)
|
||||
static inline bool __nodes_full(const nodemask_t *srcp, unsigned int nbits)
|
||||
{
|
||||
return bitmap_full(srcp->bits, nbits);
|
||||
}
|
||||
@ -260,15 +260,15 @@ static inline void __nodes_shift_left(nodemask_t *dstp,
|
||||
> MAX_NUMNODES, then the silly min_ts could be dropped. */
|
||||
|
||||
#define first_node(src) __first_node(&(src))
|
||||
static inline int __first_node(const nodemask_t *srcp)
|
||||
static inline unsigned int __first_node(const nodemask_t *srcp)
|
||||
{
|
||||
return min_t(int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES));
|
||||
return min_t(unsigned int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES));
|
||||
}
|
||||
|
||||
#define next_node(n, src) __next_node((n), &(src))
|
||||
static inline int __next_node(int n, const nodemask_t *srcp)
|
||||
static inline unsigned int __next_node(int n, const nodemask_t *srcp)
|
||||
{
|
||||
return min_t(int,MAX_NUMNODES,find_next_bit(srcp->bits, MAX_NUMNODES, n+1));
|
||||
return min_t(unsigned int, MAX_NUMNODES, find_next_bit(srcp->bits, MAX_NUMNODES, n+1));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -276,7 +276,7 @@ static inline int __next_node(int n, const nodemask_t *srcp)
|
||||
* the first node in src if needed. Returns MAX_NUMNODES if src is empty.
|
||||
*/
|
||||
#define next_node_in(n, src) __next_node_in((n), &(src))
|
||||
int __next_node_in(int node, const nodemask_t *srcp);
|
||||
unsigned int __next_node_in(int node, const nodemask_t *srcp);
|
||||
|
||||
static inline void init_nodemask_of_node(nodemask_t *mask, int node)
|
||||
{
|
||||
@ -296,9 +296,9 @@ static inline void init_nodemask_of_node(nodemask_t *mask, int node)
|
||||
})
|
||||
|
||||
#define first_unset_node(mask) __first_unset_node(&(mask))
|
||||
static inline int __first_unset_node(const nodemask_t *maskp)
|
||||
static inline unsigned int __first_unset_node(const nodemask_t *maskp)
|
||||
{
|
||||
return min_t(int,MAX_NUMNODES,
|
||||
return min_t(unsigned int, MAX_NUMNODES,
|
||||
find_first_zero_bit(maskp->bits, MAX_NUMNODES));
|
||||
}
|
||||
|
||||
@ -435,11 +435,11 @@ static inline int num_node_state(enum node_states state)
|
||||
|
||||
#define first_online_node first_node(node_states[N_ONLINE])
|
||||
#define first_memory_node first_node(node_states[N_MEMORY])
|
||||
static inline int next_online_node(int nid)
|
||||
static inline unsigned int next_online_node(int nid)
|
||||
{
|
||||
return next_node(nid, node_states[N_ONLINE]);
|
||||
}
|
||||
static inline int next_memory_node(int nid)
|
||||
static inline unsigned int next_memory_node(int nid)
|
||||
{
|
||||
return next_node(nid, node_states[N_MEMORY]);
|
||||
}
|
||||
|
119
lib/bitmap.c
119
lib/bitmap.c
@ -45,19 +45,19 @@
|
||||
* for the best explanations of this ordering.
|
||||
*/
|
||||
|
||||
int __bitmap_equal(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits)
|
||||
bool __bitmap_equal(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits)
|
||||
{
|
||||
unsigned int k, lim = bits/BITS_PER_LONG;
|
||||
for (k = 0; k < lim; ++k)
|
||||
if (bitmap1[k] != bitmap2[k])
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
if (bits % BITS_PER_LONG)
|
||||
if ((bitmap1[k] ^ bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
EXPORT_SYMBOL(__bitmap_equal);
|
||||
|
||||
@ -303,33 +303,33 @@ void __bitmap_replace(unsigned long *dst,
|
||||
}
|
||||
EXPORT_SYMBOL(__bitmap_replace);
|
||||
|
||||
int __bitmap_intersects(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits)
|
||||
bool __bitmap_intersects(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits)
|
||||
{
|
||||
unsigned int k, lim = bits/BITS_PER_LONG;
|
||||
for (k = 0; k < lim; ++k)
|
||||
if (bitmap1[k] & bitmap2[k])
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
if (bits % BITS_PER_LONG)
|
||||
if ((bitmap1[k] & bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits))
|
||||
return 1;
|
||||
return 0;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
EXPORT_SYMBOL(__bitmap_intersects);
|
||||
|
||||
int __bitmap_subset(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits)
|
||||
bool __bitmap_subset(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits)
|
||||
{
|
||||
unsigned int k, lim = bits/BITS_PER_LONG;
|
||||
for (k = 0; k < lim; ++k)
|
||||
if (bitmap1[k] & ~bitmap2[k])
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
if (bits % BITS_PER_LONG)
|
||||
if ((bitmap1[k] & ~bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits))
|
||||
return 0;
|
||||
return 1;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
EXPORT_SYMBOL(__bitmap_subset);
|
||||
|
||||
@ -527,33 +527,39 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
|
||||
* cpumap_print_to_pagebuf() or directly by drivers to export hexadecimal
|
||||
* bitmask and decimal list to userspace by sysfs ABI.
|
||||
* Drivers might be using a normal attribute for this kind of ABIs. A
|
||||
* normal attribute typically has show entry as below:
|
||||
* static ssize_t example_attribute_show(struct device *dev,
|
||||
* normal attribute typically has show entry as below::
|
||||
*
|
||||
* static ssize_t example_attribute_show(struct device *dev,
|
||||
* struct device_attribute *attr, char *buf)
|
||||
* {
|
||||
* {
|
||||
* ...
|
||||
* return bitmap_print_to_pagebuf(true, buf, &mask, nr_trig_max);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* show entry of attribute has no offset and count parameters and this
|
||||
* means the file is limited to one page only.
|
||||
* bitmap_print_to_pagebuf() API works terribly well for this kind of
|
||||
* normal attribute with buf parameter and without offset, count:
|
||||
* bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
|
||||
* normal attribute with buf parameter and without offset, count::
|
||||
*
|
||||
* bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
|
||||
* int nmaskbits)
|
||||
* {
|
||||
* }
|
||||
* {
|
||||
* }
|
||||
*
|
||||
* The problem is once we have a large bitmap, we have a chance to get a
|
||||
* bitmask or list more than one page. Especially for list, it could be
|
||||
* as complex as 0,3,5,7,9,... We have no simple way to know it exact size.
|
||||
* It turns out bin_attribute is a way to break this limit. bin_attribute
|
||||
* has show entry as below:
|
||||
* static ssize_t
|
||||
* example_bin_attribute_show(struct file *filp, struct kobject *kobj,
|
||||
* has show entry as below::
|
||||
*
|
||||
* static ssize_t
|
||||
* example_bin_attribute_show(struct file *filp, struct kobject *kobj,
|
||||
* struct bin_attribute *attr, char *buf,
|
||||
* loff_t offset, size_t count)
|
||||
* {
|
||||
* {
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* With the new offset and count parameters, this makes sysfs ABI be able
|
||||
* to support file size more than one page. For example, offset could be
|
||||
* >= 4096.
|
||||
@ -577,6 +583,7 @@ static int bitmap_print_to_buf(bool list, char *buf, const unsigned long *maskp,
|
||||
* This function is not a replacement for sprintf() or bitmap_print_to_pagebuf().
|
||||
* It is intended to workaround sysfs limitations discussed above and should be
|
||||
* used carefully in general case for the following reasons:
|
||||
*
|
||||
* - Time complexity is O(nbits^2/count), comparing to O(nbits) for snprintf().
|
||||
* - Memory complexity is O(nbits), comparing to O(1) for snprintf().
|
||||
* - @off and @count are NOT offset and number of bits to print.
|
||||
@ -1505,5 +1512,59 @@ void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits)
|
||||
buf[halfwords - 1] &= (u32) (UINT_MAX >> ((-nbits) & 31));
|
||||
}
|
||||
EXPORT_SYMBOL(bitmap_to_arr32);
|
||||
|
||||
#endif
|
||||
|
||||
#if (BITS_PER_LONG == 32) && defined(__BIG_ENDIAN)
|
||||
/**
|
||||
* bitmap_from_arr64 - copy the contents of u64 array of bits to bitmap
|
||||
* @bitmap: array of unsigned longs, the destination bitmap
|
||||
* @buf: array of u64 (in host byte order), the source bitmap
|
||||
* @nbits: number of bits in @bitmap
|
||||
*/
|
||||
void bitmap_from_arr64(unsigned long *bitmap, const u64 *buf, unsigned int nbits)
|
||||
{
|
||||
int n;
|
||||
|
||||
for (n = nbits; n > 0; n -= 64) {
|
||||
u64 val = *buf++;
|
||||
|
||||
*bitmap++ = val;
|
||||
if (n > 32)
|
||||
*bitmap++ = val >> 32;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear tail bits in the last word beyond nbits.
|
||||
*
|
||||
* Negative index is OK because here we point to the word next
|
||||
* to the last word of the bitmap, except for nbits == 0, which
|
||||
* is tested implicitly.
|
||||
*/
|
||||
if (nbits % BITS_PER_LONG)
|
||||
bitmap[-1] &= BITMAP_LAST_WORD_MASK(nbits);
|
||||
}
|
||||
EXPORT_SYMBOL(bitmap_from_arr64);
|
||||
|
||||
/**
|
||||
* bitmap_to_arr64 - copy the contents of bitmap to a u64 array of bits
|
||||
* @buf: array of u64 (in host byte order), the dest bitmap
|
||||
* @bitmap: array of unsigned longs, the source bitmap
|
||||
* @nbits: number of bits in @bitmap
|
||||
*/
|
||||
void bitmap_to_arr64(u64 *buf, const unsigned long *bitmap, unsigned int nbits)
|
||||
{
|
||||
const unsigned long *end = bitmap + BITS_TO_LONGS(nbits);
|
||||
|
||||
while (bitmap < end) {
|
||||
*buf = *bitmap++;
|
||||
if (bitmap < end)
|
||||
*buf |= (u64)(*bitmap++) << 32;
|
||||
buf++;
|
||||
}
|
||||
|
||||
/* Clear tail bits in the last element of array beyond nbits. */
|
||||
if (nbits % 64)
|
||||
buf[-1] &= GENMASK_ULL(nbits % 64, 0);
|
||||
}
|
||||
EXPORT_SYMBOL(bitmap_to_arr64);
|
||||
#endif
|
||||
|
@ -3,9 +3,9 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/random.h>
|
||||
|
||||
int __next_node_in(int node, const nodemask_t *srcp)
|
||||
unsigned int __next_node_in(int node, const nodemask_t *srcp)
|
||||
{
|
||||
int ret = __next_node(node, srcp);
|
||||
unsigned int ret = __next_node(node, srcp);
|
||||
|
||||
if (ret == MAX_NUMNODES)
|
||||
ret = __first_node(srcp);
|
||||
|
@ -585,6 +585,30 @@ static void __init test_bitmap_arr32(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void __init test_bitmap_arr64(void)
|
||||
{
|
||||
unsigned int nbits, next_bit;
|
||||
u64 arr[EXP1_IN_BITS / 64];
|
||||
DECLARE_BITMAP(bmap2, EXP1_IN_BITS);
|
||||
|
||||
memset(arr, 0xa5, sizeof(arr));
|
||||
|
||||
for (nbits = 0; nbits < EXP1_IN_BITS; ++nbits) {
|
||||
memset(bmap2, 0xff, sizeof(arr));
|
||||
bitmap_to_arr64(arr, exp1, nbits);
|
||||
bitmap_from_arr64(bmap2, arr, nbits);
|
||||
expect_eq_bitmap(bmap2, exp1, nbits);
|
||||
|
||||
next_bit = find_next_bit(bmap2, round_up(nbits, BITS_PER_LONG), nbits);
|
||||
if (next_bit < round_up(nbits, BITS_PER_LONG))
|
||||
pr_err("bitmap_copy_arr64(nbits == %d:"
|
||||
" tail is not safely cleared: %d\n", nbits, next_bit);
|
||||
|
||||
if (nbits < EXP1_IN_BITS - 64)
|
||||
expect_eq_uint(arr[DIV_ROUND_UP(nbits, 64)], 0xa5a5a5a5);
|
||||
}
|
||||
}
|
||||
|
||||
static void noinline __init test_mem_optimisations(void)
|
||||
{
|
||||
DECLARE_BITMAP(bmap1, 1024);
|
||||
@ -852,6 +876,7 @@ static void __init selftest(void)
|
||||
test_copy();
|
||||
test_replace();
|
||||
test_bitmap_arr32();
|
||||
test_bitmap_arr64();
|
||||
test_bitmap_parse();
|
||||
test_bitmap_parselist();
|
||||
test_bitmap_printlist();
|
||||
|
@ -2049,7 +2049,7 @@ static void __init init_cpu_node_state(void)
|
||||
int node;
|
||||
|
||||
for_each_online_node(node) {
|
||||
if (cpumask_weight(cpumask_of_node(node)) > 0)
|
||||
if (!cpumask_empty(cpumask_of_node(node)))
|
||||
node_set_state(node, N_CPU);
|
||||
}
|
||||
}
|
||||
@ -2081,7 +2081,7 @@ static int vmstat_cpu_dead(unsigned int cpu)
|
||||
|
||||
refresh_zone_stat_thresholds();
|
||||
node_cpus = cpumask_of_node(node);
|
||||
if (cpumask_weight(node_cpus) > 0)
|
||||
if (!cpumask_empty(node_cpus))
|
||||
return 0;
|
||||
|
||||
node_clear_state(node, N_CPU);
|
||||
|
@ -16,11 +16,11 @@ void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, int bits);
|
||||
int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits);
|
||||
int __bitmap_equal(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits);
|
||||
bool __bitmap_equal(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits);
|
||||
void bitmap_clear(unsigned long *map, unsigned int start, int len);
|
||||
int __bitmap_intersects(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits);
|
||||
bool __bitmap_intersects(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits);
|
||||
|
||||
#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
|
||||
#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
|
||||
@ -162,8 +162,8 @@ static inline int bitmap_and(unsigned long *dst, const unsigned long *src1,
|
||||
#define BITMAP_MEM_MASK (BITMAP_MEM_ALIGNMENT - 1)
|
||||
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
|
||||
|
||||
static inline int bitmap_equal(const unsigned long *src1,
|
||||
const unsigned long *src2, unsigned int nbits)
|
||||
static inline bool bitmap_equal(const unsigned long *src1,
|
||||
const unsigned long *src2, unsigned int nbits)
|
||||
{
|
||||
if (small_const_nbits(nbits))
|
||||
return !((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits));
|
||||
@ -173,8 +173,9 @@ static inline int bitmap_equal(const unsigned long *src1,
|
||||
return __bitmap_equal(src1, src2, nbits);
|
||||
}
|
||||
|
||||
static inline int bitmap_intersects(const unsigned long *src1,
|
||||
const unsigned long *src2, unsigned int nbits)
|
||||
static inline bool bitmap_intersects(const unsigned long *src1,
|
||||
const unsigned long *src2,
|
||||
unsigned int nbits)
|
||||
{
|
||||
if (small_const_nbits(nbits))
|
||||
return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0;
|
||||
|
@ -72,31 +72,31 @@ int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
|
||||
return result != 0;
|
||||
}
|
||||
|
||||
int __bitmap_equal(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits)
|
||||
bool __bitmap_equal(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits)
|
||||
{
|
||||
unsigned int k, lim = bits/BITS_PER_LONG;
|
||||
for (k = 0; k < lim; ++k)
|
||||
if (bitmap1[k] != bitmap2[k])
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
if (bits % BITS_PER_LONG)
|
||||
if ((bitmap1[k] ^ bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits))
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
int __bitmap_intersects(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits)
|
||||
bool __bitmap_intersects(const unsigned long *bitmap1,
|
||||
const unsigned long *bitmap2, unsigned int bits)
|
||||
{
|
||||
unsigned int k, lim = bits/BITS_PER_LONG;
|
||||
for (k = 0; k < lim; ++k)
|
||||
if (bitmap1[k] & bitmap2[k])
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
if (bits % BITS_PER_LONG)
|
||||
if ((bitmap1[k] & bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits))
|
||||
return 1;
|
||||
return 0;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user