0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
0024
0025 #include <linux/module.h>
0026 #include <linux/kernel.h>
0027 #include <linux/workqueue.h>
0028 #include <linux/delay.h>
0029
0030 static int sleep_secs;
0031 module_param(sleep_secs, int, 0644);
0032 MODULE_PARM_DESC(sleep_secs, "sleep_secs (default=0)");
0033
0034 static void busymod_work_func(struct work_struct *work);
0035 static DECLARE_DELAYED_WORK(work, busymod_work_func);
0036
0037 static void busymod_work_func(struct work_struct *work)
0038 {
0039 pr_info("%s, sleeping %d seconds ...\n", __func__, sleep_secs);
0040 msleep(sleep_secs * 1000);
0041 pr_info("%s exit\n", __func__);
0042 }
0043
0044 static int livepatch_callbacks_mod_init(void)
0045 {
0046 pr_info("%s\n", __func__);
0047 schedule_delayed_work(&work,
0048 msecs_to_jiffies(1000 * 0));
0049 return 0;
0050 }
0051
0052 static void livepatch_callbacks_mod_exit(void)
0053 {
0054 cancel_delayed_work_sync(&work);
0055 pr_info("%s\n", __func__);
0056 }
0057
0058 module_init(livepatch_callbacks_mod_init);
0059 module_exit(livepatch_callbacks_mod_exit);
0060 MODULE_LICENSE("GPL");