Re: Communication between kernel and kernel module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"drewd77.gm" <drewd77.gm@xxxxxxxxx> writes:

> Is there any way to call a function defined in a kernel module from within the
> kernel proper?

One needs a proper hook mechanism such as kprobes or tracepoints.

> I'm trying to keep track of when and for how long a process is being executed
> on the processor, i.e. I need to know when context switches occur.
>
> There is a function called context_switch() in linux/kernel/sched/core.c that
> is called whenever a context switch happens. I would like to call a function in
> a kernel module I've written from within context_switch() and pass some data to
> it.

The sched_switch tracepoint is probably the best spot for this.  A
systemtap script that listens for these events and simply traces them
to stdout looks like:

probe scheduler.ctxswitch { println(cpu(), ":", prev_tid, "->", next_tid) }

- FChE

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux