thermal: debug: add debug statement for core and step_wise
PATCH 1/1 thermal: debug: add debug statement for core and step_wise
To ease debugging thermal problem, add these dynamic debug statements so that user do not need rebuild kernel to see these info.
Based on a patch from Zhang Rui for debugging on bugzilla:
https://bugzilla.kernel.org/attachment.cgi?id=98671
A sample output after we turn on dynamic debug with the following cmd:
# echo 'module thermal_sys +fp' > /sys/kernel/debug/dynamic_debug/control is like:
[ 355.147627] update_temperature: thermal thermal_zone0: last_temperature=52000, current_temperature=55000 [ 355.147636] thermal_zone_trip_update: thermal thermal_zone0: Trip1[type=1,temp=79000]:trend=2,throttle=0 [ 355.147644] get_target_state: thermal cooling_device8: cur_state=0 [ 355.147647] thermal_zone_trip_update: thermal cooling_device8: old_target=-1, target=-1 [ 355.147652] get_target_state: thermal cooling_device7: cur_state=0 [ 355.147655] thermal_zone_trip_update: thermal cooling_device7: old_target=-1, target=-1 [ 355.147660] get_target_state: thermal cooling_device6: cur_state=0 [ 355.147663] thermal_zone_trip_update: thermal cooling_device6: old_target=-1, target=-1 [ 355.147668] get_target_state: thermal cooling_device5: cur_state=0 [ 355.147671] thermal_zone_trip_update: thermal cooling_device5: old_target=-1, target=-1 [ 355.147678] thermal_zone_trip_update: thermal thermal_zone0: Trip2[type=0,temp=90000]:trend=1,throttle=0 [ 355.147776] get_target_state: thermal cooling_device0: cur_state=0 [ 355.147783] thermal_zone_trip_update: thermal cooling_device0: old_target=-1, target=-1 [ 355.147792] thermal_zone_trip_update: thermal thermal_zone0: Trip3[type=0,temp=80000]:trend=1,throttle=0 [ 355.147845] get_target_state: thermal cooling_device1: cur_state=0 [ 355.147849] thermal_zone_trip_update: thermal cooling_device1: old_target=-1, target=-1 [ 355.147856] thermal_zone_trip_update: thermal thermal_zone0: Trip4[type=0,temp=70000]:trend=1,throttle=0 [ 355.147904] get_target_state: thermal cooling_device2: cur_state=0 [ 355.147908] thermal_zone_trip_update: thermal cooling_device2: old_target=-1, target=-1 [ 355.147915] thermal_zone_trip_update: thermal thermal_zone0: Trip5[type=0,temp=60000]:trend=1,throttle=0 [ 355.147963] get_target_state: thermal cooling_device3: cur_state=0 [ 355.147967] thermal_zone_trip_update: thermal cooling_device3: old_target=-1, target=-1 [ 355.147973] thermal_zone_trip_update: thermal thermal_zone0: Trip6[type=0,temp=55000]:trend=1,throttle=1 [ 355.148022] get_target_state: thermal cooling_device4: cur_state=0 [ 355.148025] thermal_zone_trip_update: thermal cooling_device4: old_target=-1, target=1 [ 355.148036] thermal_cdev_update: thermal cooling_device4: zone0->target=1 [ 355.169279] thermal_cdev_update: thermal cooling_device4: set to state 1
--- drivers/thermal/step_wise.c | 6 ++++++ drivers/thermal/thermal_core.c | 6 ++++++ 2 files changed, 12 insertions(+)
drivers/thermal/step_wise.c +6 -0
@@ -60,6 +60,7 @@ static unsigned long get_target_state(struct thermal_instance *instance,*/ cdev->ops->get_cur_state (cdev, &cur_state); next_target = instance->target; +dev_dbg (&cdev->device,"cur_state=%ld\n" , cur_state);switch (trend) {case THERMAL_TREND_RAISING :
@@ -131,6 +132,9 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)if (tz->temperature >= trip_temp) throttle = true; +dev_dbg (&tz->device,"Trip%d[type=%d,temp=%ld]:trend=%d,throttle=%d\n" , + trip, trip_type, trip_temp, trend, throttle); +mutex_lock (&tz->lock);list_for_each_entry (instance, &tz->thermal_instances, tz_node) {
@@ -139,6 +143,8 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) old_target = instance->target; instance->target =get_target_state (instance, trend, throttle); +dev_dbg (&instance->cdev->device,"old_target=%d, target=%d\n" , + old_target, (int )instance->target);if (old_target == instance->target)continue ;
drivers/thermal/thermal_core.c +6 -0
@@ -450,6 +450,9 @@ static void update_temperature(struct thermal_zone_device *tz) tz->last_temperature = tz->temperature; tz->temperature = temp;mutex_unlock (&tz->lock); + +dev_dbg (&tz->device,"last_temperature=%d, current_temperature=%d\n" , + tz->last_temperature, tz->temperature); }void thermal_zone_device_update (struct thermal_zone_device *tz)
@@ -1207,6 +1210,8 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)mutex_lock (&cdev->lock);/* Make sure cdev enters the deepest cooling state */ list_for_each_entry (instance, &cdev->thermal_instances, cdev_node) { +dev_dbg (&cdev->device,"zone%d->target=%lu\n" , + instance->tz->id, instance->target);if (instance->target ==THERMAL_NO_TARGET )continue ;if (instance->target > target)
@@ -1215,6 +1220,7 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)mutex_unlock (&cdev->lock); cdev->ops->set_cur_state (cdev, target); cdev->updated = true; +dev_dbg (&cdev->device,"set to state %lu\n" , target); }EXPORT_SYMBOL (thermal_cdev_update);
Signature · 1 line
1.8.3.1
Quoted 29 lines · Aaron Lu
To ease debugging thermal problem, add these dynamic debug statements so that user do not need rebuild kernel to see these info.
Based on a patch from Zhang Rui for debugging on bugzilla:
https://bugzilla.kernel.org/attachment.cgi?id=98671A sample output after we turn on dynamic debug with the following cmd:
# echo 'module thermal_sys +fp' > /sys/kernel/debug/dynamic_debug/control is like:[ 355.147627] update_temperature: thermal thermal_zone0: last_temperature=52000, current_temperature=55000 [ 355.147636] thermal_zone_trip_update: thermal thermal_zone0: Trip1[type=1,temp=79000]:trend=2,throttle=0 [ 355.147644] get_target_state: thermal cooling_device8: cur_state=0 [ 355.147647] thermal_zone_trip_update: thermal cooling_device8: old_target=-1, target=-1 [ 355.147652] get_target_state: thermal cooling_device7: cur_state=0 [ 355.147655] thermal_zone_trip_update: thermal cooling_device7: old_target=-1, target=-1 [ 355.147660] get_target_state: thermal cooling_device6: cur_state=0 [ 355.147663] thermal_zone_trip_update: thermal cooling_device6: old_target=-1, target=-1 [ 355.147668] get_target_state: thermal cooling_device5: cur_state=0 [ 355.147671] thermal_zone_trip_update: thermal cooling_device5: old_target=-1, target=-1 [ 355.147678] thermal_zone_trip_update: thermal thermal_zone0: Trip2[type=0,temp=90000]:trend=1,throttle=0 [ 355.147776] get_target_state: thermal cooling_device0: cur_state=0 [ 355.147783] thermal_zone_trip_update: thermal cooling_device0: old_target=-1, target=-1 [ 355.147792] thermal_zone_trip_update: thermal thermal_zone0: Trip3[type=0,temp=80000]:trend=1,throttle=0 [ 355.147845] get_target_state: thermal cooling_device1: cur_state=0 [ 355.147849] thermal_zone_trip_update: thermal cooling_device1: old_target=-1, target=-1 [ 355.147856] thermal_zone_trip_update: thermal thermal_zone0: Trip4[type=0,temp=70000]:trend=1,throttle=0 [ 355.147904] get_target_state: thermal cooling_device2: cur_state=0 [ 355.147908] thermal_zone_trip_update: thermal cooling_device2: old_target=-1, target=-1
Quoted 8 lines
[ 355.147915] thermal_zone_trip_update: thermal thermal_zone0: Trip5[type=0,temp=60000]:trend=1,throttle=0 [ 355.147963] get_target_state: thermal cooling_device3: cur_state=0 [ 355.147967] thermal_zone_trip_update: thermal cooling_device3: old_target=-1, target=-1 [ 355.147973] thermal_zone_trip_update: thermal thermal_zone0: Trip6[type=0,temp=55000]:trend=1,throttle=1 [ 355.148022] get_target_state: thermal cooling_device4: cur_state=0 [ 355.148025] thermal_zone_trip_update: thermal cooling_device4: old_target=-1, target=1 [ 355.148036] thermal_cdev_update: thermal cooling_device4: zone0->target=1 [ 355.169279] thermal_cdev_update: thermal cooling_device4: set to state 1
This patch is slightly different from what is posted by Rui.
We are missing here the function names. dev_dbg does not include function name by default, does it?
Apart from the above, you can add my:
Quoted 71 lines
Signed-off-by Aaron Lu <[email protected]>--- drivers/thermal/step_wise.c | 6 ++++++ drivers/thermal/thermal_core.c | 6 ++++++ 2 files changed, 12 insertions(+)drivers/thermal/step_wise.c +6
-0@@ -60,6 +60,7 @@ static unsigned long get_target_state(struct thermal_instance *instance,*/ cdev->ops->get_cur_state (cdev, &cur_state); next_target = instance->target; +dev_dbg (&cdev->device,"cur_state=%ld\n" , cur_state);switch (trend) {case THERMAL_TREND_RAISING :@@ -131,6 +132,9 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)if (tz->temperature >= trip_temp) throttle = true; +dev_dbg (&tz->device,"Trip%d[type=%d,temp=%ld]:trend=%d,throttle=%d\n" , + trip, trip_type, trip_temp, trend, throttle); +mutex_lock (&tz->lock);list_for_each_entry (instance, &tz->thermal_instances, tz_node) {@@ -139,6 +143,8 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) old_target = instance->target; instance->target =get_target_state (instance, trend, throttle); +dev_dbg (&instance->cdev->device,"old_target=%d, target=%d\n" , + old_target, (int )instance->target);if (old_target == instance->target)continue ;drivers/thermal/thermal_core.c +6
-0@@ -450,6 +450,9 @@ static void update_temperature(struct thermal_zone_device *tz) tz->last_temperature = tz->temperature; tz->temperature = temp;mutex_unlock (&tz->lock); + +dev_dbg (&tz->device,"last_temperature=%d, current_temperature=%d\n" , + tz->last_temperature, tz->temperature); }void thermal_zone_device_update (struct thermal_zone_device *tz)@@ -1207,6 +1210,8 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)mutex_lock (&cdev->lock);/* Make sure cdev enters the deepest cooling state */ list_for_each_entry (instance, &cdev->thermal_instances, cdev_node) { +dev_dbg (&cdev->device,"zone%d->target=%lu\n" , + instance->tz->id, instance->target);if (instance->target ==THERMAL_NO_TARGET )continue ;if (instance->target > target)@@ -1215,6 +1220,7 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)mutex_unlock (&cdev->lock); cdev->ops->set_cur_state (cdev, target); cdev->updated = true; +dev_dbg (&cdev->device,"set to state %lu\n" , target); }EXPORT_SYMBOL (thermal_cdev_update);
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport) Eduardo Valentin
Quoted 39 lines · Eduardo Valentin
Quoted 29 lines · Aaron Lu
To ease debugging thermal problem, add these dynamic debug statements so that user do not need rebuild kernel to see these info.
Based on a patch from Zhang Rui for debugging on bugzilla:
https://bugzilla.kernel.org/attachment.cgi?id=98671A sample output after we turn on dynamic debug with the following cmd:
# echo 'module thermal_sys +fp' > /sys/kernel/debug/dynamic_debug/control is like:[ 355.147627] update_temperature: thermal thermal_zone0: last_temperature=52000, current_temperature=55000 [ 355.147636] thermal_zone_trip_update: thermal thermal_zone0: Trip1[type=1,temp=79000]:trend=2,throttle=0 [ 355.147644] get_target_state: thermal cooling_device8: cur_state=0 [ 355.147647] thermal_zone_trip_update: thermal cooling_device8: old_target=-1, target=-1 [ 355.147652] get_target_state: thermal cooling_device7: cur_state=0 [ 355.147655] thermal_zone_trip_update: thermal cooling_device7: old_target=-1, target=-1 [ 355.147660] get_target_state: thermal cooling_device6: cur_state=0 [ 355.147663] thermal_zone_trip_update: thermal cooling_device6: old_target=-1, target=-1 [ 355.147668] get_target_state: thermal cooling_device5: cur_state=0 [ 355.147671] thermal_zone_trip_update: thermal cooling_device5: old_target=-1, target=-1 [ 355.147678] thermal_zone_trip_update: thermal thermal_zone0: Trip2[type=0,temp=90000]:trend=1,throttle=0 [ 355.147776] get_target_state: thermal cooling_device0: cur_state=0 [ 355.147783] thermal_zone_trip_update: thermal cooling_device0: old_target=-1, target=-1 [ 355.147792] thermal_zone_trip_update: thermal thermal_zone0: Trip3[type=0,temp=80000]:trend=1,throttle=0 [ 355.147845] get_target_state: thermal cooling_device1: cur_state=0 [ 355.147849] thermal_zone_trip_update: thermal cooling_device1: old_target=-1, target=-1 [ 355.147856] thermal_zone_trip_update: thermal thermal_zone0: Trip4[type=0,temp=70000]:trend=1,throttle=0 [ 355.147904] get_target_state: thermal cooling_device2: cur_state=0 [ 355.147908] thermal_zone_trip_update: thermal cooling_device2: old_target=-1, target=-1Quoted 8 lines
[ 355.147915] thermal_zone_trip_update: thermal thermal_zone0: Trip5[type=0,temp=60000]:trend=1,throttle=0 [ 355.147963] get_target_state: thermal cooling_device3: cur_state=0 [ 355.147967] thermal_zone_trip_update: thermal cooling_device3: old_target=-1, target=-1 [ 355.147973] thermal_zone_trip_update: thermal thermal_zone0: Trip6[type=0,temp=55000]:trend=1,throttle=1 [ 355.148022] get_target_state: thermal cooling_device4: cur_state=0 [ 355.148025] thermal_zone_trip_update: thermal cooling_device4: old_target=-1, target=1 [ 355.148036] thermal_cdev_update: thermal cooling_device4: zone0->target=1 [ 355.169279] thermal_cdev_update: thermal cooling_device4: set to state 1
Quoted 4 lines
This patch is slightly different from what is posted by Rui.
We are missing here the function names.
dev_dbgdoes not include function name by default, does it?
That depends on what flag we pass to the control file, take the above example, I passed +fp so the function name will be printed. The document about this is: Documentation/dynamic-debug-howto.txt.
Quoted 4 lines
Apart from the above, you can add my:
Acked-by Eduardo Valentin <[email protected]>
Thanks for the review!
-Aaron
Quoted 75 lines
Quoted 73 lines
Signed-off-by Aaron Lu <[email protected]>--- drivers/thermal/step_wise.c | 6 ++++++ drivers/thermal/thermal_core.c | 6 ++++++ 2 files changed, 12 insertions(+)drivers/thermal/step_wise.c +6
-0@@ -60,6 +60,7 @@ static unsigned long get_target_state(struct thermal_instance *instance,*/ cdev->ops->get_cur_state (cdev, &cur_state); next_target = instance->target; +dev_dbg (&cdev->device,"cur_state=%ld\n" , cur_state);switch (trend) {case THERMAL_TREND_RAISING :@@ -131,6 +132,9 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)if (tz->temperature >= trip_temp) throttle = true; +dev_dbg (&tz->device,"Trip%d[type=%d,temp=%ld]:trend=%d,throttle=%d\n" , + trip, trip_type, trip_temp, trend, throttle); +mutex_lock (&tz->lock);list_for_each_entry (instance, &tz->thermal_instances, tz_node) {@@ -139,6 +143,8 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) old_target = instance->target; instance->target =get_target_state (instance, trend, throttle); +dev_dbg (&instance->cdev->device,"old_target=%d, target=%d\n" , + old_target, (int )instance->target);if (old_target == instance->target)continue ;drivers/thermal/thermal_core.c +6
-0@@ -450,6 +450,9 @@ static void update_temperature(struct thermal_zone_device *tz) tz->last_temperature = tz->temperature; tz->temperature = temp;mutex_unlock (&tz->lock); + +dev_dbg (&tz->device,"last_temperature=%d, current_temperature=%d\n" , + tz->last_temperature, tz->temperature); }void thermal_zone_device_update (struct thermal_zone_device *tz)@@ -1207,6 +1210,8 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)mutex_lock (&cdev->lock);/* Make sure cdev enters the deepest cooling state */ list_for_each_entry (instance, &cdev->thermal_instances, cdev_node) { +dev_dbg (&cdev->device,"zone%d->target=%lu\n" , + instance->tz->id, instance->target);if (instance->target ==THERMAL_NO_TARGET )continue ;if (instance->target > target)@@ -1215,6 +1220,7 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)mutex_unlock (&cdev->lock); cdev->ops->set_cur_state (cdev, target); cdev->updated = true; +dev_dbg (&cdev->device,"set to state %lu\n" , target); }EXPORT_SYMBOL (thermal_cdev_update);
Quoted 40 lines · Aaron Lu
Quoted 39 lines · Eduardo Valentin
Quoted 37 lines · Aaron Lu
To ease debugging thermal problem, add these dynamic debug statements so that user do not need rebuild kernel to see these info.
Based on a patch from Zhang Rui for debugging on bugzilla:
https://bugzilla.kernel.org/attachment.cgi?id=98671A sample output after we turn on dynamic debug with the following cmd:
# echo 'module thermal_sys +fp' > /sys/kernel/debug/dynamic_debug/control is like:[ 355.147627] update_temperature: thermal thermal_zone0: last_temperature=52000, current_temperature=55000 [ 355.147636] thermal_zone_trip_update: thermal thermal_zone0: Trip1[type=1,temp=79000]:trend=2,throttle=0 [ 355.147644] get_target_state: thermal cooling_device8: cur_state=0 [ 355.147647] thermal_zone_trip_update: thermal cooling_device8: old_target=-1, target=-1 [ 355.147652] get_target_state: thermal cooling_device7: cur_state=0 [ 355.147655] thermal_zone_trip_update: thermal cooling_device7: old_target=-1, target=-1 [ 355.147660] get_target_state: thermal cooling_device6: cur_state=0 [ 355.147663] thermal_zone_trip_update: thermal cooling_device6: old_target=-1, target=-1 [ 355.147668] get_target_state: thermal cooling_device5: cur_state=0 [ 355.147671] thermal_zone_trip_update: thermal cooling_device5: old_target=-1, target=-1 [ 355.147678] thermal_zone_trip_update: thermal thermal_zone0: Trip2[type=0,temp=90000]:trend=1,throttle=0 [ 355.147776] get_target_state: thermal cooling_device0: cur_state=0 [ 355.147783] thermal_zone_trip_update: thermal cooling_device0: old_target=-1, target=-1 [ 355.147792] thermal_zone_trip_update: thermal thermal_zone0: Trip3[type=0,temp=80000]:trend=1,throttle=0 [ 355.147845] get_target_state: thermal cooling_device1: cur_state=0 [ 355.147849] thermal_zone_trip_update: thermal cooling_device1: old_target=-1, target=-1 [ 355.147856] thermal_zone_trip_update: thermal thermal_zone0: Trip4[type=0,temp=70000]:trend=1,throttle=0 [ 355.147904] get_target_state: thermal cooling_device2: cur_state=0 [ 355.147908] thermal_zone_trip_update: thermal cooling_device2: old_target=-1, target=-1 [ 355.147915] thermal_zone_trip_update: thermal thermal_zone0: Trip5[type=0,temp=60000]:trend=1,throttle=0 [ 355.147963] get_target_state: thermal cooling_device3: cur_state=0 [ 355.147967] thermal_zone_trip_update: thermal cooling_device3: old_target=-1, target=-1 [ 355.147973] thermal_zone_trip_update: thermal thermal_zone0: Trip6[type=0,temp=55000]:trend=1,throttle=1 [ 355.148022] get_target_state: thermal cooling_device4: cur_state=0 [ 355.148025] thermal_zone_trip_update: thermal cooling_device4: old_target=-1, target=1 [ 355.148036] thermal_cdev_update: thermal cooling_device4: zone0->target=1 [ 355.169279] thermal_cdev_update: thermal cooling_device4: set to state 1
Quoted 9 lines
Quoted 4 lines
This patch is slightly different from what is posted by Rui.
We are missing here the function names.
dev_dbgdoes not include function name by default, does it?That depends on what flag we pass to the control file, take the above example, I passed +fp so the function name will be printed. The document about this is:
Documentation/dynamic-debug-howto.txt.
Yeah, I completed missed that.
Quoted 5 lines
Quoted 4 lines
Apart from the above, you can add my:
Acked-by Eduardo Valentin <[email protected]>
Patch looks fine to me.
Quoted 82 lines
Thanks for the review!
-Aaron
Quoted 75 lines
Quoted 73 lines
Signed-off-by Aaron Lu <[email protected]>--- drivers/thermal/step_wise.c | 6 ++++++ drivers/thermal/thermal_core.c | 6 ++++++ 2 files changed, 12 insertions(+)drivers/thermal/step_wise.c +6
-0@@ -60,6 +60,7 @@ static unsigned long get_target_state(struct thermal_instance *instance,*/ cdev->ops->get_cur_state (cdev, &cur_state); next_target = instance->target; +dev_dbg (&cdev->device,"cur_state=%ld\n" , cur_state);switch (trend) {case THERMAL_TREND_RAISING :@@ -131,6 +132,9 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip)if (tz->temperature >= trip_temp) throttle = true; +dev_dbg (&tz->device,"Trip%d[type=%d,temp=%ld]:trend=%d,throttle=%d\n" , + trip, trip_type, trip_temp, trend, throttle); +mutex_lock (&tz->lock);list_for_each_entry (instance, &tz->thermal_instances, tz_node) {@@ -139,6 +143,8 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) old_target = instance->target; instance->target =get_target_state (instance, trend, throttle); +dev_dbg (&instance->cdev->device,"old_target=%d, target=%d\n" , + old_target, (int )instance->target);if (old_target == instance->target)continue ;drivers/thermal/thermal_core.c +6
-0@@ -450,6 +450,9 @@ static void update_temperature(struct thermal_zone_device *tz) tz->last_temperature = tz->temperature; tz->temperature = temp;mutex_unlock (&tz->lock); + +dev_dbg (&tz->device,"last_temperature=%d, current_temperature=%d\n" , + tz->last_temperature, tz->temperature); }void thermal_zone_device_update (struct thermal_zone_device *tz)@@ -1207,6 +1210,8 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)mutex_lock (&cdev->lock);/* Make sure cdev enters the deepest cooling state */ list_for_each_entry (instance, &cdev->thermal_instances, cdev_node) { +dev_dbg (&cdev->device,"zone%d->target=%lu\n" , + instance->tz->id, instance->target);if (instance->target ==THERMAL_NO_TARGET )continue ;if (instance->target > target)@@ -1215,6 +1220,7 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)mutex_unlock (&cdev->lock); cdev->ops->set_cur_state (cdev, target); cdev->updated = true; +dev_dbg (&cdev->device,"set to state %lu\n" , target); }EXPORT_SYMBOL (thermal_cdev_update);
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport) Eduardo Valentin