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