LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   attach preempt_notifier to user process in linux (http://www.linuxquestions.org/questions/linux-kernel-70/attach-preempt_notifier-to-user-process-in-linux-4175421959/)

maheshma 08-14-2012 01: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 07: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 10:57 AM

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

http://stackoverflow.com/questions/1...ocess-in-linux

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 05:21 PM

Found the solution notifier has to be global


All times are GMT -5. The time now is 05:43 PM.