LCOV - code coverage report
Current view: top level - include/linux - task_io_accounting_ops.h (source / functions) Hit Total Coverage
Test: landlock.info Lines: 13 29 44.8 %
Date: 2021-04-22 12:43:58 Functions: 0 2 0.0 %

          Line data    Source code
       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
      11        5662 : static inline void task_io_account_read(size_t bytes)
      12             : {
      13        5662 :         current->ioac.read_bytes += bytes;
      14           0 : }
      15             : 
      16             : /*
      17             :  * We approximate number of blocks, because we account bytes only.
      18             :  * A 'block' is 512 bytes
      19             :  */
      20           2 : static inline unsigned long task_io_get_inblock(const struct task_struct *p)
      21             : {
      22           2 :         return p->ioac.read_bytes >> 9;
      23             : }
      24             : 
      25        2493 : static inline void task_io_account_write(size_t bytes)
      26             : {
      27        2493 :         current->ioac.write_bytes += bytes;
      28           0 : }
      29             : 
      30             : /*
      31             :  * We approximate number of blocks, because we account bytes only.
      32             :  * A 'block' is 512 bytes
      33             :  */
      34           2 : static inline unsigned long task_io_get_oublock(const struct task_struct *p)
      35             : {
      36           2 :         return p->ioac.write_bytes >> 9;
      37             : }
      38             : 
      39         496 : static inline void task_io_account_cancelled_write(size_t bytes)
      40             : {
      41         496 :         current->ioac.cancelled_write_bytes += bytes;
      42         496 : }
      43             : 
      44         916 : static inline void task_io_accounting_init(struct task_io_accounting *ioac)
      45             : {
      46         916 :         memset(ioac, 0, sizeof(*ioac));
      47             : }
      48             : 
      49           0 : static inline void task_blk_io_accounting_add(struct task_io_accounting *dst,
      50             :                                                 struct task_io_accounting *src)
      51             : {
      52           0 :         dst->read_bytes += src->read_bytes;
      53           0 :         dst->write_bytes += src->write_bytes;
      54           0 :         dst->cancelled_write_bytes += src->cancelled_write_bytes;
      55             : }
      56             : 
      57             : #else
      58             : 
      59             : static inline void task_io_account_read(size_t bytes)
      60             : {
      61             : }
      62             : 
      63             : static inline unsigned long task_io_get_inblock(const struct task_struct *p)
      64             : {
      65             :         return 0;
      66             : }
      67             : 
      68             : static inline void task_io_account_write(size_t bytes)
      69             : {
      70             : }
      71             : 
      72             : static inline unsigned long task_io_get_oublock(const struct task_struct *p)
      73             : {
      74             :         return 0;
      75             : }
      76             : 
      77             : static inline void task_io_account_cancelled_write(size_t bytes)
      78             : {
      79             : }
      80             : 
      81             : static inline void task_io_accounting_init(struct task_io_accounting *ioac)
      82             : {
      83             : }
      84             : 
      85             : static 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
      93           0 : static inline void task_chr_io_accounting_add(struct task_io_accounting *dst,
      94             :                                                 struct task_io_accounting *src)
      95             : {
      96           0 :         dst->rchar += src->rchar;
      97           0 :         dst->wchar += src->wchar;
      98           0 :         dst->syscr += src->syscr;
      99           0 :         dst->syscw += src->syscw;
     100           0 : }
     101             : #else
     102             : static 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             : 
     108           0 : static inline void task_io_accounting_add(struct task_io_accounting *dst,
     109             :                                                 struct task_io_accounting *src)
     110             : {
     111           0 :         task_chr_io_accounting_add(dst, src);
     112           0 :         task_blk_io_accounting_add(dst, src);
     113           0 : }
     114             : #endif /* __TASK_IO_ACCOUNTING_OPS_INCLUDED */

Generated by: LCOV version 1.14