tracing/power: Polish the tracepoints cpu_idle and cpu_frequency
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): CAJZ5v0jqG0pcqOuvAVoP7sNKoOe+3ByMk4X5AZASp84OPcrgPg@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): [email protected]
[Fix up LKML address.]
Quoted 23 lines · Changbin
Hi,
Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · On Wed, Feb 28, 2018 at 10:20 AM, <[email protected]> wrote:
From: Changbin Du <[email protected]>
The type of state is signed int, convert it to unsigned int looks weird. (-1 become 4294967295)
932.123 power:cpu_idle:state=1 cpu_id=0)
932.125 power:cpu_idle:state=4294967295 cpu_id=0)
932.132 power:cpu_idle:state=1 cpu_id=0)
932.133 power:cpu_idle:state=4294967295 cpu_id=0)Quoted 8 lines
Quoted 4 lines
Similarly for
cpu_frequencyas "state=%lu cpu_id=%lu". User need to read the code to understand what 'state' means.No functional change in this patch.
That rather isn't the case if negative values are ever passed to the tracepoint, right?
yes.
Quoted 2 lines
Which seems to be the reason why you want to make this change, isn't it?
Quoted 7 lines
yes, to improve readability.
Quoted 2 lines
So maybe fix the code using the tracepoint(s) to avoid passing negative values to it(them)?
For
cpu_idleevent, [0,CPUIDLE_STATE_MAX) are used to index the idle state arrary, so I think a appropriate value forPWR_EVENT_EXITis -1 (defined ininclude/trace/events/power.h). Or do you have a better idea? Thanks!
Sorry, I'm not sure what you mean.
I'm saying that the code using the CPU PM tracepoints is not expected to pass -1 as the CPU number to them. IOW, neither -1 nor its UL representation should ever appear in the output of these tracepoints. If that happens, it is a problem with the code using the tracepoints which needs to be fixed. Users should not see any of these values.
Quoted 14 lines
Quoted 6 lines
Quoted 3 lines
That rather isn't the case if negative values are ever passed to the tracepoint, right?
yes.
Quoted 2 lines
Which seems to be the reason why you want to make this change, isn't it?
Quoted 7 lines
yes, to improve readability.
Quoted 2 lines
So maybe fix the code using the tracepoint(s) to avoid passing negative values to it(them)?
For
cpu_idleevent, [0,CPUIDLE_STATE_MAX) are used to index the idle state arrary, so I think a appropriate value forPWR_EVENT_EXITis -1 (defined ininclude/trace/events/power.h). Or do you have a better idea? Thanks!
Quoted 7 lines
Sorry, I'm not sure what you mean.
I'm saying that the code using the CPU PM tracepoints is not expected to pass -1 as the CPU number to them. IOW, neither -1 nor its UL representation should ever appear in the output of these tracepoints. If that happens, it is a problem with the code using the tracepoints which needs to be fixed. Users should not see any of these values.
This patch only changed 'state' field but cpuid. For cpu_idle event, 'state' is singned value, but for cpu_frequency it is unsinged.
The cpuid is always unsinged value. So no one passes -1 as CPU number.
Signature · 2 lines
Thanks, Changbin Du
Quoted 22 lines · Changbin
Quoted 14 lines
Quoted 6 lines
Quoted 3 lines
That rather isn't the case if negative values are ever passed to the tracepoint, right?
yes.
Quoted 2 lines
Which seems to be the reason why you want to make this change, isn't it?
Quoted 7 lines
yes, to improve readability.
Quoted 2 lines
So maybe fix the code using the tracepoint(s) to avoid passing negative values to it(them)?
For
cpu_idleevent, [0,CPUIDLE_STATE_MAX) are used to index the idle state arrary, so I think a appropriate value forPWR_EVENT_EXITis -1 (defined ininclude/trace/events/power.h). Or do you have a better idea? Thanks!Quoted 7 lines
Sorry, I'm not sure what you mean.
I'm saying that the code using the CPU PM tracepoints is not expected to pass -1 as the CPU number to them. IOW, neither -1 nor its UL representation should ever appear in the output of these tracepoints. If that happens, it is a problem with the code using the tracepoints which needs to be fixed. Users should not see any of these values.
Quoted 3 lines
This patch only changed 'state' field but cpuid. For
cpu_idleevent, 'state' is singned value, but forcpu_frequencyit is unsinged.
The cpuid is always unsinged value. So no one passes -1 as CPU number.
You are right, 'state' not 'cpuid', sorry.
Negative 'state' should not be passed to these tracepoints too, though.
Quoted 23 lines · Rafael J. Wysocki
Quoted 22 lines · Changbin
Quoted 21 lines
Quoted 6 lines
Quoted 3 lines
That rather isn't the case if negative values are ever passed to the tracepoint, right?
yes.
Quoted 2 lines
Which seems to be the reason why you want to make this change, isn't it?
Quoted 7 lines
yes, to improve readability.
Quoted 2 lines
So maybe fix the code using the tracepoint(s) to avoid passing negative values to it(them)?
For
cpu_idleevent, [0,CPUIDLE_STATE_MAX) are used to index the idle state arrary, so I think a appropriate value forPWR_EVENT_EXITis -1 (defined ininclude/trace/events/power.h). Or do you have a better idea? Thanks!Sorry, I'm not sure what you mean.
I'm saying that the code using the CPU PM tracepoints is not expected to pass -1 as the CPU number to them. IOW, neither -1 nor its UL representation should ever appear in the output of these tracepoints. If that happens, it is a problem with the code using the tracepoints which needs to be fixed. Users should not see any of these values.
Quoted 7 lines
Quoted 3 lines
This patch only changed 'state' field but cpuid. For
cpu_idleevent, 'state' is singned value, but forcpu_frequencyit is unsinged.
The cpuid is always unsinged value. So no one passes -1 as CPU number.You are right, 'state' not 'cpuid', sorry.
Negative 'state' should not be passed to these tracepoints too, though.
The current situtation is that 'state' can be negative for event cpu_idle :(. This is why I made this change.
Signature · 2 lines
Thanks, Changbin Du
Quoted 22 lines · Changbin
Quoted 21 lines · Rafael J. Wysocki
Quoted 20 lines · Changbin
Quoted 20 lines
Quoted 6 lines
Quoted 3 lines
That rather isn't the case if negative values are ever passed to the tracepoint, right?
yes.
Quoted 2 lines
Which seems to be the reason why you want to make this change, isn't it?
Quoted 7 lines
yes, to improve readability.
Quoted 2 lines
So maybe fix the code using the tracepoint(s) to avoid passing negative values to it(them)?
For
cpu_idleevent, [0,CPUIDLE_STATE_MAX) are used to index the idle state arrary, so I think a appropriate value forPWR_EVENT_EXITis -1 (defined ininclude/trace/events/power.h). Or do you have a better idea? Thanks!Sorry, I'm not sure what you mean.
I'm saying that the code using the CPU PM tracepoints is not expected to pass -1 as the CPU number to them. IOW, neither -1 nor its UL representation should ever appear in the output of these tracepoints. If that happens, it is a problem with the code using the tracepoints which needs to be fixed. Users should not see any of these values.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
This patch only changed 'state' field but cpuid. For
cpu_idleevent, 'state' is singned value, but forcpu_frequencyit is unsinged.
The cpuid is always unsinged value. So no one passes -1 as CPU number.You are right, 'state' not 'cpuid', sorry.
Negative 'state' should not be passed to these tracepoints too, though.
The current situtation is that 'state' can be negative for event
cpu_idle:(. This is why I made this change.
And which is why I said that IMO it would be better to change the current situation.
Your patch makes the results of it slightly less confusing to a human reader of the tracepoint output, but the situation is still unchanged after it.
And what if someone has a script built around these tracepoints that knows how to handle the UL representation of -1, but doesn't know how to parse "-1"? They would need to update the script after your change, wouldn't they? And why would it be OK to inflict that work on them just to improve the readability of the output for humans?
Quoted 35 lines · Rafael J. Wysocki
Quoted 22 lines · Changbin
Quoted 21 lines · Rafael J. Wysocki
Quoted 20 lines · Changbin
Quoted 20 lines
Quoted 6 lines
Quoted 3 lines
That rather isn't the case if negative values are ever passed to the tracepoint, right?
yes.
Quoted 2 lines
Which seems to be the reason why you want to make this change, isn't it?
Quoted 7 lines
yes, to improve readability.
Quoted 2 lines
So maybe fix the code using the tracepoint(s) to avoid passing negative values to it(them)?
For
cpu_idleevent, [0,CPUIDLE_STATE_MAX) are used to index the idle state arrary, so I think a appropriate value forPWR_EVENT_EXITis -1 (defined ininclude/trace/events/power.h). Or do you have a better idea? Thanks!Sorry, I'm not sure what you mean.
I'm saying that the code using the CPU PM tracepoints is not expected to pass -1 as the CPU number to them. IOW, neither -1 nor its UL representation should ever appear in the output of these tracepoints. If that happens, it is a problem with the code using the tracepoints which needs to be fixed. Users should not see any of these values.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
This patch only changed 'state' field but cpuid. For
cpu_idleevent, 'state' is singned value, but forcpu_frequencyit is unsinged.
The cpuid is always unsinged value. So no one passes -1 as CPU number.You are right, 'state' not 'cpuid', sorry.
Negative 'state' should not be passed to these tracepoints too, though.
The current situtation is that 'state' can be negative for event
cpu_idle:(. This is why I made this change.And which is why I said that IMO it would be better to change the current situation.
Quoted 9 lines
Your patch makes the results of it slightly less confusing to a human reader of the tracepoint output, but the situation is still unchanged after it.
And what if someone has a script built around these tracepoints that knows how to handle the UL representation of -1, but doesn't know how to parse "-1"? They would need to update the script after your change, wouldn't they? And why would it be OK to inflict that work on them just to improve the readability of the output for humans?
yeah, I can guarantee all in kernel tools updated but people's private script. For me, I just read the raw event for debug purpose. It is fair enough that leave code as it was considering users' private tool based on this event.
Quoted 2 lines
Signature · 2 lines
Thanks, Changbin Du