* [GIT PULL] Bitmap patches for v5.19-rc1
@ 2022-05-27 15:43 Yury Norov
2022-05-28 4:17 ` Linus Torvalds
0 siblings, 1 reply; 6+ messages in thread
From: Yury Norov @ 2022-05-27 15:43 UTC (permalink / raw)
To: Linus Torvalds, Linux Kernel Mailing List
Cc: Yury Norov, Andy Shevchenko, Rasmus Villemoes
Hi Linus,
The following changes since commit ce522ba9ef7e2d9fb22a39eb3371c0c64e2a433e:
Linux 5.18-rc2 (2022-04-10 14:21:36 -1000)
are available in the Git repository at:
https://github.com/norov/linux.git/ tags/bitmap-for-5.19-rc1
for you to fetch changes up to db7b4edf37fe9872bec4d1537d67c4c9f95810b6:
nodemask: Fix return values to be unsigned (2022-05-23 13:17:07 -0700)
----------------------------------------------------------------
Bitmap patches for 5.19-rc1
This series includes the following patch-sets:
- 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.
----------------------------------------------------------------
Anna-Maria Behnsen (1):
include/linux/find: Fix documentation
Kees Cook (2):
bitmap: Fix return values to be unsigned
nodemask: Fix return values to be unsigned
Mauro Carvalho Chehab (1):
lib/bitmap.c make bitmap_print_bitmask_to_buf parseable
Yury Norov (51):
net: dsa: don't use bitmap_weight() in b53_arl_read()
net: systemport: don't use bitmap_weight() in bcm_sysport_rule_set()
net: mellanox: fix open-coded for_each_set_bit()
iio: fix opencoded for_each_set_bit()
qed: rework qed_rdma_bmap_free()
KVM: x86: replace bitmap_weight with bitmap_empty where appropriate
octeontx2-pf: replace bitmap_weight with bitmap_empty where appropriate
qed: replace bitmap_weight with bitmap_empty in qed_roce_stop()
arch/alpha: replace cpumask_weight with cpumask_empty where appropriate
arch/ia64: replace cpumask_weight with cpumask_empty where appropriate
arch/x86: replace cpumask_weight with cpumask_empty where appropriate
drm/i915/pmu: replace cpumask_weight with cpumask_empty where appropriate
irq: mips: replace cpumask_weight with cpumask_empty where appropriate
genirq/affinity: replace cpumask_weight with cpumask_empty where appropriate
clocksource: replace cpumask_weight with cpumask_empty in clocksource.c
mm/vmstat: replace cpumask_weight with cpumask_empty where appropriate
arch/x86: replace nodes_weight with nodes_empty where appropriate
bitmap: add bitmap_weight_{cmp, eq, gt, ge, lt, le} functions
arch/x86: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le} where appropriate
iio: replace bitmap_weight() with bitmap_weight_{eq,gt} where appropriate
memstick: replace bitmap_weight with bitmap_weight_eq where appropriate
ixgbe: replace bitmap_weight with bitmap_weight_eq
octeontx2-pf: replace bitmap_weight with bitmap_weight_{eq,gt}
mlx4: replace bitmap_weight with bitmap_weight_{eq,gt,ge,lt,le}
perf: replace bitmap_weight with bitmap_weight_eq for ThunderX2
media: tegra-video: replace bitmap_weight with bitmap_weight_le
cpumask: add cpumask_weight_{eq,gt,ge,lt,le}
arch/ia64: replace cpumask_weight with cpumask_weight_eq in mm/tlb.c
arch/mips: replace cpumask_weight with cpumask_weight_{eq, ...} where appropriate
arch/powerpc: replace cpumask_weight with cpumask_weight_{eq, ...} where appropriate
arch/s390: replace cpumask_weight with cpumask_weight_eq where appropriate
firmware: psci: replace cpumask_weight with cpumask_weight_eq
RDMA/hfi1: replace cpumask_weight with cpumask_weight_{eq, ...} where appropriate
scsi: lpfc: replace cpumask_weight with cpumask_weight_gt
soc/qman: replace cpumask_weight with cpumask_weight_lt
nodemask: add nodemask_weight_{eq,gt,ge,lt,le}
ACPI: replace nodes__weight with nodes_weight_ge for numa
mm/mempolicy: replace nodes_weight with nodes_weight_eq
nodemask: add num_node_state_eq()
tools: bitmap: sync bitmap_weight
MAINTAINERS: add cpumask and nodemask files to BITMAP_API
lib/bitmap: extend comment for bitmap_(from,to)_arr32()
lib: add bitmap_{from,to}_arr64
lib/bitmap: add test for bitmap_{from,to}_arr64
KVM: s390: replace bitmap_copy with bitmap_{from,to}_arr64 where appropriate
drm/amd/pm: use bitmap_{from,to}_arr32 where appropriate
ia64: cleanup remove_siblinginfo()
cpufreq: use cpumask_weight_gt() in policy_is_shared()
KVM: x86: hyper-v: fix type of valid_bank_mask
KVM: x86: hyper-v: replace bitmap_weight() with hweight64()
risc-v: replace bitmap_weight with bitmap_empty in riscv_fill_hwcap()
MAINTAINERS | 4 +
arch/alpha/kernel/process.c | 2 +-
arch/ia64/kernel/setup.c | 2 +-
arch/ia64/kernel/smpboot.c | 4 -
arch/ia64/mm/tlb.c | 2 +-
arch/mips/cavium-octeon/octeon-irq.c | 4 +-
arch/mips/kernel/crash.c | 2 +-
arch/powerpc/kernel/smp.c | 2 +-
arch/powerpc/kernel/watchdog.c | 2 +-
arch/powerpc/xmon/xmon.c | 4 +-
arch/riscv/kernel/cpufeature.c | 7 +-
arch/s390/kernel/perf_cpum_cf.c | 2 +-
arch/s390/kvm/kvm-s390.c | 10 +-
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 +--
arch/x86/kvm/hyperv.c | 14 +--
arch/x86/mm/amdtopology.c | 2 +-
arch/x86/mm/mmio-mod.c | 2 +-
arch/x86/mm/numa_emulation.c | 4 +-
arch/x86/platform/uv/uv_nmi.c | 2 +-
drivers/acpi/numa/srat.c | 2 +-
drivers/firmware/psci/psci_checker.c | 2 +-
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 +-
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 +-
drivers/gpu/drm/i915/i915_pmu.c | 2 +-
drivers/iio/dummy/iio_simple_dummy_buffer.c | 48 +++----
drivers/iio/industrialio-trigger.c | 2 +-
drivers/infiniband/hw/hfi1/affinity.c | 9 +-
drivers/infiniband/hw/qib/qib_file_ops.c | 2 +-
drivers/infiniband/hw/qib/qib_iba7322.c | 2 +-
drivers/irqchip/irq-bcm6345-l1.c | 2 +-
drivers/memstick/core/ms_block.c | 4 +-
drivers/net/dsa/b53/b53_common.c | 6 +-
drivers/net/ethernet/broadcom/bcmsysport.c | 6 +-
drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c | 2 +-
.../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 2 +-
.../ethernet/marvell/octeontx2/nic/otx2_flows.c | 8 +-
.../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 2 +-
drivers/net/ethernet/mellanox/mlx4/cmd.c | 33 ++---
drivers/net/ethernet/mellanox/mlx4/eq.c | 4 +-
drivers/net/ethernet/mellanox/mlx4/fw.c | 4 +-
drivers/net/ethernet/mellanox/mlx4/main.c | 2 +-
drivers/net/ethernet/qlogic/qed/qed_rdma.c | 45 +++----
drivers/net/ethernet/qlogic/qed/qed_roce.c | 2 +-
drivers/perf/thunderx2_pmu.c | 4 +-
drivers/scsi/lpfc/lpfc_init.c | 2 +-
drivers/soc/fsl/qbman/qman_test_stash.c | 2 +-
drivers/staging/media/tegra-video/vi.c | 2 +-
include/linux/bitmap.h | 139 ++++++++++++++++++---
include/linux/cpufreq.h | 2 +-
include/linux/cpumask.h | 50 ++++++++
include/linux/find.h | 6 +-
include/linux/nodemask.h | 78 +++++++++---
kernel/irq/affinity.c | 2 +-
kernel/time/clocksource.c | 2 +-
lib/bitmap.c | 138 +++++++++++++++-----
lib/nodemask.c | 4 +-
lib/test_bitmap.c | 25 ++++
mm/mempolicy.c | 2 +-
mm/page_alloc.c | 2 +-
mm/vmstat.c | 4 +-
tools/include/linux/bitmap.h | 60 +++++++--
tools/lib/bitmap.c | 40 ++++--
tools/perf/util/pmu.c | 2 +-
63 files changed, 578 insertions(+), 270 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [GIT PULL] Bitmap patches for v5.19-rc1
2022-05-27 15:43 [GIT PULL] Bitmap patches for v5.19-rc1 Yury Norov
@ 2022-05-28 4:17 ` Linus Torvalds
2022-06-01 1:15 ` Yury Norov
0 siblings, 1 reply; 6+ messages in thread
From: Linus Torvalds @ 2022-05-28 4:17 UTC (permalink / raw)
To: Yury Norov; +Cc: Linux Kernel Mailing List, Andy Shevchenko, Rasmus Villemoes
On Fri, May 27, 2022 at 8:44 AM Yury Norov <yury.norov@gmail.com> wrote:
>
> bitmap: add bitmap_weight_{cmp, eq, gt, ge, lt, le} functions
So honestly, I pulled this, looked at the code, and then unpulled it again.
This is not helping.
Making changes like this:
- if (mm != current->active_mm || cpumask_weight(mm_cpumask(mm)) != 1) {
+ if (mm != current->active_mm || !cpumask_weight_eq(mm_cpumask(mm), 1)) {
only makes the code harder to understand.
And it gets worse:
- if (cpumask_weight(mask) > cpumask_weight(sibling_mask(cpu)))
+ if (cpumask_weight_gt(mask, cpumask_weight(sibling_mask(cpu))))
is just disgusting. That original line is simple to read and makes
sense. That new replacement really makes you do "Whaa?"
Now, I understand that these kinds of helper functions could make for
slightly more efficient code in that you can break out of the bitmap
scanning early when you have found enough bits set. I get it.
BUT.
(a) code legibility is really really important
(b) the places I found this weren't that performance-critical.
(c) in most cases, the bitmaps in question are one single word
so I'm unpulling this again.
Now, some other parts of the pull were clear improvements. For
example, the hyperv changes like this:
- if (hc->var_cnt != bitmap_weight((unsigned long
*)&valid_bank_mask, 64))
+ if (hc->var_cnt != hweight64(valid_bank_mask))
were clear improvements where the old code was disgusting, and clearly
improved by the change.
But the "bitmap_weight_cmp()" functions (and the cpumask_weight_cmp()
ones) are just not a direction we want to go.
The special case of zero (ie "cpumask_weight() == 0" ->
"bitmap_empty()") is one thing: making that kind of change tends to
keep the code legible or even make it more understandable. So I didn't
mind that. But I do mind the pointlessly complex new arbitrary weight
comparisons, and the kind of mental cost they have.
There are people in the CS world that think "abstractions are always
good". Those people are very very wrong.
Linus
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [GIT PULL] Bitmap patches for v5.19-rc1
2022-05-28 4:17 ` Linus Torvalds
@ 2022-06-01 1:15 ` Yury Norov
0 siblings, 0 replies; 6+ messages in thread
From: Yury Norov @ 2022-06-01 1:15 UTC (permalink / raw)
To: Linus Torvalds
Cc: Linux Kernel Mailing List, Andy Shevchenko, Rasmus Villemoes
On Fri, May 27, 2022 at 09:17:21PM -0700, Linus Torvalds wrote:
> On Fri, May 27, 2022 at 8:44 AM Yury Norov <yury.norov@gmail.com> wrote:
> >
> > bitmap: add bitmap_weight_{cmp, eq, gt, ge, lt, le} functions
>
> So honestly, I pulled this, looked at the code, and then unpulled it again.
>
> This is not helping.
>
> Making changes like this:
>
> - if (mm != current->active_mm || cpumask_weight(mm_cpumask(mm)) != 1) {
> + if (mm != current->active_mm || !cpumask_weight_eq(mm_cpumask(mm), 1)) {
>
> only makes the code harder to understand.
>
> And it gets worse:
>
> - if (cpumask_weight(mask) > cpumask_weight(sibling_mask(cpu)))
> + if (cpumask_weight_gt(mask, cpumask_weight(sibling_mask(cpu))))
>
> is just disgusting. That original line is simple to read and makes
> sense. That new replacement really makes you do "Whaa?"
>
> Now, I understand that these kinds of helper functions could make for
> slightly more efficient code in that you can break out of the bitmap
> scanning early when you have found enough bits set. I get it.
>
> BUT.
>
> (a) code legibility is really really important
>
> (b) the places I found this weren't that performance-critical.
>
> (c) in most cases, the bitmaps in question are one single word
>
> so I'm unpulling this again.
>
> Now, some other parts of the pull were clear improvements. For
> example, the hyperv changes like this:
>
> - if (hc->var_cnt != bitmap_weight((unsigned long
> *)&valid_bank_mask, 64))
> + if (hc->var_cnt != hweight64(valid_bank_mask))
>
> were clear improvements where the old code was disgusting, and clearly
> improved by the change.
>
> But the "bitmap_weight_cmp()" functions (and the cpumask_weight_cmp()
> ones) are just not a direction we want to go.
>
> The special case of zero (ie "cpumask_weight() == 0" ->
> "bitmap_empty()") is one thing: making that kind of change tends to
> keep the code legible or even make it more understandable. So I didn't
> mind that. But I do mind the pointlessly complex new arbitrary weight
> comparisons, and the kind of mental cost they have.
>
> There are people in the CS world that think "abstractions are always
> good". Those people are very very wrong.
Ok, I'll send a new pull with all but bitmap_weight_cmp() patches.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [GIT PULL] Bitmap patches for v5.19-rc1
@ 2022-06-03 19:46 Yury Norov
2022-06-04 21:20 ` pr-tracker-bot
2022-06-04 21:24 ` Linus Torvalds
0 siblings, 2 replies; 6+ messages in thread
From: Yury Norov @ 2022-06-03 19:46 UTC (permalink / raw)
To: Linus Torvalds, Linux Kernel Mailing List
Cc: Yury Norov, Andy Shevchenko, Rasmus Villemoes
Hi Linus,
This is a shorter version of the original pull request for 5.19:
https://lkml.org/lkml/2022/5/27/1096
with all bitmap_weight_cmp() patches excluded.
Please, pull.
Thanks,
Yury
The following changes since commit ce522ba9ef7e2d9fb22a39eb3371c0c64e2a433e:
Linux 5.18-rc2 (2022-04-10 14:21:36 -1000)
are available in the Git repository at:
git@github.com:/norov/linux.git tags/bitmap-for-5.19-rc1
for you to fetch changes up to 0dfe54071d7c828a02917b595456bfde1afdddc9:
nodemask: Fix return values to be unsigned (2022-06-03 06:52:58 -0700)
----------------------------------------------------------------
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.
----------------------------------------------------------------
Anna-Maria Behnsen (1):
include/linux/find: Fix documentation
Kees Cook (2):
bitmap: Fix return values to be unsigned
nodemask: Fix return values to be unsigned
Mauro Carvalho Chehab (1):
lib/bitmap.c make bitmap_print_bitmask_to_buf parseable
Yury Norov (27):
net: dsa: don't use bitmap_weight() in b53_arl_read()
net: systemport: don't use bitmap_weight() in bcm_sysport_rule_set()
net: mellanox: fix open-coded for_each_set_bit()
iio: fix opencoded for_each_set_bit()
qed: rework qed_rdma_bmap_free()
KVM: x86: replace bitmap_weight with bitmap_empty where appropriate
octeontx2-pf: replace bitmap_weight with bitmap_empty where appropriate
qed: replace bitmap_weight with bitmap_empty in qed_roce_stop()
risc-v: replace bitmap_weight with bitmap_empty in riscv_fill_hwcap()
arch/alpha: replace cpumask_weight with cpumask_empty where appropriate
arch/ia64: replace cpumask_weight with cpumask_empty where appropriate
arch/x86: replace cpumask_weight with cpumask_empty where appropriate
drm/i915/pmu: replace cpumask_weight with cpumask_empty where appropriate
irq: mips: replace cpumask_weight with cpumask_empty where appropriate
genirq/affinity: replace cpumask_weight with cpumask_empty where appropriate
clocksource: replace cpumask_weight with cpumask_empty in clocksource.c
mm/vmstat: replace cpumask_weight with cpumask_empty where appropriate
arch/x86: replace nodes_weight with nodes_empty where appropriate
MAINTAINERS: add cpumask and nodemask files to BITMAP_API
lib/bitmap: extend comment for bitmap_(from,to)_arr32()
lib: add bitmap_{from,to}_arr64
lib/bitmap: add test for bitmap_{from,to}_arr64
KVM: s390: replace bitmap_copy with bitmap_{from,to}_arr64 where appropriate
drm/amd/pm: use bitmap_{from,to}_arr32 where appropriate
ia64: cleanup remove_siblinginfo()
KVM: x86: hyper-v: fix type of valid_bank_mask
KVM: x86: hyper-v: replace bitmap_weight() with hweight64()
MAINTAINERS | 4 +
arch/alpha/kernel/process.c | 2 +-
arch/ia64/kernel/setup.c | 2 +-
arch/ia64/kernel/smpboot.c | 4 -
arch/riscv/kernel/cpufeature.c | 7 +-
arch/s390/kvm/kvm-s390.c | 10 +-
arch/x86/kernel/cpu/resctrl/rdtgroup.c | 14 +--
arch/x86/kvm/hyperv.c | 14 +--
arch/x86/mm/amdtopology.c | 2 +-
arch/x86/mm/mmio-mod.c | 2 +-
arch/x86/mm/numa_emulation.c | 4 +-
arch/x86/platform/uv/uv_nmi.c | 2 +-
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 +-
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 2 +-
drivers/gpu/drm/i915/i915_pmu.c | 2 +-
drivers/iio/dummy/iio_simple_dummy_buffer.c | 48 ++++-----
drivers/irqchip/irq-bcm6345-l1.c | 2 +-
drivers/net/dsa/b53/b53_common.c | 6 +-
drivers/net/ethernet/broadcom/bcmsysport.c | 6 +-
.../ethernet/marvell/octeontx2/nic/otx2_flows.c | 4 +-
.../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 2 +-
drivers/net/ethernet/mellanox/mlx4/cmd.c | 23 ++--
drivers/net/ethernet/qlogic/qed/qed_rdma.c | 45 +++-----
drivers/net/ethernet/qlogic/qed/qed_roce.c | 2 +-
include/linux/bitmap.h | 56 ++++++----
include/linux/find.h | 6 +-
include/linux/nodemask.h | 38 +++----
kernel/irq/affinity.c | 2 +-
kernel/time/clocksource.c | 2 +-
lib/bitmap.c | 117 ++++++++++++++++-----
lib/nodemask.c | 4 +-
lib/test_bitmap.c | 25 +++++
mm/vmstat.c | 4 +-
tools/include/linux/bitmap.h | 17 +--
tools/lib/bitmap.c | 20 ++--
35 files changed, 279 insertions(+), 223 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [GIT PULL] Bitmap patches for v5.19-rc1
2022-06-03 19:46 Yury Norov
@ 2022-06-04 21:20 ` pr-tracker-bot
2022-06-04 21:24 ` Linus Torvalds
1 sibling, 0 replies; 6+ messages in thread
From: pr-tracker-bot @ 2022-06-04 21:20 UTC (permalink / raw)
To: Yury Norov
Cc: Linus Torvalds, Linux Kernel Mailing List, Yury Norov,
Andy Shevchenko, Rasmus Villemoes
The pull request you sent on Fri, 3 Jun 2022 12:46:06 -0700:
> git@github.com:/norov/linux.git tags/bitmap-for-5.19-rc1
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/d0e60d46bc03252b8d4ffaaaa0b371970ac16cda
Thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [GIT PULL] Bitmap patches for v5.19-rc1
2022-06-03 19:46 Yury Norov
2022-06-04 21:20 ` pr-tracker-bot
@ 2022-06-04 21:24 ` Linus Torvalds
1 sibling, 0 replies; 6+ messages in thread
From: Linus Torvalds @ 2022-06-04 21:24 UTC (permalink / raw)
To: Yury Norov; +Cc: Linux Kernel Mailing List, Andy Shevchenko, Rasmus Villemoes
On Fri, Jun 3, 2022 at 12:48 PM Yury Norov <yury.norov@gmail.com> wrote:
>
> arch/ia64: replace cpumask_weight with cpumask_empty where appropriate
As you can tell from the pr-tracker-bot reply, I've pulled this.
But I did want to point out that this patch should probably have gone further.
That first argument to per_cpu_scan_finalize() is kind of ugly, but it
should probably have been something like
n = cpumask_weight(&early_cpu_possible_map) ? : 32;
instead of doing *both* cpumask_weight() and cpumask_empty().
The only case cpumask_empty() can be optimized if it's not entirely
empty, but that's the also the case where that code then ends up
calling cpumask_weight() to get the final result.
Note: I don't really care. This is ia64 boot-time setup code, so it's
not like performance matters. It's dead and irrelevant. I just reacted
to "that patch tries to micro-optimize the code, but is missing the
forest for the trees".
Linus
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-06-04 21:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-27 15:43 [GIT PULL] Bitmap patches for v5.19-rc1 Yury Norov
2022-05-28 4:17 ` Linus Torvalds
2022-06-01 1:15 ` Yury Norov
2022-06-03 19:46 Yury Norov
2022-06-04 21:20 ` pr-tracker-bot
2022-06-04 21:24 ` Linus Torvalds
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).