Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PM: EM: Change cpus' type from string to u64 array in the EM YNL spec

Previously, the cpus attribute was a string format which was a "%*pb"
stringification of a bitmap. That is not very consumable for a UAPI,
so let’s change it to an u64 array of CPU ids.

Suggested-by: Donald Hunter <donald.hunter@gmail.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Signed-off-by: Changwoo Min <changwoo@igalia.com>
Link: https://patch.msgid.link/20260108053212.642478-4-changwoo@igalia.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Changwoo Min and committed by
Rafael J. Wysocki
d29b900c caa07a81

+13 -12
+2 -1
Documentation/netlink/specs/dev-energymodel.yaml
··· 73 73 enum: perf-domain-flags 74 74 - 75 75 name: cpus 76 - type: string 76 + type: u64 77 + multi-attr: true 77 78 doc: >- 78 79 CPUs that belong to this performance domain. 79 80 -
+11 -11
kernel/power/em_netlink.c
··· 17 17 #include "em_netlink.h" 18 18 #include "em_netlink_autogen.h" 19 19 20 - #define DEV_ENERGYMODEL_A_PERF_DOMAIN_CPUS_LEN 256 21 - 22 20 /*************************** Command encoding ********************************/ 23 21 static int __em_nl_get_pd_size(struct em_perf_domain *pd, void *data) 24 22 { 25 - char cpus_buf[DEV_ENERGYMODEL_A_PERF_DOMAIN_CPUS_LEN]; 23 + int nr_cpus, msg_sz, cpus_sz; 26 24 int *tot_msg_sz = data; 27 - int msg_sz, cpus_sz; 28 25 29 - cpus_sz = snprintf(cpus_buf, sizeof(cpus_buf), "%*pb", 30 - cpumask_pr_args(to_cpumask(pd->cpus))); 26 + nr_cpus = cpumask_weight(to_cpumask(pd->cpus)); 27 + cpus_sz = nla_total_size_64bit(sizeof(u64)) * nr_cpus; 31 28 32 29 msg_sz = nla_total_size(0) + 33 30 /* DEV_ENERGYMODEL_A_PERF_DOMAINS_PERF_DOMAIN */ ··· 41 44 42 45 static int __em_nl_get_pd(struct em_perf_domain *pd, void *data) 43 46 { 44 - char cpus_buf[DEV_ENERGYMODEL_A_PERF_DOMAIN_CPUS_LEN]; 45 47 struct sk_buff *msg = data; 48 + struct cpumask *cpumask; 46 49 struct nlattr *entry; 50 + int cpu; 47 51 48 52 entry = nla_nest_start(msg, 49 53 DEV_ENERGYMODEL_A_PERF_DOMAINS_PERF_DOMAIN); ··· 59 61 pd->flags, DEV_ENERGYMODEL_A_PERF_DOMAIN_PAD)) 60 62 goto out_cancel_nest; 61 63 62 - snprintf(cpus_buf, sizeof(cpus_buf), "%*pb", 63 - cpumask_pr_args(to_cpumask(pd->cpus))); 64 - if (nla_put_string(msg, DEV_ENERGYMODEL_A_PERF_DOMAIN_CPUS, cpus_buf)) 65 - goto out_cancel_nest; 64 + cpumask = to_cpumask(pd->cpus); 65 + for_each_cpu(cpu, cpumask) { 66 + if (nla_put_u64_64bit(msg, DEV_ENERGYMODEL_A_PERF_DOMAIN_CPUS, 67 + cpu, DEV_ENERGYMODEL_A_PERF_DOMAIN_PAD)) 68 + goto out_cancel_nest; 69 + } 66 70 67 71 nla_nest_end(msg, entry); 68 72