Re: [PATCH v2 2/2] cpufreq: powernv: Redesign the presentation of throttle notification
Hi Shilpasri, [auto build test WARNING on tip/perf/core] [also build test WARNING on v4.4-rc7 next-20151231] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Shilpasri-G-Bhat/cpufreq-powernv-tracing-Add-powernv_throttle-tracepoint/20160102-062606 config: powerpc-allmodconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=powerpc All warnings (new ones prefixed by >>): drivers/cpufreq/powernv-cpufreq.c: In function 'occ_reset_show': drivers/cpufreq/powernv-cpufreq.c:609:2: warning: ignoring return value of 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); \ ^ >> drivers/cpufreq/powernv-cpufreq.c:625:1: note: in expansion of macro >> 'define_throttle_reason_attr' define_throttle_reason_attr(occ_reset, OCC_RESET_THROTTLE); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'over_current_show': drivers/cpufreq/powernv-cpufreq.c:609:2: warning: ignoring return value of 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); \ ^ drivers/cpufreq/powernv-cpufreq.c:624:1: note: in expansion of macro 'define_throttle_reason_attr' define_throttle_reason_attr(over_current, OVERCURRENT); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'power_supply_failure_show': drivers/cpufreq/powernv-cpufreq.c:609:2: warning: ignoring return value of 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); \ ^ drivers/cpufreq/powernv-cpufreq.c:623:1: note: in expansion of macro 'define_throttle_reason_attr' define_throttle_reason_attr(power_supply_failure, POWER_SUPPLY_FAILURE); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'cpu_over_temperature_show': drivers/cpufreq/powernv-cpufreq.c:609:2: warning: ignoring return value of 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); \ ^ drivers/cpufreq/powernv-cpufreq.c:622:1: note: in expansion of macro 'define_throttle_reason_attr' define_throttle_reason_attr(cpu_over_temperature, CPU_OVERTEMP); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'power_cap_show': drivers/cpufreq/powernv-cpufreq.c:609:2: warning: ignoring return value of 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); \ ^ drivers/cpufreq/powernv-cpufreq.c:621:1: note: in expansion of macro 'define_throttle_reason_attr' define_throttle_reason_attr(power_cap, POWERCAP); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'throttle_reset_show': drivers/cpufreq/powernv-cpufreq.c:609:2: warning: ignoring return value of 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); \ ^ drivers/cpufreq/powernv-cpufreq.c:620:1: note: in expansion of macro 'define_throttle_reason_attr' define_throttle_reason_attr(throttle_reset, NO_THROTTLE); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'throttle_stat_show': drivers/cpufreq/powernv-cpufreq.c:589:2: warning: ignoring return value of 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'throttle_freq_show': drivers/cpufreq/powernv-cpufreq.c:568:2: warning: ignoring return value of 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); ^ vim +/define_throttle_reason_attr +625 drivers/cpufreq/powernv-cpufreq.c 603 #define define_throttle_reason_attr(attr_name, val) \ 604 static ssize_t attr_name##_show(struct kobject *kobj, \ 605 struct kobj_attribute *attr, char *buf) \ 606 { \ 607 int i, id; \ 608 \ > 609 kstrtoint(kobj->name + 4, 0, &id); >\ 610 for (i = 0; i < nr_chips; i++) \ 611 if (chips[i].id == id) \ 612 break; \ 613 \
Re: [PATCH v2 2/2] cpufreq: powernv: Redesign the presentation of throttle notification
Hi Shilpasri, [auto build test WARNING on tip/perf/core] [also build test WARNING on v4.4-rc7 next-20151231] [if your patch is applied to the wrong git tree, please drop us a note to help improving the system] url: https://github.com/0day-ci/linux/commits/Shilpasri-G-Bhat/cpufreq-powernv-tracing-Add-powernv_throttle-tracepoint/20160102-062606 config: powerpc-defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=powerpc All warnings (new ones prefixed by >>): drivers/cpufreq/powernv-cpufreq.c: In function 'occ_reset_show': >> drivers/cpufreq/powernv-cpufreq.c:609:2: warning: ignoring return value of >> 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); \ ^ drivers/cpufreq/powernv-cpufreq.c:625:1: note: in expansion of macro 'define_throttle_reason_attr' define_throttle_reason_attr(occ_reset, OCC_RESET_THROTTLE); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'over_current_show': >> drivers/cpufreq/powernv-cpufreq.c:609:2: warning: ignoring return value of >> 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); \ ^ drivers/cpufreq/powernv-cpufreq.c:624:1: note: in expansion of macro 'define_throttle_reason_attr' define_throttle_reason_attr(over_current, OVERCURRENT); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'power_supply_failure_show': >> drivers/cpufreq/powernv-cpufreq.c:609:2: warning: ignoring return value of >> 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); \ ^ drivers/cpufreq/powernv-cpufreq.c:623:1: note: in expansion of macro 'define_throttle_reason_attr' define_throttle_reason_attr(power_supply_failure, POWER_SUPPLY_FAILURE); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'cpu_over_temperature_show': >> drivers/cpufreq/powernv-cpufreq.c:609:2: warning: ignoring return value of >> 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); \ ^ drivers/cpufreq/powernv-cpufreq.c:622:1: note: in expansion of macro 'define_throttle_reason_attr' define_throttle_reason_attr(cpu_over_temperature, CPU_OVERTEMP); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'power_cap_show': >> drivers/cpufreq/powernv-cpufreq.c:609:2: warning: ignoring return value of >> 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); \ ^ drivers/cpufreq/powernv-cpufreq.c:621:1: note: in expansion of macro 'define_throttle_reason_attr' define_throttle_reason_attr(power_cap, POWERCAP); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'throttle_reset_show': >> drivers/cpufreq/powernv-cpufreq.c:609:2: warning: ignoring return value of >> 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); \ ^ drivers/cpufreq/powernv-cpufreq.c:620:1: note: in expansion of macro 'define_throttle_reason_attr' define_throttle_reason_attr(throttle_reset, NO_THROTTLE); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'throttle_stat_show': drivers/cpufreq/powernv-cpufreq.c:589:2: warning: ignoring return value of 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); ^ drivers/cpufreq/powernv-cpufreq.c: In function 'throttle_freq_show': drivers/cpufreq/powernv-cpufreq.c:568:2: warning: ignoring return value of 'kstrtoint', declared with attribute warn_unused_result [-Wunused-result] kstrtoint(kobj->name + 4, 0, &id); ^ vim +/kstrtoint +609 drivers/cpufreq/powernv-cpufreq.c 593 594 count += sprintf(&buf[count], "turbo %d\n", chips[i].throt_turbo); 595 count += sprintf(&buf[count], "sub-turbo %d\n", chips[i].throt_nominal); 596 597 return count; 598 } 599 600 static struct kobj_attribute attr_throttle_stat = 601 __ATTR(throttle_stat, 0444, throttle_stat_show, NULL); 602 603 #define define_throttle_reason_attr(attr_name, val) \ 604 static ssize_t attr_name##_show(struct kobject *kobj, \ 605 struct kobj_attribute *attr, char *buf) \ 606 { \ 607 int i, id; \ 608 \ > 609 kstrtoint(kobj->name + 4, 0, &id);
[PATCH v2 2/2] cpufreq: powernv: Redesign the presentation of throttle notification
Replace the throttling event console messages to perf trace point "power:powernv_throttle" and throttle counter stats which are exported in sysfs in /sys/devices/system/cpu/cpufreq/chipN. The newly added sysfs files are as follows: 1)/sys/devices/system/cpu/cpufreq/chip0/throttle_frequencies This gives the throttle stats for each of the available frequencies. The throttle stat of a frequency is the total number of times the max frequency is reduced to that frequency. # cat /sys/devices/system/cpu/cpufreq/chip0/throttle_frequencies 4023000 0 399 0 3956000 1 3923000 0 389 0 3857000 2 3823000 0 379 0 3757000 2 3724000 1 369 1 ... 2)/sys/devices/system/cpu/cpufreq/chip0/throttle_reasons This directory contains throttle reason files. Each file gives the total number of times the max frequency is throttled, except for 'throttle_reset', which gives the total number of times the max frequency is unthrottled after being throttled. # cd /sys/devices/system/cpu/cpufreq/chip0/throttle_reasons # cat cpu_over_temperature 7 # cat occ_reset 0 # cat over_current 0 # cat power_cap 0 # cat power_supply_failure 0 # cat throttle_reset 7 3)/sys/devices/system/cpu/cpufreq/chip0/throttle_stat This gives the total number of events of max frequency throttling to lower frequencies in the turbo range of frequencies and the sub-turbo(at and below nominal) range of frequencies. # cat /sys/devices/system/cpu/cpufreq/chip0/throttle_stat turbo 7 sub-turbo 0 Signed-off-by: Shilpasri G Bhat --- Changes from v1: - Added a kobject to struct chip - Grouped the throttle reasons under a separate attribute_group and exported each reason as individual file. - Moved the sysfs files from /sys/devices/system/node/nodeN to /sys/devices/system/cpu/cpufreq/chipN - As suggested by Paul Clarke replaced 'Nominal' with 'sub-turbo' and char * throttle_reason[][30] by const char * const throttle_reason[]. - Modified the commit message. drivers/cpufreq/powernv-cpufreq.c | 247 +++--- 1 file changed, 204 insertions(+), 43 deletions(-) diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index cb50138..00caef1 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -43,12 +44,37 @@ static struct cpufreq_frequency_table powernv_freqs[POWERNV_MAX_PSTATES+1]; static bool rebooting, throttled, occ_reset; +static const char * const throttle_reason[] = { + "No throttling", + "Power Cap", + "Processor Over Temperature", + "Power Supply Failure", + "Over Current", + "OCC Reset" +}; + +enum throt_reason_type { + NO_THROTTLE = 0, + POWERCAP, + CPU_OVERTEMP, + POWER_SUPPLY_FAILURE, + OVERCURRENT, + OCC_RESET_THROTTLE +}; + static struct chip { unsigned int id; bool throttled; cpumask_t mask; struct work_struct throttle; bool restore; + /* Pmax throttle stats */ + int throt_reason; + int throt_turbo; + int throt_nominal; + int reason[OCC_MAX_THROTTLE_STATUS + 1]; + int *pstate_stat; + struct kobject *kobj; } *chips; static int nr_chips; @@ -309,11 +335,11 @@ static inline unsigned int get_nominal_index(void) return powernv_pstate_info.max - powernv_pstate_info.nominal; } -static void powernv_cpufreq_throttle_check(void *data) +static void powernv_cpufreq_read_pmax(void *data) { unsigned int cpu = smp_processor_id(); unsigned long pmsr; - int pmsr_pmax, i; + int pmsr_pmax, i, index; pmsr = get_pmspr(SPRN_PMSR); @@ -321,28 +347,43 @@ static void powernv_cpufreq_throttle_check(void *data) if (chips[i].id == cpu_to_chip_id(cpu)) break; - /* Check for Pmax Capping */ pmsr_pmax = (s8)PMSR_MAX(pmsr); if (pmsr_pmax != powernv_pstate_info.max) { if (chips[i].throttled) - goto next; + return; chips[i].throttled = true; - if (pmsr_pmax < powernv_pstate_info.nominal) - pr_crit("CPU %d on Chip %u has Pmax reduced below nominal frequency (%d < %d)\n", - cpu, chips[i].id, pmsr_pmax, + if (pmsr_pmax < powernv_pstate_info.nominal) { + pr_warn_once("CPU %d on Chip %u has Pmax reduced below nominal frequency (%d < %d)\n", +cpu, chips[i].id, pmsr_pmax, powernv_pstate_info.nominal); - else - pr_info("CPU %d on Chip %u has Pmax reduced below turbo frequency (%d < %d)\n", - cpu, chips[i].id, pmsr_pmax, -