page_ref.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM page_ref
  4. #if !defined(_TRACE_PAGE_REF_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_PAGE_REF_H
  6. #include <linux/types.h>
  7. #include <linux/page_ref.h>
  8. #include <linux/tracepoint.h>
  9. #include <trace/events/mmflags.h>
  10. DECLARE_EVENT_CLASS(page_ref_mod_template,
  11. TP_PROTO(struct page *page, int v),
  12. TP_ARGS(page, v),
  13. TP_STRUCT__entry(
  14. __field(unsigned long, pfn)
  15. __field(unsigned long, flags)
  16. __field(int, count)
  17. __field(int, mapcount)
  18. __field(void *, mapping)
  19. __field(int, mt)
  20. __field(int, val)
  21. ),
  22. TP_fast_assign(
  23. __entry->pfn = page_to_pfn(page);
  24. __entry->flags = page->flags;
  25. __entry->count = page_ref_count(page);
  26. __entry->mapcount = page_mapcount(page);
  27. __entry->mapping = page->mapping;
  28. __entry->mt = get_pageblock_migratetype(page);
  29. __entry->val = v;
  30. ),
  31. TP_printk("pfn=0x%lx flags=%s count=%d mapcount=%d mapping=%p mt=%d val=%d",
  32. __entry->pfn,
  33. show_page_flags(__entry->flags & ((1UL << NR_PAGEFLAGS) - 1)),
  34. __entry->count,
  35. __entry->mapcount, __entry->mapping, __entry->mt,
  36. __entry->val)
  37. );
  38. DEFINE_EVENT(page_ref_mod_template, page_ref_set,
  39. TP_PROTO(struct page *page, int v),
  40. TP_ARGS(page, v)
  41. );
  42. DEFINE_EVENT(page_ref_mod_template, page_ref_mod,
  43. TP_PROTO(struct page *page, int v),
  44. TP_ARGS(page, v)
  45. );
  46. DECLARE_EVENT_CLASS(page_ref_mod_and_test_template,
  47. TP_PROTO(struct page *page, int v, int ret),
  48. TP_ARGS(page, v, ret),
  49. TP_STRUCT__entry(
  50. __field(unsigned long, pfn)
  51. __field(unsigned long, flags)
  52. __field(int, count)
  53. __field(int, mapcount)
  54. __field(void *, mapping)
  55. __field(int, mt)
  56. __field(int, val)
  57. __field(int, ret)
  58. ),
  59. TP_fast_assign(
  60. __entry->pfn = page_to_pfn(page);
  61. __entry->flags = page->flags;
  62. __entry->count = page_ref_count(page);
  63. __entry->mapcount = page_mapcount(page);
  64. __entry->mapping = page->mapping;
  65. __entry->mt = get_pageblock_migratetype(page);
  66. __entry->val = v;
  67. __entry->ret = ret;
  68. ),
  69. TP_printk("pfn=0x%lx flags=%s count=%d mapcount=%d mapping=%p mt=%d val=%d ret=%d",
  70. __entry->pfn,
  71. show_page_flags(__entry->flags & ((1UL << NR_PAGEFLAGS) - 1)),
  72. __entry->count,
  73. __entry->mapcount, __entry->mapping, __entry->mt,
  74. __entry->val, __entry->ret)
  75. );
  76. DEFINE_EVENT(page_ref_mod_and_test_template, page_ref_mod_and_test,
  77. TP_PROTO(struct page *page, int v, int ret),
  78. TP_ARGS(page, v, ret)
  79. );
  80. DEFINE_EVENT(page_ref_mod_and_test_template, page_ref_mod_and_return,
  81. TP_PROTO(struct page *page, int v, int ret),
  82. TP_ARGS(page, v, ret)
  83. );
  84. DEFINE_EVENT(page_ref_mod_and_test_template, page_ref_mod_unless,
  85. TP_PROTO(struct page *page, int v, int ret),
  86. TP_ARGS(page, v, ret)
  87. );
  88. DEFINE_EVENT(page_ref_mod_and_test_template, page_ref_freeze,
  89. TP_PROTO(struct page *page, int v, int ret),
  90. TP_ARGS(page, v, ret)
  91. );
  92. DEFINE_EVENT(page_ref_mod_template, page_ref_unfreeze,
  93. TP_PROTO(struct page *page, int v),
  94. TP_ARGS(page, v)
  95. );
  96. #endif /* _TRACE_PAGE_COUNT_H */
  97. /* This part must be outside protection */
  98. #include <trace/define_trace.h>