Situation
I'm writing a kernel module for learning purpose and want to use sched_class_highest and for_each_class as defined here.
I saw that if I want to use symbols in the file /include/linux/sched.h, I'll #include <linux/sched.h>. So in the same manner, since the file I'm trying to add now is at location /kernel/sched/sched.h, I tried to: #include:
- First try:
<kernel/sched.h> - Second try:
<kernel/sched/sched.h> - Third try:
<../kernel/sched/sched.h>- just copying paste from a comment in this question
None of these worked and all gave me the error No such file or directory.
I'm not very familiar with C, just trying to learn the kernel and pick up C as I go a long the way.
Here's my Makefile. I knew basics about Makefile's target but don't understand the compiling process or what files it needs to feed it...
MODULE_FILENAME=my-schedule
obj-m += $(MODULE_FILENAME).o
KO_FILE=$(MODULE_FILENAME).ko
export KROOT=/lib/modules/$(shell uname -r)/build
modules:
@$(MAKE) -C $(KROOT) M=$(PWD) modules
modules_install:
@$(MAKE) -C $(KROOT) M=$(PWD) modules_install
clean:
@$(MAKE) -C $(KROOT) M=$(PWD) clean
rm -rf Module.symvers modules.order
insert: modules
sudo insmod $(KO_FILE)
sudo dmesg -c
remove:
sudo rmmod $(MODULE_FILENAME)
sudo dmesg -c
printlog:
sudo dmesg -c
sudo insmod $(KO_FILE)
dmesg
Questions
- How do I reference those 2 symbols in my kernel module?
- Are those symbols supposed to be referenced directly by a standard module? If so, what is the standard way of doing it?
- Is the Makefile related to how I can import a file in kernel code into my module?