Commit graph

627 commits

Author SHA1 Message Date
Bob Moore a3ce7a8e0d ACPICA: Rename nameseg copy macro for clarity
ACPICA commit 19c18d3157945d1b8b64a826f0a8e848b7dbb127

ACPI_MOVE_NAME changed to ACPI_COPY_NAMESEG
This clarifies (1) this is a copy operation, and
(2) it operates on ACPI name_segs.
Improves understanding of the code.

Link: https://github.com/acpica/acpica/commit/19c18d31
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-04-09 10:08:28 +02:00
Rafael J. Wysocki 59cc8cd60c Merge branch 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
Pull turbostat utility updates for 5.1 from Len Brown:

"Misc fixes and updates."

* 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
  tools/power turbostat: update version number
  tools/power turbostat: Warn on bad ACPI LPIT data
  tools/power turbostat: Add checks for failure of fgets() and fscanf()
  tools/power turbostat: Also read package power on AMD F17h (Zen)
  tools/power turbostat: Add support for AMD Fam 17h (Zen) RAPL
  tools/power turbostat: Do not display an error on systems without a cpufreq driver
  tools/power turbostat: Add Die column
  tools/power turbostat: Add Icelake support
  tools/power turbostat: Cleanup CNL-specific code
  tools/power turbostat: Cleanup CC3-skip code
  tools/power turbostat: Restore ability to execute in topology-order
2019-03-30 01:41:22 +01:00
Len Brown 0f71d089c9 tools/power turbostat: update version number
Signed-off-by: Len Brown <len.brown@intel.com>
2019-03-20 23:23:25 -04:00
Prarit Bhargava 5ea7647b33 tools/power turbostat: Warn on bad ACPI LPIT data
On some systems /sys/devices/system/cpu/cpuidle/low_power_idle_cpu_residency_us
or /sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us
return a file error because of bad ACPI LPIT data from a misconfigured BIOS.
turbostat interprets this failure as a fatal error and outputs

	turbostat: CPU LPI: No data available

If the ACPI LPIT sysfs files return an error output a warning instead of
a fatal error, disable the ACPI LPIT evaluation code, and continue.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2019-03-20 23:11:44 -04:00
Ben Hutchings 8173c33698 tools/power turbostat: Add checks for failure of fgets() and fscanf()
Most calls to fgets() and fscanf() are followed by error checks.
Add an exit-on-error in the remaining cases.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Len Brown <len.brown@intel.com>
2019-03-20 23:02:27 -04:00
Calvin Walton 3316f99a9f tools/power turbostat: Also read package power on AMD F17h (Zen)
The package power can also be read from an MSR. It's not clear exactly
what is included, and whether it's aggregated over all nodes or
reported separately.

It does look like this is reported separately per CCX (I get a single
value on the Ryzen R7 1700), but it might be reported separately per-
die (node?) on larger processors. If that's the case, it would have to
be recorded per node and aggregated for the socket.

Note that although Zen has these MSRs reporting power, it looks like
the actual RAPL configuration (power limits, configured TDP) is done
through PCI configuration space. I have not yet found any public
documentation for this.

Signed-off-by: Calvin Walton <calvin.walton@kepstin.ca>
Signed-off-by: Len Brown <len.brown@intel.com>
2019-03-20 22:55:45 -04:00
Calvin Walton 9392bd98bb tools/power turbostat: Add support for AMD Fam 17h (Zen) RAPL
Based on the Open-Source Register Reference for AMD Family 17h
Processors Models 00h-2Fh:
https://support.amd.com/TechDocs/56255_OSRR.pdf

These processors report RAPL support in bit 14 of CPUID 0x80000007 EDX,
and the following MSRs are present:
0xc0010299 (RAPL_PWR_UNIT), like Intel's RAPL_POWER_UNIT
0xc001029a (CORE_ENERGY_STAT), kind of like Intel's PP0_ENERGY_STATUS
0xc001029b (PKG_ENERGY_STAT), like Intel's PKG_ENERGY_STATUS

A notable difference from the Intel implementation is that AMD reports
the "Cores" energy usage separately for each core, rather than a
per-package total. The code has been adjusted to handle either case in a
generic way.

I haven't yet enabled collection of package power, due to being unable
to test it on multi-node systems (TR, EPYC).

Signed-off-by: Calvin Walton <calvin.walton@kepstin.ca>
Signed-off-by: Len Brown <len.brown@intel.com>
2019-03-20 22:55:45 -04:00
Prarit Bhargava 0a42d235e5 tools/power turbostat: Do not display an error on systems without a cpufreq driver
Running without a cpufreq driver is a valid case so warnings output in
this case should not be to stderr.

Use outf instead of stderr for these warnings.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2019-03-20 22:55:44 -04:00
Len Brown 6de68fe15a tools/power turbostat: Add Die column
If the system has more than one software visible die per package,
print a Die column.

Signed-off-by: Len Brown <len.brown@intel.com>
2019-03-20 22:55:44 -04:00
Len Brown 937807d355 tools/power turbostat: Add Icelake support
From a turbostat point of view, Iceland is like Cannonlake.

Signed-off-by: Len Brown <len.brown@intel.com>
2019-03-20 22:55:44 -04:00
Len Brown 31a1f15cea tools/power turbostat: Cleanup CNL-specific code
no functional change.

Signed-off-by: Len Brown <len.brown@intel.com>
2019-03-20 22:55:44 -04:00
Len Brown 562855eeb1 tools/power turbostat: Cleanup CC3-skip code
no functional change

Signed-off-by: Len Brown <len.brown@intel.com>
2019-03-20 22:55:43 -04:00
Len Brown df2f677dee tools/power turbostat: Restore ability to execute in topology-order
turbostat executes on CPUs in "topology order".
This is an optimization for measuring profoundly idle systems --
as the closest hardware is woken next...

Fix a typo that was added with the sub-die-node support,
that broke topology ordering on multi-node systems.

Signed-off-by: Len Brown <len.brown@intel.com>
2019-03-20 22:55:37 -04:00
David Arcari 2a95496634 tools/power turbostat: return the exit status of a command
turbostat failed to return a non-zero exit status even though the
supplied command (turbostat <command>) failed.  Currently when turbostat
forks a command it returns zero instead of the actual exit status of the
command.  Modify the code to return the exit status.

Signed-off-by: David Arcari <darcari@redhat.com>
Acked-by: Len Brown <len.brown@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-03-19 16:51:16 +01:00
Linus Torvalds 9352ca585b Additional power management updates for 5.1-rc1
- Fix registration of new cpuidle governors partially broken during
    the 5.0 development cycle by mistake (Rafael Wysocki).
 
  - Avoid integer overflows in the menu cpuidle governor by making
    it discard the overflowing data points upfront (Rafael Wysocki).
 
  - Fix minor mistake in the recent update of the iowait boost
    computation in the intel_pstate driver (Rafael Wysocki).
 
  - Drop incorrect __init annotation from one function in the pxa2xx
    cpufreq driver (Arnd Bergmann).
 
  - Fix the operating performance points (OPP) framework
    initialization for devices in multiple power domains if
    only one of them is scalable (Rajendra Nayak).
 
  - Fix mistake in dev_pm_opp_set_rate() which causes it to skip
    updating the performance state if the new frequency is the same
    as the old one (Viresh Kumar).
 
  - Rework the cancellation of wakeup source timers to avoid
    potential issues with it and do some cleanups unlocked by
    that change (Viresh Kumar, Rafael Wysocki).
 
  - Clean up the code computing the active/suspended time of devices
    in the PM-runtime framework after recent changes (Ulf Hansson).
 
  - Make the power management infrastructure code use pr_fmt()
    consistently (Joe Perches).
 
  - Clean up the generic power domains (genpd) framework somewhat
    (Aisheng Dong).
 
  - Improve kerneldoc comments for two functions in the cpufreq core
    (Rafael Wysocki).
 
  - Fix typo in a PM QoS file description comment (Aisheng Dong).
 
  - Update the handling of CPU boost frequencies in the cpupower
    utility (Abhishek Goel).
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJcija/AAoJEILEb/54YlRx7O8P/AlxJK8EKVkLq6/zIh/TcvQm
 G7LclduUtOQ6punqh/NFHPLWnazIO3/Rg1ApqApEn4SheYzrINix76gAd0cYvYHA
 /ZfkscQ0SeMjT6w1fVJ55ubKcJUQXrUxXzBaBdo0Z33FBBLxh9seJXQVF3ZSuahQ
 RhdrSoCtZEI7pHuCY91LanfL1LmHpApSLKcpPvCjvtwj2rm3L8zDFwYsuArbNCX+
 yvzhGJZ/vQFo5gJbf6M9msgtx2AfryHR3fgtM/RZhwI+7qPIuzFanuAydxBxgstT
 wmzpv2y3lvIv/y3q5SDt0LhEzcuUXtNZLpM1AGAlogo9ZgvhtjUpK+Gjkpn9g01r
 Y8qv+8BOL2PSrfZVyLXyyA8oRiDxbYlGQmoRy89zq9ukQorOhJ4kv+wApOq88krA
 AFZPMHTBFCqH9GHeUIOfGZN15/r3GCBGC8D0G8kl8MUI6cFlV85uliAJcuS3/A3s
 Z+xAfC/75ue2vlXhF8iiWnRuya5LRLwdwmMdlAWeguTLqNF3RlwlOroR7RTx9f8j
 sBauXyRO9ovxbfbmBqFIFWU1yBIMd3hU+XU47xjvvDdoKTl/TpgXT+AEofBaMokl
 rFbnK2LsVn3H5wXKD0CaH71qxiF/Q8g7BuoXc4SqWYI8N/pbQe+WEYoRvrb2NYkr
 gpkTZmNUXrDXu/9ypEoR
 =fHRq
 -----END PGP SIGNATURE-----

