* [PATCH] fix IPC output in perf intel-pt-events script
@ 2023-03-10 11:10 Roman Lozko
2023-03-10 13:32 ` Adrian Hunter
0 siblings, 1 reply; 7+ messages in thread
From: Roman Lozko @ 2023-03-10 11:10 UTC (permalink / raw)
To: adrian.hunter; +Cc: linux-perf-users, Roman Lozko
Integers are not converted to floats during division in Python 2
which results in incorrect IPC values, convert to float explicitly.
Signed-off-by: Roman Lozko <lozko.roma@gmail.com>
---
tools/perf/scripts/python/intel-pt-events.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/scripts/python/intel-pt-events.py b/tools/perf/scripts/python/intel-pt-events.py
index 08862a2582f4..26e840e17062 100644
--- a/tools/perf/scripts/python/intel-pt-events.py
+++ b/tools/perf/scripts/python/intel-pt-events.py
@@ -269,7 +269,7 @@ def print_common_ip(param_dict, sample, symbol, dso):
if "cyc_cnt" in sample:
cyc_cnt = sample["cyc_cnt"]
insn_cnt = get_optional_zero(sample, "insn_cnt")
- ipc_str = " IPC: %#.2f (%u/%u)" % (insn_cnt / cyc_cnt, insn_cnt, cyc_cnt)
+ ipc_str = " IPC: %#.2f (%u/%u)" % (float(insn_cnt) / cyc_cnt, insn_cnt, cyc_cnt)
else:
ipc_str = ""
if glb_insn and glb_disassembler is not None:
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] fix IPC output in perf intel-pt-events script
2023-03-10 11:10 [PATCH] fix IPC output in perf intel-pt-events script Roman Lozko
@ 2023-03-10 13:32 ` Adrian Hunter
2023-03-10 14:02 ` Roman Lozko
2023-03-10 15:04 ` [PATCH v2] perf scripts: intel-pt-events.py: Fix IPC output for Python 2 Roman Lozko
0 siblings, 2 replies; 7+ messages in thread
From: Adrian Hunter @ 2023-03-10 13:32 UTC (permalink / raw)
To: Roman Lozko; +Cc: linux-perf-users
On 10/03/23 13:10, Roman Lozko wrote:
> Integers are not converted to floats during division in Python 2
> which results in incorrect IPC values, convert to float explicitly.
Thanks for finding this. Obviously Python 3 is preferred nowadays
but Python 2 seems to be still a thing.
AFAICT, it would be better to fix this by adding:
from __future__ import division
at the top of the script, next to from __future__ import print_function
Also the patch subject should be:
perf scripts: intel-pt-events.py: Fix IPC output for Python 2
Also a Fixes tag could be added i.e.
Fixes: a483e64c0b62 ("perf scripting python: intel-pt-events.py: Add --insn-trace and --src-trace")
>
> Signed-off-by: Roman Lozko <lozko.roma@gmail.com>
> ---
> tools/perf/scripts/python/intel-pt-events.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/scripts/python/intel-pt-events.py b/tools/perf/scripts/python/intel-pt-events.py
> index 08862a2582f4..26e840e17062 100644
> --- a/tools/perf/scripts/python/intel-pt-events.py
> +++ b/tools/perf/scripts/python/intel-pt-events.py
> @@ -269,7 +269,7 @@ def print_common_ip(param_dict, sample, symbol, dso):
> if "cyc_cnt" in sample:
> cyc_cnt = sample["cyc_cnt"]
> insn_cnt = get_optional_zero(sample, "insn_cnt")
> - ipc_str = " IPC: %#.2f (%u/%u)" % (insn_cnt / cyc_cnt, insn_cnt, cyc_cnt)
> + ipc_str = " IPC: %#.2f (%u/%u)" % (float(insn_cnt) / cyc_cnt, insn_cnt, cyc_cnt)
> else:
> ipc_str = ""
> if glb_insn and glb_disassembler is not None:
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fix IPC output in perf intel-pt-events script
2023-03-10 13:32 ` Adrian Hunter
@ 2023-03-10 14:02 ` Roman Lozko
2023-03-10 14:19 ` Adrian Hunter
2023-03-10 15:04 ` [PATCH v2] perf scripts: intel-pt-events.py: Fix IPC output for Python 2 Roman Lozko
1 sibling, 1 reply; 7+ messages in thread
From: Roman Lozko @ 2023-03-10 14:02 UTC (permalink / raw)
To: Adrian Hunter; +Cc: linux-perf-users
On Fri, Mar 10, 2023 at 3:32 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> Thanks for finding this. Obviously Python 3 is preferred nowadays
> but Python 2 seems to be still a thing.
>
> AFAICT, it would be better to fix this by adding:
>
> from __future__ import division
>
> at the top of the script, next to from __future__ import print_function
Is it possible to build perf with python3? May it be better to stop
supporting Python 2?
> Also the patch subject should be:
>
> perf scripts: intel-pt-events.py: Fix IPC output for Python 2
>
> Also a Fixes tag could be added i.e.
>
> Fixes: a483e64c0b62 ("perf scripting python: intel-pt-events.py: Add --insn-trace and --src-trace")
Thanks for details, this is my first patch, I knew I would miss something :)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fix IPC output in perf intel-pt-events script
2023-03-10 14:02 ` Roman Lozko
@ 2023-03-10 14:19 ` Adrian Hunter
0 siblings, 0 replies; 7+ messages in thread
From: Adrian Hunter @ 2023-03-10 14:19 UTC (permalink / raw)
To: Roman Lozko; +Cc: linux-perf-users
On 10/03/23 16:02, Roman Lozko wrote:
> On Fri, Mar 10, 2023 at 3:32 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>>
>> Thanks for finding this. Obviously Python 3 is preferred nowadays
>> but Python 2 seems to be still a thing.
>>
>> AFAICT, it would be better to fix this by adding:
>>
>> from __future__ import division
>>
>> at the top of the script, next to from __future__ import print_function
>
> Is it possible to build perf with python3? May it be better to stop
> supporting Python 2?
PYTHON=python3 make -C tools/perf install
For more information refer:
https://perf.wiki.kernel.org/index.php/Perf_tools_support_for_Intel%C2%AE_Processor_Trace#Downloading_and_building_the_latest_perf_tools
>
>> Also the patch subject should be:
>>
>> perf scripts: intel-pt-events.py: Fix IPC output for Python 2
>>
>> Also a Fixes tag could be added i.e.
>>
>> Fixes: a483e64c0b62 ("perf scripting python: intel-pt-events.py: Add --insn-trace and --src-trace")
>
> Thanks for details, this is my first patch, I knew I would miss something :)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] perf scripts: intel-pt-events.py: Fix IPC output for Python 2
2023-03-10 13:32 ` Adrian Hunter
2023-03-10 14:02 ` Roman Lozko
@ 2023-03-10 15:04 ` Roman Lozko
2023-03-10 16:50 ` Adrian Hunter
1 sibling, 1 reply; 7+ messages in thread
From: Roman Lozko @ 2023-03-10 15:04 UTC (permalink / raw)
To: adrian.hunter; +Cc: linux-perf-users, Roman Lozko
Integers are not converted to floats during division in Python 2
which results in incorrect IPC values. Fix by switching to new division
behavior.
Fixes: a483e64c0b62 ("perf scripting python: intel-pt-events.py: Add --insn-trace and --src-trace")
Signed-off-by: Roman Lozko <lozko.roma@gmail.com>
---
tools/perf/scripts/python/intel-pt-events.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/scripts/python/intel-pt-events.py b/tools/perf/scripts/python/intel-pt-events.py
index 08862a2582f4..1c76368f13c1 100644
--- a/tools/perf/scripts/python/intel-pt-events.py
+++ b/tools/perf/scripts/python/intel-pt-events.py
@@ -11,7 +11,7 @@
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
-from __future__ import print_function
+from __future__ import division, print_function
import io
import os
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] perf scripts: intel-pt-events.py: Fix IPC output for Python 2
2023-03-10 15:04 ` [PATCH v2] perf scripts: intel-pt-events.py: Fix IPC output for Python 2 Roman Lozko
@ 2023-03-10 16:50 ` Adrian Hunter
2023-03-14 11:44 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 7+ messages in thread
From: Adrian Hunter @ 2023-03-10 16:50 UTC (permalink / raw)
To: Roman Lozko; +Cc: linux-perf-users, Arnaldo Carvalho de Melo
On 10/03/23 17:04, Roman Lozko wrote:
> Integers are not converted to floats during division in Python 2
> which results in incorrect IPC values. Fix by switching to new division
> behavior.
There is usually a blank line here
> Fixes: a483e64c0b62 ("perf scripting python: intel-pt-events.py: Add --insn-trace and --src-trace")
> Signed-off-by: Roman Lozko <lozko.roma@gmail.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> tools/perf/scripts/python/intel-pt-events.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/scripts/python/intel-pt-events.py b/tools/perf/scripts/python/intel-pt-events.py
> index 08862a2582f4..1c76368f13c1 100644
> --- a/tools/perf/scripts/python/intel-pt-events.py
> +++ b/tools/perf/scripts/python/intel-pt-events.py
> @@ -11,7 +11,7 @@
> # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> # more details.
>
> -from __future__ import print_function
> +from __future__ import division, print_function
>
> import io
> import os
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] perf scripts: intel-pt-events.py: Fix IPC output for Python 2
2023-03-10 16:50 ` Adrian Hunter
@ 2023-03-14 11:44 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-14 11:44 UTC (permalink / raw)
To: Adrian Hunter; +Cc: Roman Lozko, linux-perf-users
Em Fri, Mar 10, 2023 at 06:50:48PM +0200, Adrian Hunter escreveu:
> On 10/03/23 17:04, Roman Lozko wrote:
> > Integers are not converted to floats during division in Python 2
> > which results in incorrect IPC values. Fix by switching to new division
> > behavior.
>
> There is usually a blank line here
Fixed
> > Fixes: a483e64c0b62 ("perf scripting python: intel-pt-events.py: Add --insn-trace and --src-trace")
> > Signed-off-by: Roman Lozko <lozko.roma@gmail.com>
>
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Thanks, applied.
- Arnaldo
> > ---
> > tools/perf/scripts/python/intel-pt-events.py | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/scripts/python/intel-pt-events.py b/tools/perf/scripts/python/intel-pt-events.py
> > index 08862a2582f4..1c76368f13c1 100644
> > --- a/tools/perf/scripts/python/intel-pt-events.py
> > +++ b/tools/perf/scripts/python/intel-pt-events.py
> > @@ -11,7 +11,7 @@
> > # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
> > # more details.
> >
> > -from __future__ import print_function
> > +from __future__ import division, print_function
> >
> > import io
> > import os
>
--
- Arnaldo
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-03-14 11:45 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-10 11:10 [PATCH] fix IPC output in perf intel-pt-events script Roman Lozko
2023-03-10 13:32 ` Adrian Hunter
2023-03-10 14:02 ` Roman Lozko
2023-03-10 14:19 ` Adrian Hunter
2023-03-10 15:04 ` [PATCH v2] perf scripts: intel-pt-events.py: Fix IPC output for Python 2 Roman Lozko
2023-03-10 16:50 ` Adrian Hunter
2023-03-14 11:44 ` Arnaldo Carvalho de Melo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).