Linux Audio

Check our new training course

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