diff mbox series

cpumask: de-duplicate assign_cpu() API

Message ID 20240731195355.97488-1-yury.norov@gmail.com (mailing list archive)
State Changes Requested
Headers show
Series cpumask: de-duplicate assign_cpu() API | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR success PR summary
conchuod/vmtest-fixes-PR success PR summary
conchuod/patch-1-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh
conchuod/patch-1-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh
conchuod/patch-1-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh
conchuod/patch-1-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh
conchuod/patch-1-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh
conchuod/patch-1-test-6 success .github/scripts/patches/tests/checkpatch.sh
conchuod/patch-1-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh
conchuod/patch-1-test-8 success .github/scripts/patches/tests/header_inline.sh
conchuod/patch-1-test-9 success .github/scripts/patches/tests/kdoc.sh
conchuod/patch-1-test-10 success .github/scripts/patches/tests/module_param.sh
conchuod/patch-1-test-11 success .github/scripts/patches/tests/verify_fixes.sh
conchuod/patch-1-test-12 success .github/scripts/patches/tests/verify_signedoff.sh

Commit Message

Yury Norov July 31, 2024, 7:53 p.m. UTC
We've got cpumask_assign_cpu() function and assign_cpu() macro, both
doing the same thing. We need to drop one to avoid unneeded duplicatioon.

Now that underlying assign_bit() implemented as a macro, it would make
sense to keep assign_cpu() which is also implemented as a macro, in sake
of unification.

This patch also removes __cpumask_assign_cpu() as the function is
unused.

Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 arch/riscv/mm/cacheflush.c |  2 +-
 include/linux/cpumask.h    | 16 ----------------
 2 files changed, 1 insertion(+), 17 deletions(-)

Comments

Charlie Jenkins Aug. 1, 2024, 5:27 p.m. UTC | #1
On Wed, Jul 31, 2024 at 12:53:54PM -0700, Yury Norov wrote:
> We've got cpumask_assign_cpu() function and assign_cpu() macro, both
> doing the same thing. We need to drop one to avoid unneeded duplicatioon.
> 
> Now that underlying assign_bit() implemented as a macro, it would make
> sense to keep assign_cpu() which is also implemented as a macro, in sake
> of unification.
> 
> This patch also removes __cpumask_assign_cpu() as the function is
> unused.
> 
> Signed-off-by: Yury Norov <yury.norov@gmail.com>
> ---
>  arch/riscv/mm/cacheflush.c |  2 +-
>  include/linux/cpumask.h    | 16 ----------------
>  2 files changed, 1 insertion(+), 17 deletions(-)
> 
> diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c
> index a03c994eed3b..fa136627ccaa 100644
> --- a/arch/riscv/mm/cacheflush.c
> +++ b/arch/riscv/mm/cacheflush.c
> @@ -171,7 +171,7 @@ static void set_icache_stale_mask(void)
>  	stale_cpu = cpumask_test_cpu(smp_processor_id(), mask);
>  
>  	cpumask_setall(mask);
> -	cpumask_assign_cpu(smp_processor_id(), mask, stale_cpu);
> +	assign_cpu(smp_processor_id(), mask, stale_cpu);
>  }
>  #endif
>  
> diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
> index 801a7e524113..f896c6ffa78e 100644
> --- a/include/linux/cpumask.h
> +++ b/include/linux/cpumask.h
> @@ -534,22 +534,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);
> -}

This deletion is the wrong way around. cpumask_assign_cpu already
existed when assign_cpu was added. cpumask_assign_cpu uses the same
naming convention as all of the other cpumask functions, so it is
inconsistent with the other defines in this file to drop the "cpumask"
prefix.

__cpumask_assign_cpu is not currently used but all of the other cpumask
functions have a "__" alternative so that's why I added it.

- Charlie

> -
>  /**
>   * cpumask_test_cpu - test for a cpu in a cpumask
>   * @cpu: cpu number (< nr_cpu_ids)
> -- 

> 2.43.0
>
diff mbox series

Patch

diff --git a/arch/riscv/mm/cacheflush.c b/arch/riscv/mm/cacheflush.c
index a03c994eed3b..fa136627ccaa 100644
--- a/arch/riscv/mm/cacheflush.c
+++ b/arch/riscv/mm/cacheflush.c
@@ -171,7 +171,7 @@  static void set_icache_stale_mask(void)
 	stale_cpu = cpumask_test_cpu(smp_processor_id(), mask);
 
 	cpumask_setall(mask);
-	cpumask_assign_cpu(smp_processor_id(), mask, stale_cpu);
+	assign_cpu(smp_processor_id(), mask, stale_cpu);
 }
 #endif
 
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 801a7e524113..f896c6ffa78e 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -534,22 +534,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)