[PATCH v6 0/3] arm64: topology: Handle AMU FIE setup on CPU hotplug

zhenglifeng (A) zhenglifeng1 at huawei.com
Mon Dec 1 19:08:05 PST 2025


On 2025/12/2 11:05, zhenglifeng (A) wrote:
> On 2025/12/1 23:27, Beata Michalska wrote:
>> Hi,
>>
>> Apologies for the delay in reviewing this - currently in progress....
>> Out of curiosity: what's the cpufreq driver used for testing this series ?
> 
> I used cppc_cpufreq for testing this. But with some modifications in
> processor_driver.c, or you'll find that the driver will fail to load with
> maxcpus set. The modification below is only a temporary solution. I'm still
> working on that.

In addition, I exposed some sysfs interfaces for easily checking freq scale
and source as below when testing. Hope this helps.

---
diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 331a0654f3dc..ba15c90cf908 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -98,6 +98,23 @@ void topology_set_scale_freq_source(struct scale_freq_data *data,
 }
 EXPORT_SYMBOL_GPL(topology_set_scale_freq_source);
 
+int topology_get_scale_freq_source(int cpu)
+{
+	struct scale_freq_data *sfd;
+	int scale_freq_source;
+
+	rcu_read_lock();
+
+	sfd = rcu_dereference(*per_cpu_ptr(&sft_data, cpu));
+	if (sfd)
+		scale_freq_source = sfd->source;
+
+	rcu_read_unlock();
+
+	return scale_freq_source;
+}
+EXPORT_SYMBOL_GPL(topology_get_scale_freq_source);
+
 void topology_clear_scale_freq_source(enum scale_freq_source source,
 				      const struct cpumask *cpus)
 {
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index c890e2a5b428..79c0dc8d5361 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -13,6 +13,7 @@
 #include <linux/module.h>
 #include <linux/hardirq.h>
 #include <linux/topology.h>
+#include <linux/arch_topology.h>
 
 #define define_id_show_func(name, fmt)					\
 static ssize_t name##_show(struct device *dev,				\
@@ -226,7 +227,27 @@ static ssize_t cpu_capacity_show(struct device *dev,
 	return sysfs_emit(buf, "%lu\n", topology_get_cpu_scale(cpu->dev.id));
 }
 
+static ssize_t arch_freq_scale_show(struct device *dev,
+				    struct device_attribute *attr,
+				    char *buf)
+{
+	struct cpu *cpu = container_of(dev, struct cpu, dev);
+
+	return sysfs_emit(buf, "%lu\n", topology_get_freq_scale(cpu->dev.id));
+}
+
+static ssize_t scale_freq_source_show(struct device *dev,
+				    struct device_attribute *attr,
+				    char *buf)
+{
+	struct cpu *cpu = container_of(dev, struct cpu, dev);
+
+	return sysfs_emit(buf, "%d\n", topology_get_scale_freq_source(cpu->dev.id));
+}
+
 static DEVICE_ATTR_RO(cpu_capacity);
+static DEVICE_ATTR_RO(arch_freq_scale);
+static DEVICE_ATTR_RO(scale_freq_source);
 
 static int cpu_capacity_sysctl_add(unsigned int cpu)
 {
@@ -236,6 +257,8 @@ static int cpu_capacity_sysctl_add(unsigned int cpu)
 		return -ENOENT;
 
 	device_create_file(cpu_dev, &dev_attr_cpu_capacity);
+	device_create_file(cpu_dev, &dev_attr_arch_freq_scale);
+	device_create_file(cpu_dev, &dev_attr_scale_freq_source);
 
 	return 0;
 }
@@ -248,6 +271,8 @@ static int cpu_capacity_sysctl_remove(unsigned int cpu)
 		return -ENOENT;
 
 	device_remove_file(cpu_dev, &dev_attr_cpu_capacity);
+	device_remove_file(cpu_dev, &dev_attr_arch_freq_scale);
+	device_remove_file(cpu_dev, &dev_attr_scale_freq_source);
 
 	return 0;
 }
diff --git a/include/linux/arch_topology.h b/include/linux/arch_topology.h
index d72d6e5aa200..0149aef7b684 100644
--- a/include/linux/arch_topology.h
+++ b/include/linux/arch_topology.h
@@ -47,6 +47,7 @@ struct scale_freq_data {
 
 void topology_scale_freq_tick(void);
 void topology_set_scale_freq_source(struct scale_freq_data *data, const struct cpumask *cpus);
+int topology_get_scale_freq_source(int cpu);
 void topology_clear_scale_freq_source(enum scale_freq_source source, const struct cpumask *cpus);
 
 DECLARE_PER_CPU(unsigned long, hw_pressure);




More information about the linux-arm-kernel mailing list