Merge tag 'pm-5.1-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull more power management updates from Rafael Wysocki:
 "These are mostly fixes and cleanups on top of the previously merged
  power management material for 5.1-rc1 with one cpupower utility update
  that wasn't pushed earlier due to unfortunate timing.

  Specifics:

   - Fix registration of new cpuidle governors partially broken during
     the 5.0 development cycle by mistake (Rafael Wysocki).

   - Avoid integer overflows in the menu cpuidle governor by making it
     discard the overflowing data points upfront (Rafael Wysocki).

   - Fix minor mistake in the recent update of the iowait boost
     computation in the intel_pstate driver (Rafael Wysocki).

   - Drop incorrect __init annotation from one function in the pxa2xx
     cpufreq driver (Arnd Bergmann).

   - Fix the operating performance points (OPP) framework initialization
     for devices in multiple power domains if only one of them is
     scalable (Rajendra Nayak).

   - Fix mistake in dev_pm_opp_set_rate() which causes it to skip
     updating the performance state if the new frequency is the same as
     the old one (Viresh Kumar).

   - Rework the cancellation of wakeup source timers to avoid potential
     issues with it and do some cleanups unlocked by that change (Viresh
     Kumar, Rafael Wysocki).

   - Clean up the code computing the active/suspended time of devices in
     the PM-runtime framework after recent changes (Ulf Hansson).

   - Make the power management infrastructure code use pr_fmt()
     consistently (Joe Perches).

   - Clean up the generic power domains (genpd) framework somewhat
     (Aisheng Dong).

   - Improve kerneldoc comments for two functions in the cpufreq core
     (Rafael Wysocki).

   - Fix typo in a PM QoS file description comment (Aisheng Dong).

   - Update the handling of CPU boost frequencies in the cpupower
     utility (Abhishek Goel)"

* tag 'pm-5.1-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  cpuidle: governor: Add new governors to cpuidle_governors again
  cpufreq: intel_pstate: Fix up iowait_boost computation
  PM / OPP: Update performance state when freq == old_freq
  PM / wakeup: Drop wakeup_source_drop()
  PM / wakeup: Rework wakeup source timer cancellation
  PM / domains: Remove one unnecessary blank line
  PM / Domains: Return early for all errors in _genpd_power_off()
  PM / Domains: Improve warn for multiple states but no governor
  OPP: Fix handling of multiple power domains
  PM / QoS: Fix typo in file description
  cpufreq: pxa2xx: remove incorrect __init annotation
  PM-runtime: Call pm_runtime_active|suspended_time() from sysfs
  PM-runtime: Consolidate code to get active/suspended time
  PM: Add and use pr_fmt()
  cpufreq: Improve kerneldoc comments for cpufreq_cpu_get/put()
  cpuidle: menu: Avoid overflows when computing variance
  tools/power/cpupower: Display boost frequency separately
2019-03-14 10:30:06 -07:00
Thomas Gleixner d8eabc3731 x86/msr-index: Cleanup bit defines
Greg pointed out that speculation related bit defines are using (1 << N)
format instead of BIT(N). Aside of that (1 << N) is wrong as it should use
1UL at least.

Clean it up.

[ Josh Poimboeuf: Fix tools build ]

Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Reviewed-by: Jon Masters <jcm@redhat.com>
Tested-by: Jon Masters <jcm@redhat.com>
2019-03-06 21:52:10 +01:00
Abhishek Goel ae2917093f tools/power/cpupower: Display boost frequency separately
cpufreq driver creates sysfs file "scaling_boost_frequency" for platforms
which support boost frequency. Cpupower now prints boost frequencies
separately. For few x86 vendors who already have different way to get boost
frequency, will continue to use the existing logic. Rest of the platforms
will rely on "scaling_boost_frequency" file to display boost frequency.

Signed-off-by: Abhishek Goel <huntbag@linux.vnet.ibm.com>
Signed-off-by: Shuah Khan <shuah@kernel.org>
2019-02-13 09:26:17 -07:00
Bob Moore 840c02ca22 ACPICA: All acpica: Update copyrights to 2019
ACPICA commit 62f4f98e941d86e41969bf2ab5a93b8dc94dc49e

The update includes userspace tool signons.

Link: https://github.com/acpica/acpica/commit/62f4f98e
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-01-15 18:04:02 +01:00
Ingo Molnar 2573be22e5 perf/core improvements and fixes:
perf c2c:
 
   Jiri Olsa:
 
   - Change the default coalesce setup to from '--coalesce pid,iaddr' to just '--coalesce iaddr'.
 
   - Increase the HITM ratio limit for displayed cachelines.
 
 perf script:
 
   Andi Kleen:
 
   - Fix LBR skid dump problems in brstackinsn.
 
 perf trace:
 
   Arnaldo Carvalho de Melo:
 
   - Check if the raw_syscalls:sys_{enter,exit} are setup before setting tp filter.
 
   - Do not hardcode the size of the tracepoint common_ fields.
 
   - Beautify USBDEFFS_ ioctl commands.
 
   Colin Ian King:
 
   - Use correct SECCOMP prefix spelling, "SECOMP_*" -> "SECCOMP_*".
 
 perf python:
 
   Jiri Olsa:
 
   - Do not force closing original perf descriptor in evlist.get_pollfd().
 
 tools misc:
 
   Jiri Olsa:
 
   - Allow overriding CFLAGS and LDFLAGS.
 
 perf build:
 
   Stanislav Fomichev:
 
   - Don't unconditionally link the libbfd feature test to -liberty and -lz
 
 thread-stack:
 
   Adrian Hunter:
 
   - Fix processing for the idle task, having a stack per cpu.
 
 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQR2GiIUctdOfX2qHhGyPKLppCJ+JwUCXC4BOgAKCRCyPKLppCJ+
 Jy1BAP0Vr6fC+mv/ul0x3WC4dlF0UG9p9+GxBoKsXPpG5vojCgEAqX7F+Pmx+6HK
 FIBjbOWIL5NYRViskwPlQy5+qkKmJgA=
 =I4gE
 -----END PGP SIGNATURE-----

Merge tag 'perf-core-for-mingo-4.21-20190103' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:

perf c2c:

  Jiri Olsa:

  - Change the default coalesce setup to from '--coalesce pid,iaddr' to just '--coalesce iaddr'.

  - Increase the HITM ratio limit for displayed cachelines.

perf script:

  Andi Kleen:

  - Fix LBR skid dump problems in brstackinsn.

perf trace:

  Arnaldo Carvalho de Melo:

  - Check if the raw_syscalls:sys_{enter,exit} are setup before setting tp filter.

  - Do not hardcode the size of the tracepoint common_ fields.

  - Beautify USBDEFFS_ ioctl commands.

  Colin Ian King:

  - Use correct SECCOMP prefix spelling, "SECOMP_*" -> "SECCOMP_*".

perf python:

  Jiri Olsa:

  - Do not force closing original perf descriptor in evlist.get_pollfd().

tools misc:

  Jiri Olsa:

  - Allow overriding CFLAGS and LDFLAGS.

perf build:

  Stanislav Fomichev:

  - Don't unconditionally link the libbfd feature test to -liberty and -lz

thread-stack:

  Adrian Hunter:

  - Fix processing for the idle task, having a stack per cpu.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2019-01-03 14:05:16 +01:00
Jiri Olsa 6b7f98a37a tools power turbostat: Override CFLAGS assignments and add LDFLAGS to build command
So that the user can specify outside CFLAGS/LDFLAGS values.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Herton Krzesinski <herton@redhat.com>
Cc: Len Brown <len.brown@intel.com>
Link: http://lkml.kernel.org/r/20181212102537.25902-5-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-12-28 16:33:08 -03:00
Jiri Olsa f1770e3ca4 tools power x86_energy_perf_policy: Override CFLAGS assignments and add LDFLAGS to build command
So user could specify outside CFLAGS/LDFLAGS values.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Herton Krzesinski <herton@redhat.com>
Cc: Len Brown <len.brown@intel.com>
Link: https://lkml.kernel.org/r/20181212102537.25902-2-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-12-28 16:33:07 -03:00
Linus Torvalds e6d1315006 ACPI updates for 4.21-rc1
- Update the ACPICA code in the kernel to the 20181213 upstream
    revision including:
    * New Windows _OSI strings (Bob Moore, Jung-uk Kim).
    * Buffers-to-string conversions update (Bob Moore).
    * Removal of support for expressions in package elements (Bob
      Moore).
    * New option to display method/object evaluation in debug output
      (Bob Moore).
    * Compiler improvements (Bob Moore, Erik Schmauss).
    * Minor debugger fix (Erik Schmauss).
    * Disassembler improvement (Erik Schmauss).
    * Assorted cleanups (Bob Moore, Colin Ian King, Erik Schmauss).
 
  - Add support for a new OEM _OSI string to indicate special handling
    of secondary graphics adapters on some systems (Alex Hung).
 
  - Make it possible to build the ACPI subystem without PCI support
    (Sinan Kaya).
 
  - Make the SPCR table handling regard baud rate 0 in accordance with
    the specification of it and make the DSDT override code support
    DSDT code names generated by recent ACPICA (Andy Shevchenko, Wang
    Dongsheng, Nathan Chancellor).
 
  - Add clock frequency for Hisilicon Hip08 SPI controller to the ACPI
    driver for AMD SoCs (APD) (Jay Fang).
 
  - Fix the PM handling during device init in the ACPI driver for
    Intel SoCs (LPSS) (Hans de Goede).
 
  - Avoid double panic()s by clearing the APEI GHES block_status
    before panic() (Lenny Szubowicz).
 
  - Clean up a function invocation in the ACPI core and get rid of
    some code duplication by using the DEFINE_SHOW_ATTRIBUTE macro
    in the APEI support code (Alexey Dobriyan, Yangtao Li).
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJcHMSBAAoJEILEb/54YlRxZmEQAIbRXKOwvvt3my9HLBC/6V1u
 +Wed0yNBQ9HkVWQzFuppDq97/kk5DRODnPNu9RaeS7QXxVOBfwElinm8NhzVI7Fm
 FP5iPwnNq8EAkDTBOoG139Fs82EkaVSa2x9FHy84Jge3BXmauQM13bWP/kF5TjCn
 Frjuh0TfhQ+ub853GisAr/SW7ixCWp81FZaW/xFcDuJU2E6AvjNQusdiAocgAqQ8
 rnl8D0gjSW6m6HcauaTizRMXOIyePkfT86xQKwU7259ByRW20iQtsl/6+Rnyy3wG
 cCrlsaHd0bP6qwVAQyh6cURq8hdLAUYI9tzBW0EL+UEpJ289j51s+RSh2nZNyIKO
 wfbr2DdK3aaWcUygSxoP4FFHqINch/IRwaP2huT9szO1yLCikAN8Xmrb1BPZvOIK
 m6Lywb1B+SOfGgJl4Z1GjzIc6dimrXVbgxjN1+Bpe1NeKqe/M6vMdbcvPIsMs7b8
 iE/1gJPeJ5pvAgsQiWncZvyaOKaSmrLWbaw/ITQnNXVLDlTI3hIQExiPPl5hJ00v
 Z4egVMdCCxYqZxxkZKEYnEe/lb9BRAMIvbkkocPBdmtNAWPuVnCqdR26BppaEt7i
 r2tnEd84aISCDcBc2sIpo/pVUwncw5GtK20z8Ke+3rlg8lDZ0hAdHQWgBtj4xnnw
 grImzXnKvSdajfZnvjRg
 =yxXc
 -----END PGP SIGNATURE-----

