Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f44993f authored by Shailabh Nagar's avatar Shailabh Nagar Committed by Linus Torvalds
Browse files

[PATCH] per-task-delay-accounting: delay accounting usage of taskstats interface



Usage of taskstats interface by delay accounting.

Signed-off-by: default avatarShailabh Nagar <nagar@us.ibm.com>
Signed-off-by: default avatarBalbir Singh <balbir@in.ibm.com>
Cc: Jes Sorensen <jes@sgi.com>
Cc: Peter Chubb <peterc@gelato.unsw.edu.au>
Cc: Erich Focht <efocht@ess.nec.de>
Cc: Levent Serinol <lserinol@gmail.com>
Cc: Jay Lan <jlan@engr.sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c757249a
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define _LINUX_DELAYACCT_H

#include <linux/sched.h>
#include <linux/taskstats_kern.h>

/*
 * Per-task flags relevant to delay accounting
@@ -35,6 +36,7 @@ extern void __delayacct_tsk_init(struct task_struct *);
extern void __delayacct_tsk_exit(struct task_struct *);
extern void __delayacct_blkio_start(void);
extern void __delayacct_blkio_end(void);
extern int __delayacct_add_tsk(struct taskstats *, struct task_struct *);

static inline void delayacct_set_flag(int flag)
{
@@ -74,6 +76,16 @@ static inline void delayacct_blkio_end(void)
		__delayacct_blkio_end();
}

static inline int delayacct_add_tsk(struct taskstats *d,
					struct task_struct *tsk)
{
	if (likely(!delayacct_on))
		return -EINVAL;
	if (!tsk->delays)
		return 0;
	return __delayacct_add_tsk(d, tsk);
}

#else
static inline void delayacct_set_flag(int flag)
{}
@@ -89,6 +101,9 @@ static inline void delayacct_blkio_start(void)
{}
static inline void delayacct_blkio_end(void)
{}
static inline int delayacct_add_tsk(struct taskstats *d,
					struct task_struct *tsk)
{ return 0; }
#endif /* CONFIG_TASK_DELAY_ACCT */

#endif
+1 −0
Original line number Diff line number Diff line
@@ -990,6 +990,7 @@ struct task_struct {
	 */
	struct pipe_inode_info *splice_pipe;
#ifdef	CONFIG_TASK_DELAY_ACCT
	spinlock_t delays_lock;
	struct task_delay_info *delays;
#endif
};
+54 −1
Original line number Diff line number Diff line
@@ -34,7 +34,60 @@
struct taskstats {

	/* Version 1 */
	__u64	version;
	__u16	version;
	__u16	padding[3];	/* Userspace should not interpret the padding
				 * field which can be replaced by useful
				 * fields if struct taskstats is extended.
				 */

	/* Delay accounting fields start
	 *
	 * All values, until comment "Delay accounting fields end" are
	 * available only if delay accounting is enabled, even though the last
	 * few fields are not delays
	 *
	 * xxx_count is the number of delay values recorded
	 * xxx_delay_total is the corresponding cumulative delay in nanoseconds
	 *
	 * xxx_delay_total wraps around to zero on overflow
	 * xxx_count incremented regardless of overflow
	 */

	/* Delay waiting for cpu, while runnable
	 * count, delay_total NOT updated atomically
	 */
	__u64	cpu_count;
	__u64	cpu_delay_total;

	/* Following four fields atomically updated using task->delays->lock */

	/* Delay waiting for synchronous block I/O to complete
	 * does not account for delays in I/O submission
	 */
	__u64	blkio_count;
	__u64	blkio_delay_total;

	/* Delay waiting for page fault I/O (swap in only) */
	__u64	swapin_count;
	__u64	swapin_delay_total;

	/* cpu "wall-clock" running time
	 * On some architectures, value will adjust for cpu time stolen
	 * from the kernel in involuntary waits due to virtualization.
	 * Value is cumulative, in nanoseconds, without a corresponding count
	 * and wraps around to zero silently on overflow
	 */
	__u64	cpu_run_real_total;

	/* cpu "virtual" running time
	 * Uses time intervals seen by the kernel i.e. no adjustment
	 * for kernel's involuntary waits due to virtualization.
	 * Value is cumulative, in nanoseconds, without a corresponding count
	 * and wraps around to zero silently on overflow
	 */
	__u64	cpu_run_virtual_total;
	/* Delay accounting fields end */
	/* version 1 ends here */
};


+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ enum {

#ifdef CONFIG_TASKSTATS
extern kmem_cache_t *taskstats_cache;
extern struct mutex taskstats_exit_mutex;

static inline void taskstats_exit_alloc(struct taskstats **ptidstats,
					struct taskstats **ptgidstats)
+1 −0
Original line number Diff line number Diff line
@@ -173,6 +173,7 @@ config TASKSTATS

config TASK_DELAY_ACCT
	bool "Enable per-task delay accounting (EXPERIMENTAL)"
	depends on TASKSTATS
	help
	  Collect information on time spent by a task waiting for system
	  resources like cpu, synchronous block I/O completion and swapping
Loading