delayacct.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* delayacct.h - per-task delay accounting
  2. *
  3. * Copyright (C) Shailabh Nagar, IBM Corp. 2006
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  13. * the GNU General Public License for more details.
  14. *
  15. */
  16. #ifndef _LINUX_DELAYACCT_H
  17. #define _LINUX_DELAYACCT_H
  18. #include <linux/sched.h>
  19. /*
  20. * Per-task flags relevant to delay accounting
  21. * maintained privately to avoid exhausting similar flags in sched.h:PF_*
  22. * Used to set current->delays->flags
  23. */
  24. #define DELAYACCT_PF_SWAPIN 0x00000001 /* I am doing a swapin */
  25. #ifdef CONFIG_TASK_DELAY_ACCT
  26. extern int delayacct_on; /* Delay accounting turned on/off */
  27. extern kmem_cache_t *delayacct_cache;
  28. extern void delayacct_init(void);
  29. extern void __delayacct_tsk_init(struct task_struct *);
  30. extern void __delayacct_tsk_exit(struct task_struct *);
  31. extern void __delayacct_blkio_start(void);
  32. extern void __delayacct_blkio_end(void);
  33. static inline void delayacct_set_flag(int flag)
  34. {
  35. if (current->delays)
  36. current->delays->flags |= flag;
  37. }
  38. static inline void delayacct_clear_flag(int flag)
  39. {
  40. if (current->delays)
  41. current->delays->flags &= ~flag;
  42. }
  43. static inline void delayacct_tsk_init(struct task_struct *tsk)
  44. {
  45. /* reinitialize in case parent's non-null pointer was dup'ed*/
  46. tsk->delays = NULL;
  47. if (unlikely(delayacct_on))
  48. __delayacct_tsk_init(tsk);
  49. }
  50. static inline void delayacct_tsk_exit(struct task_struct *tsk)
  51. {
  52. if (tsk->delays)
  53. __delayacct_tsk_exit(tsk);
  54. }
  55. static inline void delayacct_blkio_start(void)
  56. {
  57. if (current->delays)
  58. __delayacct_blkio_start();
  59. }
  60. static inline void delayacct_blkio_end(void)
  61. {
  62. if (current->delays)
  63. __delayacct_blkio_end();
  64. }
  65. #else
  66. static inline void delayacct_set_flag(int flag)
  67. {}
  68. static inline void delayacct_clear_flag(int flag)
  69. {}
  70. static inline void delayacct_init(void)
  71. {}
  72. static inline void delayacct_tsk_init(struct task_struct *tsk)
  73. {}
  74. static inline void delayacct_tsk_exit(struct task_struct *tsk)
  75. {}
  76. static inline void delayacct_blkio_start(void)
  77. {}
  78. static inline void delayacct_blkio_end(void)
  79. {}
  80. #endif /* CONFIG_TASK_DELAY_ACCT */
  81. #endif