hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/release-management/issues/ID5CMS -------------------------------- Export two function to kernel module, then each module can create their private procfs below the /proc/xcall path, which is the root path for xcall Signed-off-by: Xinyu Zheng <zhengxinyu6@huawei.com> --- arch/arm64/kernel/xcall/proc.c | 17 +++++++++++++++-- drivers/staging/xcall/prefetch.c | 24 ++++++++++++------------ include/linux/xcall.h | 4 ++++ 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/arch/arm64/kernel/xcall/proc.c b/arch/arm64/kernel/xcall/proc.c index 12032120c7d6..0e3b714ac730 100644 --- a/arch/arm64/kernel/xcall/proc.c +++ b/arch/arm64/kernel/xcall/proc.c @@ -16,6 +16,8 @@ static LIST_HEAD(comm_list); static DECLARE_RWSEM(comm_rwsem); +struct proc_dir_entry *root_xcall_dir; + static void free_xcall_comm(struct xcall_comm *info) { if (!info) @@ -213,6 +215,19 @@ static ssize_t xcall_comm_write(struct file *file, return ret ? ret : nbytes; } +struct proc_dir_entry *xcall_subdir_create(const char *name) +{ + return proc_mkdir(name, root_xcall_dir); +} +EXPORT_SYMBOL(xcall_subdir_create); + +struct proc_dir_entry *xcall_proc_create(const char *name, umode_t mode, + struct proc_dir_entry *parent, const struct proc_ops *proc_ops) +{ + return proc_create(name, mode, parent, proc_ops); +} +EXPORT_SYMBOL(xcall_proc_create); + static const struct proc_ops xcall_comm_ops = { .proc_open = xcall_comm_open, .proc_read = seq_read, @@ -223,8 +238,6 @@ static const struct proc_ops xcall_comm_ops = { static int __init xcall_proc_init(void) { - struct proc_dir_entry *root_xcall_dir; - if (!static_key_enabled(&xcall_enable)) return 0; diff --git a/drivers/staging/xcall/prefetch.c b/drivers/staging/xcall/prefetch.c index f444a78d2a66..572bc4c90690 100644 --- a/drivers/staging/xcall/prefetch.c +++ b/drivers/staging/xcall/prefetch.c @@ -35,7 +35,7 @@ static DEFINE_PER_CPU_ALIGNED(unsigned long, xcall_cache_miss); static struct workqueue_struct *rc_work; static struct cpumask xcall_mask; -struct proc_dir_entry *xcall_proc_dir, *prefetch_dir, *xcall_mask_dir; +struct proc_dir_entry *prefetch_proc_dir, *prefetch_dir, *xcall_mask_dir; enum cache_state { XCALL_CACHE_NONE = 0, @@ -526,14 +526,14 @@ struct xcall_prog xcall_prefetch_prog = { static int __init init_xcall_prefetch_procfs(void) { - xcall_proc_dir = proc_mkdir("xcall_feature", NULL); - if (!xcall_proc_dir) + prefetch_proc_dir = xcall_subdir_create("prefetch"); + if (!prefetch_proc_dir) return -ENOMEM; - prefetch_dir = proc_create("prefetch", 0640, xcall_proc_dir, - &xcall_prefetch_fops); + prefetch_dir = xcall_proc_create("prefetch", 0640, prefetch_proc_dir, + &xcall_prefetch_fops); if (!prefetch_dir) - goto rm_xcall_proc_dir; - xcall_mask_dir = proc_create("cpu_list", 0640, xcall_proc_dir, + goto rm_prefetch_proc_dir; + xcall_mask_dir = proc_create("cpu_list", 0640, prefetch_proc_dir, &xcall_mask_fops); if (!xcall_mask_dir) goto rm_prefetch_dir; @@ -543,8 +543,8 @@ static int __init init_xcall_prefetch_procfs(void) rm_prefetch_dir: proc_remove(prefetch_dir); -rm_xcall_proc_dir: - proc_remove(xcall_proc_dir); +rm_prefetch_proc_dir: + proc_remove(prefetch_proc_dir); return -ENOMEM; } @@ -572,7 +572,7 @@ static int __init xcall_prefetch_init(void) remove_dir: proc_remove(prefetch_dir); proc_remove(xcall_mask_dir); - proc_remove(xcall_proc_dir); + proc_remove(prefetch_proc_dir); destroy_queue: destroy_workqueue(rc_work); return ret; @@ -587,8 +587,8 @@ static void __exit xcall_prefetch_exit(void) proc_remove(prefetch_dir); if (xcall_mask_dir) proc_remove(xcall_mask_dir); - if (xcall_proc_dir) - proc_remove(xcall_proc_dir); + if (prefetch_proc_dir) + proc_remove(prefetch_proc_dir); xcall_prog_unregister(&xcall_prefetch_prog); } diff --git a/include/linux/xcall.h b/include/linux/xcall.h index 510aebe4e7c0..215542097dfa 100644 --- a/include/linux/xcall.h +++ b/include/linux/xcall.h @@ -7,6 +7,7 @@ #define _LINUX_XCALL_H #include <linux/module.h> +#include <linux/proc_fs.h> struct vm_area_struct; struct mm_struct; @@ -32,6 +33,9 @@ struct xcall_prog { extern int xcall_prog_register(struct xcall_prog *prog); extern void xcall_prog_unregister(struct xcall_prog *prog); extern void mm_init_xcall_area(struct mm_struct *mm, struct task_struct *p); +struct proc_dir_entry *xcall_subdir_create(const char *name); +struct proc_dir_entry *xcall_proc_create(const char *name, umode_t mode, + struct proc_dir_entry *parent, const struct proc_ops *proc_ops); extern void clear_xcall_area(struct mm_struct *mm); extern int xcall_mmap(struct vm_area_struct *vma, struct mm_struct *mm); #else /* !CONFIG_DYNAMIC_XCALL */ -- 2.34.1