forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PATCH] per-task-delay-accounting: setup
Initialization code related to collection of per-task "delay" statistics which measure how long it had to wait for cpu, sync block io, swapping etc. The collection of statistics and the interface are in other patches. This patch sets up the data structures and allows the statistics collection to be disabled through a kernel boot parameter. Signed-off-by: Shailabh Nagar <[email protected]> Signed-off-by: Balbir Singh <[email protected]> Cc: Jes Sorensen <[email protected]> Cc: Peter Chubb <[email protected]> Cc: Erich Focht <[email protected]> Cc: Levent Serinol <[email protected]> Cc: Jay Lan <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
- Loading branch information
Shailabh Nagar
authored and
Linus Torvalds
committed
Jul 15, 2006
1 parent
e8f4d97
commit ca74e92
Showing
10 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* delayacct.h - per-task delay accounting | ||
* | ||
* Copyright (C) Shailabh Nagar, IBM Corp. 2006 | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See | ||
* the GNU General Public License for more details. | ||
* | ||
*/ | ||
|
||
#ifndef _LINUX_DELAYACCT_H | ||
#define _LINUX_DELAYACCT_H | ||
|
||
#include <linux/sched.h> | ||
|
||
#ifdef CONFIG_TASK_DELAY_ACCT | ||
|
||
extern int delayacct_on; /* Delay accounting turned on/off */ | ||
extern kmem_cache_t *delayacct_cache; | ||
extern void delayacct_init(void); | ||
extern void __delayacct_tsk_init(struct task_struct *); | ||
extern void __delayacct_tsk_exit(struct task_struct *); | ||
|
||
static inline void delayacct_set_flag(int flag) | ||
{ | ||
if (current->delays) | ||
current->delays->flags |= flag; | ||
} | ||
|
||
static inline void delayacct_clear_flag(int flag) | ||
{ | ||
if (current->delays) | ||
current->delays->flags &= ~flag; | ||
} | ||
|
||
static inline void delayacct_tsk_init(struct task_struct *tsk) | ||
{ | ||
/* reinitialize in case parent's non-null pointer was dup'ed*/ | ||
tsk->delays = NULL; | ||
if (unlikely(delayacct_on)) | ||
__delayacct_tsk_init(tsk); | ||
} | ||
|
||
static inline void delayacct_tsk_exit(struct task_struct *tsk) | ||
{ | ||
if (tsk->delays) | ||
__delayacct_tsk_exit(tsk); | ||
} | ||
|
||
#else | ||
static inline void delayacct_set_flag(int flag) | ||
{} | ||
static inline void delayacct_clear_flag(int flag) | ||
{} | ||
static inline void delayacct_init(void) | ||
{} | ||
static inline void delayacct_tsk_init(struct task_struct *tsk) | ||
{} | ||
static inline void delayacct_tsk_exit(struct task_struct *tsk) | ||
{} | ||
#endif /* CONFIG_TASK_DELAY_ACCT */ | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ obj-$(CONFIG_GENERIC_HARDIRQS) += irq/ | |
obj-$(CONFIG_SECCOMP) += seccomp.o | ||
obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o | ||
obj-$(CONFIG_RELAY) += relay.o | ||
obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o | ||
|
||
ifneq ($(CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER),y) | ||
# According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* delayacct.c - per-task delay accounting | ||
* | ||
* Copyright (C) Shailabh Nagar, IBM Corp. 2006 | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it would be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See | ||
* the GNU General Public License for more details. | ||
*/ | ||
|
||
#include <linux/sched.h> | ||
#include <linux/slab.h> | ||
#include <linux/time.h> | ||
#include <linux/sysctl.h> | ||
#include <linux/delayacct.h> | ||
|
||
int delayacct_on __read_mostly; /* Delay accounting turned on/off */ | ||
kmem_cache_t *delayacct_cache; | ||
|
||
static int __init delayacct_setup_enable(char *str) | ||
{ | ||
delayacct_on = 1; | ||
return 1; | ||
} | ||
__setup("delayacct", delayacct_setup_enable); | ||
|
||
void delayacct_init(void) | ||
{ | ||
delayacct_cache = kmem_cache_create("delayacct_cache", | ||
sizeof(struct task_delay_info), | ||
0, | ||
SLAB_PANIC, | ||
NULL, NULL); | ||
delayacct_tsk_init(&init_task); | ||
} | ||
|
||
void __delayacct_tsk_init(struct task_struct *tsk) | ||
{ | ||
tsk->delays = kmem_cache_zalloc(delayacct_cache, SLAB_KERNEL); | ||
if (tsk->delays) | ||
spin_lock_init(&tsk->delays->lock); | ||
} | ||
|
||
void __delayacct_tsk_exit(struct task_struct *tsk) | ||
{ | ||
kmem_cache_free(delayacct_cache, tsk->delays); | ||
tsk->delays = NULL; | ||
} | ||
|
||
/* | ||
* Start accounting for a delay statistic using | ||
* its starting timestamp (@start) | ||
*/ | ||
|
||
static inline void delayacct_start(struct timespec *start) | ||
{ | ||
do_posix_clock_monotonic_gettime(start); | ||
} | ||
|
||
/* | ||
* Finish delay accounting for a statistic using | ||
* its timestamps (@start, @end), accumalator (@total) and @count | ||
*/ | ||
|
||
static void delayacct_end(struct timespec *start, struct timespec *end, | ||
u64 *total, u32 *count) | ||
{ | ||
struct timespec ts; | ||
s64 ns; | ||
|
||
do_posix_clock_monotonic_gettime(end); | ||
ts = timespec_sub(*end, *start); | ||
ns = timespec_to_ns(&ts); | ||
if (ns < 0) | ||
return; | ||
|
||
spin_lock(¤t->delays->lock); | ||
*total += ns; | ||
(*count)++; | ||
spin_unlock(¤t->delays->lock); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters