it is the first time working in a Linux environment. i need a lot of help from you. i want to add prink() in shced_setattr https://elixir.bootlin.com/linux/v4.18/source/kernel/sched/core.c#L4578
SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
unsigned int, flags)
{
printk();
struct sched_attr attr;
struct task_struct *p;
int retval;
if (!uattr || pid < 0 || flags)
return -EINVAL;
retval = sched_copy_attr(uattr, &attr);
if (retval)
return retval;
if ((int)attr.sched_policy < 0)
return -EINVAL;
rcu_read_lock();
retval = -ESRCH;
p = find_process_by_pid(pid);
if (p != NULL)
retval = sched_setattr(p, &attr);
rcu_read_unlock();
return retval;
}
but i don't know how to edit the procedure. If someone could explain me edit the linux function for the printk() function it would be great!
It all depends on what you're trying to print using
printk, which is similar toprintf. Theprintkdocumentation can be found at:https://www.kernel.org/doc/html/latest/core-api/printk-formats.html
It's also part of the source:
Documentation/printk-formats.txtThe simplest call would only involve a format string without placeholders:
printk("sched_setattr called\n");Printing that with
pidwould result in:printk("sched_setattr called: pid: %d\n", pid);The output can be read using
dmesg.printkalso supports multiple log levels, but that shouldn't be relevant for getting started.