From e94137274fd3f6ba998e5be78c8926460691cb3a Mon Sep 17 00:00:00 2001 From: wenyuzifang Date: Sun, 28 Sep 2025 17:05:18 +0800 Subject: [PATCH] Update code from upstream --- libpfm-initp.patch | 19 +++++++++++++++++++ libpfm-zen4.patch | 29 +++++++++++++++++++++++++++++ libpfm.spec | 9 +++++++-- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 libpfm-initp.patch create mode 100644 libpfm-zen4.patch diff --git a/libpfm-initp.patch b/libpfm-initp.patch new file mode 100644 index 0000000..4eeb498 --- /dev/null +++ b/libpfm-initp.patch @@ -0,0 +1,19 @@ +commit 75d8bb06f6ea0d7a8edf8e080c7ea6d434d598ff +Author: William Cohen +Date: Fri Apr 14 16:07:07 2023 -0400 + + Make sure that p is set to a known value before using. + +diff --git a/lib/pfmlib_perf_event_pmu.c b/lib/pfmlib_perf_event_pmu.c +index 637c5b1..8f7d7d1 100644 +--- a/lib/pfmlib_perf_event_pmu.c ++++ b/lib/pfmlib_perf_event_pmu.c +@@ -361,7 +361,7 @@ gen_tracepoint_table(void) + { + DIR *dir1, *dir2; + struct dirent *d1, *d2; +- perf_event_t *p; ++ perf_event_t *p = NULL; + perf_umask_t *um; + char d2path[MAXPATHLEN]; + char idpath[MAXPATHLEN]; diff --git a/libpfm-zen4.patch b/libpfm-zen4.patch new file mode 100644 index 0000000..e319e32 --- /dev/null +++ b/libpfm-zen4.patch @@ -0,0 +1,29 @@ +commit 1befa3d200cc17d5a278fcb2f597c4876c58f949 +Author: Stephane Eranian +Date: Tue Apr 25 00:35:41 2023 -0700 + + fix AMD Zen3/Zen4 detection + + To cover more models of Zen4. + + Signed-off-by: Stephane Eranian + +diff --git a/lib/pfmlib_amd64.c b/lib/pfmlib_amd64.c +index e51a43d..0c6702d 100644 +--- a/lib/pfmlib_amd64.c ++++ b/lib/pfmlib_amd64.c +@@ -181,10 +181,10 @@ amd64_get_revision(pfm_amd64_config_t *cfg) + } else if (cfg->family == 22) { /* family 16h */ + rev = PFM_PMU_AMD64_FAM16H; + } else if (cfg->family == 25) { /* family 19h */ +- if (cfg->model <= 0x0f || (cfg->model >= 0x20 && cfg->model <= 0x5f)) { +- rev = PFM_PMU_AMD64_FAM19H_ZEN3; +- } else if (cfg->model == 17) { +- rev = PFM_PMU_AMD64_FAM19H_ZEN4; ++ if (cfg->model >= 0x60 || (cfg->model >= 0x10 && cfg->model <= 0x1f)) { ++ rev = PFM_PMU_AMD64_FAM19H_ZEN4; ++ } else { ++ rev = PFM_PMU_AMD64_FAM19H_ZEN3; + } + } + diff --git a/libpfm.spec b/libpfm.spec index c2d140e..22d9140 100644 --- a/libpfm.spec +++ b/libpfm.spec @@ -1,4 +1,4 @@ -%define anolis_release 1 +%define anolis_release 2 # Default to no static libraries %{!?with_static: %global with_static 1} @@ -18,8 +18,10 @@ Release: %{anolis_release}%{?dist} Summary: Library to encode performance events for use by perf tool License: MIT URL: http://perfmon2.sourceforge.net/ -Source0: http://sourceforge.net/projects/perfmon2/files/libpfm4/%{name}-%{version}.tar.gz +Source0: http://sourceforge.net/projects/perfmon2/files/libpfm4/libpfm-4.13.0.tar.gz Patch0: libpfm-python3-setup.patch +Patch1: libpfm-initp.patch +Patch2: libpfm-zen4.patch BuildRequires: make BuildRequires: gcc @@ -134,6 +136,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/lib*.a %doc README %changelog +* Sun Sep 28 2025 wenyuzifang - 4.13.0-2 +- Initialize pointers to prevent undefined behavior and enhance code reliability. +- Fix Zen3/Zen4 detection to ensure correct PMU configuration on newer AMD processors. * Tue Feb 18 2025 mgb01105731 - 4.13.0-1 - Update to 4.13.0 from 4.12.0 - Remove patch as the new version of tarball already includes changes. -- Gitee