When CONFIG_PROC_FS is disabled psi code generates the following warnings: kernel/sched/psi.c:1364:30: warning: 'psi_cpu_proc_ops' defined but not used [-Wunused-const-variable=] 1364 | static const struct proc_ops psi_cpu_proc_ops = { | ^~~~~~~~~~~~~~~~ kernel/sched/psi.c:1355:30: warning: 'psi_memory_proc_ops' defined but not used [-Wunused-const-variable=] 1355 | static const struct proc_ops psi_memory_proc_ops = { | ^~~~~~~~~~~~~~~~~~~ kernel/sched/psi.c:1346:30: warning: 'psi_io_proc_ops' defined but not used [-Wunused-const-variable=] 1346 | static const struct proc_ops psi_io_proc_ops = { | ^~~~~~~~~~~~~~~ Make definitions of these structures and related functions conditional on CONFIG_PROC_FS config.
Unified · Split
| @@ -1082,44 +1082,6 @@ int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res) · 1081 unmodified lines | ||
| 1082 | 1082 | return 0; |
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | −static int psi_io_show(struct seq_file *m, void *v) | |
| 1086 | −{ | |
| 1087 | − return psi_show(m, &psi_system, PSI_IO); | |
| 1088 | −} | |
| 1089 | − | |
| 1090 | −static int psi_memory_show(struct seq_file *m, void *v) | |
| 1091 | −{ | |
| 1092 | − return psi_show(m, &psi_system, PSI_MEM); | |
| 1093 | −} | |
| 1094 | − | |
| 1095 | −static int psi_cpu_show(struct seq_file *m, void *v) | |
| 1096 | −{ | |
| 1097 | − return psi_show(m, &psi_system, PSI_CPU); | |
| 1098 | −} | |
| 1099 | − | |
| 1100 | −static int psi_open(struct file *file, int (*psi_show)(struct seq_file *, void *)) | |
| 1101 | −{ | |
| 1102 | − if (file->f_mode & FMODE_WRITE && !capable(CAP_SYS_RESOURCE)) | |
| 1103 | − return -EPERM; | |
| 1104 | − | |
| 1105 | − return single_open(file, psi_show, NULL); | |
| 1106 | −} | |
| 1107 | − | |
| 1108 | −static int psi_io_open(struct inode *inode, struct file *file) | |
| 1109 | −{ | |
| 1110 | − return psi_open(file, psi_io_show); | |
| 1111 | −} | |
| 1112 | − | |
| 1113 | −static int psi_memory_open(struct inode *inode, struct file *file) | |
| 1114 | −{ | |
| 1115 | − return psi_open(file, psi_memory_show); | |
| 1116 | −} | |
| 1117 | − | |
| 1118 | −static int psi_cpu_open(struct inode *inode, struct file *file) | |
| 1119 | −{ | |
| 1120 | − return psi_open(file, psi_cpu_show); | |
| 1121 | −} | |
| 1122 | − | |
| 1123 | 1085 | struct psi_trigger *psi_trigger_create(struct psi_group *group, |
| 1124 | 1086 | char *buf, size_t nbytes, enum psi_res res) |
| 1125 | 1087 | { |
| @@ -1278,6 +1240,45 @@ __poll_t psi_trigger_poll(void **trigger_ptr, · 152 unmodified lines | ||
| 1278 | 1240 | return ret; |
| 1279 | 1241 | } |
| 1280 | 1242 | |
| 1243 | +#ifdef CONFIG_PROC_FS | |
| 1244 | +static int psi_io_show(struct seq_file *m, void *v) | |
| 1245 | +{ | |
| 1246 | + return psi_show(m, &psi_system, PSI_IO); | |
| 1247 | +} | |
| 1248 | + | |
| 1249 | +static int psi_memory_show(struct seq_file *m, void *v) | |
| 1250 | +{ | |
| 1251 | + return psi_show(m, &psi_system, PSI_MEM); | |
| 1252 | +} | |
| 1253 | + | |
| 1254 | +static int psi_cpu_show(struct seq_file *m, void *v) | |
| 1255 | +{ | |
| 1256 | + return psi_show(m, &psi_system, PSI_CPU); | |
| 1257 | +} | |
| 1258 | + | |
| 1259 | +static int psi_open(struct file *file, int (*psi_show)(struct seq_file *, void *)) | |
| 1260 | +{ | |
| 1261 | + if (file->f_mode & FMODE_WRITE && !capable(CAP_SYS_RESOURCE)) | |
| 1262 | + return -EPERM; | |
| 1263 | + | |
| 1264 | + return single_open(file, psi_show, NULL); | |
| 1265 | +} | |
| 1266 | + | |
| 1267 | +static int psi_io_open(struct inode *inode, struct file *file) | |
| 1268 | +{ | |
| 1269 | + return psi_open(file, psi_io_show); | |
| 1270 | +} | |
| 1271 | + | |
| 1272 | +static int psi_memory_open(struct inode *inode, struct file *file) | |
| 1273 | +{ | |
| 1274 | + return psi_open(file, psi_memory_show); | |
| 1275 | +} | |
| 1276 | + | |
| 1277 | +static int psi_cpu_open(struct inode *inode, struct file *file) | |
| 1278 | +{ | |
| 1279 | + return psi_open(file, psi_cpu_show); | |
| 1280 | +} | |
| 1281 | + | |
| 1281 | 1282 | static ssize_t psi_write(struct file *file, const char __user *user_buf, |
| 1282 | 1283 | size_t nbytes, enum psi_res res) |
| 1283 | 1284 | { |
| @@ -1392,3 +1393,5 @@ static int __init psi_proc_init(void) · 108 unmodified lines | ||
| 1392 | 1393 | return 0; |
| 1393 | 1394 | } |
| 1394 | 1395 | module_init(psi_proc_init); |
| 1396 | + | |
| 1397 | +#endif /* CONFIG_PROC_FS */ | |