-   Linux - Kernel (
-   -   attach preempt_notifier to user process in linux (

maheshma 08-14-2012 02:24 AM

attach preempt_notifier to user process in linux
I am needing to identify whether a user process was ever preempted somehow, I understand we have hooks in preempt.h and sched.c which allow us to define preempt_notifiers which can in turn call sched_in and sched_out functions whenever a process is rescheduled or preempted.

But I still can't find out how can I attach a notifier to a particular process or pid in user space and then somehow log if this particular process was ever pre-empted. I'm assuming I have to write a module to do so, but how would I go about attaching a pid to a particular notifier?

sundialsvcs 08-17-2012 08:59 AM

Probably the cleanest approach would be to attach a preemption-counter which is incremented (with silent rollover in case of overflow) each time the process is dispatched. I do not readily know if such a counter now exists but it would not surprise me if it did. The process can read the counter twice: if it changed, pre-emption did occur. The value is unimportant.

maheshma 08-20-2012 11:57 AM

Well , i did find a way to use preempt_notifiers , following thread tells how to do that using psuedo syscall.

But , when i do try to run a user program to to make the call , my linux gnome shell becomes unresponsive and only option is to do a hard reset. Any clues what could possibly cause this ?

maheshma 09-07-2012 06:21 PM

Found the solution notifier has to be global

All times are GMT -5. The time now is 07:01 AM.