|
14 | 14 | #include <linux/cpumask.h>
|
15 | 15 | #include <linux/debugfs.h>
|
16 | 16 | #include <linux/energy_model.h>
|
| 17 | +#include <linux/fsnotify.h> |
17 | 18 | #include <linux/sched/topology.h>
|
18 | 19 | #include <linux/slab.h>
|
19 | 20 |
|
@@ -156,9 +157,53 @@ static int __init em_debug_init(void)
|
156 | 157 | return 0;
|
157 | 158 | }
|
158 | 159 | fs_initcall(em_debug_init);
|
| 160 | + |
| 161 | +static void em_debug_update_ps(struct em_perf_domain *em_pd, int i, |
| 162 | + struct dentry *pd) |
| 163 | +{ |
| 164 | + static const char *names[] = { |
| 165 | + "frequency", |
| 166 | + "power", |
| 167 | + "cost", |
| 168 | + "performance", |
| 169 | + "inefficient", |
| 170 | + }; |
| 171 | + struct em_perf_state *table; |
| 172 | + unsigned long freq; |
| 173 | + struct dentry *d, *cd; |
| 174 | + char name[24]; |
| 175 | + int j; |
| 176 | + |
| 177 | + rcu_read_lock(); |
| 178 | + table = em_perf_state_from_pd(em_pd); |
| 179 | + freq = table[i].frequency; |
| 180 | + rcu_read_unlock(); |
| 181 | + |
| 182 | + snprintf(name, sizeof(name), "ps:%lu", freq); |
| 183 | + d = debugfs_lookup(name, pd); |
| 184 | + |
| 185 | + for (j = 0; j < ARRAY_SIZE(names); j++) { |
| 186 | + cd = debugfs_lookup(names[j], d); |
| 187 | + if (!cd) |
| 188 | + return; |
| 189 | + fsnotify_dentry(cd, FS_MODIFY); |
| 190 | + cond_resched(); |
| 191 | + } |
| 192 | +} |
| 193 | + |
| 194 | +static void em_debug_update(struct device *dev) |
| 195 | +{ |
| 196 | + struct dentry *d; |
| 197 | + int i; |
| 198 | + |
| 199 | + d = debugfs_lookup(dev_name(dev), rootdir); |
| 200 | + for (i = 0; i < dev->em_pd->nr_perf_states; i++) |
| 201 | + em_debug_update_ps(dev->em_pd, i, d); |
| 202 | +} |
159 | 203 | #else /* CONFIG_DEBUG_FS */
|
160 | 204 | static void em_debug_create_pd(struct device *dev) {}
|
161 | 205 | static void em_debug_remove_pd(struct device *dev) {}
|
| 206 | +static void em_debug_update(struct device *dev) {} |
162 | 207 | #endif
|
163 | 208 |
|
164 | 209 | static void em_release_table_kref(struct kref *kref)
|
@@ -323,6 +368,8 @@ int em_dev_update_perf_domain(struct device *dev,
|
323 | 368 |
|
324 | 369 | em_table_free(old_table);
|
325 | 370 |
|
| 371 | + em_debug_update(dev); |
| 372 | + |
326 | 373 | mutex_unlock(&em_pd_mutex);
|
327 | 374 | return 0;
|
328 | 375 | }
|
|
0 commit comments