taskstats-fork: Add a new taskstats command to get notification on fork/clone
Subsystems (4)
PATCH 1/3 taskstats-fork: Add a new taskstats command to get notification on fork/clone
Add a new taskstats command to register for notification, whenever a new task forks in the cpumask specified.
---
include/linux/taskstats.h +3 -0
@@ -188,6 +188,7 @@ enum {TASKSTATS_TYPE_STATS ,/* taskstats structure */ TASKSTATS_TYPE_AGGR_PID ,/* contains pid + stats */ TASKSTATS_TYPE_AGGR_TGID ,/* contains tgid + stats */ +TASKSTATS_TYPE_PID_TGID ,/* contains pid + tgid */ __TASKSTATS_TYPE_MAX, };
@@ -199,6 +200,8 @@ enum {TASKSTATS_CMD_ATTR_TGID ,TASKSTATS_CMD_ATTR_REGISTER_CPUMASK ,TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK , +TASKSTATS_CMD_ATTR_REGISTER_FORK_CPUMASK , +TASKSTATS_CMD_ATTR_DEREGISTER_FORK_CPUMASK , __TASKSTATS_CMD_ATTR_MAX, };
include/linux/taskstats_kern.h +3 -0
@@ -26,9 +26,12 @@ static inline void taskstats_tgid_free(struct signal_struct *sig) kmem_cache_free(taskstats_cache, sig->stats); } +extern void taskstats_fork (struct task_struct *);extern void taskstats_exit (struct task_struct *,int group_dead);extern void taskstats_init_early (void );#else +static inline void taskstats_fork (struct task_struct *tsk) +{}static inline void taskstats_exit (struct task_struct *tsk,int group_dead) {}static inline void taskstats_tgid_init (struct signal_struct *sig)
kernel/fork.c +1 -0
@@ -1447,6 +1447,7 @@ long do_fork(unsigned long clone_flags,freezer_count ();tracehook_report_vfork_done (p, nr); } +taskstats_fork (p); }else { nr =PTR_ERR (p); }
kernel/taskstats.c +84 -10
158 lines not on this page · raw message
Quoted 3 lines · Nikanth Karthikesan
Add a new taskstats command to register for notification, whenever a new task forks in the cpumask specified.
The changelog is sucky.. why do we need this? Why is proc-events not sufficient?
Signature · 1 line
Balbir
Quoted 6 lines · On Tuesday 21 July 2009 11:31:14 Balbir Singh wrote:
Quoted 2 lines · Nikanth Karthikesan
Add a new taskstats command to register for notification, whenever a new task forks in the cpumask specified.
The changelog is sucky.. why do we need this? Why is proc-events not sufficient?
Ah.. proc-events was the exact thing, I was looking for! Thanks. But it seems there is no documentation for it? May be I didn't search properly...
BTW I did mention the need for this, in
http://patchwork.kernel.org/patch/36451/ , but didn't invest time to write a good changelog here, as I suspected something exists already. Sorry. ;-(
[CC-ed iotop/top people, who were CC-ed in the above mail. So that they can consider using proc-events interface, if it was not considered/used already]
Thanks
Nikanth
Quoted 1 line · Nikanth Karthikesan
Ah.. proc-events was the exact thing, I was looking for! Thanks.
AFAICT proc-events can only be used by root, so that makes it unsuitable for *top.
Anyway, iotop will always have to iterate over all threads to query their taskstats and other attributes, so the O(nr_threads) complexity is unavoidable.
Thanks.
Signature · 1 line
Guillaume
Quoted 10 lines · Guillaume Chazarain
Quoted 1 line · Nikanth Karthikesan
Ah.. proc-events was the exact thing, I was looking for! Thanks.
AFAICT proc-events can only be used by root, so that makes it unsuitable for *top.
Anyway, iotop will always have to iterate over all threads to query their taskstats and other attributes, so the
O(nr_threads)complexity is unavoidable.
Unless you want the stats for tgid in signal struct. In some cases we accumulate, in some we don't. But yes irrespective or kernel/user space the complexity exists.
Signature · 1 line
Balbir
Quoted 1 line · On Monday 31 August 2009 01:22:22 Guillaume Chazarain wrote:
On Tue, Jul 21, 2009 at 8:24 AM, Nikanth Karthikesan<[email protected]>
Quoted 9 lines · wrote:
Quoted 1 line
Ah.. proc-events was the exact thing, I was looking for! Thanks.
AFAICT proc-events can only be used by root, so that makes it unsuitable for *top.
Anyway, iotop will always have to iterate over all threads to query their taskstats and other attributes, so the
O(nr_threads)complexity is unavoidable.
If it would simply iterate over all the current threads, the complexity would be O(nr_threads). But while iterating through all the current threads, it checks whether it is a new thread or a known thread, so that it can calculate the delta values. This is what I optimized by using taskstats-fork, which could be optimized using proc-events.
Thanks
Nikanth