Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6334

Why "__tracepoint_sched_switch" is undefined

$
0
0

I want to compile and load module from this answer https://stackoverflow.com/a/29526520/9609843There was some errors: I included <linux/sched/clock.h> because it is needed by sched_clock and I passed parameter bool ignr after void* ignore because it is needed by (un)register_trace_sched_switch. So, now my code is compiling, but there is a warning from make:

WARNING: "__tracepoint_sched_switch" [/some_path/myclock.ko] undefined!

And when I try to insmod, there is an error:

insmod: ERROR: could not insert module myclock.ko: Unknown symbol in module

So, what I have to do to make this works?

UPD: whole code I have at this moment

#include <linux/sched/clock.h>#include <linux/sched.h>#include <linux/module.h>#include <linux/printk.h>#include <linux/types.h>#include <linux/tracepoint.h>#include <trace/events/sched.h>MODULE_LICENSE("GPL");MODULE_AUTHOR("somebody");void my_sched_switch_probe(void* ignore, bool ignr, struct task_struct* prev, struct task_struct* next) {    printk("my_sched_switch_probe: %s -> %s at %lu\n", prev->comm, next->comm,    (unsigned long) sched_clock());}int cswtracer_init(void) {    register_trace_sched_switch(my_sched_switch_probe, 0);    return 0;}void cswtracer_fini(void) {    unregister_trace_sched_switch(my_sched_switch_probe, 0);}module_init(cswtracer_init);module_exit(cswtracer_fini);

UPD: seems __tracepoint_sched_switch is not exported to be used by other modules:

$ sudo cat /proc/kallsyms | grep __tracepoint_sched_switchffffffff91c123a0 D __tracepoint_sched_switch$ cat /lib/modules/`uname -r`/build/Module.symvers | grep __tracepoint_sched_switch$ (nothing was shown)

Maybe my Makefile is wrong and there is a way to use __tracepoint_sched_switch by using some option in Makefile? Here it is:

ifneq ($(KERNELRELEASE),)    obj-m := myclock.oelse    CURRENT = $(shell uname -r)    KDIR = /lib/modules/$(CURRENT)/build    PWD = $(shell pwd)default:    $(MAKE) -C $(KDIR) M=$(PWD) modulesclean:    rm *.o    rm *.mod.c    rm *.symvers    rm *.order    rm .cache.mk    rm .*.*.cmd    rm -r .tmp_versionsendif

Viewing all articles
Browse latest Browse all 6334

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>