From 06c992a215be19c1abc3f427cb7eb27ddab9bf2f Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Wed, 3 Jul 2019 17:42:05 -0700 Subject: [PATCH] psi: Improve ftrace events Improve readability of logs by converting hex values to decimal, and printing memstall deltas instead of absolute values. Change-Id: I43f21dd9817b540184ce05fd7151459d3502ea28 Signed-off-by: Patrick Daly Signed-off-by: Isaac J. Manjarres --- include/trace/events/psi.h | 16 +++++++++------- kernel/sched/psi.c | 24 ++++++++++++++++-------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/include/trace/events/psi.h b/include/trace/events/psi.h index 00659776cea3..7563baaba40a 100644 --- a/include/trace/events/psi.h +++ b/include/trace/events/psi.h @@ -14,13 +14,14 @@ TRACE_EVENT(psi_window_vmstat, - TP_PROTO(u64 memstall, const char *zone_name, u64 high, + TP_PROTO(u64 mem_some, u64 mem_full, const char *zone_name, u64 high, u64 free, u64 cma, u64 file), - TP_ARGS(memstall, zone_name, high, free, cma, file), + TP_ARGS(mem_some, mem_full, zone_name, high, free, cma, file), TP_STRUCT__entry( - __field(u64, memstall) + __field(u64, mem_some) + __field(u64, mem_full) __string(name, zone_name) __field(u64, high) __field(u64, free) @@ -29,7 +30,8 @@ TRACE_EVENT(psi_window_vmstat, ), TP_fast_assign( - __entry->memstall = memstall; + __entry->mem_some = mem_some; + __entry->mem_full = mem_full; __assign_str(name, zone_name); __entry->high = high; __entry->free = free; @@ -37,9 +39,9 @@ TRACE_EVENT(psi_window_vmstat, __entry->file = file; ), - TP_printk("%16s: Memstall: %#16llx High: %#8llx Free: %#8llx CMA: %#8llx File: %#8llx", - __get_str(name), __entry->memstall, __entry->high, - __entry->free, __entry->cma, __entry->file + TP_printk("%16s: MEMSOME: %9lluns MEMFULL: %9lluns High: %9llukB Free: %9llukB CMA: %8llukB File: %9llukB", + __get_str(name), __entry->mem_some, __entry->mem_full, + __entry->high, __entry->free, __entry->cma, __entry->file ) ); diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index cb3d020dc2f9..b5bbc48d8220 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -445,6 +445,9 @@ static void psi_avgs_work(struct work_struct *work) } #ifdef CONFIG_PSI_FTRACE + +#define TOKB(x) ((x) * (PAGE_SIZE / 1024)) + static void trace_event_helper(struct psi_group *group) { struct zone *zone; @@ -452,17 +455,22 @@ static void trace_event_helper(struct psi_group *group) unsigned long free; unsigned long cma; unsigned long file; - u64 memstall = group->total[PSI_POLL][PSI_MEM_SOME]; + + u64 mem_some_delta = group->total[PSI_POLL][PSI_MEM_SOME] - + group->polling_total[PSI_MEM_SOME]; + u64 mem_full_delta = group->total[PSI_POLL][PSI_MEM_FULL] - + group->polling_total[PSI_MEM_FULL]; for_each_populated_zone(zone) { - wmark = high_wmark_pages(zone); - free = zone_page_state(zone, NR_FREE_PAGES); - cma = zone_page_state(zone, NR_FREE_CMA_PAGES); - file = zone_page_state(zone, NR_ZONE_ACTIVE_FILE) + - zone_page_state(zone, NR_ZONE_INACTIVE_FILE); + wmark = TOKB(high_wmark_pages(zone)); + free = TOKB(zone_page_state(zone, NR_FREE_PAGES)); + cma = TOKB(zone_page_state(zone, NR_FREE_CMA_PAGES)); + file = TOKB(zone_page_state(zone, NR_ZONE_ACTIVE_FILE) + + zone_page_state(zone, NR_ZONE_INACTIVE_FILE)); trace_psi_window_vmstat( - memstall, zone->name, wmark, free, cma, file); + mem_some_delta, mem_full_delta, zone->name, wmark, + free, cma, file); } } #else @@ -571,6 +579,7 @@ static u64 update_triggers(struct psi_group *group, u64 now) t->last_event_time = now; } + trace_event_helper(group); if (new_stall) memcpy(group->polling_total, total, sizeof(group->polling_total)); @@ -637,7 +646,6 @@ static void psi_poll_work(struct kthread_work *work) */ group->polling_until = now + group->poll_min_period * UPDATES_PER_WINDOW; - trace_event_helper(group); } if (now > group->polling_until) {