From: Jiri Kosina <[email protected]>

In addition to having a per-process flag that shows which processess have
already been "migrated", it's useful to have a global-wide flag that will
show whether the patching operation is currently undergoing without having
to traverse all /proc entries.

js: handle error

Reported-by: Libor Pechacek <[email protected]>
Signed-off-by: Jiri Kosina <[email protected]>
Signed-off-by: Jiri Slaby <[email protected]>
---
 kernel/kgraft.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/kernel/kgraft.c b/kernel/kgraft.c
index 89414957cf74..b427812c12cd 100644
--- a/kernel/kgraft.c
+++ b/kernel/kgraft.c
@@ -26,6 +26,8 @@
 #include <linux/spinlock.h>
 #include <linux/types.h>
 #include <linux/workqueue.h>
+#include <linux/seq_file.h>
+#include <linux/proc_fs.h>
 
 static int kgr_patch_code(const struct kgr_patch *patch,
                struct kgr_patch_fun *patch_fun, bool final);
@@ -382,6 +384,25 @@ unlock_free:
 }
 EXPORT_SYMBOL_GPL(kgr_start_patching);
 
+static int kgr_show(struct seq_file *m, void *v)
+{
+       seq_printf(m, "%d\n", kgr_in_progress);
+       return 0;
+}
+
+static int kgr_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, kgr_show, NULL);
+}
+
+static const struct file_operations kgr_fops = {
+       .owner      = THIS_MODULE,
+       .open       = kgr_open,
+       .read       = seq_read,
+       .llseek     = seq_lseek,
+       .release    = single_release,
+};
+
 static int __init kgr_init(void)
 {
        if (ftrace_is_dead()) {
@@ -398,6 +419,9 @@ static int __init kgr_init(void)
        kgr_initialized = true;
        pr_info("kgr: successfully initialized\n");
 
+       if (!proc_create("kgr_in_progress", 0, NULL, &kgr_fops))
+               pr_warn("kgr: cannot create kgr_in_progress in procfs\n");
+
        return 0;
 }
 module_init(kgr_init);
-- 
2.0.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to