Hello community, here is the log from the commit of package cpupower.12033 for openSUSE:Leap:15.1:Update checked in at 2020-03-02 00:15:44 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.1:Update/cpupower.12033 (Old) and /work/SRC/openSUSE:Leap:15.1:Update/.cpupower.12033.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "cpupower.12033" Mon Mar 2 00:15:44 2020 rev:1 rq:779217 version:4.19 Changes: -------- New Changes file: --- /dev/null 2019-12-19 10:12:34.003146842 +0100 +++ /work/SRC/openSUSE:Leap:15.1:Update/.cpupower.12033.new.26092/cpupower.changes 2020-03-02 00:15:45.384819490 +0100 @@ -0,0 +1,306 @@ +------------------------------------------------------------------- +Thu Feb 6 16:10:57 UTC 2020 - tr...@suse.de + +- Fix missing governors when running cpupower frequency-info (bsc#1117709) + bsc#1141729 +M rapl_monitor.patch + +------------------------------------------------------------------- +Mon Dec 2 13:00:48 UTC 2019 - tr...@suse.de + +- Fixes aperf/mperf monitoring on latest AMD Rome CPUs (bsc#1152967) + Backporting mainline commits: +A cpupower-Move-needs_root-variable-into-a-sub-struct.patch +A cpupower-mperf_monitor-Introduce-per_cpu_schedule-flag.patch +A cpupower-mperf_monitor-Update-cpupower-to-use-the-RDPRU-instruction.patch + +------------------------------------------------------------------- +Mon Oct 1 13:59:45 UTC 2018 - tr...@suse.de + +- Updating to latest 4.19(-rc6) kernel sources + Turbostat is increased to version 18.07.27 by this + Patches which got deleted because they are now mainline: +D turbostat_decode_MSR_IA32_MISC_ENABLE_only_on_Intel.patch +D turbostat_fix_man_perm.patch +D x86_perf_fix_man_permissions.patch + +------------------------------------------------------------------- +Thu Jan 11 16:00:56 UTC 2018 - tr...@suse.de + +- Update cpupower to latest kernel version (version name 4.15, but + checked out against latest kernel tag 4.15-rc7. There will not + be important changes any more, maybe a fix). +- cpu online/offline fixes +- This is the first cpupower package (with updated version) which + includes x86_energy_perf_policy binary. + This is important for later package dependencies, namely tuned. +A cpupower_exclude_kernel_Makefile.patch + +------------------------------------------------------------------- +Tue Jan 9 16:07:07 UTC 2018 - tr...@suse.de + +- Add x86_energy_perf_bias tool + This is a tool which is, same as turbostat, located in kernel sources here: + tools/power/x86/ +A x86_energy_perf_policy-17.05.11.tar.bz2 +A x86_perf_fix_man_permissions.patch +A x86_perf_makefile_fix_asm_header.patch + +------------------------------------------------------------------- +Fri Oct 20 15:09:15 UTC 2017 - tr...@suse.de + +fate#321274 +- Provide rapl domain info (cpupower powercap-info cmd) +* Add: cpupower_rapl.patch +- Provide rapl power monitoring +* Add: rapl_monitor.patch + +------------------------------------------------------------------- +Fri Oct 6 13:01:48 UTC 2017 - josef.moell...@suse.com + +- Added missing references. + [bsc#1041332,bsc#996052,bsc#976983] + +------------------------------------------------------------------- +Thu Oct 5 14:52:11 UTC 2017 - jeng...@inai.de + +- Rectify RPM groups. Replace old $RPM_ shell variables by macros. + Apply consistent styling to macros. + +------------------------------------------------------------------- +Thu Oct 5 12:02:46 UTC 2017 - josef.moell...@suse.com + +- Enter decode_misc_enable_msr() only if genuine_intel. + [bsc#1048546, + turbostat_decode_MSR_IA32_MISC_ENABLE_only_on_Intel.patch] + +------------------------------------------------------------------- +Wed May 3 11:13:53 UTC 2017 - tr...@suse.de + +- Update to latest mainline sources +- turbostat changed versioning scheme (we now have version 17.04.12) + +------------------------------------------------------------------- +Wed Mar 22 19:00:17 UTC 2017 - tr...@suse.de + +- Update cpupower and turbostat to latest kernel v4.10 sources +D library_cleanup.patch +- Change .c file header file modification, modify in Makefile instead: +D turbostat_set_asm_header_fixed.patch +A turbostat_makefile_fix_asm_header.patch +- fate #320908: KBL: Turbostat for KBL H/S & U/Y +- fate #321191: [KNL] turbostat reports to report corect MSR_TURBO_RATIO_LIMIT + information +- fate #321193: [KNL] turbostat should report correct cpu clock values for + Knights Landing +- fate #321285: turbostat support for Skylake-SP server +- fate #321286: turbostat support for Harrisonville (Denverton SoC) +- fate #321925: [HPC, KNM, kernel] turbostat support + +------------------------------------------------------------------- +Thu Apr 28 12:28:09 UTC 2016 - tr...@suse.de + +- Update turbostat to version 4.12 +- Update cpupower to latest sources +- Let turbostat only build against a local msr-index.h + Also add the msr-index.h export to the tarball from git repo script +*Delete make_header_file_passable_from_outside.patch + +------------------------------------------------------------------- +Wed Apr 20 13:16:43 UTC 2016 - tr...@suse.de + +- Add cpuidle functions to public libcpupower +*Add library_cleanup.patch + +------------------------------------------------------------------- +Tue Jan 26 17:29:27 UTC 2016 - tr...@suse.de + +- Move from kernel version to turbostat internal version for turbostat +- Add latest turbostat sources (latest git commit: 30f05309bde492) +- Adds Skylake, Broadwell and Knights Landing support for turbostat + (fate#319798, fate#319183, fate#319516) + +------------------------------------------------------------------- +Wed Jan 6 10:22:14 UTC 2016 - jdelv...@suse.com + +- Drop dead link. +- Fix Obsoletes statement, cpufrequtils package versions were + greater than cpupower package versions so we must obsolete all + versions of cpufrequtils. + +------------------------------------------------------------------- +Wed Jan 28 18:18:52 UTC 2015 - tr...@suse.de + +- Make sources also build against 13.1 and older by providing + asm-index.h which is included in linux-glibc-devel in newer + distributions +*Add turbostat_set_asm_header_fixed.patch + +------------------------------------------------------------------- +Wed Jan 28 17:11:07 UTC 2015 - tr...@suse.de + +- Update cpupower and turbostat to latest git kernel HEAD version + this currently is 3.19-rc6, but it is expected that there are no + changes anymore and the version gets named 3.19 already. + The patches are already included mainline and get removed from osc: + cpupower_disable_by_latency.patch + add_idle_manpages_in_Makefile.patch + cpupower-always_try_to_load_msr_driver_as_root.patch + cpupower-return_zero_on_success.patch + cpupower-remove_mc_scheduler_bits.patch + +------------------------------------------------------------------- +Wed Aug 13 13:06:27 UTC 2014 - tr...@suse.de + +- Fix cpupower_export_tarball_from_git.sh script and make sure msr-index.h + is included in the turbostat tarball. + +------------------------------------------------------------------- +Tue Aug 12 13:49:16 UTC 2014 - tr...@suse.de + +- Update turbostat to latest 3.17 kernel version (in fact it is 3.16-rc7) + This fixes bnc#891523 + +------------------------------------------------------------------- +Tue Apr 1 12:31:14 UTC 2014 - tr...@suse.de + +- Do return 0 if cpupower info -b is called instead of the perf bias value + which is already printed to stdout. + Add cpupower-return_zero_on_success.patch +- Remove mc and smt scheduler knobs. These do not exist anymore in latest + kernels for quite a while now. + Add cpupower-remove_mc_scheduler_bits.patch + +------------------------------------------------------------------- +Mon Mar 31 15:27:14 UTC 2014 - tr...@suse.de + +- If root, try to load msr driver on x86 if /dev/cpu/0/msr is not avail + Add cpupower-always_try_to_load_msr_driver_as_root.patch + +------------------------------------------------------------------- +Fri Mar 28 19:35:10 UTC 2014 - tr...@suse.de + +- Update to latest turbostat version (git 2d6e532279ddf30188d5fbd) + bnc#866862, bnc#869071, bnc#869809 +- Adjust MSR include path + add make_header_file_passable_from_outside.patch + +------------------------------------------------------------------- +Fri Mar 28 19:05:46 UTC 2014 - tr...@suse.de + +- Fix Makefile: Install latest cpupower-idle-* manpages + Add add_idle_manpages_in_Makefile.patch + +------------------------------------------------------------------- +Fri Mar 14 03:22:50 UTC 2014 - tr...@suse.de + +- Introduce idle state disable-by-latency and enable-all ++++ 109 more lines (skipped) ++++ between /dev/null ++++ and /work/SRC/openSUSE:Leap:15.1:Update/.cpupower.12033.new.26092/cpupower.changes New: ---- cpupower-4.19.tar.bz2 cpupower-Move-needs_root-variable-into-a-sub-struct.patch cpupower-mperf_monitor-Introduce-per_cpu_schedule-flag.patch cpupower-mperf_monitor-Update-cpupower-to-use-the-RDPRU-instruction.patch cpupower.changes cpupower.spec cpupower_exclude_kernel_Makefile.patch cpupower_export_tarball_from_git.sh cpupower_rapl.patch rapl_monitor.patch turbostat-18.07.27.tar.bz2 turbostat_makefile_fix_asm_header.patch x86_energy_perf_policy-17.05.11.tar.bz2 x86_perf_makefile_fix_asm_header.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ cpupower.spec ++++++ # # spec file for package cpupower # # Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # Author: Thomas Renninger <tr...@suse.de> # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via http://bugs.opensuse.org/ # Name: cpupower # Use this as version when things are in mainline kernel %define version %(rpm -q --qf '%VERSION' kernel-source) Version: 4.19 Release: 0 %define tsversion 18.07.27 %define pbversion 17.05.11 Summary: Tools to determine and set CPU Power related Settings License: GPL-2.0 Group: System/Base Url: https://git.kernel.org/cgit/linux/kernel/git/rafael/linux-pm.git Source: %name-%version.tar.bz2 Source1: turbostat-%tsversion.tar.bz2 Source2: cpupower_export_tarball_from_git.sh Source3: x86_energy_perf_policy-%{pbversion}.tar.bz2 Patch1: cpupower_rapl.patch Patch2: rapl_monitor.patch Patch3: cpupower_exclude_kernel_Makefile.patch Patch4: cpupower-Move-needs_root-variable-into-a-sub-struct.patch Patch5: cpupower-mperf_monitor-Introduce-per_cpu_schedule-flag.patch Patch6: cpupower-mperf_monitor-Update-cpupower-to-use-the-RDPRU-instruction.patch Patch22: turbostat_makefile_fix_asm_header.patch # Fixes bsc#1048546: Patch30: x86_perf_makefile_fix_asm_header.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: gettext-tools BuildRequires: pciutils BuildRequires: pciutils-devel Obsoletes: cpufrequtils Provides: cpufrequtils = %version %description This tool is to make access to the Linux kernel's processor power subsystems like CPU frequency switching (cpufreq) or CPU sleep states (cpuidle) for users and userspace tools easier. %package -n libcpupower0 Summary: Obsolete processor frequency related C-library Group: System/Libraries %description -n libcpupower0 Contains libcpupower and soon possibly other CPU power related C libraries. %package devel Summary: Include files and C-libraries Group: Development/Languages/C and C++ Conflicts: cpufrequtils-devel Requires: libcpupower0 = %version %description devel Include files and C-libraries for C/C++ development %package bench Summary: CPU frequency micro benchmark Group: System/Benchmark Obsoletes: cpufrequtils-bench < %version Provides: cpufrequtils-bench = %version %description bench Helps to test the condition of a given kernel cpufreq governor (e.g. ondemand, userspace, conservative) and the cpufreq HW driver (e.g. powernow-k8, acpi-cpufreq, ...). For that purpose, it compares the performance governor to a configured powersave module. %prep %setup -D -b 1 -b 3 %patch1 -p1 %patch2 -p1 %patch3 -p1 %patch4 -p1 %patch5 -p1 %patch6 -p1 cd ../turbostat-%tsversion %patch22 -p1 cd ../x86_energy_perf_policy-%{pbversion} %patch30 -p1 %build # This package failed when testing with -Wl,-as-needed being default. # So we disable it here, if you want to retest, just delete this comment and the line below. export SUSE_ASNEEDED=0 CONF="PACKAGE_BUGREPORT=http://bugs.opensuse.org mandir=%_mandir libdir=%_libdir CPUFRQ_BENCH=true VERSION=%version" export CFLAGS="%optflags -I ." make $CONF %{?_smp_mflags} %ifarch ix86 x86_64 cd ../turbostat-%tsversion export CFLAGS="%optflags -I ." make %{?_smp_mflags} cd ../x86_energy_perf_policy-%{pbversion} make %{?_smp_mflags} %endif %install export SUSE_ASNEEDED=0 CONF="PACKAGE_BUGREPORT=http://bugs.opensuse.org mandir=%_mandir libdir=%_libdir CPUFRQ_BENCH=true DESTDIR=%buildroot sbindir=%_sbindir docdir=%_docdir/%name confdir=%_sysconfdir VERSION=%version" %make_install $CONF # copy to examples doc dir to avoid complains from the build # system about an executable in the doc dir. mkdir -p %buildroot/%_docdir/%name/examples mv %buildroot//%_docdir/%name/cpufreq-bench_script.sh %buildroot/%_docdir/%name/examples %find_lang %name %ifarch ix86 x86_64 cd ../turbostat-%tsversion %make_install -e cd ../x86_energy_perf_policy-%{pbversion} %make_install %endif %post -n libcpupower0 -p /sbin/ldconfig %postun -n libcpupower0 -p /sbin/ldconfig %files -f %name.lang %defattr (-,root,root) %_mandir/man1/cpupower* %_bindir/cpupower %ifarch ix86 x86_64 %_mandir/man8/turbostat* %_bindir/turbostat %_mandir/man8/x86_energy_perf_policy* %_bindir/x86_energy_perf_policy %endif %files bench %defattr (-,root,root) %config %_sysconfdir/cpufreq-bench.conf %_sbindir/cpufreq-bench %_bindir/cpufreq-bench_plot.sh %dir %_docdir/%name %dir %_docdir/%name/examples %_docdir/%name/examples/cpufreq-bench_script.sh %_docdir/%name/README-BENCH %files -n libcpupower0 %defattr(-,root,root) %_libdir/libcpupower*.so.* %files devel %defattr(-,root,root) %_includedir/cpufreq.h %_includedir/cpuidle.h /usr/include/powercap.h %_libdir/libcpu*.so %changelog ++++++ cpupower-Move-needs_root-variable-into-a-sub-struct.patch ++++++ From: Janakarajan Natarajan <janakarajan.natara...@amd.com> Subject: cpupower: Move needs_root variable into a sub-struct References: bsc#1152967 Patch-Mainline: v5.5-rc1 Git-commit: d3f5d2a192a299f56579ae6e6283f9011b00208f Move the needs_root variable into a sub-struct. This is in preparation for adding a new flag for cpuidle_monitor. Update all uses of the needs_root variable to reflect this change. Signed-off-by: Janakarajan Natarajan <janakarajan.natara...@amd.com> Acked-by: Thomas Renninger <tr...@suse.de> Signed-off-by: Shuah Khan <sk...@linuxfoundation.org> Signed-off-by: <tr...@suse.com> Index: cpupower-4.19/utils/idle_monitor/amd_fam14h_idle.c =================================================================== --- cpupower-4.19.orig/utils/idle_monitor/amd_fam14h_idle.c 2018-09-30 16:15:35.000000000 +0200 +++ cpupower-4.19/utils/idle_monitor/amd_fam14h_idle.c 2020-01-14 14:39:51.708604074 +0100 @@ -329,7 +329,7 @@ struct cpuidle_monitor amd_fam14h_monito .stop = amd_fam14h_stop, .do_register = amd_fam14h_register, .unregister = amd_fam14h_unregister, - .needs_root = 1, + .flags.needs_root = 1, .overflow_s = OVERFLOW_MS / 1000, }; #endif /* #if defined(__i386__) || defined(__x86_64__) */ Index: cpupower-4.19/utils/idle_monitor/cpuidle_sysfs.c =================================================================== --- cpupower-4.19.orig/utils/idle_monitor/cpuidle_sysfs.c 2018-09-30 16:15:35.000000000 +0200 +++ cpupower-4.19/utils/idle_monitor/cpuidle_sysfs.c 2020-01-14 14:39:51.708604074 +0100 @@ -209,6 +209,6 @@ struct cpuidle_monitor cpuidle_sysfs_mon .stop = cpuidle_stop, .do_register = cpuidle_register, .unregister = cpuidle_unregister, - .needs_root = 0, + .flags.needs_root = 0, .overflow_s = UINT_MAX, }; Index: cpupower-4.19/utils/idle_monitor/cpupower-monitor.c =================================================================== --- cpupower-4.19.orig/utils/idle_monitor/cpupower-monitor.c 2020-01-14 14:39:49.148603936 +0100 +++ cpupower-4.19/utils/idle_monitor/cpupower-monitor.c 2020-01-14 14:39:51.708604074 +0100 @@ -410,7 +410,7 @@ int cmd_monitor(int argc, char **argv) dprint("Try to register: %s\n", all_monitors[num]->name); test_mon = all_monitors[num]->do_register(); if (test_mon) { - if (test_mon->needs_root && !run_as_root) { + if (test_mon->flags.needs_root && !run_as_root) { fprintf(stderr, _("Available monitor %s needs " "root access\n"), test_mon->name); continue; Index: cpupower-4.19/utils/idle_monitor/cpupower-monitor.h =================================================================== --- cpupower-4.19.orig/utils/idle_monitor/cpupower-monitor.h 2018-09-30 16:15:35.000000000 +0200 +++ cpupower-4.19/utils/idle_monitor/cpupower-monitor.h 2020-01-14 14:39:51.712604074 +0100 @@ -62,7 +62,9 @@ struct cpuidle_monitor { struct cpuidle_monitor* (*do_register) (void); void (*unregister)(void); unsigned int overflow_s; - int needs_root; + struct { + unsigned int needs_root:1; + } flags; }; extern long long timespec_diff_us(struct timespec start, struct timespec end); Index: cpupower-4.19/utils/idle_monitor/hsw_ext_idle.c =================================================================== --- cpupower-4.19.orig/utils/idle_monitor/hsw_ext_idle.c 2018-09-30 16:15:35.000000000 +0200 +++ cpupower-4.19/utils/idle_monitor/hsw_ext_idle.c 2020-01-14 14:39:51.712604074 +0100 @@ -189,7 +189,7 @@ struct cpuidle_monitor intel_hsw_ext_mon .stop = hsw_ext_stop, .do_register = hsw_ext_register, .unregister = hsw_ext_unregister, - .needs_root = 1, + .flags.needs_root = 1, .overflow_s = 922000000 /* 922337203 seconds TSC overflow at 20GHz */ }; Index: cpupower-4.19/utils/idle_monitor/mperf_monitor.c =================================================================== --- cpupower-4.19.orig/utils/idle_monitor/mperf_monitor.c 2018-09-30 16:15:35.000000000 +0200 +++ cpupower-4.19/utils/idle_monitor/mperf_monitor.c 2020-01-14 14:39:51.712604074 +0100 @@ -333,7 +333,7 @@ struct cpuidle_monitor mperf_monitor = { .stop = mperf_stop, .do_register = mperf_register, .unregister = mperf_unregister, - .needs_root = 1, + .flags.needs_root = 1, .overflow_s = 922000000 /* 922337203 seconds TSC overflow at 20GHz */ }; Index: cpupower-4.19/utils/idle_monitor/nhm_idle.c =================================================================== --- cpupower-4.19.orig/utils/idle_monitor/nhm_idle.c 2018-09-30 16:15:35.000000000 +0200 +++ cpupower-4.19/utils/idle_monitor/nhm_idle.c 2020-01-14 14:39:51.712604074 +0100 @@ -209,7 +209,7 @@ struct cpuidle_monitor intel_nhm_monitor .stop = nhm_stop, .do_register = intel_nhm_register, .unregister = intel_nhm_unregister, - .needs_root = 1, + .flags.needs_root = 1, .overflow_s = 922000000 /* 922337203 seconds TSC overflow at 20GHz */ }; Index: cpupower-4.19/utils/idle_monitor/snb_idle.c =================================================================== --- cpupower-4.19.orig/utils/idle_monitor/snb_idle.c 2018-09-30 16:15:35.000000000 +0200 +++ cpupower-4.19/utils/idle_monitor/snb_idle.c 2020-01-14 14:39:51.712604074 +0100 @@ -193,7 +193,7 @@ struct cpuidle_monitor intel_snb_monitor .stop = snb_stop, .do_register = snb_register, .unregister = snb_unregister, - .needs_root = 1, + .flags.needs_root = 1, .overflow_s = 922000000 /* 922337203 seconds TSC overflow at 20GHz */ }; Index: cpupower-4.19/utils/idle_monitor/rapl_monitor.c =================================================================== --- cpupower-4.19.orig/utils/idle_monitor/rapl_monitor.c 2020-01-14 14:39:49.152603936 +0100 +++ cpupower-4.19/utils/idle_monitor/rapl_monitor.c 2020-01-14 14:44:23.640618727 +0100 @@ -134,7 +134,7 @@ struct cpuidle_monitor rapl_monitor = { .start = rapl_start, .stop = rapl_stop, .do_register = rapl_register, - .needs_root = 0, + .flags.needs_root = 0, .overflow_s = 60 * 60 * 24 * 100, /* To be implemented */ }; ++++++ cpupower-mperf_monitor-Introduce-per_cpu_schedule-flag.patch ++++++ From: Janakarajan Natarajan <janakarajan.natara...@amd.com> Subject: cpupower: mperf_monitor: Introduce per_cpu_schedule flag References: bsc#1152967 Patch-Mainline: v5.5-rc1 Git-commit: 7adafe541fe5e015261a92d39db8b163db477337 The per_cpu_schedule flag is used to move the cpupower process to the cpu on which we are looking to read the APERF/MPERF registers. This prevents IPIs from being generated by read_msr()s as we are already on the cpu of interest. Ex: If cpupower is running on CPU 0 and we execute read_msr(20, MSR_APERF, val) then, read_msr(20, MSR_MPERF, val) the msr module will generate an IPI from CPU 0 to CPU 20 to query for the MSR_APERF and then the MSR_MPERF in separate IPIs. This delay, caused by IPI latency, between reading the APERF and MPERF registers may cause both of them to go out of sync. The use of the per_cpu_schedule flag reduces the probability of this from happening. It comes at the cost of a negligible increase in cpu consumption caused by the migration of cpupower across each of the cpus of the system. Signed-off-by: Janakarajan Natarajan <janakarajan.natara...@amd.com> Acked-by: Thomas Renninger <tr...@suse.de> Signed-off-by: Shuah Khan <sk...@linuxfoundation.org> Signed-off-by: <tr...@suse.com> diff --git a/utils/idle_monitor/cpupower-monitor.h b/utils/idle_monitor/cpupower-monitor.h index 9b612d999660..5b5eb1da0cce 100644 --- a/utils/idle_monitor/cpupower-monitor.h +++ b/utils/idle_monitor/cpupower-monitor.h @@ -62,6 +62,7 @@ struct cpuidle_monitor { unsigned int overflow_s; struct { unsigned int needs_root:1; + unsigned int per_cpu_schedule:1; } flags; }; diff --git a/utils/idle_monitor/mperf_monitor.c b/utils/idle_monitor/mperf_monitor.c index 7cae74202a4d..afb2e6f8edd3 100644 --- a/utils/idle_monitor/mperf_monitor.c +++ b/utils/idle_monitor/mperf_monitor.c @@ -86,15 +86,35 @@ static int mperf_get_tsc(unsigned long long *tsc) return ret; } +static int get_aperf_mperf(int cpu, unsigned long long *aval, + unsigned long long *mval) +{ + int ret; + + /* + * Running on the cpu from which we read the registers will + * prevent APERF/MPERF from going out of sync because of IPI + * latency introduced by read_msr()s. + */ + if (mperf_monitor.flags.per_cpu_schedule) { + if (bind_cpu(cpu)) + return 1; + } + + ret = read_msr(cpu, MSR_APERF, aval); + ret |= read_msr(cpu, MSR_MPERF, mval); + + return ret; +} + static int mperf_init_stats(unsigned int cpu) { - unsigned long long val; + unsigned long long aval, mval; int ret; - ret = read_msr(cpu, MSR_APERF, &val); - aperf_previous_count[cpu] = val; - ret |= read_msr(cpu, MSR_MPERF, &val); - mperf_previous_count[cpu] = val; + ret = get_aperf_mperf(cpu, &aval, &mval); + aperf_previous_count[cpu] = aval; + mperf_previous_count[cpu] = mval; is_valid[cpu] = !ret; return 0; @@ -102,13 +122,12 @@ static int mperf_init_stats(unsigned int cpu) static int mperf_measure_stats(unsigned int cpu) { - unsigned long long val; + unsigned long long aval, mval; int ret; - ret = read_msr(cpu, MSR_APERF, &val); - aperf_current_count[cpu] = val; - ret |= read_msr(cpu, MSR_MPERF, &val); - mperf_current_count[cpu] = val; + ret = get_aperf_mperf(cpu, &aval, &mval); + aperf_current_count[cpu] = aval; + mperf_current_count[cpu] = mval; is_valid[cpu] = !ret; return 0; @@ -305,6 +324,9 @@ struct cpuidle_monitor *mperf_register(void) if (init_maxfreq_mode()) return NULL; + if (cpupower_cpu_info.vendor == X86_VENDOR_AMD) + mperf_monitor.flags.per_cpu_schedule = 1; + /* Free this at program termination */ is_valid = calloc(cpu_count, sizeof(int)); mperf_previous_count = calloc(cpu_count, sizeof(unsigned long long)); ++++++ cpupower-mperf_monitor-Update-cpupower-to-use-the-RDPRU-instruction.patch ++++++ From: Janakarajan Natarajan <janakarajan.natara...@amd.com> Subject: cpupower: mperf_monitor: Update cpupower to use the RDPRU instruction References: bsc#1152967 Patch-Mainline: v5.5-rc1 Git-commit: 6af2ed53f0402c09b36d2b38698e18a25ca732a7 AMD Zen 2 introduces the RDPRU instruction which can be used to access some processor registers which are typically only accessible in privilege level 0. ECX specifies the register to read and EDX:EAX will contain the value read. ECX: 0 - Register MPERF 1 - Register APERF This has the added advantage of not having to use the msr module, since the userspace to kernel transitions which occur during each read_msr() might cause APERF and MPERF to go out of sync. Signed-off-by: Janakarajan Natarajan <janakarajan.natara...@amd.com> Acked-by: Thomas Renninger <tr...@suse.de> Signed-off-by: Shuah Khan <sk...@linuxfoundation.org> Signed-off-by: <tr...@suse.com> diff --git a/utils/helpers/cpuid.c b/utils/helpers/cpuid.c index 5cc39d4e23ed..73bfafc60e9b 100644 --- a/utils/helpers/cpuid.c +++ b/utils/helpers/cpuid.c @@ -131,6 +131,10 @@ int get_cpu_info(struct cpupower_cpu_info *cpu_info) if (ext_cpuid_level >= 0x80000007 && (cpuid_edx(0x80000007) & (1 << 9))) cpu_info->caps |= CPUPOWER_CAP_AMD_CBP; + + if (ext_cpuid_level >= 0x80000008 && + cpuid_ebx(0x80000008) & (1 << 4)) + cpu_info->caps |= CPUPOWER_CAP_AMD_RDPRU; } if (cpu_info->vendor == X86_VENDOR_INTEL) { diff --git a/utils/helpers/helpers.h b/utils/helpers/helpers.h index 357b19bb136e..c258eeccd05f 100644 --- a/utils/helpers/helpers.h +++ b/utils/helpers/helpers.h @@ -69,6 +69,7 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL, #define CPUPOWER_CAP_HAS_TURBO_RATIO 0x00000010 #define CPUPOWER_CAP_IS_SNB 0x00000020 #define CPUPOWER_CAP_INTEL_IDA 0x00000040 +#define CPUPOWER_CAP_AMD_RDPRU 0x00000080 #define CPUPOWER_AMD_CPBDIS 0x02000000 diff --git a/utils/idle_monitor/mperf_monitor.c b/utils/idle_monitor/mperf_monitor.c index afb2e6f8edd3..e7d48cb563c0 100644 --- a/utils/idle_monitor/mperf_monitor.c +++ b/utils/idle_monitor/mperf_monitor.c @@ -19,6 +19,10 @@ #define MSR_APERF 0xE8 #define MSR_MPERF 0xE7 +#define RDPRU ".byte 0x0f, 0x01, 0xfd" +#define RDPRU_ECX_MPERF 0 +#define RDPRU_ECX_APERF 1 + #define MSR_TSC 0x10 #define MSR_AMD_HWCR 0xc0010015 @@ -89,6 +93,8 @@ static int mperf_get_tsc(unsigned long long *tsc) static int get_aperf_mperf(int cpu, unsigned long long *aval, unsigned long long *mval) { + unsigned long low_a, high_a; + unsigned long low_m, high_m; int ret; /* @@ -101,6 +107,20 @@ static int get_aperf_mperf(int cpu, unsigned long long *aval, return 1; } + if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_RDPRU) { + asm volatile(RDPRU + : "=a" (low_a), "=d" (high_a) + : "c" (RDPRU_ECX_APERF)); + asm volatile(RDPRU + : "=a" (low_m), "=d" (high_m) + : "c" (RDPRU_ECX_MPERF)); + + *aval = ((low_a) | (high_a) << 32); + *mval = ((low_m) | (high_m) << 32); + + return 0; + } + ret = read_msr(cpu, MSR_APERF, aval); ret |= read_msr(cpu, MSR_MPERF, mval); ++++++ cpupower_exclude_kernel_Makefile.patch ++++++ Index: cpupower-4.15/Makefile =================================================================== --- cpupower-4.15.orig/Makefile 2018-01-11 16:49:23.619489210 +0100 +++ cpupower-4.15/Makefile 2018-01-11 16:50:32.263630773 +0100 @@ -30,8 +30,6 @@ OUTDIR := $(shell cd $(OUTPUT) && pwd) $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist)) endif -include ../../scripts/Makefile.arch - # --- CONFIGURATION BEGIN --- # Set the following to `true' to make a unstripped, unoptimized ++++++ cpupower_export_tarball_from_git.sh ++++++ #!/bin/bash # Author: Thomas Renninger <tr...@suse.de> # This code is covered and distributed under # the General Public Licence v2 GIT_TAG=HEAD VERSION="" TOOL="" function usage(){ echo "$(basename $0) [ -k git_tag ] [ -v tag_to_use ] -t cpupower | turbostat | x86_perf_bias " echo echo "git_tag Must be a valid kernel git tag, for example v3.1" echo " if git_tag is not passed HEAD will be used which" echo " may produce a package incompatible tarball name" echo " BEST ALWAYS PASS AN EXISTING TAG" echo " cpupower got introduced in 3.1-rc1" echo "tag_to_use obs does not like -rcX as a version tag. Pass a verion" echo " tag you like to use (e.g. 3.13 instead of 3.13-rc7" echo echo "export GIT_DIR= environment variable if the git repo is not the current directory" echo "For example: GIT_DIR=/path_to_git_repo/.git" } function parse_args() { while getopts hv:k:t: name ; do case $name in v) VERSION="$OPTARG" ;; k) GIT_TAG="$OPTARG" ;; t) echo XXXXXXXXX TOOL="$OPTARG" echo $TOOL echo YYYYYYYY ;; ?|h) usage exit 1 ;; esac done shift $(($OPTIND -1)) } function export_cpupower() { echo "Exporting cpupower from kernel version $GIT_TAG" if [ "$VERSION" = "" ];then # convert - to . as package versions do not allow - if [ $# -eq 1 ];then VERSION="${GIT_TAG/-/.}" # remove leading v VERSION="-${VERSION#v}" elif [ $# -eq 2 ];then VERSION="${2/-/.}" # remove leading v VERSION="-${VERSION#v}" elif [ $# -gt 2 ];then usage exit 1 fi fi # Tried to do this with one git archive command, but # --remote= param seem not to be configured for kernel.org gits set -x git archive --format=tar $GIT_TAG tools/power/cpupower |tar -x set +x mv tools/power/cpupower cpupower-${VERSION} tar -cvjf cpupower-${VERSION}.tar.bz2 cpupower-${VERSION} popd mv "$DIR/cpupower-${VERSION}".tar.bz2 . echo cpupower-${VERSION}.tar.bz2 } function export_turbostat() { git archive --format=tar $GIT_TAG tools/power/x86/turbostat |tar -x if [ "$TURBOSTAT_VERSION"x == ""x ];then TURBOSTAT_VERSION=$(grep "turbostat version" tools/power/x86/turbostat/turbostat.c |grep fprintf |sed 's/.*turbostat version \([0-9][0-9].[0-9][0-9].[0-9][0-9]\).*/\1/') fi TURBOSTAT_VERSION=$(echo "-$TURBOSTAT_VERSION") mv tools/power/x86/turbostat turbostat${TURBOSTAT_VERSION} git checkout $GIT_TAG arch/x86/include/asm/msr-index.h git checkout $GIT_TAG arch/x86/include/asm/intel-family.h cp arch/x86/include/asm/intel-family.h turbostat${TURBOSTAT_VERSION} cp arch/x86/include/asm/msr-index.h turbostat${TURBOSTAT_VERSION} tar -cvjf turbostat${TURBOSTAT_VERSION}.tar.bz2 turbostat${TURBOSTAT_VERSION} popd mv "$DIR/turbostat${TURBOSTAT_VERSION}".tar.bz2 . echo turbostat${TURBOSTAT_VERSION}.tar.bz2 } function export_x86_perf_bias() { set -x git archive --format=tar $GIT_TAG tools/power/x86/x86_energy_perf_policy |tar -x if [ "$PERF_BIAS_VERSION"x == ""x ];then PERF_BIAS_VERSION=$(grep 'printf("x86_energy_perf_policy .* (C) Len Brown <len.br...@intel.com' tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c |sed 's/.*x86_energy_perf_policy \([0-9][0-9].[0-9][0-9].[0-9][0-9]\).*/\1/') fi PERF_BIAS_VERSION=$(echo "-$PERF_BIAS_VERSION") mv tools/power/x86/x86_energy_perf_policy x86_energy_perf_policy${PERF_BIAS_VERSION} set +x git checkout $GIT_TAG arch/x86/include/asm/msr-index.h cp arch/x86/include/asm/msr-index.h x86_energy_perf_policy${PERF_BIAS_VERSION} tar -cvjf x86_energy_perf_policy${PERF_BIAS_VERSION}.tar.bz2 x86_energy_perf_policy${PERF_BIAS_VERSION} popd mv "$DIR/x86_energy_perf_policy${PERF_BIAS_VERSION}".tar.bz2 . echo x86_energy_perf_policy${PERF_BIAS_VERSION}.tar.bz2 } parse_args $* DIR=`mktemp -d` pushd $DIR if [ "$GIT_DIR" = "" ];then export GIT_DIR=/archteam/trenn/git/linux-2.6/.git fi case $TOOL in cpupower) echo XXX export_cpupower ;; turbostat) export_turbostat ;; x86_perf_bias) export_x86_perf_bias ;; *) echo "You have to provide the tool you want to export cpupower|turbostat|x86_energy_perf_bias" usage rm -rf "$DIR" exit 1 ;; esac #rm -rf "$DIR" ++++++ cpupower_rapl.patch ++++++ ++++ 612 lines (skipped) ++++++ rapl_monitor.patch ++++++ cpupower: rapl monitor - shows the used power consumption in uj for each rapl domain Signed-off-by: Thomas Renninger <tr...@suse.com> Index: cpupower-4.15/Makefile =================================================================== --- cpupower-4.15.orig/Makefile 2018-01-11 16:49:11.946784841 +0100 +++ cpupower-4.15/Makefile 2018-01-11 16:49:23.619489210 +0100 @@ -139,6 +139,7 @@ UTIL_OBJS = utils/helpers/amd.o utils/h utils/idle_monitor/hsw_ext_idle.o \ utils/idle_monitor/amd_fam14h_idle.o utils/idle_monitor/cpuidle_sysfs.o \ utils/idle_monitor/mperf_monitor.o utils/idle_monitor/cpupower-monitor.o \ + utils/idle_monitor/rapl_monitor.o \ utils/cpupower.o utils/cpufreq-info.o utils/cpufreq-set.o \ utils/cpupower-set.o utils/cpupower-info.o utils/cpuidle-info.o \ utils/cpuidle-set.o utils/powercap-info.o Index: cpupower-4.15/utils/idle_monitor/cpupower-monitor.c =================================================================== --- cpupower-4.15.orig/utils/idle_monitor/cpupower-monitor.c 2018-01-10 20:18:31.000000000 +0100 +++ cpupower-4.15/utils/idle_monitor/cpupower-monitor.c 2018-01-11 16:49:23.619489210 +0100 @@ -454,9 +454,10 @@ int cmd_monitor(int argc, char **argv) print_results(1, cpu); } - for (num = 0; num < avail_monitors; num++) - monitors[num]->unregister(); - + for (num = 0; num < avail_monitors; num++) { + if (monitors[num]->unregister) + monitors[num]->unregister(); + } cpu_topology_release(cpu_top); return 0; } Index: cpupower-4.15/utils/idle_monitor/idle_monitors.def =================================================================== --- cpupower-4.15.orig/utils/idle_monitor/idle_monitors.def 2018-01-10 20:18:31.000000000 +0100 +++ cpupower-4.15/utils/idle_monitor/idle_monitors.def 2018-01-11 16:49:23.619489210 +0100 @@ -4,5 +4,6 @@ DEF(intel_nhm) DEF(intel_snb) DEF(intel_hsw_ext) DEF(mperf) +DEF(rapl) #endif DEF(cpuidle_sysfs) Index: cpupower-4.15/utils/idle_monitor/rapl_monitor.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ cpupower-4.15/utils/idle_monitor/rapl_monitor.c 2018-01-11 16:49:23.623489452 +0100 @@ -0,0 +1,141 @@ +/* + * (C) 2016 Thomas Renninger <tr...@suse.com> + * + * Licensed under the terms of the GNU GPL License version 2. + * + */ + +#if defined(__i386__) || defined(__x86_64__) + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <time.h> +#include <string.h> + +#include <pci/pci.h> + +#include "idle_monitor/cpupower-monitor.h" +#include "helpers/helpers.h" +#include "powercap.h" + +#define MAX_RAPL_ZONES 10 + +int rapl_zone_count = 0; +cstate_t rapl_zones[MAX_RAPL_ZONES]; +struct powercap_zone *rapl_zones_pt[MAX_RAPL_ZONES] = { 0 }; + +unsigned long long rapl_zone_previous_count[MAX_RAPL_ZONES]; +unsigned long long rapl_zone_current_count[MAX_RAPL_ZONES]; +unsigned long long rapl_max_count; + +static int rapl_get_count_uj(unsigned int id, unsigned long long *count, + unsigned int cpu) +{ + if (rapl_zones_pt[id] == NULL) + /* error */ + return -1; + + *count = rapl_zone_current_count[id] - rapl_zone_previous_count[id]; + + return 0; +} + +static int powercap_count_zones(struct powercap_zone *zone) +{ + if (rapl_zone_count >= MAX_RAPL_ZONES) + return -1; + + if (!zone->has_energy_uj) + return 0; + + strncpy(rapl_zones[rapl_zone_count].name, zone->name, CSTATE_NAME_LEN - 1); + strcpy(rapl_zones[rapl_zone_count].desc, ""); + rapl_zones[rapl_zone_count].id = rapl_zone_count; + rapl_zones[rapl_zone_count].range = RANGE_MACHINE; + rapl_zones[rapl_zone_count].get_count = rapl_get_count_uj; + rapl_zones_pt[rapl_zone_count] = zone; + rapl_zone_count++; + + return 0; +} + +static int rapl_start(void) +{ + int i, ret; + uint64_t uj_val; + + for (i = 0; i < rapl_zone_count; i++) { + ret = powercap_get_energy_uj(rapl_zones_pt[i], &uj_val); + if (ret) + return ret; + rapl_zone_previous_count[i] = uj_val; + } + + return 0; +} + +static int rapl_stop(void) +{ + int i; + uint64_t uj_val; + + for (i = 0; i < rapl_zone_count; i++) { + int ret; + ret = powercap_get_energy_uj(rapl_zones_pt[i], &uj_val); + if (ret) + return ret; + rapl_zone_current_count[i] = uj_val; + if (rapl_max_count < uj_val) + rapl_max_count = uj_val - rapl_zone_previous_count[i]; + } + return 0; +} + +struct cpuidle_monitor *rapl_register(void) +{ + struct powercap_zone *root_zone; + char line[MAX_LINE_LEN] = ""; + int ret, val; + + ret = powercap_get_driver(line, MAX_LINE_LEN); + if (ret < 0) { + dprint("No powercapping driver loaded\n"); + return NULL; + } + + dprint("Driver: %s\n", line); + ret = powercap_get_enabled(&val); + if (ret < 0) + return NULL; + if (!val) { + dprint("Powercapping is disabled\n"); + return NULL; + } + + dprint("Powercap domain hierarchy:\n\n"); + root_zone = powercap_init_zones(); + + if (root_zone == NULL) { + dprint("No powercap info found\n"); + return NULL; + } + + powercap_walk_zones(root_zone, powercap_count_zones); + rapl_monitor.hw_states_num = rapl_zone_count; + + return &rapl_monitor; +} + +struct cpuidle_monitor rapl_monitor = { + .name = "RAPL", + .hw_states = rapl_zones, + .hw_states_num = 0, + .start = rapl_start, + .stop = rapl_stop, + .do_register = rapl_register, + .needs_root = 0, + .overflow_s = 60 * 60 * 24 * 100, /* To be implemented */ +}; + +#endif ++++++ turbostat_makefile_fix_asm_header.patch ++++++ Index: turbostat-4.16/Makefile =================================================================== --- turbostat-4.16.orig/Makefile 2017-03-22 19:36:31.329182164 +0100 +++ turbostat-4.16/Makefile 2017-03-22 19:38:04.762500669 +0100 @@ -9,8 +9,8 @@ endif turbostat : turbostat.c CFLAGS += -Wall -CFLAGS += -DMSRHEADER='"../../../../arch/x86/include/asm/msr-index.h"' -CFLAGS += -DINTEL_FAMILY_HEADER='"../../../../arch/x86/include/asm/intel-family.h"' +CFLAGS += -DMSRHEADER='"msr-index.h"' +CFLAGS += -DINTEL_FAMILY_HEADER='"intel-family.h"' %: %.c @mkdir -p $(BUILD_OUTPUT) ++++++ x86_perf_makefile_fix_asm_header.patch ++++++ Index: x86_energy_perf_policy-17.05.11/Makefile =================================================================== --- x86_energy_perf_policy-17.05.11.orig/Makefile 2017-12-21 01:52:01.000000000 +0100 +++ x86_energy_perf_policy-17.05.11/Makefile 2018-01-09 16:17:56.058472491 +0100 @@ -10,7 +10,7 @@ endif x86_energy_perf_policy : x86_energy_perf_policy.c CFLAGS += -Wall -CFLAGS += -DMSRHEADER='"../../../../arch/x86/include/asm/msr-index.h"' +CFLAGS += -DMSRHEADER='"msr-index.h"' %: %.c @mkdir -p $(BUILD_OUTPUT)