Liyuu
Liyuu

Reputation: 1

modpost: "__tracepoint_sched_switch" was exported without definition

I am trying to build a kernel module(.ko) to trace context switch of system. So I use the sched_switch tracepoint and want to register my function to it. But When I build my code, there are some errors.

ERROR: modpost: "__tracepoint_sched_switch" undefined
make[1]: *** [Makefile:1978: modpost] Error 2

Then I added the MODULE_LICENSE(GPL) in main.c and EXPORT_TRACEPOINT_SYMBOL_GPL(sched_switch) in 'sched.h', but it doesn't work.

ERROR: modpost: "__tracepoint_sched_switch" was exported without definition
ERROR: modpost: "__traceiter_sched_switch" was exported without definition
ERROR: modpost: "__SCK__tp_func_sched_switch" was exported without definition

I use the register function in this part

static int start_sched_tracing(void){
    int ret;
    ret = register_trace_sched_switch(LTRACE_SWITCH_PROBE, NULL);
    if (ret == -1){
        printk("register_trace_sched_switch failed\n");
    }
    ret = register_trace_sched_process_exit(LTRACE_EXIT_PROBE, NULL);
    if (ret == -1){
        printk("register_trace_sched_process_exit failed\n");
    }
    return 0;
}

Here is my Makefile

arch := x86
MODULE:= linuxtrace
obj-m += linuxtrace.o

CURRENT_PATH:=$(shell pwd)
LINUX_KERNEL:=$(shell uname -r)
LINUX_KERNEL_PATH:=/usr/src/linux-headers-$(LINUX_KERNEL)

CPPFLAGS += -I$(LINUX_KERNEL_PATH)/include \
            -I$(LINUX_KERNEL_PATH)/arch/x86/include \
            -I$(LINUX_KERNEL_PATH)/arch/x86/include/generated \

            
all:
    make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules
clean:
    make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) clean

Upvotes: 0

Views: 216

Answers (0)

Related Questions