Merge tag 'acpi-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI updates from Rafael Wysocki:
 "These update the ACPICA code in the kernel to the 20181213 upstream
  revision, make it possible to build the ACPI subsystem without PCI
  support, and a new OEM _OSI string, add a new device support to the
  ACPI driver for AMD SoCs and fix PM handling in the ACPI driver for
  Intel SoCs, fix the SPCR table handling and do some assorted fixes and
  cleanups.

  Specifics:

   - Update the ACPICA code in the kernel to the 20181213 upstream
     revision including:
      * New Windows _OSI strings (Bob Moore, Jung-uk Kim).
      * Buffers-to-string conversions update (Bob Moore).
      * Removal of support for expressions in package elements (Bob
        Moore).
      * New option to display method/object evaluation in debug output
        (Bob Moore).
      * Compiler improvements (Bob Moore, Erik Schmauss).
      * Minor debugger fix (Erik Schmauss).
      * Disassembler improvement (Erik Schmauss).
      * Assorted cleanups (Bob Moore, Colin Ian King, Erik Schmauss).

   - Add support for a new OEM _OSI string to indicate special handling
     of secondary graphics adapters on some systems (Alex Hung).

   - Make it possible to build the ACPI subystem without PCI support
     (Sinan Kaya).

   - Make the SPCR table handling regard baud rate 0 in accordance with
     the specification of it and make the DSDT override code support
     DSDT code names generated by recent ACPICA (Andy Shevchenko, Wang
     Dongsheng, Nathan Chancellor).

   - Add clock frequency for Hisilicon Hip08 SPI controller to the ACPI
     driver for AMD SoCs (APD) (Jay Fang).

   - Fix the PM handling during device init in the ACPI driver for Intel
     SoCs (LPSS) (Hans de Goede).

   - Avoid double panic()s by clearing the APEI GHES block_status before
     panic() (Lenny Szubowicz).

   - Clean up a function invocation in the ACPI core and get rid of some
     code duplication by using the DEFINE_SHOW_ATTRIBUTE macro in the
     APEI support code (Alexey Dobriyan, Yangtao Li)"

* tag 'acpi-4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (31 commits)
  ACPI / tables: Add an ifdef around amlcode and dsdt_amlcode
  ACPI/APEI: Clear GHES block_status before panic()
  ACPI: Make PCI slot detection driver depend on PCI
  ACPI/IORT: Stub out ACS functions when CONFIG_PCI is not set
  arm64: select ACPI PCI code only when both features are enabled
  PCI/ACPI: Allow ACPI to be built without CONFIG_PCI set
  ACPICA: Remove PCI bits from ACPICA when CONFIG_PCI is unset
  ACPI: Allow CONFIG_PCI to be unset for reboot
  ACPI: Move PCI reset to a separate function
  ACPI / OSI: Add OEM _OSI string to enable dGPU direct output
  ACPI / tables: add DSDT AmlCode new declaration name support
  ACPICA: Update version to 20181213
  ACPICA: change coding style to match ACPICA, no functional change
  ACPICA: Debug output: Add option to display method/object evaluation
  ACPICA: disassembler: disassemble OEMx tables as AML
  ACPICA: Add "Windows 2018.2" string in the _OSI support
  ACPICA: Expressions in package elements are not supported
  ACPICA: Update buffer-to-string conversions
  ACPICA: add comments, no functional change
  ACPICA: Remove defines that use deprecated flag
  ...
2018-12-25 14:21:18 -08:00
Rafael J. Wysocki 1027fb0fb9 Merge branch 'acpica'
* acpica:
  ACPICA: Update version to 20181213
  ACPICA: change coding style to match ACPICA, no functional change
  ACPICA: Debug output: Add option to display method/object evaluation
  ACPICA: disassembler: disassemble OEMx tables as AML
  ACPICA: Add "Windows 2018.2" string in the _OSI support
  ACPICA: Expressions in package elements are not supported
  ACPICA: Update buffer-to-string conversions
  ACPICA: add comments, no functional change
  ACPICA: Remove defines that use deprecated flag
  ACPICA: Add "Windows 2018" string in the _OSI support
  ACPICA: Update version to 20181031
  ACPICA: iASL: Enhance error detection
  ACPICA: iASL: adding definition and disassembly for TPM2 revision 3
  ACPICA: Use %d for signed int print formatting instead of %u
  ACPICA: Debugger: refactor to fix unused variable warning
2018-12-21 10:03:16 +01:00
Rafael J. Wysocki 584923efe9 Merge branch 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
Pull turbostat utility updates for v4.21 from Len Brown:

"A couple of random fixes that were sitting in the queue."

* 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
  tools/power turbostat: consolidate duplicate model numbers
  tools/power turbostat: fix goldmont C-state limit decoding
  tools/power turbostat: reduce debug output
  tools/power turbosat: fix AMD APIC-id output
2018-12-18 16:32:12 +01:00
Doug Smythies 663546903c tools/power/x86/intel_pstate_tracer: Fix non root execution for post processing a trace file
This script is supposed to be allowed to run with regular user
privileges if a previously captured trace is being post processed.

Commit fbe313884d (tools/power/x86/intel_pstate_tracer: Free the
trace buffer memory) introduced a bug that breaks that option.

Commit 35459105de (tools/power/x86/intel_pstate_tracer: Add
optional setting of trace buffer memory allocation) moved the code
but kept the bug.

This patch fixes the issue.

Fixes: 35459105de (tools/power/x86/intel_pstate_tracer: Add optional ...)
Signed-off-by: Doug Smythies <dsmythies@telus.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-12-18 10:44:17 +01:00
Len Brown f5a4c76ad7 tools/power turbostat: consolidate duplicate model numbers
Often a new processor gets a new model number, but from a turbostat
point of view, it is the same as a previous model.  Support duplicates
with 1-line updates, rather than error-prone scattering of model #'s.

Signed-off-by: Len Brown <len.brown@intel.com>
2018-12-14 20:08:55 -05:00
Len Brown 445640a563 tools/power turbostat: fix goldmont C-state limit decoding
When the C-state limit is 8 on Goldmont, PC10 is enabled.
Previously turbostat saw this as "undefined", and thus assumed
it should not show some counters, such as pc3, pc6, pc7.

Signed-off-by: Len Brown <len.brown@intel.com>
2018-12-14 20:08:55 -05:00
Abhishek Goel 901d32bc69 cpupower : Auto-completion for cpupower tool
This script adds support for auto-completion for cpupower tool.
Added support for auto-completion of all the eight commands for
cpupower tool and their all subsequent sub-commands, wherever
possible.

A sample output after applying this script -

root@ubuntu:~# cpupower f<TAB>
root@ubuntu:~# cpupower frequency-<TAB>
frequency-info  frequency-set
root@ubuntu:~# cpupower frequency-set -
-d          --freq      --governor  --min       --related
-f          -g          --max       -r          -u
root@ubuntu:~# cpupower frequency-set -g <TAB>
conservative ondemand performance powersave schedutil userspace
root@ubuntu:~# cpupower frequency-set -f <TAB>
2061000  2194000  2327000  2460000  2593000  2726000  2859000
2094000  2227000  2360000  2493000  2626000  2759000  2892000
2128000  2261000  2394000  2527000  2660000  2793000  2926000
2161000  2294000  2427000  2560000  2693000  2826000  2959000
root@ubuntu:~# cpupower frequency-set -f 206<TAB>
root@ubuntu:~# cpupower frequency-set -f 2061000

Signed-off-by: Abhishek Goel <huntbag@linux.vnet.ibm.com>
Signed-off-by: Bharath Thodla <bharath.thodla@in.ibm.com>
Tested-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Shuah Khan <shuah@kernel.org>
2018-12-05 07:52:45 -07:00
Colin Ian King f8ddf49b42 ACPICA: Use %d for signed int print formatting instead of %u
Fix warnings found using static analysis with cppcheck, use %d printf
format specifier for signed ints rather than %u

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-11-08 18:41:47 +01:00
Jiri Olsa dbc4ca339c tools cpupower: Override CFLAGS assignments
So user could specify outside CFLAGS values.

Cc: Thomas Renninger <trenn@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-11-06 08:54:16 -07:00
Jiri Olsa 4bf3bd0f15 tools cpupower debug: Allow to use outside build flags
Adding CFLAGS and LDFLAGS to be used during the build.

Cc: Thomas Renninger <trenn@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-11-06 08:54:16 -07:00
Konstantin Khlebnikov 9de9aa45e9 tools/power/cpupower: fix compilation with STATIC=true
Rename duplicate sysfs_read_file into cpupower_read_sysfs and fix linking.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Acked-by: Thomas Renninger <trenn@suse.de>
Cc: <stable@vger.kernel.org>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-11-06 08:54:16 -07:00
Len Brown 0ec712e36c tools/power turbostat: reduce debug output
A recent turbostat release increased topo.max_cpu_num
to make it convenient to handle sysfs bitmaps of 32-cpus.

