Skip to contentSkip to conversation

cpufreq: ACPI: Use on_each_cpu_mask() in drv_write()

PATCH Superseded Rafael J. Wysocki 2 participants 3 messages Sep 9, 2025 – Sep 11, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Rafael J. Wysocki

author maintainer
#0 lore raw

PATCH 1/1 cpufreq: ACPI: Use on_each_cpu_mask() in drv_write()

From: Rafael J. Wysocki <[email protected]>

Make drv_write() call on_each_cpu_mask() instead of using an open-coded equivalent of the latter.

No intentional functional impact.

---
 drivers/cpufreq/acpi-cpufreq.c |    8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +1 -7
@@ -335,14 +335,8 @@ static void drv_write(struct acpi_cpufre
 		.val = val,
 		.func.write = data->cpu_freq_write,
 	};
-	int this_cpu;
 
-	this_cpu = get_cpu();
-	if (cpumask_test_cpu(this_cpu, mask))
-		do_drv_write(&cmd);
-
-	smp_call_function_many(mask, do_drv_write, &cmd, 1);
-	put_cpu();
+	on_each_cpu_mask(mask, do_drv_write, &cmd, true);
 }
 
 static u32 get_cur_val(const struct cpumask *mask, struct acpi_cpufreq_data *data)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Make drv_write() call on_each_cpu_mask() instead of using an open-coded equivalent of the latter.

No intentional functional impact.

---

I feel you should also update the comment before do_drv_write() to mention it's called with a NULL conditional to smp_call_function_many_cond(), or just drop that comment.

Quoted 24 lines
  drivers/cpufreq/acpi-cpufreq.c |    8 +-------
  1 file changed, 1 insertion(+), 7 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +1 -7
@@ -335,14 +335,8 @@ static void drv_write(struct acpi_cpufre
  		.val = val,
  		.func.write = data->cpu_freq_write,
  	};
-	int this_cpu;
 
-	this_cpu = get_cpu();
-	if (cpumask_test_cpu(this_cpu, mask))
-		do_drv_write(&cmd);
-
-	smp_call_function_many(mask, do_drv_write, &cmd, 1);
-	put_cpu();
+	on_each_cpu_mask(mask, do_drv_write, &cmd, true);
  }
 
  static u32 get_cur_val(const struct cpumask *mask, struct acpi_cpufreq_data *data)
author maintainer
#2 lore raw
Quoted 7 lines · Mario Limonciello
Quoted 5 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Make drv_write() call on_each_cpu_mask() instead of using an open-coded equivalent of the latter.

Quoted 8 lines
Quoted 4 lines

No intentional functional impact.

---

I feel you should also update the comment before do_drv_write() to mention it's called with a NULL conditional to smp_call_function_many_cond(), or just drop that comment.

I'll drop it.

Quoted 1 line

Thanks!

Quoted 25 lines
Quoted 24 lines
  drivers/cpufreq/acpi-cpufreq.c |    8 +-------
  1 file changed, 1 insertion(+), 7 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +1 -7
@@ -335,14 +335,8 @@ static void drv_write(struct acpi_cpufre
              .val = val,
              .func.write = data->cpu_freq_write,
      };
-     int this_cpu;
 
-     this_cpu = get_cpu();
-     if (cpumask_test_cpu(this_cpu, mask))
-             do_drv_write(&cmd);
-
-     smp_call_function_many(mask, do_drv_write, &cmd, 1);
-     put_cpu();
+     on_each_cpu_mask(mask, do_drv_write, &cmd, true);
  }
 
  static u32 get_cur_val(const struct cpumask *mask, struct acpi_cpufreq_data *data)