Please make the stub function a proper C function, not a macro. It
provides type checking, can prevent compile warnings and is generally
easier on the eyes.
I think this should be under the kernel hacking menu, dependent on
CONFIG_DEBUG_KERNEL, in lib/Kconfig.debug.
struct kthread {
int should_stop;
+#ifdef CONFIG_MODULE_KTHREAD_CHECK
+ void *fn;
+#endif
A little comment describing what this field is for would be nice.
+unsigned long get_kthread_func(struct task_struct *tsk)
+{
+ struct kthread *kt;
+ unsigned long addr;
+
+ get_task_struct(tsk);
+ BUG_ON(!(tsk->flags& PF_KTHREAD));
+ kt = to_kthread(tsk);
+ barrier();
+ addr = tsk->vfork_done ? (unsigned long)kt->fn : 0UL;
+ put_task_struct(tsk);
+ return addr;
+}
gack, I hadn't noticed the kthread ab^wre^wuse of vfork_done before.
Kooky. Undocumented, too.
+#ifdef CONFIG_KALLSYMS
+static const char *get_ksymbol(struct module *mod, unsigned long addr,
+ unsigned long *size, unsigned long *offset);
+#else
+#define get_ksymbol(mod, addr, size, offset) NULL
+#endif
Can this code block be moved to after the get_ksymbol() definition so
the forward declaration is unneeded?
Did we really need to use the internal get_ksymbol(), rather than an
official kallsyms interface function?
The CONFIG_KALLSYMS=n stub should be written in C. Make it return
"<unknown>" and the ?: in check_kthreads() can be done away with.
+#else
+
+#define check_kthreads(mod) do { } while (0)
In C, please.