public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] cleanup dead code in nodemasks and cpumasks
@ 2025-03-13  2:19 Yury Norov
  2025-03-13  2:19 ` [PATCH 1/4] nodemask: drop nodes_shift Yury Norov
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Yury Norov @ 2025-03-13  2:19 UTC (permalink / raw)
  To: linux-kernel, linux-riscv
  Cc: Yury Norov, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Rasmus Villemoes, Charlie Jenkins, Alexandre Ghiti,
	Samuel Holland, Anup Patel

Cleanup dead code in nodemasks and cpumasks, and while there, fix
set_icache_stale_mask() that misuses atomic cpumask_assign_cpu().

Yury Norov (4):
  nodemask: drop nodes_shift
  cpumask: add non-atomic __assign_cpu()
  riscv: switch set_icache_stale_mask() to using non-atomic assign_cpu()
  cpumask: drop cpumask_assign_cpu()

 arch/riscv/mm/cacheflush.c |  2 +-
 include/linux/cpumask.h    | 19 +++----------------
 include/linux/nodemask.h   | 19 -------------------
 3 files changed, 4 insertions(+), 36 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] nodemask: drop nodes_shift
  2025-03-13  2:19 [PATCH 0/4] cleanup dead code in nodemasks and cpumasks Yury Norov
@ 2025-03-13  2:19 ` Yury Norov
  2025-03-13  2:19 ` [PATCH 2/4] cpumask: add non-atomic __assign_cpu() Yury Norov
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Yury Norov @ 2025-03-13  2:19 UTC (permalink / raw)
  To: linux-kernel, linux-riscv
  Cc: Yury Norov, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Rasmus Villemoes, Charlie Jenkins, Alexandre Ghiti,
	Samuel Holland, Anup Patel

nodes_shift_{left,right} are not used. Drop them.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 include/linux/nodemask.h | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index 9fd7a0ce9c1a..b1a26ef5912e 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -39,9 +39,6 @@
  * int nodes_full(mask)			Is mask full (all bits sets)?
  * int nodes_weight(mask)		Hamming weight - number of set bits
  *
- * void nodes_shift_right(dst, src, n)	Shift right
- * void nodes_shift_left(dst, src, n)	Shift left
- *
  * 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,
@@ -241,22 +238,6 @@ static __always_inline int __nodes_weight(const nodemask_t *srcp, unsigned int n
 	return bitmap_weight(srcp->bits, nbits);
 }
 
-#define nodes_shift_right(dst, src, n) \
-			__nodes_shift_right(&(dst), &(src), (n), MAX_NUMNODES)
-static __always_inline void __nodes_shift_right(nodemask_t *dstp,
-					const nodemask_t *srcp, int n, int nbits)
-{
-	bitmap_shift_right(dstp->bits, srcp->bits, n, nbits);
-}
-
-#define nodes_shift_left(dst, src, n) \
-			__nodes_shift_left(&(dst), &(src), (n), MAX_NUMNODES)
-static __always_inline void __nodes_shift_left(nodemask_t *dstp,
-					const nodemask_t *srcp, int n, int nbits)
-{
-	bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
-}
-
 /* FIXME: better would be to fix all architectures to never return
           > MAX_NUMNODES, then the silly min_ts could be dropped. */
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] cpumask: add non-atomic __assign_cpu()
  2025-03-13  2:19 [PATCH 0/4] cleanup dead code in nodemasks and cpumasks Yury Norov
  2025-03-13  2:19 ` [PATCH 1/4] nodemask: drop nodes_shift Yury Norov
@ 2025-03-13  2:19 ` Yury Norov
  2025-03-13  2:19 ` [PATCH 3/4] riscv: switch set_icache_stale_mask() to using non-atomic assign_cpu() Yury Norov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Yury Norov @ 2025-03-13  2:19 UTC (permalink / raw)
  To: linux-kernel, linux-riscv
  Cc: Yury Norov, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Rasmus Villemoes, Charlie Jenkins, Alexandre Ghiti,
	Samuel Holland, Anup Patel