But users, who regularly make use of "--debug", then saw a bunch of output
for cpus that were not present.

Remove that extra output by checking a cpu is online before dumping its info.

Signed-off-by: Len Brown <len.brown@intel.com>
Cc: Prarit Bhargava <prarit@redhat.com>
2018-11-02 14:06:31 -04:00
Len Brown 3404155190 tools/power turbosat: fix AMD APIC-id output
turbostat recently gained a feature adding APIC and X2APIC columns.
While they are disabled by-default, they are enabled with --debug
or when explicitly requested, eg.

$ sudo turbostat --quiet --show Package,Node,Core,CPU,APIC,X2APIC date

But these columns erroneously showed zeros on AMD hardware.
This patch corrects the APIC and X2APIC [sic] columns on AMD.

Signed-off-by: Len Brown <len.brown@intel.com>
2018-11-02 14:06:30 -04:00
Linus Torvalds fec98069fb Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 cpu updates from Ingo Molnar:
 "The main changes in this cycle were:

   - Add support for the "Dhyana" x86 CPUs by Hygon: these are licensed
     based on the AMD Zen architecture, and are built and sold in China,
     for domestic datacenter use. The code is pretty close to AMD
     support, mostly with a few quirks and enumeration differences. (Pu
     Wen)

   - Enable CPUID support on Cyrix 6x86/6x86L processors"

* 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  tools/cpupower: Add Hygon Dhyana support
  cpufreq: Add Hygon Dhyana support
  ACPI: Add Hygon Dhyana support
  x86/xen: Add Hygon Dhyana support to Xen
  x86/kvm: Add Hygon Dhyana support to KVM
  x86/mce: Add Hygon Dhyana support to the MCA infrastructure
  x86/bugs: Add Hygon Dhyana to the respective mitigation machinery
  x86/apic: Add Hygon Dhyana support
  x86/pci, x86/amd_nb: Add Hygon Dhyana support to PCI and northbridge
  x86/amd_nb: Check vendor in AMD-only functions
  x86/alternative: Init ideal_nops for Hygon Dhyana
  x86/events: Add Hygon Dhyana support to PMU infrastructure
  x86/smpboot: Do not use BSP INIT delay and MWAIT to idle on Dhyana
  x86/cpu/mtrr: Support TOP_MEM2 and get MTRR number
  x86/cpu: Get cache info and setup cache cpumap for Hygon Dhyana
  x86/cpu: Create Hygon Dhyana architecture support file
  x86/CPU: Change query logic so CPUID is enabled before testing
  x86/CPU: Use correct macros for Cyrix calls
2018-10-23 16:16:40 +01:00
Linus Torvalds c05f3642f4 Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Ingo Molnar:
 "The main updates in this cycle were:

   - Lots of perf tooling changes too voluminous to list (big perf trace
     and perf stat improvements, lots of libtraceevent reorganization,
     etc.), so I'll list the authors and refer to the changelog for
     details:

       Benjamin Peterson, Jérémie Galarneau, Kim Phillips, Peter
       Zijlstra, Ravi Bangoria, Sangwon Hong, Sean V Kelley, Steven
       Rostedt, Thomas Gleixner, Ding Xiang, Eduardo Habkost, Thomas
       Richter, Andi Kleen, Sanskriti Sharma, Adrian Hunter, Tzvetomir
       Stoyanov, Arnaldo Carvalho de Melo, Jiri Olsa.

     ... with the bulk of the changes written by Jiri Olsa, Tzvetomir
     Stoyanov and Arnaldo Carvalho de Melo.

   - Continued intel_rdt work with a focus on playing well with perf
     events. This also imported some non-perf RDT work due to
     dependencies. (Reinette Chatre)

   - Implement counter freezing for Arch Perfmon v4 (Skylake and newer).
     This allows to speed up the PMI handler by avoiding unnecessary MSR
     writes and make it more accurate. (Andi Kleen)

   - kprobes cleanups and simplification (Masami Hiramatsu)

   - Intel Goldmont PMU updates (Kan Liang)

   - ... plus misc other fixes and updates"

* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (155 commits)
  kprobes/x86: Use preempt_enable() in optimized_callback()
  x86/intel_rdt: Prevent pseudo-locking from using stale pointers
  kprobes, x86/ptrace.h: Make regs_get_kernel_stack_nth() not fault on bad stack
  perf/x86/intel: Export mem events only if there's PEBS support
  x86/cpu: Drop pointless static qualifier in punit_dev_state_show()
  x86/intel_rdt: Fix initial allocation to consider CDP
  x86/intel_rdt: CBM overlap should also check for overlap with CDP peer
  x86/intel_rdt: Introduce utility to obtain CDP peer
  tools lib traceevent, perf tools: Move struct tep_handler definition in a local header file
  tools lib traceevent: Separate out tep_strerror() for strerror_r() issues
  perf python: More portable way to make CFLAGS work with clang
  perf python: Make clang_has_option() work on Python 3
  perf tools: Free temporary 'sys' string in read_event_files()
  perf tools: Avoid double free in read_event_file()
  perf tools: Free 'printk' string in parse_ftrace_printk()
  perf tools: Cleanup trace-event-info 'tdata' leak
  perf strbuf: Match va_{add,copy} with va_end
  perf test: S390 does not support watchpoints in test 22
  perf auxtrace: Include missing asm/bitsperlong.h to get BITS_PER_LONG
  tools include: Adopt linux/bits.h
  ...
2018-10-23 13:32:18 +01:00
Rafael J. Wysocki 9a69e3ac41 linux-cpupower-4.20-rc1
This cpupower update for Linux 4.20-rc1 consists of fixes for bugs and
 compile warnings from Prarit Bhargava and Anders Roxell.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEPZKym/RZuOCGeA/kCwJExA0NQxwFAlvE5l8ACgkQCwJExA0N
 QxwFrQ//QJO6IKz63LpHE0NZ1o57SrORtEC3ZNl3gZl/T4avvlnyzR3bQBNmsGVT
 m/XPkXN6QGOKYyAC6WHSNgWKeziFYL13Z/vy98l5+hCT5ZCENYJiN4zgTufkFM0U
 hexYLGwFG40fOSMbyyyeAb/awRuO0oh4IFgUVthbnG9nPrhC7Ym/pkIscQ2Zg8jx
 HhcQaW5znVDy6AP1Tz7QPWdLFBKnM103TpFodl/5tLm4zChqUt1ZXH9+7b3NlgCh
 LURrN96BGonm+b45yrWm2EJ/Wc3FpIzUJ2x+XHQhrTYUmn5H6K4CG4vY7yknDxFG
 syrOdi3+oclkXVtcG9MRNw1UV7YcIpGch//rLGXYrySI60lpBBKw2qy7oQxbqovX
 OL8IqAAl7WC9rVL2CtZe/o0xUftr66FTtxOOZoe8Ur2zoqTBB9k++qbTeGUUFxH7
 vp/LVOqiMtnaY95YsiaNbQtQaZ8E3AqT3tzVQ6XZzs3pEK7F1AdKEg09YhFYb6xg
 B0L0BCkis+2B/4zzp/V3g0bmcBErDa4F4gKTmtC9wPwz8SfsFpXR+7Kvz8tIiiUS
 Al85gDdfdVvf+/VkF5A0/TCSAL/x1Exn0UYLt7ZDa0QBO+qoG712rtfJ9pseRLXZ
 /3jybXr6CdW0IbV3AOaMsmpmlUnzjze8+LDeunoe/7PLB8VX3+I=
 =S5Ie
 -----END PGP SIGNATURE-----

Merge tag 'linux-cpupower-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux into pm-tools

Pull cpupower utility changes for 4.20 from Shuah Khan:

"This cpupower update consists of fixes for bugs and compile warnings
 from Prarit Bhargava and Anders Roxell."

* tag 'linux-cpupower-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux:
  cpupower: Fix coredump on VMWare
  cpupower: Fix AMD Family 0x17 msr_pstate size
  cpupower: remove stringop-truncation waring
2018-10-16 10:10:35 +02:00
Todd Brandt 18d3f8fc0c PM / tools: sleepgraph and bootgraph: upgrade to v5.2
bootgraph & sleepgraph:
- funnel all prints through the pprint function
- remove superfluous print calls, arrange them in single blocks
- flush stdout on every print, enables log capture on hang

sleepgraph:
- in -summary, if all tests have the same host+kernel+mode, add to title
- update verbose device detail print to include machine suspend/resume
- match tKernSus and tKernRes to pm_prepare/restore_console
- fully support multiple suspend/resumes in a single timeline
- enable various disk modes (disk-suspend, disk-test_resume, etc)
- add warnings when -display (xset) fails

Signed-off-by: Todd Brandt <todd.e.brandt@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-10-09 09:27:34 +02:00
Todd Brandt 5484f03344 PM / tools: sleepgraph: first batch of v5.2 changes
general:
- add battery charge data before and after test
- remove special s0i3 handling
- remove melding of dmesg & ftrace data in old kernels, use one only
- updates to various kprobes in trace (ksys_sync, etc)
- enable pm_debug_messages during the test
- instrument more subsystems with dev functions (phy0)

error handling:
- return codes for tool show the status of the test run
- 0: success, 1: general error (no timeline), 2: fail (suspend aborted)
- monitor output of /sys/power/state, mark as failure if exception occurs
- add signal handler when using -result to catch tool exceptions

display control
- add -x commands for testing xset with mode settings and status
- allow display setting to on, off, suspend, standby
- add display mode change info to the log, along with a warning on fail

s2idle (freeze)
- remove fixed 10-phase dependency, allow any phase order & any count
- multiple phase occurences show as phase_nameN e.g. suspend_noirq3
- if multiple freezes occur, print multiple time values in header

