mirror of https://gitee.com/openkylin/linux.git
task IO accounting: move all IO statistics in struct task_io_accounting
Simplify the code of include/linux/task_io_accounting.h. It is also more reasonable to have all the task i/o-related statistics in a single struct (task_io_accounting). Signed-off-by: Andrea Righi <righi.andrea@gmail.com> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
837b41b5de
commit
940389b8af
|
@ -2403,7 +2403,7 @@ static int proc_base_fill_cache(struct file *filp, void *dirent,
|
||||||
#ifdef CONFIG_TASK_IO_ACCOUNTING
|
#ifdef CONFIG_TASK_IO_ACCOUNTING
|
||||||
static int do_io_accounting(struct task_struct *task, char *buffer, int whole)
|
static int do_io_accounting(struct task_struct *task, char *buffer, int whole)
|
||||||
{
|
{
|
||||||
struct proc_io_accounting acct = task->ioac;
|
struct task_io_accounting acct = task->ioac;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (whole && lock_task_sighand(task, &flags)) {
|
if (whole && lock_task_sighand(task, &flags)) {
|
||||||
|
@ -2423,10 +2423,10 @@ static int do_io_accounting(struct task_struct *task, char *buffer, int whole)
|
||||||
"read_bytes: %llu\n"
|
"read_bytes: %llu\n"
|
||||||
"write_bytes: %llu\n"
|
"write_bytes: %llu\n"
|
||||||
"cancelled_write_bytes: %llu\n",
|
"cancelled_write_bytes: %llu\n",
|
||||||
acct.chr.rchar, acct.chr.wchar,
|
acct.rchar, acct.wchar,
|
||||||
acct.chr.syscr, acct.chr.syscw,
|
acct.syscr, acct.syscw,
|
||||||
acct.blk.read_bytes, acct.blk.write_bytes,
|
acct.read_bytes, acct.write_bytes,
|
||||||
acct.blk.cancelled_write_bytes);
|
acct.cancelled_write_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int proc_tid_io_accounting(struct task_struct *task, char *buffer)
|
static int proc_tid_io_accounting(struct task_struct *task, char *buffer)
|
||||||
|
|
|
@ -505,7 +505,7 @@ struct signal_struct {
|
||||||
unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
|
unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
|
||||||
unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
|
unsigned long min_flt, maj_flt, cmin_flt, cmaj_flt;
|
||||||
unsigned long inblock, oublock, cinblock, coublock;
|
unsigned long inblock, oublock, cinblock, coublock;
|
||||||
struct proc_io_accounting ioac;
|
struct task_io_accounting ioac;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cumulative ns of scheduled CPU time for dead threads in the
|
* Cumulative ns of scheduled CPU time for dead threads in the
|
||||||
|
@ -1253,7 +1253,7 @@ struct task_struct {
|
||||||
|
|
||||||
unsigned long ptrace_message;
|
unsigned long ptrace_message;
|
||||||
siginfo_t *last_siginfo; /* For ptrace use. */
|
siginfo_t *last_siginfo; /* For ptrace use. */
|
||||||
struct proc_io_accounting ioac;
|
struct task_io_accounting ioac;
|
||||||
#if defined(CONFIG_TASK_XACCT)
|
#if defined(CONFIG_TASK_XACCT)
|
||||||
u64 acct_rss_mem1; /* accumulated rss usage */
|
u64 acct_rss_mem1; /* accumulated rss usage */
|
||||||
u64 acct_vm_mem1; /* accumulated virtual memory usage */
|
u64 acct_vm_mem1; /* accumulated virtual memory usage */
|
||||||
|
@ -2183,22 +2183,22 @@ extern long sched_group_rt_period(struct task_group *tg);
|
||||||
#ifdef CONFIG_TASK_XACCT
|
#ifdef CONFIG_TASK_XACCT
|
||||||
static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
|
static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
|
||||||
{
|
{
|
||||||
tsk->ioac.chr.rchar += amt;
|
tsk->ioac.rchar += amt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void add_wchar(struct task_struct *tsk, ssize_t amt)
|
static inline void add_wchar(struct task_struct *tsk, ssize_t amt)
|
||||||
{
|
{
|
||||||
tsk->ioac.chr.wchar += amt;
|
tsk->ioac.wchar += amt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void inc_syscr(struct task_struct *tsk)
|
static inline void inc_syscr(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
tsk->ioac.chr.syscr++;
|
tsk->ioac.syscr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void inc_syscw(struct task_struct *tsk)
|
static inline void inc_syscw(struct task_struct *tsk)
|
||||||
{
|
{
|
||||||
tsk->ioac.chr.syscw++;
|
tsk->ioac.syscw++;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
|
static inline void add_rchar(struct task_struct *tsk, ssize_t amt)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* proc_io_accounting: a structure which is used for recording a single task's
|
* task_io_accounting: a structure which is used for recording a single task's
|
||||||
* IO statistics.
|
* IO statistics.
|
||||||
*
|
*
|
||||||
* Don't include this header file directly - it is designed to be dragged in via
|
* Don't include this header file directly - it is designed to be dragged in via
|
||||||
|
@ -8,8 +8,8 @@
|
||||||
* Blame akpm@osdl.org for all this.
|
* Blame akpm@osdl.org for all this.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct task_io_accounting {
|
||||||
#ifdef CONFIG_TASK_XACCT
|
#ifdef CONFIG_TASK_XACCT
|
||||||
struct task_chr_io_accounting {
|
|
||||||
/* bytes read */
|
/* bytes read */
|
||||||
u64 rchar;
|
u64 rchar;
|
||||||
/* bytes written */
|
/* bytes written */
|
||||||
|
@ -18,14 +18,9 @@ struct task_chr_io_accounting {
|
||||||
u64 syscr;
|
u64 syscr;
|
||||||
/* # of write syscalls */
|
/* # of write syscalls */
|
||||||
u64 syscw;
|
u64 syscw;
|
||||||
};
|
|
||||||
#else /* CONFIG_TASK_XACCT */
|
|
||||||
struct task_chr_io_accounting {
|
|
||||||
};
|
|
||||||
#endif /* CONFIG_TASK_XACCT */
|
#endif /* CONFIG_TASK_XACCT */
|
||||||
|
|
||||||
#ifdef CONFIG_TASK_IO_ACCOUNTING
|
#ifdef CONFIG_TASK_IO_ACCOUNTING
|
||||||
struct task_io_accounting {
|
|
||||||
/*
|
/*
|
||||||
* The number of bytes which this task has caused to be read from
|
* The number of bytes which this task has caused to be read from
|
||||||
* storage.
|
* storage.
|
||||||
|
@ -46,13 +41,5 @@ struct task_io_accounting {
|
||||||
* information loss in doing that.
|
* information loss in doing that.
|
||||||
*/
|
*/
|
||||||
u64 cancelled_write_bytes;
|
u64 cancelled_write_bytes;
|
||||||
};
|
|
||||||
#else /* CONFIG_TASK_IO_ACCOUNTING */
|
|
||||||
struct task_io_accounting {
|
|
||||||
};
|
|
||||||
#endif /* CONFIG_TASK_IO_ACCOUNTING */
|
#endif /* CONFIG_TASK_IO_ACCOUNTING */
|
||||||
|
|
||||||
struct proc_io_accounting {
|
|
||||||
struct task_chr_io_accounting chr;
|
|
||||||
struct task_io_accounting blk;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#ifdef CONFIG_TASK_IO_ACCOUNTING
|
#ifdef CONFIG_TASK_IO_ACCOUNTING
|
||||||
static inline void task_io_account_read(size_t bytes)
|
static inline void task_io_account_read(size_t bytes)
|
||||||
{
|
{
|
||||||
current->ioac.blk.read_bytes += bytes;
|
current->ioac.read_bytes += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -18,12 +18,12 @@ static inline void task_io_account_read(size_t bytes)
|
||||||
*/
|
*/
|
||||||
static inline unsigned long task_io_get_inblock(const struct task_struct *p)
|
static inline unsigned long task_io_get_inblock(const struct task_struct *p)
|
||||||
{
|
{
|
||||||
return p->ioac.blk.read_bytes >> 9;
|
return p->ioac.read_bytes >> 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void task_io_account_write(size_t bytes)
|
static inline void task_io_account_write(size_t bytes)
|
||||||
{
|
{
|
||||||
current->ioac.blk.write_bytes += bytes;
|
current->ioac.write_bytes += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -32,25 +32,25 @@ static inline void task_io_account_write(size_t bytes)
|
||||||
*/
|
*/
|
||||||
static inline unsigned long task_io_get_oublock(const struct task_struct *p)
|
static inline unsigned long task_io_get_oublock(const struct task_struct *p)
|
||||||
{
|
{
|
||||||
return p->ioac.blk.write_bytes >> 9;
|
return p->ioac.write_bytes >> 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void task_io_account_cancelled_write(size_t bytes)
|
static inline void task_io_account_cancelled_write(size_t bytes)
|
||||||
{
|
{
|
||||||
current->ioac.blk.cancelled_write_bytes += bytes;
|
current->ioac.cancelled_write_bytes += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void task_io_accounting_init(struct proc_io_accounting *ioac)
|
static inline void task_io_accounting_init(struct task_io_accounting *ioac)
|
||||||
{
|
{
|
||||||
memset(ioac, 0, sizeof(*ioac));
|
memset(ioac, 0, sizeof(*ioac));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void task_blk_io_accounting_add(struct proc_io_accounting *dst,
|
static inline void task_blk_io_accounting_add(struct task_io_accounting *dst,
|
||||||
struct proc_io_accounting *src)
|
struct task_io_accounting *src)
|
||||||
{
|
{
|
||||||
dst->blk.read_bytes += src->blk.read_bytes;
|
dst->read_bytes += src->read_bytes;
|
||||||
dst->blk.write_bytes += src->blk.write_bytes;
|
dst->write_bytes += src->write_bytes;
|
||||||
dst->blk.cancelled_write_bytes += src->blk.cancelled_write_bytes;
|
dst->cancelled_write_bytes += src->cancelled_write_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -77,35 +77,35 @@ static inline void task_io_account_cancelled_write(size_t bytes)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void task_io_accounting_init(struct proc_io_accounting *ioac)
|
static inline void task_io_accounting_init(struct task_io_accounting *ioac)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void task_blk_io_accounting_add(struct proc_io_accounting *dst,
|
static inline void task_blk_io_accounting_add(struct task_io_accounting *dst,
|
||||||
struct proc_io_accounting *src)
|
struct task_io_accounting *src)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_TASK_IO_ACCOUNTING */
|
#endif /* CONFIG_TASK_IO_ACCOUNTING */
|
||||||
|
|
||||||
#ifdef CONFIG_TASK_XACCT
|
#ifdef CONFIG_TASK_XACCT
|
||||||
static inline void task_chr_io_accounting_add(struct proc_io_accounting *dst,
|
static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
|
||||||
struct proc_io_accounting *src)
|
struct task_io_accounting *src)
|
||||||
{
|
{
|
||||||
dst->chr.rchar += src->chr.rchar;
|
dst->rchar += src->rchar;
|
||||||
dst->chr.wchar += src->chr.wchar;
|
dst->wchar += src->wchar;
|
||||||
dst->chr.syscr += src->chr.syscr;
|
dst->syscr += src->syscr;
|
||||||
dst->chr.syscw += src->chr.syscw;
|
dst->syscw += src->syscw;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline void task_chr_io_accounting_add(struct proc_io_accounting *dst,
|
static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
|
||||||
struct proc_io_accounting *src)
|
struct task_io_accounting *src)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_TASK_XACCT */
|
#endif /* CONFIG_TASK_XACCT */
|
||||||
|
|
||||||
static inline void task_io_accounting_add(struct proc_io_accounting *dst,
|
static inline void task_io_accounting_add(struct task_io_accounting *dst,
|
||||||
struct proc_io_accounting *src)
|
struct task_io_accounting *src)
|
||||||
{
|
{
|
||||||
task_chr_io_accounting_add(dst, src);
|
task_chr_io_accounting_add(dst, src);
|
||||||
task_blk_io_accounting_add(dst, src);
|
task_blk_io_accounting_add(dst, src);
|
||||||
|
|
|
@ -94,14 +94,14 @@ void xacct_add_tsk(struct taskstats *stats, struct task_struct *p)
|
||||||
stats->hiwater_vm = mm->hiwater_vm * PAGE_SIZE / KB;
|
stats->hiwater_vm = mm->hiwater_vm * PAGE_SIZE / KB;
|
||||||
mmput(mm);
|
mmput(mm);
|
||||||
}
|
}
|
||||||
stats->read_char = p->ioac.chr.rchar;
|
stats->read_char = p->ioac.rchar;
|
||||||
stats->write_char = p->ioac.chr.wchar;
|
stats->write_char = p->ioac.wchar;
|
||||||
stats->read_syscalls = p->ioac.chr.syscr;
|
stats->read_syscalls = p->ioac.syscr;
|
||||||
stats->write_syscalls = p->ioac.chr.syscw;
|
stats->write_syscalls = p->ioac.syscw;
|
||||||
#ifdef CONFIG_TASK_IO_ACCOUNTING
|
#ifdef CONFIG_TASK_IO_ACCOUNTING
|
||||||
stats->read_bytes = p->ioac.blk.read_bytes;
|
stats->read_bytes = p->ioac.read_bytes;
|
||||||
stats->write_bytes = p->ioac.blk.write_bytes;
|
stats->write_bytes = p->ioac.write_bytes;
|
||||||
stats->cancelled_write_bytes = p->ioac.blk.cancelled_write_bytes;
|
stats->cancelled_write_bytes = p->ioac.cancelled_write_bytes;
|
||||||
#else
|
#else
|
||||||
stats->read_bytes = 0;
|
stats->read_bytes = 0;
|
||||||
stats->write_bytes = 0;
|
stats->write_bytes = 0;
|
||||||
|
|
Loading…
Reference in New Issue