aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorShailabh Nagar <nagar@watson.ibm.com>2006-07-14 03:24:44 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-07-15 00:53:57 -0400
commitad4ecbcba72855a2b5319b96e2a3a65ed1ca3bfd (patch)
treea2f5b98598948525de77ab594e4432f09a230388 /include/linux
parent25890454667b3295f67b3372352be90705f8667c (diff)
[PATCH] delay accounting taskstats interface send tgid once
Send per-tgid data only once during exit of a thread group instead of once with each member thread exit. Currently, when a thread exits, besides its per-tid data, the per-tgid data of its thread group is also sent out, if its thread group is non-empty. The per-tgid data sent consists of the sum of per-tid stats for all *remaining* threads of the thread group. This patch modifies this sending in two ways: - the per-tgid data is sent only when the last thread of a thread group exits. This cuts down heavily on the overhead of sending/receiving per-tgid data, especially when other exploiters of the taskstats interface aren't interested in per-tgid stats - the semantics of the per-tgid data sent are changed. Instead of being the sum of per-tid data for remaining threads, the value now sent is the true total accumalated statistics for all threads that are/were part of the thread group. The patch also addresses a minor issue where failure of one accounting subsystem to fill in the taskstats structure was causing the send of taskstats to not be sent at all. The patch has been tested for stability and run cerberus for over 4 hours on an SMP. [akpm@osdl.org: bugfixes] Signed-off-by: Shailabh Nagar <nagar@watson.ibm.com> Signed-off-by: Balbir Singh <balbir@in.ibm.com> Cc: Jay Lan <jlan@engr.sgi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/sched.h4
-rw-r--r--include/linux/taskstats_kern.h71
2 files changed, 59 insertions, 16 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 3c5610ca0c92..6afa72e080cb 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -463,6 +463,10 @@ struct signal_struct {
463#ifdef CONFIG_BSD_PROCESS_ACCT 463#ifdef CONFIG_BSD_PROCESS_ACCT
464 struct pacct_struct pacct; /* per-process accounting information */ 464 struct pacct_struct pacct; /* per-process accounting information */
465#endif 465#endif
466#ifdef CONFIG_TASKSTATS
467 spinlock_t stats_lock;
468 struct taskstats *stats;
469#endif
466}; 470};
467 471
468/* Context switch must be unlocked if interrupts are to be enabled */ 472/* Context switch must be unlocked if interrupts are to be enabled */
diff --git a/include/linux/taskstats_kern.h b/include/linux/taskstats_kern.h
index fc9da2e26443..0ae8f67af1fd 100644
--- a/include/linux/taskstats_kern.h
+++ b/include/linux/taskstats_kern.h
@@ -19,36 +19,75 @@ enum {
19extern kmem_cache_t *taskstats_cache; 19extern kmem_cache_t *taskstats_cache;
20extern struct mutex taskstats_exit_mutex; 20extern struct mutex taskstats_exit_mutex;
21 21
22static inline void taskstats_exit_alloc(struct taskstats **ptidstats, 22static inline void taskstats_exit_alloc(struct taskstats **ptidstats)
23 struct taskstats **ptgidstats)
24{ 23{
25 *ptidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL); 24 *ptidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
26 *ptgidstats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
27} 25}
28 26
29static inline void taskstats_exit_free(struct taskstats *tidstats, 27static inline void taskstats_exit_free(struct taskstats *tidstats)
30 struct taskstats *tgidstats)
31{ 28{
32 if (tidstats) 29 if (tidstats)
33 kmem_cache_free(taskstats_cache, tidstats); 30 kmem_cache_free(taskstats_cache, tidstats);
34 if (tgidstats)
35 kmem_cache_free(taskstats_cache, tgidstats);
36} 31}
37 32
38extern void taskstats_exit_send(struct task_struct *, struct taskstats *, 33static inline void taskstats_tgid_init(struct signal_struct *sig)
39 struct taskstats *); 34{
40extern void taskstats_init_early(void); 35 spin_lock_init(&sig->stats_lock);
36 sig->stats = NULL;
37}
38
39static inline void taskstats_tgid_alloc(struct signal_struct *sig)
40{
41 struct taskstats *stats;
42 unsigned long flags;
43
44 stats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
45 if (!stats)
46 return;
47
48 spin_lock_irqsave(&sig->stats_lock, flags);
49 if (!sig->stats) {
50 sig->stats = stats;
51 stats = NULL;
52 }
53 spin_unlock_irqrestore(&sig->stats_lock, flags);
54
55 if (stats)
56 kmem_cache_free(taskstats_cache, stats);
57}
41 58
59static inline void taskstats_tgid_free(struct signal_struct *sig)
60{
61 struct taskstats *stats = NULL;
62 unsigned long flags;
63
64 spin_lock_irqsave(&sig->stats_lock, flags);
65 if (sig->stats) {
66 stats = sig->stats;
67 sig->stats = NULL;
68 }
69 spin_unlock_irqrestore(&sig->stats_lock, flags);
70 if (stats)
71 kmem_cache_free(taskstats_cache, stats);
72}
73
74extern void taskstats_exit_send(struct task_struct *, struct taskstats *, int);
75extern void taskstats_init_early(void);
76extern void taskstats_tgid_alloc(struct signal_struct *);
42#else 77#else
43static inline void taskstats_exit_alloc(struct taskstats **ptidstats, 78static inline void taskstats_exit_alloc(struct taskstats **ptidstats)
44 struct taskstats **ptgidstats)
45{} 79{}
46static inline void taskstats_exit_free(struct taskstats *ptidstats, 80static inline void taskstats_exit_free(struct taskstats *ptidstats)
47 struct taskstats *ptgidstats)
48{} 81{}
49static inline void taskstats_exit_send(struct task_struct *tsk, 82static inline void taskstats_exit_send(struct task_struct *tsk,
50 struct taskstats *tidstats, 83 struct taskstats *tidstats,
51 struct taskstats *tgidstats) 84 int group_dead)
85{}
86static inline void taskstats_tgid_init(struct signal_struct *sig)
87{}
88static inline void taskstats_tgid_alloc(struct signal_struct *sig)
89{}
90static inline void taskstats_tgid_free(struct signal_struct *sig)
52{} 91{}
53static inline void taskstats_init_early(void) 92static inline void taskstats_init_early(void)
54{} 93{}