From 7123adfcc050635124de2db868a8f2f9849678d1 Mon Sep 17 00:00:00 2001 From: Junjie Wu Date: Wed, 16 Jan 2019 18:31:11 -0800 Subject: [PATCH] PM / devfreq: cache_hwmon: Use array for reporting monitor stats Using an array to report monitor stats instead of hard coded variable names would allow for cleaner implementations of some cache hwmon device drivers. Change-Id: I787bdc12f10a0c8ff3c4195ce229a2987acdfce7 Signed-off-by: Junjie Wu [avajid@codeaurora.org: made minor styling changes] Signed-off-by: Amir Vajid --- drivers/devfreq/governor_cache_hwmon.c | 22 ++++++------- drivers/devfreq/governor_cache_hwmon.h | 11 +++++-- include/trace/events/power.h | 43 ++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 14 deletions(-) diff --git a/drivers/devfreq/governor_cache_hwmon.c b/drivers/devfreq/governor_cache_hwmon.c index e670ee9e7548..25cccb41af8d 100644 --- a/drivers/devfreq/governor_cache_hwmon.c +++ b/drivers/devfreq/governor_cache_hwmon.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "governor.h" #include "governor_cache_hwmon.h" @@ -119,11 +120,9 @@ static unsigned long measure_mrps_and_set_irq(struct cache_hwmon_node *node, preempt_enable(); - dev_dbg(hw->df->dev.parent, - "stat H=%3lu, M=%3lu, T=%3lu, b=%3u, f=%4lu, us=%d\n", - stat->high, stat->med, stat->high + stat->med, - stat->busy_percent, hw->df->previous_freq / 1000, us); - + trace_cache_hwmon_meas(dev_name(hw->df->dev.parent), stat->mrps[HIGH], + stat->mrps[MED], stat->mrps[LOW], + stat->busy_percent, us); return 0; } @@ -133,9 +132,9 @@ static void compute_cache_freq(struct cache_hwmon_node *node, unsigned long new_mhz; unsigned int busy; - new_mhz = mrps->high * node->cycles_per_high_req - + mrps->med * node->cycles_per_med_req - + mrps->low * node->cycles_per_low_req; + new_mhz = mrps->mrps[HIGH] * node->cycles_per_high_req + + mrps->mrps[MED] * node->cycles_per_med_req + + mrps->mrps[LOW] * node->cycles_per_low_req; busy = max(node->min_busy, mrps->busy_percent); busy = min(node->max_busy, busy); @@ -152,6 +151,7 @@ static void compute_cache_freq(struct cache_hwmon_node *node, new_mhz += node->guard_band_mhz; *freq = new_mhz * 1000; + trace_cache_hwmon_update(dev_name(node->hw->df->dev.parent), *freq); } #define TOO_SOON_US (1 * USEC_PER_MSEC) @@ -280,9 +280,9 @@ static int start_monitoring(struct devfreq *df) node->prev_ts = ktime_get(); node->prev_mhz = 0; - mrps.high = (df->previous_freq / 1000) - node->guard_band_mhz; - mrps.high /= node->cycles_per_high_req; - mrps.med = mrps.low = 0; + mrps.mrps[HIGH] = (df->previous_freq / 1000) - node->guard_band_mhz; + mrps.mrps[HIGH] /= node->cycles_per_high_req; + mrps.mrps[MED] = mrps.mrps[LOW] = 0; ret = hw->start_hwmon(hw, &mrps); if (ret < 0) { diff --git a/drivers/devfreq/governor_cache_hwmon.h b/drivers/devfreq/governor_cache_hwmon.h index f78a1d7cd028..26e7313a841f 100644 --- a/drivers/devfreq/governor_cache_hwmon.h +++ b/drivers/devfreq/governor_cache_hwmon.h @@ -9,10 +9,15 @@ #include #include +enum request_group { + HIGH, + MED, + LOW, + MAX_NUM_GROUPS, +}; + struct mrps_stats { - unsigned long high; - unsigned long med; - unsigned long low; + unsigned long mrps[MAX_NUM_GROUPS]; unsigned int busy_percent; }; diff --git a/include/trace/events/power.h b/include/trace/events/power.h index bd6a9606647b..cb523728964c 100644 --- a/include/trace/events/power.h +++ b/include/trace/events/power.h @@ -585,6 +585,49 @@ TRACE_EVENT(bw_hwmon_update, __entry->down_thres) ); +TRACE_EVENT(cache_hwmon_meas, + TP_PROTO(const char *name, unsigned long high_mrps, + unsigned long med_mrps, unsigned long low_mrps, + unsigned int busy_percent, unsigned int us), + TP_ARGS(name, high_mrps, med_mrps, low_mrps, busy_percent, us), + TP_STRUCT__entry( + __string(name, name) + __field(unsigned long, high_mrps) + __field(unsigned long, med_mrps) + __field(unsigned long, low_mrps) + __field(unsigned long, total_mrps) + __field(unsigned int, busy_percent) + __field(unsigned int, us) + ), + TP_fast_assign( + __assign_str(name, name); + __entry->high_mrps = high_mrps; + __entry->med_mrps = med_mrps; + __entry->low_mrps = low_mrps; + __entry->total_mrps = high_mrps + med_mrps + low_mrps; + __entry->busy_percent = busy_percent; + __entry->us = us; + ), + TP_printk("dev=%s H=%lu M=%lu L=%lu T=%lu busy_pct=%u period=%u", + __get_str(name), __entry->high_mrps, __entry->med_mrps, + __entry->low_mrps, __entry->total_mrps, + __entry->busy_percent, __entry->us) +); + +TRACE_EVENT(cache_hwmon_update, + TP_PROTO(const char *name, unsigned long freq_mhz), + TP_ARGS(name, freq_mhz), + TP_STRUCT__entry( + __string(name, name) + __field(unsigned long, freq) + ), + TP_fast_assign( + __assign_str(name, name); + __entry->freq = freq_mhz; + ), + TP_printk("dev=%s freq=%lu", __get_str(name), __entry->freq) +); + #endif /* _TRACE_POWER_H */ /* This part must be outside protection */