2 * Task I/O accounting operations
4 #ifndef __TASK_IO_ACCOUNTING_OPS_INCLUDED
5 #define __TASK_IO_ACCOUNTING_OPS_INCLUDED
7 #include <linux/sched.h>
9 #ifdef CONFIG_TASK_IO_ACCOUNTING
10 static inline void task_io_account_read(size_t bytes)
12 current->ioac.blk.read_bytes += bytes;
16 * We approximate number of blocks, because we account bytes only.
17 * A 'block' is 512 bytes
19 static inline unsigned long task_io_get_inblock(const struct task_struct *p)
21 return p->ioac.blk.read_bytes >> 9;
24 static inline void task_io_account_write(size_t bytes)
26 current->ioac.blk.write_bytes += bytes;
30 * We approximate number of blocks, because we account bytes only.
31 * A 'block' is 512 bytes
33 static inline unsigned long task_io_get_oublock(const struct task_struct *p)
35 return p->ioac.blk.write_bytes >> 9;
38 static inline void task_io_account_cancelled_write(size_t bytes)
40 current->ioac.blk.cancelled_write_bytes += bytes;
43 static inline void task_io_accounting_init(struct proc_io_accounting *ioac)
45 memset(ioac, 0, sizeof(*ioac));
48 static inline void task_blk_io_accounting_add(struct proc_io_accounting *dst,
49 struct proc_io_accounting *src)
51 dst->blk.read_bytes += src->blk.read_bytes;
52 dst->blk.write_bytes += src->blk.write_bytes;
53 dst->blk.cancelled_write_bytes += src->blk.cancelled_write_bytes;
58 static inline void task_io_account_read(size_t bytes)
62 static inline unsigned long task_io_get_inblock(const struct task_struct *p)
67 static inline void task_io_account_write(size_t bytes)
71 static inline unsigned long task_io_get_oublock(const struct task_struct *p)
76 static inline void task_io_account_cancelled_write(size_t bytes)
80 static inline void task_io_accounting_init(struct proc_io_accounting *ioac)
84 static inline void task_blk_io_accounting_add(struct proc_io_accounting *dst,
85 struct proc_io_accounting *src)
89 #endif /* CONFIG_TASK_IO_ACCOUNTING */
91 #ifdef CONFIG_TASK_XACCT
92 static inline void task_chr_io_accounting_add(struct proc_io_accounting *dst,
93 struct proc_io_accounting *src)
95 dst->chr.rchar += src->chr.rchar;
96 dst->chr.wchar += src->chr.wchar;
97 dst->chr.syscr += src->chr.syscr;
98 dst->chr.syscw += src->chr.syscw;
101 static inline void task_chr_io_accounting_add(struct proc_io_accounting *dst,
102 struct proc_io_accounting *src)
105 #endif /* CONFIG_TASK_XACCT */
107 static inline void task_io_accounting_add(struct proc_io_accounting *dst,
108 struct proc_io_accounting *src)
110 task_chr_io_accounting_add(dst, src);
111 task_blk_io_accounting_add(dst, src);
113 #endif /* __TASK_IO_ACCOUNTING_OPS_INCLUDED */