cpufreq: use dynamic debug instead of custom infrastructure
Subsystems (2)
PATCH 1/2 cpufreq: use dynamic debug instead of custom infrastructure
With dynamic debug having gained the capability to report debug messages also during the boot process, it offers a far superior interface for debug messages than the custom cpufreq infrastructure. As a first step, remove the old cpufreq_debug_printk() function and replace it with a call to the generic pr_debug() function.
How can dynamic debug be used on cpufreq? You need a kernel which has CONFIG_DYNAMIC_DEBUG enabled.
To enabled debugging during runtime, mount debugfs and
$ echo -n 'module cpufreq +p' > /sys/kernel/debug/dynamic_debug/control
for debugging the complete "cpufreq" module. To achieve the same goal during boot, append
ddebug_query="module cpufreq +p"
as a boot parameter to the kernel of your choice.
For more detailled instructions, please seeDocumentation/dynamic-debug-howto.txt
--- drivers/cpufreq/Kconfig | 13 ------ drivers/cpufreq/cpufreq.c | 104 +-------------------------------------------- include/linux/cpufreq.h | 11 +---- 3 files changed, 2 insertions(+), 126 deletions(-)
drivers/cpufreq/Kconfig +0 -13
@@ -18,19 +18,6 @@ if CPU_FREQ config CPU_FREQ_TABLE tristate -config CPU_FREQ_DEBUG - bool "Enable CPUfreq debugging" - help - Say Y here to enable CPUfreq subsystem (including drivers) - debugging. You will need to activate it via the kernel - command line by passing - cpufreq.debug=<value> - - To get <value>, add - 1 to activate CPUfreq core debugging, - 2 to activate CPUfreq drivers debugging, and - 4 to activate CPUfreq governor debugging - config CPU_FREQ_STAT tristate "CPU frequency translation statistics" select CPU_FREQ_TABLE
drivers/cpufreq/cpufreq.c +1 -103
183 lines not on this page · raw message
include/linux/cpufreq.h +1 -10
@@ -405,15 +405,6 @@ void cpufreq_frequency_table_put_attr(unsigned int cpu);#define CPUFREQ_DEBUG_DRIVER 2#define CPUFREQ_DEBUG_GOVERNOR 4 -#ifdef CONFIG_CPU_FREQ_DEBUG - -extern void cpufreq_debug_printk (unsigned int type,const char *prefix, -const char *fmt, ...); - -#else - -#define cpufreq_debug_printk(msg...) do { } while(0) - -#endif /* CONFIG_CPU_FREQ_DEBUG */ +#define cpufreq_debug_printk(type, msg...) pr_debug(msg)#endif /* _LINUX_CPUFREQ_H */
Signature · 1 line
1.7.1
ping... any chance to get this and the second patch into 2.6.40?
Quoted 278 lines · Dominik Brodowski
With dynamic debug having gained the capability to report debug messages also during the boot process, it offers a far superior interface for debug messages than the custom cpufreq infrastructure. As a first step, remove the old
cpufreq_debug_printk()function and replace it with a call to the genericpr_debug()function.How can dynamic debug be used on cpufreq? You need a kernel which has
CONFIG_DYNAMIC_DEBUGenabled.To enabled debugging during runtime, mount debugfs and
$ echo -n 'module cpufreq +p' > /sys/kernel/debug/dynamic_debug/controlfor debugging the complete "cpufreq" module. To achieve the same goal during boot, append
ddebug_query="module cpufreq +p"
as a boot parameter to the kernel of your choice.
For more detailled instructions, please see
Documentation/dynamic-debug-howto.txtSigned-off-by Dominik Brodowski <[email protected]>--- drivers/cpufreq/Kconfig | 13 ------ drivers/cpufreq/cpufreq.c | 104 +-------------------------------------------- include/linux/cpufreq.h | 11 +---- 3 files changed, 2 insertions(+), 126 deletions(-)drivers/cpufreq/Kconfig +0
-13@@ -18,19 +18,6 @@ if CPU_FREQ config CPU_FREQ_TABLE tristate -config CPU_FREQ_DEBUG - bool "Enable CPUfreq debugging" - help - Say Y here to enable CPUfreq subsystem (including drivers) - debugging. You will need to activate it via the kernel - command line by passing - cpufreq.debug=<value> - - To get <value>, add - 1 to activate CPUfreq core debugging, - 2 to activate CPUfreq drivers debugging, and - 4 to activate CPUfreq governor debugging - config CPU_FREQ_STAT tristate "CPU frequency translation statistics" select CPU_FREQ_TABLEdrivers/cpufreq/cpufreq.c +1
-103@@ -181,93 +181,6 @@ EXPORT_SYMBOL_GPL(cpufreq_cpu_put);/********************************************************************* -* UNIFIED DEBUG HELPERS * -*********************************************************************/ -#ifdef CONFIG_CPU_FREQ_DEBUG - -/* what part(s) of the CPUfreq subsystem are debugged? */ -static unsigned int debug; - -/* is the debug output ratelimit'ed using printk_ratelimit? User can -* set or modify this value. -*/ -static unsigned int debug_ratelimit =1 ; - -/* is the printk_ratelimit'ing enabled? It's enabled after a successful -* loading of a cpufreq driver, temporarily disabled when a new policy -* is set, and disabled upon cpufreq driver removal -*/ -static unsigned int disable_ratelimit =1 ; -static DEFINE_SPINLOCK (disable_ratelimit_lock); - -static void cpufreq_debug_enable_ratelimit (void ) -{ -unsigned long flags; - -spin_lock_irqsave (&disable_ratelimit_lock, flags); -if (disable_ratelimit) - disable_ratelimit--; -spin_unlock_irqrestore (&disable_ratelimit_lock, flags); -} - -static void cpufreq_debug_disable_ratelimit (void ) -{ -unsigned long flags; - -spin_lock_irqsave (&disable_ratelimit_lock, flags); - disable_ratelimit++; -spin_unlock_irqrestore (&disable_ratelimit_lock, flags); -} - -void cpufreq_debug_printk (unsigned int type,const char *prefix, -const char *fmt, ...) -{ -char s[256 ]; -va_list args; -unsigned int len; -unsigned long flags; - -WARN_ON (!prefix); -if (type & debug) { -spin_lock_irqsave (&disable_ratelimit_lock, flags); -if (!disable_ratelimit && debug_ratelimit - && !printk_ratelimit ()) { -spin_unlock_irqrestore (&disable_ratelimit_lock, flags); -return ; - } -spin_unlock_irqrestore (&disable_ratelimit_lock, flags); - - len =snprintf (s,256 ,KERN_DEBUG "%s: " , prefix); - -va_start (args, fmt); - len +=vsnprintf (&s[len], (256 - len), fmt, args); -va_end (args); - -printk (s); - -WARN_ON (len <5 ); - } -} -EXPORT_SYMBOL (cpufreq_debug_printk); - - -module_param (debug, uint,0644 ); -MODULE_PARM_DESC (debug,"CPUfreq debugging: add 1 to debug core," -" 2 to debug drivers, and 4 to debug governors." ); - -module_param (debug_ratelimit, uint,0644 ); -MODULE_PARM_DESC (debug_ratelimit,"CPUfreq debugging:" -" set to 0 to disable ratelimiting." ); - -#else /* !CONFIG_CPU_FREQ_DEBUG */ - -static inline void cpufreq_debug_enable_ratelimit (void ) {return ; } -static inline void cpufreq_debug_disable_ratelimit (void ) {return ; } - -#endif /* CONFIG_CPU_FREQ_DEBUG */ - - -/********************************************************************* * EXTERNALLY AFFECTING FREQUENCY CHANGES * *********************************************************************/ @@ -977,7 +890,6 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)if (cpu_is_offline (cpu))return 0 ; -cpufreq_debug_disable_ratelimit ();dprintk ("adding CPU %u\n" , cpu);#ifdef CONFIG_SMP @@ -986,7 +898,6 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) policy =cpufreq_cpu_get (cpu);if (unlikely (policy)) {cpufreq_cpu_put (policy); -cpufreq_debug_enable_ratelimit ();return 0 ; }#endif @@ -1064,7 +975,6 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)kobject_uevent (&policy->kobj,KOBJ_ADD );module_put (cpufreq_driver->owner);dprintk ("initialization complete\n" ); -cpufreq_debug_enable_ratelimit ();return 0 ;@@ -1088,7 +998,6 @@ err_free_policy: nomem_out:module_put (cpufreq_driver->owner); module_out: -cpufreq_debug_enable_ratelimit ();return ret; }@@ -1112,7 +1021,6 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)unsigned int j;#endif -cpufreq_debug_disable_ratelimit ();dprintk ("unregistering CPU %u\n" , cpu);spin_lock_irqsave (&cpufreq_driver_lock, flags);@@ -1120,7 +1028,6 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)if (!data) {spin_unlock_irqrestore (&cpufreq_driver_lock, flags); -cpufreq_debug_enable_ratelimit ();unlock_policy_rwsem_write (cpu);return -EINVAL ; }@@ -1137,7 +1044,6 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)spin_unlock_irqrestore (&cpufreq_driver_lock, flags); kobj = &sys_dev->kobj;cpufreq_cpu_put (data); -cpufreq_debug_enable_ratelimit ();unlock_policy_rwsem_write (cpu);sysfs_remove_link (kobj,"cpufreq" );return 0 ;@@ -1213,7 +1119,6 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev)kfree (data);per_cpu (cpufreq_cpu_data, cpu) =NULL ; -cpufreq_debug_enable_ratelimit ();return 0 ; }@@ -1697,7 +1602,6 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, {int ret =0 ; -cpufreq_debug_disable_ratelimit ();dprintk ("setting new policy for CPU %u: %u - %u kHz\n" , policy->cpu, policy->min, policy->max);@@ -1774,7 +1678,6 @@ static int __cpufreq_set_policy(struct cpufreq_policy *data, } error_out: -cpufreq_debug_enable_ratelimit ();return ret; }@@ -1928,7 +1831,6 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)register_hotcpu_notifier (&cpufreq_cpu_notifier);dprintk ("driver %s up and running\n" , driver_data->name); -cpufreq_debug_enable_ratelimit ();return 0 ; err_sysdev_unreg:@@ -1955,12 +1857,8 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver) {unsigned long flags; -cpufreq_debug_disable_ratelimit (); - -if (!cpufreq_driver || (driver != cpufreq_driver)) { -cpufreq_debug_enable_ratelimit (); +if (!cpufreq_driver || (driver != cpufreq_driver))return -EINVAL ; - }dprintk ("unregistering driver %s\n" , driver->name);include/linux/cpufreq.h +1
-10@@ -405,15 +405,6 @@ void cpufreq_frequency_table_put_attr(unsigned int cpu);#define CPUFREQ_DEBUG_DRIVER 2#define CPUFREQ_DEBUG_GOVERNOR 4 -#ifdef CONFIG_CPU_FREQ_DEBUG - -extern void cpufreq_debug_printk (unsigned int type,const char *prefix, -const char *fmt, ...); - -#else - -#define cpufreq_debug_printk(msg...) do { } while(0) - -#endif /* CONFIG_CPU_FREQ_DEBUG */ +#define cpufreq_debug_printk(type, msg...) pr_debug(msg)#endif /* _LINUX_CPUFREQ_H */ Signature · 1 line
1.7.1
Quoted 1 line · Dominik Brodowski
ping... any chance to get this and the second patch into 2.6.40?
queued it up. Sorry for the delay.
Dave
Quoted 1 line · Dominik Brodowski
ping... any chance to get this and the second patch into 2.6.40?
This looks like it needs a bit more work..
arch/x86/kernel/cpu/cpufreq/longhaul.c: In function ‘longhaul_setstate’:arch/x86/kernel/cpu/cpufreq/longhaul.c:275: error: implicit declaration of function ‘print_speed’ arch/x86/kernel/cpu/cpufreq/longhaul.c:275: warning: format ‘%s’ expects type ‘char *’, but argument 6 has type ‘int’ arch/x86/kernel/cpu/cpufreq/longhaul.c: In function ‘longhaul_get_ranges’:arch/x86/kernel/cpu/cpufreq/longhaul.c:465: warning: format ‘%s’ expects type ‘char *’, but argument 4 has type ‘int’ arch/x86/kernel/cpu/cpufreq/longhaul.c:465: warning: format ‘%s’ expects type ‘char *’, but argument 5 has type ‘int’
arch/x86/kernel/cpu/cpufreq/powernow-k7.c: In function ‘get_ranges’:arch/x86/kernel/cpu/cpufreq/powernow-k7.c:209: error: ‘mobile_vid_table’ undeclared (first use in this function) arch/x86/kernel/cpu/cpufreq/powernow-k7.c: In function ‘powernow_acpi_init’:arch/x86/kernel/cpu/cpufreq/powernow-k7.c:401: error: ‘mobile_vid_table’ undeclared (first use in this function)
arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c: In function ‘pcc_get_freq’:arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c:178: warning: format ‘%x’ expects type ‘unsigned int’, but argument 4 has type ‘void *’ arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c: In function ‘pcc_cpufreq_target’:arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c:212: warning: format ‘%x’ expects type ‘unsigned int’, but argument 5 has type ‘void *’
arch/x86/kernel/cpu/cpufreq/powernow-k8.c: In function ‘powernow_k8_cpu_init_acpi’:arch/x86/kernel/cpu/cpufreq/powernow-k8.c:852: warning: format ‘%x’ expects type ‘unsigned int’, but argument 3 has type ‘u64’ arch/x86/kernel/cpu/cpufreq/powernow-k8.c:852: warning: format ‘%x’ expects type ‘unsigned int’, but argument 4 has type ‘u64’
arch/x86/kernel/cpu/cpufreq/speedstep-smi.c: In function ‘speedstep_init’:arch/x86/kernel/cpu/cpufreq/speedstep-smi.c:407: warning: format ‘%.8lx’ expects type ‘long unsigned int’, but argument 3 has type ‘__u32’ arch/x86/kernel/cpu/cpufreq/speedstep-smi.c:407: warning: format ‘%.8lx’ expects type ‘long unsigned int’, but argument 4 has type ‘__u32’ arch/x86/kernel/cpu/cpufreq/speedstep-smi.c:407: warning: format ‘%.8lx’ expects type ‘long unsigned int’, but argument 5 has type ‘__u32’ arch/x86/kernel/cpu/cpufreq/speedstep-smi.c:407: warning: format ‘%.8lx’ expects type ‘long unsigned int’, but argument 6 has type ‘__u32’
Quoted 4 lines · Dave Jones
Quoted 1 line · Dominik Brodowski
ping... any chance to get this and the second patch into 2.6.40?
This looks like it needs a bit more work..
Argh, some debug messages and formatting obviously were broken. Could you apply this patch on top, or squash it with the other patches if you prefer that? Thanks & best,
Dominik
From: Dominik Brodowski <[email protected]>
Date: Mon, 25 Apr 2011 22:40:09 +0200
Subject: [PATCH] cpufreq: fix debug messages
Fix debug messages which created warnings or even errors when using dynamic debug instead of cpufreq's previous custom debug interface.
arch/x86/kernel/cpu/cpufreq/longhaul.c +0 -2
@@ -84,7 +84,6 @@ static int eblcr[32];static int longhaul_version;static struct cpufreq_frequency_table *longhaul_table; -#ifdef CONFIG_CPU_FREQ_DEBUG static char speedbuffer[8 ];static char *print_speed (int speed)
@@ -103,7 +102,6 @@ static char *print_speed(int speed)return speedbuffer; } -#endif static unsigned int calc_speed (int mult)
arch/x86/kernel/cpu/cpufreq/pcc-cpufreq.c +2 -2
@@ -176,7 +176,7 @@ static unsigned int pcc_get_freq(unsigned int cpu) / 100) * 1000);pr_debug ("get: SUCCESS: (virtual) output_offset for cpu %d is " -"0x%x, contains a value of: 0x%x. Speed is: %d MHz\n" , +"0x%p, contains a value of: 0x%x. Speed is: %d MHz\n" , cpu, (pcch_virt_addr + pcc_cpu_data->output_offset), output_buffer, curr_freq);
@@ -210,7 +210,7 @@ static int pcc_cpufreq_target(struct cpufreq_policy *policy, pcc_cpu_data =per_cpu_ptr (pcc_cpu_info, cpu);pr_debug ("target: CPU %d should go to target freq: %d " -"(virtual) input_offset is 0x%x\n" , +"(virtual) input_offset is 0x%p\n" , cpu, target_freq, (pcch_virt_addr + pcc_cpu_data->input_offset));
arch/x86/kernel/cpu/cpufreq/powernow-k7.c +0 -2
@@ -68,7 +68,6 @@ union powernow_acpi_control_t { };#endif -#ifdef CONFIG_CPU_FREQ_DEBUG /* divide by 1000 to get VCore voltage in V. */ static const int mobile_vid_table[32 ] = {2000 ,1950 ,1900 ,1850 ,1800 ,1750 ,1700 ,1650 ,
@@ -76,7 +75,6 @@ static const int mobile_vid_table[32] = {1275 ,1250 ,1225 ,1200 ,1175 ,1150 ,1125 ,1100 , 1075, 1050, 1025, 1000, 975, 950, 925, 0, }; -#endif /* divide by 10 to get FID. */ static const int fid_codes[32] = {
arch/x86/kernel/cpu/cpufreq/powernow-k8.c +1 -1
@@ -849,7 +849,7 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)if ((control !=ACPI_ADR_SPACE_FIXED_HARDWARE ) || (status !=ACPI_ADR_SPACE_FIXED_HARDWARE )) { -pr_debug ("Invalid control/status registers (%x - %x)\n" , +pr_debug ("Invalid control/status registers (%llx - %llx)\n" , control, status); goto err_out; }
arch/x86/kernel/cpu/cpufreq/speedstep-smi.c +2 -2
@@ -404,8 +404,8 @@ static int __init speedstep_init(void)return -ENODEV ; } -pr_debug ("signature:0x%.8lx, command:0x%.8lx, " -"event:0x%.8lx, perf_level:0x%.8lx.\n" , +pr_debug ("signature:0x%.8ulx, command:0x%.8ulx, " +"event:0x%.8ulx, perf_level:0x%.8ulx.\n" , ist_info.signature, ist_info.command, ist_info.event, ist_info.perf_level);
Quoted 9 lines · Dominik Brodowski
Quoted 4 lines · Dave Jones
Quoted 1 line · Dominik Brodowski
ping... any chance to get this and the second patch into 2.6.40?
This looks like it needs a bit more work..
Argh, some debug messages and formatting obviously were broken. Could you apply this patch on top, or squash it with the other patches if you prefer that? Thanks & best,
I had to squash all three diffs together, as there were compile failures introduced when applying just the first, with or without this third patch.
It's all pushed out now, and seems to be holding together. Haven't boot tested it at all yet.
Dave