linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Notification when a task is created/exits
@ 2010-02-16  5:48 Leonidas .
  2010-02-17  2:53 ` KAMEZAWA Hiroyuki
  0 siblings, 1 reply; 5+ messages in thread
From: Leonidas . @ 2010-02-16  5:48 UTC (permalink / raw)
  To: linux-kernel

Hi folks,

Is it possible to register a set of callbacks from my module so that
these call backs get called
whenever a certain task is created or exits. Basically, I want to keep
track of all the threads
which are created and are exiting, my module should get notified of
these events somehow.
One way is to call my functions directly from the task creation and
exit functions, but I personally
do not like this approach since I dont want to mess with this core kernel code.

-Leo.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Notification when a task is created/exits
  2010-02-16  5:48 Notification when a task is created/exits Leonidas .
@ 2010-02-17  2:53 ` KAMEZAWA Hiroyuki
  2010-02-17  3:16   ` Leonidas .
  0 siblings, 1 reply; 5+ messages in thread
From: KAMEZAWA Hiroyuki @ 2010-02-17  2:53 UTC (permalink / raw)
  To: Leonidas .; +Cc: linux-kernel

On Tue, 16 Feb 2010 11:18:25 +0530
"Leonidas ." <leonidas137@gmail.com> wrote:

> Hi folks,
> 
> Is it possible to register a set of callbacks from my module so that
> these call backs get called
> whenever a certain task is created or exits. Basically, I want to keep
> track of all the threads
> which are created and are exiting, my module should get notified of
> these events somehow.
> One way is to call my functions directly from the task creation and
> exit functions, but I personally
> do not like this approach since I dont want to mess with this core kernel code.
> 

AFAIK, there are no extensible notifier chain at task create/exit.
But I think you have 2 options.

 1. use NETLINK and catch task create/exit in userland.
    But this means "catch" is asyncronous.

 2. implement cgroup subsystem
    AFAIK, in the latest kernel, cgroup subsystem can be implemented as module. 
    cgroup has fork/exit handler.
    And you can implement some useful controls for tasks you watch via
    cgroup's control interface.

Thanks,
-Kame


> -Leo.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Notification when a task is created/exits
  2010-02-17  2:53 ` KAMEZAWA Hiroyuki
@ 2010-02-17  3:16   ` Leonidas .
  2010-02-17  3:43     ` KAMEZAWA Hiroyuki
  0 siblings, 1 reply; 5+ messages in thread
From: Leonidas . @ 2010-02-17  3:16 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki; +Cc: linux-kernel

Hi Kame,

>
>  1. use NETLINK and catch task create/exit in userland.
>    But this means "catch" is asyncronous.
>
This does not sounds like a possible solution to me in my setup. Using netlink
and having an user space component to do this job might be an over kill in what
I am doing.

>  2. implement cgroup subsystem
>    AFAIK, in the latest kernel, cgroup subsystem can be implemented as module.
>    cgroup has fork/exit handler.
>    And you can implement some useful controls for tasks you watch via
>    cgroup's control interface.
>

This sounds close to what I have in mind, but unfortunately I dont
have any idea what is cgroup
subsystem. How to implement cgroup subsystem? Can you give pointers to
some existing code
or document? Also, using this mechanism can we monitor each thread created in
user space? I.e. it is only a fork handler or even a
pthread_create/clone can be tracked this way.


> Thanks,
> -Kame
>
>
>> -Leo.
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/
>>
>
>



-- 


-Leo.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Notification when a task is created/exits
  2010-02-17  3:16   ` Leonidas .
@ 2010-02-17  3:43     ` KAMEZAWA Hiroyuki
  2010-02-17  5:43       ` Leonidas .
  0 siblings, 1 reply; 5+ messages in thread
From: KAMEZAWA Hiroyuki @ 2010-02-17  3:43 UTC (permalink / raw)
  To: Leonidas .; +Cc: linux-kernel

On Wed, 17 Feb 2010 08:46:51 +0530
"Leonidas ." <leonidas137@gmail.com> wrote:
\
> >  2. implement cgroup subsystem
> >    AFAIK, in the latest kernel, cgroup subsystem can be implemented as module.
> >    cgroup has fork/exit handler.
> >    And you can implement some useful controls for tasks you watch via
> >    cgroup's control interface.
> >
> 
> This sounds close to what I have in mind, but unfortunately I dont
> have any idea what is cgroup
> subsystem. How to implement cgroup subsystem? Can you give pointers to
> some existing code
> or document? 
Documentation/cgroup/*.txt
Maybe cpuacct cgroup in kernel/sche.c or device cgroup in security/device_cgroup.c
is portable size, but they are not module.
block/blk-cgroup is module and maybe in readable size.

> Also, using this mechanism can we monitor each thread created in
> user space? I.e. it is only a fork handler or even a
> pthread_create/clone can be tracked this way.
> 
please read documents. I think you can.

Thanks,
-Kame


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Notification when a task is created/exits
  2010-02-17  3:43     ` KAMEZAWA Hiroyuki
@ 2010-02-17  5:43       ` Leonidas .
  0 siblings, 0 replies; 5+ messages in thread
From: Leonidas . @ 2010-02-17  5:43 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki; +Cc: linux-kernel

>> This sounds close to what I have in mind, but unfortunately I dont
>> have any idea what is cgroup
>> subsystem. How to implement cgroup subsystem? Can you give pointers to
>> some existing code
>> or document?
> Documentation/cgroup/*.txt
> Maybe cpuacct cgroup in kernel/sche.c or device cgroup in security/device_cgroup.c
> is portable size, but they are not module.
> block/blk-cgroup is module and maybe in readable size.

Will go through it.

>
>> Also, using this mechanism can we monitor each thread created in
>> user space? I.e. it is only a fork handler or even a
>> pthread_create/clone can be tracked this way.
>>
> please read documents. I think you can.
>

Okay, if it can then this is what I have been looking for...Thanks for
the pointers.

> Thanks,
> -Kame
>
>



-- 


-Leo.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-02-17  5:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-16  5:48 Notification when a task is created/exits Leonidas .
2010-02-17  2:53 ` KAMEZAWA Hiroyuki
2010-02-17  3:16   ` Leonidas .
2010-02-17  3:43     ` KAMEZAWA Hiroyuki
2010-02-17  5:43       ` Leonidas .

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).