Re: [PATCH v1] arch_topology: Make cpu_capacity sysfs node as ready-only
From: Dietmar Eggemann
Date: Fri Mar 08 2019 - 06:45:20 EST
On 3/6/19 4:27 PM, Lingutla Chandrasekhar wrote:
[...]
@@ -51,37 +50,7 @@ static ssize_t cpu_capacity_show(struct device *dev,
static void update_topology_flags_workfn(struct work_struct *work);
static DECLARE_WORK(update_topology_flags_work, update_topology_flags_workfn);
-static ssize_t cpu_capacity_store(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t count)
-{
- struct cpu *cpu = container_of(dev, struct cpu, dev);
- int this_cpu = cpu->dev.id;
- int i;
- unsigned long new_capacity;
- ssize_t ret;
-
- if (!count)
- return 0;
-
- ret = kstrtoul(buf, 0, &new_capacity);
- if (ret)
- return ret;
- if (new_capacity > SCHED_CAPACITY_SCALE)
- return -EINVAL;
-
- mutex_lock(&cpu_scale_mutex);
Since we can't write to cpu_scale from here anymore, we could get rid of
cpu_scale_mutex.
topology_normalize_cpu_scale()->topology_set_cpu_scale() is now only
called from:
[ 0.202628] topology_normalize_cpu_scale+0x28/0x30
[ 0.207529] init_cpu_topology+0x168/0x1e8
[ 0.211644] smp_prepare_cpus+0x2c/0x108
[ 0.215585] kernel_init_freeable+0x104/0x518
[ 0.219963] kernel_init+0x18/0x110
[ 0.223469] ret_from_fork+0x10/0x1c
for dts capacity-dmips-mhz properties
and
[ 3.130180] topology_normalize_cpu_scale.part.0+0xac/0xd0
[ 3.135619] init_cpu_capacity_callback+0x100/0x178
[ 3.140459] notifier_call_chain+0x5c/0xa0
[ 3.144522] blocking_notifier_call_chain+0x64/0x88
[ 3.149363] cpufreq_set_policy+0xd8/0x3c8
[ 3.153427] cpufreq_init_policy+0x78/0xc8
for cpufreq max frequency related adjustments to cpu capacity.
The mutex was introduced for the sysfs interface here:
https://lore.kernel.org/lkml/1468932048-31635-8-git-send-email-juri.lelli@xxxxxxx
- for_each_cpu(i, &cpu_topology[this_cpu].core_sibling)
- topology_set_cpu_scale(i, new_capacity);
- mutex_unlock(&cpu_scale_mutex);
-
- schedule_work(&update_topology_flags_work);
-
- return count;
-}
-
-static DEVICE_ATTR_RW(cpu_capacity);
+static DEVICE_ATTR_RO(cpu_capacity);
static int register_cpu_capacity_sysctl(void)
{
Tested-by: Dietmar Eggemann <dietmar.eggemann@xxxxxxx>
on Arm64 Juno with v5.0