summary:
- add new columns to summary output: issues, worst suspend/resume devices
- worst device: includes summation of all phases of suspend or resume
- issues: includes WARNING/ERROR/BUG from dmesg log, and other issues
- s2idle: multiple freezes show as FREEZExN in the issues column

Signed-off-by: Todd Brandt <todd.e.brandt@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-10-09 09:27:33 +02:00
Prarit Bhargava f69ffc5d3d cpupower: Fix coredump on VMWare
cpupower crashes on VMWare guests.  The guests have the AMD PStateDef MSR
(0xC0010064 + state number) set to zero.  As a result fid and did are zero
and the crash occurs because of a divide by zero (cof = fid/did).  This
can be prevented by checking the enable bit in the PStateDef MSR before
calculating cof.  By doing this the value of pstate[i] remains zero and
the value can be tested before displaying the active Pstates.

Check the enable bit in the PstateDef register for all supported families
and only print out enabled Pstates.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Stafford Horne <shorne@gmail.com>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-10-08 09:19:15 -06:00
Prarit Bhargava 8c22e2f695 cpupower: Fix AMD Family 0x17 msr_pstate size
The msr_pstate data is only 63 bits long and should be 64 bits.

Add in the missing bit from res1 for AMD Family 0x17.

Reference: https://www.amd.com/system/files/TechDocs/54945_PPR_Family_17h_Models_00h-0Fh.pdf, page 138.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Stafford Horne <shorne@gmail.com>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-10-08 09:19:05 -06:00
Pu Wen 995d5f64b6 tools/cpupower: Add Hygon Dhyana support
The tool cpupower is useful to get CPU frequency information and monitor
power stats on the Hygon Dhyana platform. So add Hygon Dhyana support to
it by checking vendor and family to share the code path of AMD family
17h.

Signed-off-by: Pu Wen <puwen@hygon.cn>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
CC: Prarit Bhargava <prarit@redhat.com>
CC: Shuah Khan <shuah@kernel.org>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Thomas Renninger <trenn@suse.com>
CC: linux-pm@vger.kernel.org
Link: http://lkml.kernel.org/r/5ce86123a7b9dad925ac583d88d2f921040e859b.1538583282.git.puwen@hygon.cn
2018-10-04 09:57:25 +02:00
Peter Zijlstra f2c4db1bd8 x86/cpu: Sanitize FAM6_ATOM naming
Going primarily by:

  https://en.wikipedia.org/wiki/List_of_Intel_Atom_microprocessors

with additional information gleaned from other related pages; notably:

 - Bonnell shrink was called Saltwell
 - Moorefield is the Merriefield refresh which makes it Airmont

The general naming scheme is: FAM6_ATOM_UARCH_SOCTYPE

  for i in `git grep -l FAM6_ATOM` ; do
	sed -i  -e 's/ATOM_PINEVIEW/ATOM_BONNELL/g'		\
		-e 's/ATOM_LINCROFT/ATOM_BONNELL_MID/'		\
		-e 's/ATOM_PENWELL/ATOM_SALTWELL_MID/g'		\
		-e 's/ATOM_CLOVERVIEW/ATOM_SALTWELL_TABLET/g'	\
		-e 's/ATOM_CEDARVIEW/ATOM_SALTWELL/g'		\
		-e 's/ATOM_SILVERMONT1/ATOM_SILVERMONT/g'	\
		-e 's/ATOM_SILVERMONT2/ATOM_SILVERMONT_X/g'	\
		-e 's/ATOM_MERRIFIELD/ATOM_SILVERMONT_MID/g'	\
		-e 's/ATOM_MOOREFIELD/ATOM_AIRMONT_MID/g'	\
		-e 's/ATOM_DENVERTON/ATOM_GOLDMONT_X/g'		\
		-e 's/ATOM_GEMINI_LAKE/ATOM_GOLDMONT_PLUS/g' ${i}
  done

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: dave.hansen@linux.intel.com
Cc: len.brown@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2018-10-02 10:14:32 +02:00
Anders Roxell 8a7e2d2ea0 cpupower: remove stringop-truncation waring
The strncpy doesn't null terminate the string because the size is too
short by one byte.

parse.c: In function ‘prepare_default_config’:
parse.c:148:2: warning: ‘strncpy’ output truncated before terminating
    nul copying 8 bytes from a string of the same length
    [-Wstringop-truncation]
  strncpy(config->governor, "ondemand", 8);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The normal method of passing the length of the destination buffer works
correctly here.

Fixes: 7fe2f6399a ("cpupowerutils - cpufrequtils extended with quite some features")
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-08-28 15:46:12 -06:00
Arnd Bergmann 3723c63247 treewide: convert ISO_8859-1 text comments to utf-8
Almost all files in the kernel are either plain text or UTF-8 encoded.  A
couple however are ISO_8859-1, usually just a few characters in a C
comments, for historic reasons.

This converts them all to UTF-8 for consistency.

Link: http://lkml.kernel.org/r/20180724111600.4158975-1-arnd@arndb.de
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Simon Horman <horms@verge.net.au>			[IPVS portion]
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>	[IIO]
Acked-by: Michael Ellerman <mpe@ellerman.id.au>			[powerpc]
Acked-by: Rob Herring <robh@kernel.org>
Cc: Joe Perches <joe@perches.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-23 18:48:43 -07:00
Rafael J. Wysocki b0cd6035d3 Merge branch 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
Pull turbostat utility fixes for 4.18 from Len Brown:

"Three of them are for regressions since Linux-4.17"

* 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
  tools/power turbostat: version 18.07.27
  tools/power turbostat: Read extended processor family from CPUID
  tools/power turbostat: Fix logical node enumeration to allow for non-sequential physical nodes
  tools/power turbostat: fix x2apic debug message output file
  tools/power turbostat: fix bogus summary values
  tools/power turbostat: fix -S on UP systems
  tools/power turbostat: Update turbostat(8) RAPL throttling column description
2018-07-29 12:37:55 +02:00
Len Brown 538c48f27a tools/power turbostat: version 18.07.27
Signed-off-by: Len Brown <len.brown@intel.com>
2018-07-27 12:55:08 -04:00
Calvin Walton 5aa3d1a20a tools/power turbostat: Read extended processor family from CPUID
This fixes the reported family on modern AMD processors (e.g. Ryzen,
which is family 0x17). Previously these processors all showed up as
family 0xf.

See the document
https://support.amd.com/TechDocs/56255_OSRR.pdf
section CPUID_Fn00000001_EAX for how to calculate the family
from the BaseFamily and ExtFamily values.

This matches the code in arch/x86/lib/cpu.c

Signed-off-by: Calvin Walton <calvin.walton@kepstin.ca>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-07-27 12:54:19 -04:00
Prarit Bhargava 2ffbb22406 tools/power turbostat: Fix logical node enumeration to allow for non-sequential physical nodes
turbostat fails on some multi-package topologies because the logical node
enumeration assumes that the nodes are sequentially numbered,
which causes the logical numa nodes to not be enumerated, or enumerated incorrectly.

Use a more robust enumeration algorithm which allows for non-seqential physical nodes.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-07-26 14:20:59 -04:00
Len Brown cfce494db3 tools/power turbostat: fix x2apic debug message output file
A recently added x2apic debug message was hard-coded to stderr.
That doesn't work with "-o outfile".

Signed-off-by: Len Brown <len.brown@intel.com>
2018-07-26 14:20:59 -04:00
Artem Bityutskiy 4f206a0fab tools/power turbostat: fix bogus summary values
This patch fixes a regression introduced in

commit 8cb48b32a5 ("tools/power turbostat: track thread ID in cpu_topology")

Turbostat uses incorrect cores number ('topo.num_cores') - its value is count
of logical CPUs, instead of count of physical cores. So it is twice as large as
it should be on a typical Intel system. For example, on a 6 core Xeon system
'topo.num_cores' is 12, and on a 52 core Xeon system 'topo.num_cores' is 104.

And interestingly, on a 68-core Knights Landing Intel system 'topo.num_cores'
is 272, because this system has 4 logical CPUs per core.

As a result, some of the turbostat calculations are incorrect. For example,
on idle 52-core Xeon system when all cores are ~99% in Core C6 (CPU%c6), the
summary (very first) line shows ~48% Core C6, while it should be ~99%.

This patch fixes the problem by fixing 'topo.num_cores' calculation.

Was:

1. Init 'thread_id' for all CPUs to -1
2. Run 'get_thread_siblings()' which sets it to 0 or 1
3. Increment 'topo.num_cores' when thread_id != -1 (bug!)

Now:

1. Init 'thread_id' for all CPUs to -1
2. Run 'get_thread_siblings()' which sets it to 0 or 1
3. Increment 'topo.num_cores' when thread_id is not 0

I did not have a chance to test this on an AMD machine, and only tested on a
couple of Intel Xeons (6 and 52 cores).

Reported-by: Vladislav Govtva <vladislav.govtva@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-07-26 14:20:39 -04:00
Len Brown 9d83601a9c tools/power turbostat: fix -S on UP systems
The -S (system summary) option failed to print any data on a 1-processor system.

Reported-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-07-20 14:47:03 -04:00
Len Brown 32e7024eab tools/power turbostat: Update turbostat(8) RAPL throttling column description
Explain that this column may increment for some throttling causes,
and may not increment for others.

Signed-off-by: Len Brown <len.brown@intel.com>
2018-07-17 20:06:47 -04:00
Rafael J. Wysocki 3af20c9568 Merge branch 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
Pull turbostat utility changes for 4.18-rc2 from Len Brown.

"This includes two regression fixes, plus a couple more random, but
 worthy, patches."

* 'turbostat' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
  tools/power turbostat: version 18.06.20
  tools/power turbostat: add the missing command line switches
  tools/power turbostat: add single character tokens to help
  tools/power turbostat: alphabetize the help output
  tools/power turbostat: fix segfault on 'no node' machines
  tools/power turbostat: add optional APIC X2APIC columns
  tools/power turbostat: decode cpuid.1.HT
  tools/power turbostat: fix show/hide issues resulting from mis-merge