Similarly to atomic, add a non-atomic version.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 include/linux/cpumask.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 9289d4612170..f8caa025c6bb 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -1074,6 +1074,9 @@ void init_cpu_possible(const struct cpumask *src);
 #define assign_cpu(cpu, mask, val)	\
 	assign_bit(cpumask_check(cpu), cpumask_bits(mask), (val))
 
+#define __assign_cpu(cpu, mask, val)	\
+	__assign_bit(cpumask_check(cpu), cpumask_bits(mask), (val))
+
 #define set_cpu_possible(cpu, possible)	assign_cpu((cpu), &__cpu_possible_mask, (possible))
 #define set_cpu_enabled(cpu, enabled)	assign_cpu((cpu), &__cpu_enabled_mask, (enabled))
 #define set_cpu_present(cpu, present)	assign_cpu((cpu), &__cpu_present_mask, (present))
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] riscv: switch set_icache_stale_mask() to using non-atomic assign_cpu()
  2025-03-13  2:19 [PATCH 0/4] cleanup dead code in nodemasks and cpumasks Yury Norov
  2025-03-13  2:19 ` [PATCH 1/4] nodemask: drop nodes_shift Yury Norov
  2025-03-13  2:19 ` [PATCH 2/4] cpumask: add non-atomic __assign_cpu() Yury Norov
@ 2025-03-13  2:19 ` Yury Norov
  2025-03-13  2:19 ` [PATCH 4/4] cpumask: drop cpumask_assign_cpu() Yury Norov
  2025-03-24 15:02 ` [PATCH 0/4] cleanup dead code in nodemasks and cpumasks Yury Norov
  4 siblings, 0 replies; 6+ messages in thread
From: Yury Norov @ 2025-03-13  2:19 UTC (permalink / raw)
  To: linux-kernel, linux-riscv
  Cc: Yury Norov, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Rasmus Villemoes, Charlie Jenkins, Alexandre Ghiti,
	Samuel Holland, Anup Patel

The atomic cpumask_assign_cpu() follows non-atomic cpumask_setall(),
which makes the whole operation non-atomic. Fix this by relaxing to
non-atomic __assign_cpu().

Fixes: 7c1e5b9690b0e14 ("riscv: Disable preemption while handling PR_RISCV_CTX_SW_FENCEI_OFF")
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 arch/riscv/mm/cacheflush.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c
index b81672729887..b8e96dfff19d 100644
--- a/arch/riscv/mm/cacheflush.c
+++ b/arch/riscv/mm/cacheflush.c
@@ -172,7 +172,7 @@ static void set_icache_stale_mask(void)
 	stale_cpu = cpumask_test_cpu(cpu, mask);
 
 	cpumask_setall(mask);
-	cpumask_assign_cpu(cpu, mask, stale_cpu);
+	__assign_cpu(cpu, mask, stale_cpu);
 	put_cpu();
 }
 #endif
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] cpumask: drop cpumask_assign_cpu()
  2025-03-13  2:19 [PATCH 0/4] cleanup dead code in nodemasks and cpumasks Yury Norov
                   ` (2 preceding siblings ...)
  2025-03-13  2:19 ` [PATCH 3/4] riscv: switch set_icache_stale_mask() to using non-atomic assign_cpu() Yury Norov
@ 2025-03-13  2:19 ` Yury Norov
  2025-03-24 15:02 ` [PATCH 0/4] cleanup dead code in nodemasks and cpumasks Yury Norov
  4 siblings, 0 replies; 6+ messages in thread
From: Yury Norov @ 2025-03-13  2:19 UTC (permalink / raw)
  To: linux-kernel, linux-riscv
  Cc: Yury Norov, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Rasmus Villemoes, Charlie Jenkins, Alexandre Ghiti,
	Samuel Holland, Anup Patel

Commit decde1fa209323c7 ("cpumask: Add assign cpu") was merged bypassing
cpumasks reviewers. It adds atomic and non-atomic cpumask_assign_cpu()
helpers.

In the same merge window, commit 5c563ee90a22d3 ("cpumask: introduce
assign_cpu() macro") added the same functionality. So now we have it
duplicated.

__cpumask_assign_cpu() has never been used since introducing, and because
this series reworks the only user of cpumask_assign_cpu(), both functions
become a dead code.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 include/linux/cpumask.h | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index f8caa025c6bb..ddeefb2744b1 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -558,22 +558,6 @@ static __always_inline void __cpumask_clear_cpu(int cpu, struct cpumask *dstp)
 	__clear_bit(cpumask_check(cpu), cpumask_bits(dstp));
 }
 
-/**
- * cpumask_assign_cpu - assign a cpu in a cpumask
- * @cpu: cpu number (< nr_cpu_ids)
- * @dstp: the cpumask pointer
- * @bool: the value to assign
- */
-static __always_inline void cpumask_assign_cpu(int cpu, struct cpumask *dstp, bool value)
-{
-	assign_bit(cpumask_check(cpu), cpumask_bits(dstp), value);
-}
-
-static __always_inline void __cpumask_assign_cpu(int cpu, struct cpumask *dstp, bool value)
-{
-	__assign_bit(cpumask_check(cpu), cpumask_bits(dstp), value);
-}
-
 /**
  * cpumask_test_cpu - test for a cpu in a cpumask
  * @cpu: cpu number (< nr_cpu_ids)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] cleanup dead code in nodemasks and cpumasks
  2025-03-13  2:19 [PATCH 0/4] cleanup dead code in nodemasks and cpumasks Yury Norov
                   ` (3 preceding siblings ...)
  2025-03-13  2:19 ` [PATCH 4/4] cpumask: drop cpumask_assign_cpu() Yury Norov
@ 2025-03-24 15:02 ` Yury Norov
  4 siblings, 0 replies; 6+ messages in thread
