// SPDX-License-Identifier: GPL-2.0 #include #include #include #include #include #include typedef unsigned int __poll_t; static bool psi_enable = true; static int __init setup_psi(char *str) { return kstrtobool(str, &psi_enable) == 0; } __setup("psi=", setup_psi); static int psi_io_show(struct seq_file *m, void *v) { return 0; } static int psi_memory_show(struct seq_file *m, void *v) { return 0; } static int psi_cpu_show(struct seq_file *m, void *v) { return 0; } static int psi_io_open(struct inode *inode, struct file *file) { return single_open(file, psi_io_show, NULL); } static int psi_memory_open(struct inode *inode, struct file *file) { return single_open(file, psi_memory_show, NULL); } static int psi_cpu_open(struct inode *inode, struct file *file) { return single_open(file, psi_cpu_show, NULL); } static ssize_t psi_io_write(struct file *file, const char __user *user_buf, size_t nbytes, loff_t *ppos) { return 0; } static ssize_t psi_memory_write(struct file *file, const char __user *user_buf, size_t nbytes, loff_t *ppos) { return 0; } static ssize_t psi_cpu_write(struct file *file, const char __user *user_buf, size_t nbytes, loff_t *ppos) { return 0; } static __poll_t psi_fop_poll(struct file *file, poll_table *wait) { return 0; } static int psi_fop_release(struct inode *inode, struct file *file) { return 0; } static const struct file_operations psi_io_fops = { .open = psi_io_open, .read = seq_read, .llseek = seq_lseek, .write = psi_io_write, .poll = psi_fop_poll, .release = psi_fop_release, }; static const struct file_operations psi_memory_fops = { .open = psi_memory_open, .read = seq_read, .llseek = seq_lseek, .write = psi_memory_write, .poll = psi_fop_poll, .release = psi_fop_release, }; static const struct file_operations psi_cpu_fops = { .open = psi_cpu_open, .read = seq_read, .llseek = seq_lseek, .write = psi_cpu_write, .poll = psi_fop_poll, .release = psi_fop_release, }; static int __init psi_proc_init(void) { proc_mkdir("pressure", NULL); proc_create("pressure/io", 0, NULL, &psi_io_fops); proc_create("pressure/memory", 0, NULL, &psi_memory_fops); proc_create("pressure/cpu", 0, NULL, &psi_cpu_fops); return 0; } module_init(psi_proc_init);