2018-06-21 00:37:04 +02:00
Len Brown 73780cd816 tools/power turbostat: version 18.06.20
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-20 13:55:29 -04:00
Nathan Ciobanu 9ce80578d5 tools/power turbostat: add the missing command line switches
Document the missing command line tokens in the help() function.

Signed-off-by: Nathan Ciobanu <nathan.d.ciobanu@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-20 13:55:05 -04:00
Nathan Ciobanu cc4816503f tools/power turbostat: add single character tokens to help
Improve the help() output by adding the single character
tokens (e.g -a).

Signed-off-by: Nathan Ciobanu <nathan.d.ciobanu@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-20 13:55:04 -04:00
Nathan Ciobanu 2ee19bdea1 tools/power turbostat: alphabetize the help output
Sort the command line arguments output of help() in
alphabetical order in line with other linux tools.

Signed-off-by: Nathan Ciobanu <nathan.d.ciobanu@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-20 13:55:04 -04:00
Nathan Ciobanu 42dd452092 tools/power turbostat: fix segfault on 'no node' machines
Running turbostat on machines that don't expose nodes
in sysfs (no /sys/bus/node) causes a segfault or a -nan
value diesplayed in the log. This is caused by
physical_node_id being reported as -1 and logical_node_id
being calculated as a negative number resulting in the new
GET_THREAD/GET_CORE returning an incorrect address.

Signed-off-by: Nathan Ciobanu <nathan.d.ciobanu@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-20 13:55:04 -04:00
Len Brown 4c2122d421 tools/power turbostat: add optional APIC X2APIC columns
Add APIC and X2APIC columns to the topology section.

They are disabled-by-default -- enable like so:
--debug
or
--enable APIC,X2APIC

Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-20 13:55:04 -04:00
Len Brown d9d226ffad tools/power turbostat: decode cpuid.1.HT
eg. the "HT" here:
CPUID(1): SSE3 MONITOR - EIST TM2 TSC MSR ACPI-TM HT TM

Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-20 13:55:03 -04:00
Len Brown bdd5ae3aa5 tools/power turbostat: fix show/hide issues resulting from mis-merge
The --show and --hide options failed on "Node", which was listed as "Node%".
The --show and --hide options were generally fouled-up do due to come
content merges that scrambled the list of column name indexes.

Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-20 13:54:12 -04:00
Mauro Carvalho Chehab 5fb94e9ca3 docs: Fix some broken references
As we move stuff around, some doc references are broken. Fix some of
them via this script:
	./scripts/documentation-file-ref-check --fix

Manually checked if the produced result is valid, removing a few
false-positives.

Acked-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Coly Li <colyli@suse.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Acked-by: Jonathan Corbet <corbet@lwn.net>
2018-06-15 18:10:01 -03:00
Rafael J. Wysocki 5202e32db0 linux-cpupower-4.18-rc1
This cpupower update for 4.18-rc1 consists of two minor fixes.
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABCAAGBQJbFbJsAAoJEAsCRMQNDUMczvAQANheU35A5iJRreVQjtB6lDD1
 9gSE+yARAd/NXr1wmbEf+/0+WoIbhVekZahgvBjoQIP2vkrjCXWhaOhrPEJ90KJW
 Nza6qcaRndWwE4+0sg+kf9JwP7o23mT6vcf4/Kn4eQXuuDUbqQ+oao1iUgmEi0q6
 V2cDUMmKbzDywH8sBADYELF0kYWKiFysSj1xpoo1J0axPzblr72b3ru2tFSDV5j2
 OkTsToGUESma27fOY4ZB7DTgF9DgB56Y4vZhrD9hmz8FS+tVn9gsGTZh0GTVwlUT
 +p36GeHDLcwUeG66bqdBLTNsx/dKRbfqFeDSgv8EEyyMpSeTNVcANSfEF2NsNiNo
 /nhvOvGzFZFOMZAqcyB65/jLsZC7HDIXdDXB/FNfHLaxKR0tw45MzOavNaLwrTWg
 mnncsuNLDE6kwsyaoP1MeItN1e8aAtuwTxYL9HCBzX9vjcOD8cozuI3KlR1thOqc
 JbKFiViZSRmi/GVt2Aeu/AWsVeI2aDn0BphSo4dWcLtlM88hKzywzxpOkwhz23w7
 bwvX4jEi4pDKu5XlWAj2c7+cjizEx3paESc76TKfV1dDr/BTgTEN01prIvwP/yv2
 gEmrRG+i0HERN5hPHJ8kIG3m6HoMa75kEw9AuK0Bxb286m3JOqr8DiVoEbmrBnal
 /CtzBYVvXLBDslI1+0gZ
 =BSJW
 -----END PGP SIGNATURE-----

Merge tag 'linux-cpupower-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux

Pull cpupower updates for v4.18-rc1 from Shuah Khan:

"This cpupower update for 4.18-rc1 consists of two minor fixes."

* tag 'linux-cpupower-4.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux:
  cpupower : Fix header name to read idle state name
  cpupower: fix spelling mistake: "logilename" -> "logfilename"
2018-06-06 08:41:01 +02:00
Rafael J. Wysocki 9b34ffa09d Merge back earlier PM tools material for v4.18. 2018-06-03 10:12:30 +02:00
Len Brown 201d4f50fe tools/power turbostat: update version number
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:47 -04:00
Prarit Bhargava 012350411b tools/power turbostat: Add Node in output
Output a Node column if there is more than one node/socket.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:47 -04:00
Prarit Bhargava 40f5cfe7b8 tools/power turbostat: add node information into turbostat calculations
The previous patches have added node information to turbostat, but the
counters code does not take it into account.

Add node information from cpu_topology calculations to turbostat
counters.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:47 -04:00
Prarit Bhargava 70a9c6e8ed tools/power turbostat: remove num_ from cpu_topology struct
Cleanup, remove num_ from num_nodes_per_pkg, num_cores_per_node, and
num_threads_per_node.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:47 -04:00
Prarit Bhargava 139dd0e07c tools/power turbostat: rename num_cores_per_pkg to num_cores_per_node
turbostat incorrectly assumes that there is one node per package.  As a
result num_cores_per_pkg is not correctly named and is actually
num_cores_per_node.

Rename num_cores_per_pkg to num_cores_per_node.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:46 -04:00
Prarit Bhargava 8cb48b32a5 tools/power turbostat: track thread ID in cpu_topology
The code can be simplified if the cpu_topology *cpus tracks the thread
IDs.  This removes an additional file lookup and simplifies the counter
initialization code.

Add thread ID to cpu_topology information and cleanup the counter
initialization code.

v2: prevent thread_id from being overwritten

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:46 -04:00
Prarit Bhargava ef6057417a tools/power turbostat: Calculate additional node information for a package
The code currently assumes each package has exactly one node.  This is not
the case for AMD systems and Intel systems with COD.  AMD systems also
may re-enumerate each node's core IDs starting at 0 (for example, an AMD
processor may have two nodes, each with core IDs from 0 to 7).  In order
to properly enumerate the cores we need to track both the physical and
logical node IDs.

Add physical_node_id to track the node ID assigned by the kernel, and
logical_node_id used by turbostat to track the nodes per package ie) a
0-based count within the package.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:46 -04:00
Len Brown 0e2d8f058f tools/power turbostat: Fix node and siblings lookup data
The turbostat code only looks at thread_siblings_list to determine if
processing units/threads are on the same the core.  This works well on
Intel systems which have a shared L1 instruction and data cache.  This
does not work on AMD systems which have shared L1 instruction cache but
separate L1 data caches.  Other utilities also check sibling's core ID
to determine if the processing unit shares the same core.

Additionally, the cpu_topology *cpus list used in topology_probe() can
be used elsewhere in the code to simplify things.

Export *cpus to the entire turbostat code, and add Processing Unit/Thread
IDs information to each cpu_topology struct.  Confirm that the thread
is on the same core as indicated by thread_siblings_list.

[v2]: Fixup CPU_* usage that caused gcc malloc error.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:46 -04:00
Prarit Bhargava 843c57916d tools/power turbostat: set max_num_cpus equal to the cpumask length
Future fixes will use sysfs files that contain cpumask output.  The code
needs to know the length of the cpumask in order to determine which cpus
are set in a cpumask.  Currently topo.max_cpu_num is the maximum cpu
number.  It can be increased the the maximum value of cpus represented in
cpumasks.

Set max_num_cpus to the length of a cpumask.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:46 -04:00
Chen Yu 023fe0ac97 tools/power turbostat: if --num_iterations, print for specific number of iterations
There's a use case during test to only print specific round of iterations
if --num_iterations is specified, for example, with this patch applied:

turbostat -i 5 -n 4
will capture 4 samples with 5 seconds interval.

[lenb: renamed to --num_iterations from --iterations]

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
Reviewed-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:45 -04:00
Srinivas Pandruvada 997e53950e tools/power turbostat: Add Cannon Lake support
All MSRs related to turbostat are same as Kabylake.
Even though SDM claims that core C3 residency can be read from MSR 0x662,
the read on this MSR fails on CNL platform. Hence disabled C3 MSR read
and display.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:45 -04:00
Len Brown 9d4eab02a7 tools/power turbostat: delete duplicate #defines
The SNB_C1_AUTO_UNDEMOTE definition should have been deleted once
it was copied into msr-index.h.  One copy of the truth is better --
particularly when Matt needs to fix it:-)

Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:45 -04:00
Matt Turner e0d34648b4 tools/power turbostat: Correct SNB_C1/C3_AUTO_UNDEMOTE defines
According to the Intel Software Developers' Manual, Vol. 4, Order No.
335592, these macros have been reversed since they were added.

Fixes: 889facbee3 ("tools/power turbostat: v3.0: monitor Watts and Temperature")
Signed-off-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:44 -04:00
Len Brown 0748eaf0cf tools/power turbostat: add POLL and POLL% column
Like the "C1" and "C1%" column, the new POLL and POLL% columns
show invocations and residency% during the measurement interval.

