Back to home page

LXR

 
 

    


0001 #include <linux/kernel.h>
0002 #include <linux/module.h>
0003 #include <linux/memory.h>
0004 
0005 #include "notifier-error-inject.h"
0006 
0007 static int priority;
0008 module_param(priority, int, 0);
0009 MODULE_PARM_DESC(priority, "specify memory notifier priority");
0010 
0011 static struct notifier_err_inject memory_notifier_err_inject = {
0012     .actions = {
0013         { NOTIFIER_ERR_INJECT_ACTION(MEM_GOING_ONLINE) },
0014         { NOTIFIER_ERR_INJECT_ACTION(MEM_GOING_OFFLINE) },
0015         {}
0016     }
0017 };
0018 
0019 static struct dentry *dir;
0020 
0021 static int err_inject_init(void)
0022 {
0023     int err;
0024 
0025     dir = notifier_err_inject_init("memory", notifier_err_inject_dir,
0026                     &memory_notifier_err_inject, priority);
0027     if (IS_ERR(dir))
0028         return PTR_ERR(dir);
0029 
0030     err = register_memory_notifier(&memory_notifier_err_inject.nb);
0031     if (err)
0032         debugfs_remove_recursive(dir);
0033 
0034     return err;
0035 }
0036 
0037 static void err_inject_exit(void)
0038 {
0039     unregister_memory_notifier(&memory_notifier_err_inject.nb);
0040     debugfs_remove_recursive(dir);
0041 }
0042 
0043 module_init(err_inject_init);
0044 module_exit(err_inject_exit);
0045 
0046 MODULE_DESCRIPTION("memory notifier error injection module");
0047 MODULE_LICENSE("GPL");
0048 MODULE_AUTHOR("Akinobu Mita <akinobu.mita@gmail.com>");