taskstats.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* taskstats.h - exporting per-task statistics
  2. *
  3. * Copyright (C) Shailabh Nagar, IBM Corp. 2006
  4. * (C) Balbir Singh, IBM Corp. 2006
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of version 2.1 of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it would be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. */
  14. #ifndef _LINUX_TASKSTATS_H
  15. #define _LINUX_TASKSTATS_H
  16. /* Format for per-task data returned to userland when
  17. * - a task exits
  18. * - listener requests stats for a task
  19. *
  20. * The struct is versioned. Newer versions should only add fields to
  21. * the bottom of the struct to maintain backward compatibility.
  22. *
  23. *
  24. * To add new fields
  25. * a) bump up TASKSTATS_VERSION
  26. * b) add comment indicating new version number at end of struct
  27. * c) add new fields after version comment; maintain 64-bit alignment
  28. */
  29. #define TASKSTATS_VERSION 1
  30. struct taskstats {
  31. /* Version 1 */
  32. __u16 version;
  33. __u16 padding[3]; /* Userspace should not interpret the padding
  34. * field which can be replaced by useful
  35. * fields if struct taskstats is extended.
  36. */
  37. /* Delay accounting fields start
  38. *
  39. * All values, until comment "Delay accounting fields end" are
  40. * available only if delay accounting is enabled, even though the last
  41. * few fields are not delays
  42. *
  43. * xxx_count is the number of delay values recorded
  44. * xxx_delay_total is the corresponding cumulative delay in nanoseconds
  45. *
  46. * xxx_delay_total wraps around to zero on overflow
  47. * xxx_count incremented regardless of overflow
  48. */
  49. /* Delay waiting for cpu, while runnable
  50. * count, delay_total NOT updated atomically
  51. */
  52. __u64 cpu_count;
  53. __u64 cpu_delay_total;
  54. /* Following four fields atomically updated using task->delays->lock */
  55. /* Delay waiting for synchronous block I/O to complete
  56. * does not account for delays in I/O submission
  57. */
  58. __u64 blkio_count;
  59. __u64 blkio_delay_total;
  60. /* Delay waiting for page fault I/O (swap in only) */
  61. __u64 swapin_count;
  62. __u64 swapin_delay_total;
  63. /* cpu "wall-clock" running time
  64. * On some architectures, value will adjust for cpu time stolen
  65. * from the kernel in involuntary waits due to virtualization.
  66. * Value is cumulative, in nanoseconds, without a corresponding count
  67. * and wraps around to zero silently on overflow
  68. */
  69. __u64 cpu_run_real_total;
  70. /* cpu "virtual" running time
  71. * Uses time intervals seen by the kernel i.e. no adjustment
  72. * for kernel's involuntary waits due to virtualization.
  73. * Value is cumulative, in nanoseconds, without a corresponding count
  74. * and wraps around to zero silently on overflow
  75. */
  76. __u64 cpu_run_virtual_total;
  77. /* Delay accounting fields end */
  78. /* version 1 ends here */
  79. };
  80. #define TASKSTATS_LISTEN_GROUP 0x1
  81. /*
  82. * Commands sent from userspace
  83. * Not versioned. New commands should only be inserted at the enum's end
  84. * prior to __TASKSTATS_CMD_MAX
  85. */
  86. enum {
  87. TASKSTATS_CMD_UNSPEC = 0, /* Reserved */
  88. TASKSTATS_CMD_GET, /* user->kernel request/get-response */
  89. TASKSTATS_CMD_NEW, /* kernel->user event */
  90. __TASKSTATS_CMD_MAX,
  91. };
  92. #define TASKSTATS_CMD_MAX (__TASKSTATS_CMD_MAX - 1)
  93. enum {
  94. TASKSTATS_TYPE_UNSPEC = 0, /* Reserved */
  95. TASKSTATS_TYPE_PID, /* Process id */
  96. TASKSTATS_TYPE_TGID, /* Thread group id */
  97. TASKSTATS_TYPE_STATS, /* taskstats structure */
  98. TASKSTATS_TYPE_AGGR_PID, /* contains pid + stats */
  99. TASKSTATS_TYPE_AGGR_TGID, /* contains tgid + stats */
  100. __TASKSTATS_TYPE_MAX,
  101. };
  102. #define TASKSTATS_TYPE_MAX (__TASKSTATS_TYPE_MAX - 1)
  103. enum {
  104. TASKSTATS_CMD_ATTR_UNSPEC = 0,
  105. TASKSTATS_CMD_ATTR_PID,
  106. TASKSTATS_CMD_ATTR_TGID,
  107. __TASKSTATS_CMD_ATTR_MAX,
  108. };
  109. #define TASKSTATS_CMD_ATTR_MAX (__TASKSTATS_CMD_ATTR_MAX - 1)
  110. /* NETLINK_GENERIC related info */
  111. #define TASKSTATS_GENL_NAME "TASKSTATS"
  112. #define TASKSTATS_GENL_VERSION 0x1
  113. #endif /* _LINUX_TASKSTATS_H */