While it didn't seem important to track in the past,
we've recently found some Linux cpuidle bugs related to POLL%.

Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:44 -04:00
Len Brown 4bd1f8f21a tools/power turbostat: Fix --hide Pk%pc10
The column header for PC10 residency is "Pk%pc10"
This is missing the 'g' that others have, eg Pkg%pc6,
to allow tab-delimited columns to fit into 8-columns.

However, --hide Pk%pc10 did not work, it was still looking for the 'g'.
This was confusing, because --list shows the correct "Pk%pc10"

Reported-by: Wendy Wang <wendy.wang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:44 -04:00
Len Brown be0e54c4eb tools/power turbostat: Build-in "Low Power Idle" counters support
Linux 4.15 exports the ACPI Low Power Idle Table's
counters in /sys/devices/system/cpu/cpuidle/

low_power_idle_cpu_residency_us

	Show this in the "CPU%LPI" column.

	Today this reflects the "North Complex"
	residency in PC10, so expect it to
	closely follow "Pk%pc10".

low_power_idle_system_residency_us

	Show this in the "SYS%LPI" column.

	Today, this reflects the North is in PC10,
	plus the PCH is sufficiently quiescent
	to save additional power via the "S0ix"
	system state, as measured by the
	PCH SLP_S0 counter.

Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 23:12:40 -04:00
Laura Abbott e29dc460d6 tools/power turbostat: Don't make man pages executable
rpm-lint flagged these as being executable:

kernel-tools.x86_64: W: spurious-executable-perm /usr/share/man/man8/turbostat.8.gz
kernel-tools.x86_64: W: spurious-executable-perm /usr/share/man/man8/x86_energy_perf_policy.8.gz

Fix this

Signed-off-by: Laura Abbott <labbott@redhat.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 17:15:09 -04:00
Len Brown 94d6ab4b11 tools/power turbostat: remove blank lines
When the user reuests to collect and show columns
that are not present on every row (eg. for every CPU)
turbostat still prints an (empty) line for every CPU.
Update so no blank lines are printed.

old:
	# turbostat --quiet --show Pkg%pc6
	Pkg%pc6
	9.12
	9.12

	Pkg%pc6
	9.12
	9.12

new:
	# turbostat --quiet --show Pkg%pc6
	Pkg%pc6
	9.12
	9.12
	Pkg%pc6
	9.12
	9.12

Reported-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 17:15:09 -04:00
Artem Bityutskiy 3e8b62bf0c tools/power turbostat: a small C-states dump readability immprovement
Improve readability a little bit by changing this output:

 MSR_PKG_CST_CONFIG_CONTROL: 0x00008407 (locked: pkg-cstate-limit=7: unlimited, automatic-c-state-conversion=off)

with this output:

 MSR_PKG_CST_CONFIG_CONTROL: 0x00008407 (locked, pkg-cstate-limit=7 (unlimited), automatic-c-state-conversion=off)

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 17:15:08 -04:00
Artem Bityutskiy ac980e1357 tools/power turbostat: dump BDX, SKX automatic C-state conversion bit
BDX and SKX have a bit that tells them to PROMOTE shallow
C-states requests to MWAIT(C6).  It is generally a BIOS bug
if this bit is set.  As we have encountered that BIOS bug,
let's print this bit in turbostat debug output.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 17:15:08 -04:00
Len Brown 733ef0f8e7 tools/power turbostat: do not hard-code 25MHz crystal on SKX
Some SKX use a 24 MHz crystal, so do not hard code 25 MHz.

Also, SKX crystal is not exact, because SKX uses an EMI reduction
circuit that costs a fraction of a percent.

Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 17:15:08 -04:00
Len Brown 46c2797826 tools/power turbostat: fix possible sprintf buffer overflow
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 17:14:56 -04:00
Len Brown fd3933ca7b tools/power turbostat: fix MSR_IA32_MISC_ENABLE MWAIT printout
MSR_IA32_MISC_ENABLE[18] is the MWAIT ENABLE bit, not DISABLE bit...

so

MSR_IA32_MISC_ENABLE: 0x00850089 (TCC EIST No-MWAIT PREFETCH TURBO)

should print as:

MSR_IA32_MISC_ENABLE: 0x00850089 (TCC EIST MWAIT PREFETCH TURBO)

Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 12:13:06 -04:00
Artem Bityutskiy 47936f944e tools/power turbostat: fix printing on input
The recent patch that implements table printing on a keypress introduced a
regression - turbostat prints the table almost continuously if it is run from a
daemon program.

The problem is also easy to reproduce like this:

echo | turbostat

The reason is that we cannot assume that stdin is always a TTY. It can be many
things.

This patch adds fixes the problem by limiting the new keypress functionality to
TTYs only. If stdin is not a TTY, we just sleep for the full interval time.

While on it, clean-up 'do_sleep()' to return no value, as callers do not expect
that anyway.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 12:13:05 -04:00
Len Brown b9ad8ee0da tools/power turbostat: end current interval upon newline input
In turbostat interval mode, a newline typed on standard input
will now conclude the current interval.  Data will immediately
be collected and printed for that interval, and the next interval
will be started.

This is similar to the recently added SIGUSR1 feature.
But that is for use by programs, while this is for interactive use.

Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 12:13:05 -04:00
Len Brown 072119606a tools/power turbostat: on SIGUSR1: sample, print and continue
Interval-mode turbostat now catches and discards SIGUSR1.

Thus, SIGUSR1 can be used to tell turbostat to cut short
the current measurement interval.  Turbostat will then start
the next measurement interval using the regular interval length.

This can be used to give turbostat variable intervals.
Invoke turbostat with --interval LARGE_NUMBER_SEC
and have a program that has permission to send it a SIGUSR1
always before LARGE_NUMBER_SEC expires.

It may also be useful to use "--enable Time_Of_Day_Seconds"
to observe the actual interval length.

Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 12:13:04 -04:00
Len Brown 8aa2ed0b28 tools/power turbostat: on SIGINT: sample, print and exit
When running in interval-mode, catch interrupts
and print a final data record before exiting.

Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 12:13:04 -04:00
Len Brown 3f44a5c62b tools/power turbostat: add --enable Time_Of_Day_Seconds
Add a Time_Of_Day_Seconds column showing when measurement
for each row was completed.  Units are [sec.subsec] since Epoch,
as reported by gettimeofday(2).

While useful to correlate turbostat output with other tools,
this built-in column is disabled, by default.

Add the "--enable" option to enable such disabled-by-default
built-in columns:

"--enable Time_Of_Day_Seconds"
"--enable usec"

"--enable all", will enable all disabled-by-defauilt built-in counters.

When "--debug" is used, all disabled-by-default columns are enabled,
unless explicitly skipped using "--hide"

Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 12:13:04 -04:00
Artem Bityutskiy 2085e12441 tools/power turbostat: fix Skylake Xeon package C-state display
Turbostat neglects to display all package C-states for some Skylake Xeon BIOS configurations.

This is due to a typo in the table decoding MSR_PKG_CST_CONFIG_CONTROL (0x000000e2)

Here we fix that typo, according to Intel SDM, vol 4, Table 2-41 -
"MSRs Supported by Intel® Xeon® Processor Scalable Family with DisplayFamily_DisplayModel 06_55H".

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2018-06-01 12:13:03 -04:00
Abhishek Goel f9652d5cae cpupower : Fix header name to read idle state name
The names of the idle states in the output of cpupower monitor command are
truncated to 4 characters. On POWER9, this creates ambiguity as the states
are named "stop0", "stop1", etc.

root:~# cpupower monitor
              |Idle_Stats
PKG |CORE|CPU | snoo | stop | stop | stop | stop | stop | stop
   0|   0|   0|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  1.90
   0|   0|   1|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00
   0|   0|   2|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00
   0|   0|   3|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00

This patch modifies the output to print the state name that results in a
legible output. The names will be printed with atmost 1 padding in left.

root:~# cpupower monitor
              | Idle_Stats
 PKG|CORE| CPU|snooze|stop0L| stop0|stop1L| stop1|stop2L| stop2
   0|   0|   0|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.72
   0|   0|   1|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00
   0|   0|   2|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00
   0|   0|   3|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00|  0.00

This patch does not affect the output for intel.
Output for intel before applying the patch:

root:~# cpupower monitor
    |Idle_Stats
CPU | POLL | C1-S | C1E- | C3-S | C6-S | C7s- | C8-S | C9-S | C10-
   0|  0.00|  0.14|  0.39|  0.35|  7.41|  0.00| 17.67|  1.01| 70.03
   2|  0.00|  0.19|  0.47|  0.10|  6.50|  0.00| 29.66|  2.17| 58.07
   1|  0.00|  0.11|  0.50|  1.50|  9.11|  0.18| 18.19|  0.40| 66.63
   3|  0.00|  0.67|  0.42|  0.03|  5.84|  0.00| 12.58|  0.77| 77.14

Output for intel after applying the patch:

root:~# cpupower monitor
    | Idle_Stats
 CPU| POLL | C1-S | C1E- | C3-S | C6-S | C7s- | C8-S | C9-S | C10-
   0|  0.03|  0.33|  1.01|  0.27|  3.03|  0.00| 19.18|  0.00| 71.24
   2|  0.00|  1.58|  0.58|  0.42|  8.55|  0.09| 21.11|  0.99| 63.32
   1|  0.00|  1.26|  0.88|  0.43|  9.00|  0.02|  7.78|  4.65| 71.91
   3|  0.00|  0.30|  0.42|  0.06| 13.62|  0.21| 30.29|  0.00| 52.45

Signed-off-by: Abhishek Goel <huntbag@linux.vnet.ibm.com>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-05-29 10:48:33 -06:00
Todd E Brandt ffbb95aa2d PM / tools: pm-graph: upgrade to v5.1
general changes:
 - make python dependent on version2 to enable clearlinux
 - upgrade dmesg error/warning extraction to be more detailed
 - enable logs generated from -cmd runs to be processed in gzip form
 - add notification on power mode entry failure into the timeline
 - add -battery option to show if battery is connected and its charge

