Blame view

include/linux/task_io_accounting_ops.h 2.51 KB
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
1
2
3
4
5
  /*
   * Task I/O accounting operations
   */
  #ifndef __TASK_IO_ACCOUNTING_OPS_INCLUDED
  #define __TASK_IO_ACCOUNTING_OPS_INCLUDED
e8edc6e03   Alexey Dobriyan   Detach sched.h fr...
6
  #include <linux/sched.h>
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
7
8
9
  #ifdef CONFIG_TASK_IO_ACCOUNTING
  static inline void task_io_account_read(size_t bytes)
  {
940389b8a   Andrea Righi   task IO accountin...
10
  	current->ioac.read_bytes += bytes;
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
11
  }
6eaeeaba3   Eric Dumazet   getrusage(): fill...
12
13
14
15
16
17
  /*
   * We approximate number of blocks, because we account bytes only.
   * A 'block' is 512 bytes
   */
  static inline unsigned long task_io_get_inblock(const struct task_struct *p)
  {
940389b8a   Andrea Righi   task IO accountin...
18
  	return p->ioac.read_bytes >> 9;
6eaeeaba3   Eric Dumazet   getrusage(): fill...
19
  }
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
20
21
  static inline void task_io_account_write(size_t bytes)
  {
940389b8a   Andrea Righi   task IO accountin...
22
  	current->ioac.write_bytes += bytes;
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
23
  }
6eaeeaba3   Eric Dumazet   getrusage(): fill...
24
25
26
27
28
29
  /*
   * We approximate number of blocks, because we account bytes only.
   * A 'block' is 512 bytes
   */
  static inline unsigned long task_io_get_oublock(const struct task_struct *p)
  {
940389b8a   Andrea Righi   task IO accountin...
30
  	return p->ioac.write_bytes >> 9;
6eaeeaba3   Eric Dumazet   getrusage(): fill...
31
  }
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
32
33
  static inline void task_io_account_cancelled_write(size_t bytes)
  {
940389b8a   Andrea Righi   task IO accountin...
34
  	current->ioac.cancelled_write_bytes += bytes;
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
35
  }
940389b8a   Andrea Righi   task IO accountin...
36
  static inline void task_io_accounting_init(struct task_io_accounting *ioac)
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
37
  {
5995477ab   Andrea Righi   task IO accountin...
38
39
  	memset(ioac, 0, sizeof(*ioac));
  }
940389b8a   Andrea Righi   task IO accountin...
40
41
  static inline void task_blk_io_accounting_add(struct task_io_accounting *dst,
  						struct task_io_accounting *src)
5995477ab   Andrea Righi   task IO accountin...
42
  {
940389b8a   Andrea Righi   task IO accountin...
43
44
45
  	dst->read_bytes += src->read_bytes;
  	dst->write_bytes += src->write_bytes;
  	dst->cancelled_write_bytes += src->cancelled_write_bytes;
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
46
47
48
49
50
51
52
  }
  
  #else
  
  static inline void task_io_account_read(size_t bytes)
  {
  }
6eaeeaba3   Eric Dumazet   getrusage(): fill...
53
54
55
56
  static inline unsigned long task_io_get_inblock(const struct task_struct *p)
  {
  	return 0;
  }
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
57
58
59
  static inline void task_io_account_write(size_t bytes)
  {
  }
6eaeeaba3   Eric Dumazet   getrusage(): fill...
60
61
62
63
  static inline unsigned long task_io_get_oublock(const struct task_struct *p)
  {
  	return 0;
  }
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
64
65
66
  static inline void task_io_account_cancelled_write(size_t bytes)
  {
  }
940389b8a   Andrea Righi   task IO accountin...
67
  static inline void task_io_accounting_init(struct task_io_accounting *ioac)
5995477ab   Andrea Righi   task IO accountin...
68
69
  {
  }
940389b8a   Andrea Righi   task IO accountin...
70
71
  static inline void task_blk_io_accounting_add(struct task_io_accounting *dst,
  						struct task_io_accounting *src)
7c3ab7381   Andrew Morton   [PATCH] io-accoun...
72
73
  {
  }
5995477ab   Andrea Righi   task IO accountin...
74
75
76
  #endif /* CONFIG_TASK_IO_ACCOUNTING */
  
  #ifdef CONFIG_TASK_XACCT
940389b8a   Andrea Righi   task IO accountin...
77
78
  static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
  						struct task_io_accounting *src)
5995477ab   Andrea Righi   task IO accountin...
79
  {
940389b8a   Andrea Righi   task IO accountin...
80
81
82
83
  	dst->rchar += src->rchar;
  	dst->wchar += src->wchar;
  	dst->syscr += src->syscr;
  	dst->syscw += src->syscw;
5995477ab   Andrea Righi   task IO accountin...
84
85
  }
  #else
940389b8a   Andrea Righi   task IO accountin...
86
87
  static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
  						struct task_io_accounting *src)
5995477ab   Andrea Righi   task IO accountin...
88
89
90
  {
  }
  #endif /* CONFIG_TASK_XACCT */
940389b8a   Andrea Righi   task IO accountin...
91
92
  static inline void task_io_accounting_add(struct task_io_accounting *dst,
  						struct task_io_accounting *src)
5995477ab   Andrea Righi   task IO accountin...
93
94
95
96
97
  {
  	task_chr_io_accounting_add(dst, src);
  	task_blk_io_accounting_add(dst, src);
  }
  #endif /* __TASK_IO_ACCOUNTING_OPS_INCLUDED */