From: Yury Norov @ 2025-03-24 15:02 UTC (permalink / raw)
  To: linux-kernel, linux-riscv
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Rasmus Villemoes,
	Charlie Jenkins, Alexandre Ghiti, Samuel Holland, Anup Patel

Ping?

If no objections, I'll schedule it for 6.15.

On Wed, Mar 12, 2025 at 10:19:48PM -0400, Yury Norov wrote:
> Cleanup dead code in nodemasks and cpumasks, and while there, fix
> set_icache_stale_mask() that misuses atomic cpumask_assign_cpu().
> 
> Yury Norov (4):
>   nodemask: drop nodes_shift
>   cpumask: add non-atomic __assign_cpu()
>   riscv: switch set_icache_stale_mask() to using non-atomic assign_cpu()
>   cpumask: drop cpumask_assign_cpu()
> 
>  arch/riscv/mm/cacheflush.c |  2 +-
>  include/linux/cpumask.h    | 19 +++----------------
>  include/linux/nodemask.h   | 19 -------------------
>  3 files changed, 4 insertions(+), 36 deletions(-)
> 
> -- 
> 2.43.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-03-24 15:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-13  2:19 [PATCH 0/4] cleanup dead code in nodemasks and cpumasks Yury Norov
2025-03-13  2:19 ` [PATCH 1/4] nodemask: drop nodes_shift Yury Norov
2025-03-13  2:19 ` [PATCH 2/4] cpumask: add non-atomic __assign_cpu() Yury Norov
2025-03-13  2:19 ` [PATCH 3/4] riscv: switch set_icache_stale_mask() to using non-atomic assign_cpu() Yury Norov
2025-03-13  2:19 ` [PATCH 4/4] cpumask: drop cpumask_assign_cpu() Yury Norov
2025-03-24 15:02 ` [PATCH 0/4] cleanup dead code in nodemasks and cpumasks Yury Norov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox