~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/task_io_accounting_ops.h

Version: ~ [ linux-5.3-rc5 ] ~ [ linux-5.2.9 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.67 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.139 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.189 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.189 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.72 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Task I/O accounting operations
  3  */
  4 #ifndef __TASK_IO_ACCOUNTING_OPS_INCLUDED
  5 #define __TASK_IO_ACCOUNTING_OPS_INCLUDED
  6 
  7 #include <linux/sched.h>
  8 
  9 #ifdef CONFIG_TASK_IO_ACCOUNTING
 10 static inline void task_io_account_read(size_t bytes)
 11 {
 12         current->ioac.read_bytes += bytes;
 13 }
 14 
 15 /*
 16  * We approximate number of blocks, because we account bytes only.
 17  * A 'block' is 512 bytes
 18  */
 19 static inline unsigned long task_io_get_inblock(const struct task_struct *p)
 20 {
 21         return p->ioac.read_bytes >> 9;
 22 }
 23 
 24 static inline void task_io_account_write(size_t bytes)
 25 {
 26         current->ioac.write_bytes += bytes;
 27 }
 28 
 29 /*
 30  * We approximate number of blocks, because we account bytes only.
 31  * A 'block' is 512 bytes
 32  */
 33 static inline unsigned long task_io_get_oublock(const struct task_struct *p)
 34 {
 35         return p->ioac.write_bytes >> 9;
 36 }
 37 
 38 static inline void task_io_account_cancelled_write(size_t bytes)
 39 {
 40         current->ioac.cancelled_write_bytes += bytes;
 41 }
 42 
 43 static inline void task_io_accounting_init(struct task_io_accounting *ioac)
 44 {
 45         memset(ioac, 0, sizeof(*ioac));
 46 }
 47 
 48 static inline void task_blk_io_accounting_add(struct task_io_accounting *dst,
 49                                                 struct task_io_accounting *src)
 50 {
 51         dst->read_bytes += src->read_bytes;
 52         dst->write_bytes += src->write_bytes;
 53         dst->cancelled_write_bytes += src->cancelled_write_bytes;
 54 }
 55 
 56 #else
 57 
 58 static inline void task_io_account_read(size_t bytes)
 59 {
 60 }
 61 
 62 static inline unsigned long task_io_get_inblock(const struct task_struct *p)
 63 {
 64         return 0;
 65 }
 66 
 67 static inline void task_io_account_write(size_t bytes)
 68 {
 69 }
 70 
 71 static inline unsigned long task_io_get_oublock(const struct task_struct *p)
 72 {
 73         return 0;
 74 }
 75 
 76 static inline void task_io_account_cancelled_write(size_t bytes)
 77 {
 78 }
 79 
 80 static inline void task_io_accounting_init(struct task_io_accounting *ioac)
 81 {
 82 }
 83 
 84 static inline void task_blk_io_accounting_add(struct task_io_accounting *dst,
 85                                                 struct task_io_accounting *src)
 86 {
 87 }
 88 
 89 #endif /* CONFIG_TASK_IO_ACCOUNTING */
 90 
 91 #ifdef CONFIG_TASK_XACCT
 92 static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
 93                                                 struct task_io_accounting *src)
 94 {
 95         dst->rchar += src->rchar;
 96         dst->wchar += src->wchar;
 97         dst->syscr += src->syscr;
 98         dst->syscw += src->syscw;
 99 }
100 #else
101 static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
102                                                 struct task_io_accounting *src)
103 {
104 }
105 #endif /* CONFIG_TASK_XACCT */
106 
107 static inline void task_io_accounting_add(struct task_io_accounting *dst,
108                                                 struct task_io_accounting *src)
109 {
110         task_chr_io_accounting_add(dst, src);
111         task_blk_io_accounting_add(dst, src);
112 }
113 #endif /* __TASK_IO_ACCOUNTING_OPS_INCLUDED */
114 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp