debugfs-kmemtrace 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. What: /sys/kernel/debug/kmemtrace/
  2. Date: July 2008
  3. Contact: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
  4. Description:
  5. In kmemtrace-enabled kernels, the following files are created:
  6. /sys/kernel/debug/kmemtrace/
  7. cpu<n> (0400) Per-CPU tracing data, see below. (binary)
  8. total_overruns (0400) Total number of bytes which were dropped from
  9. cpu<n> files because of full buffer condition,
  10. non-binary. (text)
  11. abi_version (0400) Kernel's kmemtrace ABI version. (text)
  12. Each per-CPU file should be read according to the relay interface. That is,
  13. the reader should set affinity to that specific CPU and, as currently done by
  14. the userspace application (though there are other methods), use poll() with
  15. an infinite timeout before every read(). Otherwise, erroneous data may be
  16. read. The binary data has the following _core_ format:
  17. Event ID (1 byte) Unsigned integer, one of:
  18. 0 - represents an allocation (KMEMTRACE_EVENT_ALLOC)
  19. 1 - represents a freeing of previously allocated memory
  20. (KMEMTRACE_EVENT_FREE)
  21. Type ID (1 byte) Unsigned integer, one of:
  22. 0 - this is a kmalloc() / kfree()
  23. 1 - this is a kmem_cache_alloc() / kmem_cache_free()
  24. 2 - this is a __get_free_pages() et al.
  25. Event size (2 bytes) Unsigned integer representing the
  26. size of this event. Used to extend
  27. kmemtrace. Discard the bytes you
  28. don't know about.
  29. Sequence number (4 bytes) Signed integer used to reorder data
  30. logged on SMP machines. Wraparound
  31. must be taken into account, although
  32. it is unlikely.
  33. Caller address (8 bytes) Return address to the caller.
  34. Pointer to mem (8 bytes) Pointer to target memory area. Can be
  35. NULL, but not all such calls might be
  36. recorded.
  37. In case of KMEMTRACE_EVENT_ALLOC events, the next fields follow:
  38. Requested bytes (8 bytes) Total number of requested bytes,
  39. unsigned, must not be zero.
  40. Allocated bytes (8 bytes) Total number of actually allocated
  41. bytes, unsigned, must not be lower
  42. than requested bytes.
  43. Requested flags (4 bytes) GFP flags supplied by the caller.
  44. Target CPU (4 bytes) Signed integer, valid for event id 1.
  45. If equal to -1, target CPU is the same
  46. as origin CPU, but the reverse might
  47. not be true.
  48. The data is made available in the same endianness the machine has.
  49. Other event ids and type ids may be defined and added. Other fields may be
  50. added by increasing event size, but see below for details.
  51. Every modification to the ABI, including new id definitions, are followed
  52. by bumping the ABI version by one.
  53. Adding new data to the packet (features) is done at the end of the mandatory
  54. data:
  55. Feature size (2 byte)
  56. Feature ID (1 byte)
  57. Feature data (Feature size - 3 bytes)
  58. Users:
  59. kmemtrace-user - git://repo.or.cz/kmemtrace-user.git