summary changes (output of -summary):
 - add -genhtml option to regenerate missing timelines from logs found
 - add min/max/median/avg data to the summary page with links to the data
 - add highlight to minimum, maximum, and median tests
 - add result column to summary (pass or fail) with red highlight on fail
 - add issues column to summary with a list of dmesg err/warn/bugs

Signed-off-by: Todd Brandt <todd.e.brandt@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-05-27 12:03:50 +02:00
Doug Smythies 35459105de tools/power/x86/intel_pstate_tracer: Add optional setting of trace buffer memory allocation
Allow the user to override the default trace buffer memory allocation
by adding a command line option to override the default.

The patch also:

Adds a SIGINT (i.e. CTRL C exit) handler,
so that things can be cleaned up before exit.

Moves the postion of some other cleanup from after to
before the potential "No valid data to plot" exit.

Replaces all quit() calls with sys.exit, because
quit() is not supposed to be used in scripts.

Signed-off-by: Doug Smythies <dsmythies@telus.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-05-17 10:19:34 +02:00
Colin Ian King 9fd0c40451 cpupower: fix spelling mistake: "logilename" -> "logfilename"
Trivial fix to spelling mistake in dprintf message

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
2018-05-10 10:24:30 -06:00
Jiri Slaby 7553961631 tools: power/acpi, revert to LD = gcc
Commit 7ed1c1901f (tools: fix cross-compile var clobbering) removed
setting of LD to $(CROSS_COMPILE)gcc. This broke build of acpica
(acpidump) in power/acpi:
 ld: unrecognized option '-D_LINUX'

The tools pass CFLAGS to the linker (incl. -D_LINUX), so revert this
particular change and let LD be $(CC) again. Note that the old behaviour
was a bit different, it used $(CROSS_COMPILE)gcc which was eliminated by
the commit 7ed1c1901f. We use $(CC) for that reason.

Fixes: 7ed1c1901f (tools: fix cross-compile var clobbering)
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: 4.16+ <stable@vger.kernel.org> # 4.16+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-05-04 11:24:22 +02:00
Linus Torvalds f2d285669a Power management updates for 4.17-rc1
- Modify the cpuidle poll state implementation to prevent CPUs from
    staying in the loop in there for excessive times (Rafael Wysocki).
 
  - Add Intel Cannon Lake chips support to the RAPL power capping
    driver (Joe Konno).
 
  - Add reference counting to the device links handling code in the
    PM core (Lukas Wunner).
 
  - Avoid reconfiguring GPEs on suspend-to-idle in the ACPI system
    suspend code (Rafael Wysocki).
 
  - Allow devices to be put into deeper low-power states via ACPI
    if both _SxD and _SxW are missing (Daniel Drake).
 
  - Reorganize the core ACPI suspend-to-idle wakeup code to avoid a
    keyboard wakeup issue on Asus UX331UA (Chris Chiu).
 
  - Prevent the PCMCIA library code from aborting suspend-to-idle due
    to noirq suspend failures resulting from incorrect assumptions
    (Rafael Wysocki).
 
  - Add coupled cpuidle supprt to the Exynos3250 platform (Marek
    Szyprowski).
 
  - Add new sysfs file to make it easier to specify the image storage
    location during hibernation (Mario Limonciello).
 
  - Add sysfs files for collecting suspend-to-idle usage and time
    statistics for CPU idle states (Rafael Wysocki).
 
  - Update the pm-graph utilities (Todd Brandt).
 
  - Reduce the kernel log noise related to reporting Low-power Idle
    constraings by the ACPI system suspend code (Rafael Wysocki).
 
  - Make it easier to distinguish dedicated wakeup IRQs in the
    /proc/interrupts output (Tony Lindgren).
 
  - Add the frequency table validation in cpufreq to the core and
    drop it from a number of cpufreq drivers (Viresh Kumar).
 
  - Drop "cooling-{min|max}-level" for CPU nodes from a couple of
    DT bindings (Viresh Kumar).
 
  - Clean up the CPU online error code path in the cpufreq core
    (Viresh Kumar).
 
  - Fix assorted issues in the SCPI, CPPC, mediatek and tegra186
    cpufreq drivers (Arnd Bergmann, Chunyu Hu, George Cherian,
    Viresh Kumar).
 
  - Drop memory allocation error messages from a few places in
    cpufreq and cpuildle drivers (Markus Elfring).
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJawgTUAAoJEILEb/54YlRxI48QALc6IUfj/O+gLAWAf8qHk+8V
 eLn9E1NrZXUtNMNYItBcgZfuMImIj7MC5qRo/BhzYdd0VyUzFYEyd9liUVFBDEXA
 SH65jyjRrXORKfLrSP5H8lcCdckTFXfxzonVFN2n4l7Gdv540UFuqloU+vS4Wrfp
 wMg9UvKRxr+7LwOI4q2sMFtB8Uki+lySY5UECqRIKUIJKIH6RPo3m73Kps7kw8kU
 c2RCU8w/9PoomPaEjvwZ0vT5lNrQXmBbC5hxcMzBHtLS0Cwb3xJsUB4w6niezdGY
 e+n6Vx7XeId7+Ujnn4praxUwyVq2wEirJccvAEgKFcZzjmGAXrHl8rOgMLvb3ugN
 P+ftkYk+Vizci9hmACeA1LGw4hN/dXMfephnezCsy9Q/QK8QPJV8XO0vxfyaQYhZ
 ie6SKcdZimFDzqd6oHLFftRou3imvq8RUvKTx2CR0KVkApnaDDiTeP5ay1Yd+UU3
 EomWe7/mxoSgJ9kB/9GlKifQXBof62/fbrWH0AdM1oliONbbOZcLqg5x4DZUmfTK
 hTAx3SSxMRZSlc4Zl1CzbrHnFKi9cRBYCs0tPdOSnAO2ZfCsOmokJE+ig5I8lZre
 SlaciUpG2Vvf7m61mVlrqLLos8T9rTVM2pqwsoxII7A+dFrWK3HpqoypEN/87tm7
 4/zjPF6LK2eTKL9WdTCk
 =6JC2
 -----END PGP SIGNATURE-----

Merge tag 'pm-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management updates from Rafael Wysocki:
 "These update the cpuidle poll state definition to reduce excessive
  energy usage related to it, add new CPU ID to the RAPL power capping
  driver, update the ACPI system suspend code to handle some special
  cases better, extend the PM core's device links code slightly, add new
  sysfs attribute for better suspend-to-idle diagnostics and easier
  hibernation handling, update power management tools and clean up
  cpufreq quite a bit.

  Specifics:

   - Modify the cpuidle poll state implementation to prevent CPUs from
     staying in the loop in there for excessive times (Rafael Wysocki).

   - Add Intel Cannon Lake chips support to the RAPL power capping
     driver (Joe Konno).

   - Add reference counting to the device links handling code in the PM
     core (Lukas Wunner).

   - Avoid reconfiguring GPEs on suspend-to-idle in the ACPI system
     suspend code (Rafael Wysocki).

   - Allow devices to be put into deeper low-power states via ACPI if
     both _SxD and _SxW are missing (Daniel Drake).

   - Reorganize the core ACPI suspend-to-idle wakeup code to avoid a
     keyboard wakeup issue on Asus UX331UA (Chris Chiu).

   - Prevent the PCMCIA library code from aborting suspend-to-idle due
     to noirq suspend failures resulting from incorrect assumptions
     (Rafael Wysocki).

   - Add coupled cpuidle supprt to the Exynos3250 platform (Marek
     Szyprowski).

   - Add new sysfs file to make it easier to specify the image storage
     location during hibernation (Mario Limonciello).

   - Add sysfs files for collecting suspend-to-idle usage and time
     statistics for CPU idle states (Rafael Wysocki).

   - Update the pm-graph utilities (Todd Brandt).

   - Reduce the kernel log noise related to reporting Low-power Idle
     constraings by the ACPI system suspend code (Rafael Wysocki).

   - Make it easier to distinguish dedicated wakeup IRQs in the
     /proc/interrupts output (Tony Lindgren).

   - Add the frequency table validation in cpufreq to the core and drop
     it from a number of cpufreq drivers (Viresh Kumar).

   - Drop "cooling-{min|max}-level" for CPU nodes from a couple of DT
     bindings (Viresh Kumar).

   - Clean up the CPU online error code path in the cpufreq core (Viresh
     Kumar).

   - Fix assorted issues in the SCPI, CPPC, mediatek and tegra186
     cpufreq drivers (Arnd Bergmann, Chunyu Hu, George Cherian, Viresh
     Kumar).

   - Drop memory allocation error messages from a few places in cpufreq
     and cpuildle drivers (Markus Elfring)"

* tag 'pm-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (56 commits)
  ACPI / PM: Fix keyboard wakeup from suspend-to-idle on ASUS UX331UA
  cpufreq: CPPC: Use transition_delay_us depending transition_latency
  PM / hibernate: Change message when writing to /sys/power/resume
  PM / hibernate: Make passing hibernate offsets more friendly
  cpuidle: poll_state: Avoid invoking local_clock() too often
  PM: cpuidle/suspend: Add s2idle usage and time state attributes
  cpuidle: Enable coupled cpuidle support on Exynos3250 platform
  cpuidle: poll_state: Add time limit to poll_idle()
  cpufreq: tegra186: Don't validate the frequency table twice
  cpufreq: speedstep: Don't validate the frequency table twice
  cpufreq: sparc: Don't validate the frequency table twice
  cpufreq: sh: Don't validate the frequency table twice
  cpufreq: sfi: Don't validate the frequency table twice
  cpufreq: scpi: Don't validate the frequency table twice
  cpufreq: sc520: Don't validate the frequency table twice
  cpufreq: s3c24xx: Don't validate the frequency table twice
  cpufreq: qoirq: Don't validate the frequency table twice
  cpufreq: pxa: Don't validate the frequency table twice
  cpufreq: ppc_cbe: Don't validate the frequency table twice
  cpufreq: powernow: Don't validate the frequency table twice
  ...
2018-04-03 10:45:39 -07:00