On 01.09.2021 14:36, Nikita Yushchenko wrote:
High order allocation detector monitors allocations of order greater
than zero, and generates an uevent if a configured number of allocations
happen within configured time.

In return to this uevent, userspace can enable event tracing. If a
stream of high-order allocations continues, the trace could help to
detect the code path causing them.

HOAD has a sysfs control interface, at /sys/kernel/mm/hoad/control:
- "enable ORDER COUNT MSECS"
   Sets up monitoring allocations of order ORDER: if COUNT such
   allocations are detected within MSECS, uevent is sent. Then further
   uevents is suspended, to avoid userspace races.
- "disable ORDER"
   Stops monitoring allocations of order ORDER.
- "resume [delay-msecs]"
   Allow sending a new uevent, either immediately or after the given
   delay.

The uevent is generated with ACTION="change", SUBSYSTEM="hoad", ORDER
set to the order of the allocation that has caused the uevent.

Also HOAD provides a tracepoint named "hoad", under kmem/ group, that
could be used for tracing. This tracepoint hits on every allocation of
order greater or equal to minimal order for which monitoring is enabled.

https://jira.sw.ru/browse/PSBM-92088
Signed-off-by: Nikita Yushchenko <[email protected]>
---
  include/trace/events/kmem.h |  12 ++
  mm/page_alloc.c             | 266 ++++++++++++++++++++++++++++++++++++
  2 files changed, 278 insertions(+)

diff --git a/include/trace/events/kmem.h b/include/trace/events/kmem.h
index 9cb647609df3..b425c6856bfd 100644
--- a/include/trace/events/kmem.h
+++ b/include/trace/events/kmem.h
@@ -305,6 +305,18 @@ TRACE_EVENT(mm_page_alloc_extfrag,
                __entry->alloc_migratetype == __entry->fallback_migratetype)
  );
+TRACE_EVENT(hoad,
+       TP_PROTO(int order),
+       TP_ARGS(order),
+       TP_STRUCT__entry(
+               __field(int, order)
+       ),
+       TP_fast_assign(
+               __entry->order = order;
+       ),
+       TP_printk("order=%d", __entry->order)
+);
+
  #endif /* _TRACE_KMEM_H */
/* This part must be outside protection */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1ae193b26a1d..959b1bfbafef 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3533,6 +3533,270 @@ static __always_inline void warn_high_order(int order, 
gfp_t gfp_mask)
        }
  }
+struct hoad_order_info {
+       unsigned long interval;
+       int max_allocs;
+       atomic_t counter;
+       unsigned long since_jiffies;
+       struct timer_list reset_counter_timer;
+};
+
+static struct hoad_order_info *hoad_table[MAX_ORDER];
+static DEFINE_MUTEX(hoad_mutex);
+static struct kobject *hoad_kobj;
+static int hoad_uevent_order;
+static unsigned long hoad_resume_jiffies;
+static int hoad_trace_min_order;
+
+#define MSEC_PER_MINUTE                (60 * MSEC_PER_SEC)
+#define MSEC_PER_HOUR          (60 * MSEC_PER_MINUTE)
+#define MSEC_PER_DAY           (60 * MSEC_PER_HOUR)

Missprint?

--
Best regards, Tikhomirov Pavel
Software Developer, Virtuozzo.
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to