LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 08-14-2012, 01:24 AM   #1
maheshma
LQ Newbie
 
Registered: Aug 2012
Posts: 3

Rep: Reputation: Disabled
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?
 
Old 08-17-2012, 07:59 AM   #2
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,378

Rep: Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108Reputation: 1108
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.
 
Old 08-20-2012, 10:57 AM   #3
maheshma
LQ Newbie
 
Registered: Aug 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
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 ?
 
Old 09-07-2012, 05:21 PM   #4
maheshma
LQ Newbie
 
Registered: Aug 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Found the solution notifier has to be global
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using ssh and nc to attach to a remote process xeon123 Linux - Software 5 01-12-2012 12:50 AM
Using sh and nc to attach to a remote process xeon123 Linux - Software 2 01-09-2012 01:14 PM
attach a process to init sagar.1986 Linux - General 1 04-24-2007 07:01 AM
How can i attach gdb to a daemon process praveengujar Linux - General 0 08-11-2004 06:58 AM


All times are GMT -5. The time now is 05:42 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration