intel_pstate.rst 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. ===============================================
  2. ``intel_pstate`` CPU Performance Scaling Driver
  3. ===============================================
  4. ::
  5. Copyright (c) 2017 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  6. General Information
  7. ===================
  8. ``intel_pstate`` is a part of the
  9. :doc:`CPU performance scaling subsystem <cpufreq>` in the Linux kernel
  10. (``CPUFreq``). It is a scaling driver for the Sandy Bridge and later
  11. generations of Intel processors. Note, however, that some of those processors
  12. may not be supported. [To understand ``intel_pstate`` it is necessary to know
  13. how ``CPUFreq`` works in general, so this is the time to read :doc:`cpufreq` if
  14. you have not done that yet.]
  15. For the processors supported by ``intel_pstate``, the P-state concept is broader
  16. than just an operating frequency or an operating performance point (see the
  17. `LinuxCon Europe 2015 presentation by Kristen Accardi <LCEU2015_>`_ for more
  18. information about that). For this reason, the representation of P-states used
  19. by ``intel_pstate`` internally follows the hardware specification (for details
  20. refer to `Intel® 64 and IA-32 Architectures Software Developer’s Manual
  21. Volume 3: System Programming Guide <SDM_>`_). However, the ``CPUFreq`` core
  22. uses frequencies for identifying operating performance points of CPUs and
  23. frequencies are involved in the user space interface exposed by it, so
  24. ``intel_pstate`` maps its internal representation of P-states to frequencies too
  25. (fortunately, that mapping is unambiguous). At the same time, it would not be
  26. practical for ``intel_pstate`` to supply the ``CPUFreq`` core with a table of
  27. available frequencies due to the possible size of it, so the driver does not do
  28. that. Some functionality of the core is limited by that.
  29. Since the hardware P-state selection interface used by ``intel_pstate`` is
  30. available at the logical CPU level, the driver always works with individual
  31. CPUs. Consequently, if ``intel_pstate`` is in use, every ``CPUFreq`` policy
  32. object corresponds to one logical CPU and ``CPUFreq`` policies are effectively
  33. equivalent to CPUs. In particular, this means that they become "inactive" every
  34. time the corresponding CPU is taken offline and need to be re-initialized when
  35. it goes back online.
  36. ``intel_pstate`` is not modular, so it cannot be unloaded, which means that the
  37. only way to pass early-configuration-time parameters to it is via the kernel
  38. command line. However, its configuration can be adjusted via ``sysfs`` to a
  39. great extent. In some configurations it even is possible to unregister it via
  40. ``sysfs`` which allows another ``CPUFreq`` scaling driver to be loaded and
  41. registered (see `below <status_attr_>`_).
  42. Operation Modes
  43. ===============
  44. ``intel_pstate`` can operate in three different modes: in the active mode with
  45. or without hardware-managed P-states support and in the passive mode. Which of
  46. them will be in effect depends on what kernel command line options are used and
  47. on the capabilities of the processor.
  48. Active Mode
  49. -----------
  50. This is the default operation mode of ``intel_pstate``. If it works in this
  51. mode, the ``scaling_driver`` policy attribute in ``sysfs`` for all ``CPUFreq``
  52. policies contains the string "intel_pstate".
  53. In this mode the driver bypasses the scaling governors layer of ``CPUFreq`` and
  54. provides its own scaling algorithms for P-state selection. Those algorithms
  55. can be applied to ``CPUFreq`` policies in the same way as generic scaling
  56. governors (that is, through the ``scaling_governor`` policy attribute in
  57. ``sysfs``). [Note that different P-state selection algorithms may be chosen for
  58. different policies, but that is not recommended.]
  59. They are not generic scaling governors, but their names are the same as the
  60. names of some of those governors. Moreover, confusingly enough, they generally
  61. do not work in the same way as the generic governors they share the names with.
  62. For example, the ``powersave`` P-state selection algorithm provided by
  63. ``intel_pstate`` is not a counterpart of the generic ``powersave`` governor
  64. (roughly, it corresponds to the ``schedutil`` and ``ondemand`` governors).
  65. There are two P-state selection algorithms provided by ``intel_pstate`` in the
  66. active mode: ``powersave`` and ``performance``. The way they both operate
  67. depends on whether or not the hardware-managed P-states (HWP) feature has been
  68. enabled in the processor and possibly on the processor model.
  69. Which of the P-state selection algorithms is used by default depends on the
  70. :c:macro:`CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE` kernel configuration option.
  71. Namely, if that option is set, the ``performance`` algorithm will be used by
  72. default, and the other one will be used by default if it is not set.
  73. Active Mode With HWP
  74. ~~~~~~~~~~~~~~~~~~~~
  75. If the processor supports the HWP feature, it will be enabled during the
  76. processor initialization and cannot be disabled after that. It is possible
  77. to avoid enabling it by passing the ``intel_pstate=no_hwp`` argument to the
  78. kernel in the command line.
  79. If the HWP feature has been enabled, ``intel_pstate`` relies on the processor to
  80. select P-states by itself, but still it can give hints to the processor's
  81. internal P-state selection logic. What those hints are depends on which P-state
  82. selection algorithm has been applied to the given policy (or to the CPU it
  83. corresponds to).
  84. Even though the P-state selection is carried out by the processor automatically,
  85. ``intel_pstate`` registers utilization update callbacks with the CPU scheduler
  86. in this mode. However, they are not used for running a P-state selection
  87. algorithm, but for periodic updates of the current CPU frequency information to
  88. be made available from the ``scaling_cur_freq`` policy attribute in ``sysfs``.
  89. HWP + ``performance``
  90. .....................
  91. In this configuration ``intel_pstate`` will write 0 to the processor's
  92. Energy-Performance Preference (EPP) knob (if supported) or its
  93. Energy-Performance Bias (EPB) knob (otherwise), which means that the processor's
  94. internal P-state selection logic is expected to focus entirely on performance.
  95. This will override the EPP/EPB setting coming from the ``sysfs`` interface
  96. (see `Energy vs Performance Hints`_ below).
  97. Also, in this configuration the range of P-states available to the processor's
  98. internal P-state selection logic is always restricted to the upper boundary
  99. (that is, the maximum P-state that the driver is allowed to use).
  100. HWP + ``powersave``
  101. ...................
  102. In this configuration ``intel_pstate`` will set the processor's
  103. Energy-Performance Preference (EPP) knob (if supported) or its
  104. Energy-Performance Bias (EPB) knob (otherwise) to whatever value it was
  105. previously set to via ``sysfs`` (or whatever default value it was
  106. set to by the platform firmware). This usually causes the processor's
  107. internal P-state selection logic to be less performance-focused.
  108. Active Mode Without HWP
  109. ~~~~~~~~~~~~~~~~~~~~~~~
  110. This is the default operation mode for processors that do not support the HWP
  111. feature. It also is used by default with the ``intel_pstate=no_hwp`` argument
  112. in the kernel command line. However, in this mode ``intel_pstate`` may refuse
  113. to work with the given processor if it does not recognize it. [Note that
  114. ``intel_pstate`` will never refuse to work with any processor with the HWP
  115. feature enabled.]
  116. In this mode ``intel_pstate`` registers utilization update callbacks with the
  117. CPU scheduler in order to run a P-state selection algorithm, either
  118. ``powersave`` or ``performance``, depending on the ``scaling_governor`` policy
  119. setting in ``sysfs``. The current CPU frequency information to be made
  120. available from the ``scaling_cur_freq`` policy attribute in ``sysfs`` is
  121. periodically updated by those utilization update callbacks too.
  122. ``performance``
  123. ...............
  124. Without HWP, this P-state selection algorithm is always the same regardless of
  125. the processor model and platform configuration.
  126. It selects the maximum P-state it is allowed to use, subject to limits set via
  127. ``sysfs``, every time the driver configuration for the given CPU is updated
  128. (e.g. via ``sysfs``).
  129. This is the default P-state selection algorithm if the
  130. :c:macro:`CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE` kernel configuration option
  131. is set.
  132. ``powersave``
  133. .............
  134. Without HWP, this P-state selection algorithm is similar to the algorithm
  135. implemented by the generic ``schedutil`` scaling governor except that the
  136. utilization metric used by it is based on numbers coming from feedback
  137. registers of the CPU. It generally selects P-states proportional to the
  138. current CPU utilization.
  139. This algorithm is run by the driver's utilization update callback for the
  140. given CPU when it is invoked by the CPU scheduler, but not more often than
  141. every 10 ms. Like in the ``performance`` case, the hardware configuration
  142. is not touched if the new P-state turns out to be the same as the current
  143. one.
  144. This is the default P-state selection algorithm if the
  145. :c:macro:`CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE` kernel configuration option
  146. is not set.
  147. Passive Mode
  148. ------------
  149. This mode is used if the ``intel_pstate=passive`` argument is passed to the
  150. kernel in the command line (it implies the ``intel_pstate=no_hwp`` setting too).
  151. Like in the active mode without HWP support, in this mode ``intel_pstate`` may
  152. refuse to work with the given processor if it does not recognize it.
  153. If the driver works in this mode, the ``scaling_driver`` policy attribute in
  154. ``sysfs`` for all ``CPUFreq`` policies contains the string "intel_cpufreq".
  155. Then, the driver behaves like a regular ``CPUFreq`` scaling driver. That is,
  156. it is invoked by generic scaling governors when necessary to talk to the
  157. hardware in order to change the P-state of a CPU (in particular, the
  158. ``schedutil`` governor can invoke it directly from scheduler context).
  159. While in this mode, ``intel_pstate`` can be used with all of the (generic)
  160. scaling governors listed by the ``scaling_available_governors`` policy attribute
  161. in ``sysfs`` (and the P-state selection algorithms described above are not
  162. used). Then, it is responsible for the configuration of policy objects
  163. corresponding to CPUs and provides the ``CPUFreq`` core (and the scaling
  164. governors attached to the policy objects) with accurate information on the
  165. maximum and minimum operating frequencies supported by the hardware (including
  166. the so-called "turbo" frequency ranges). In other words, in the passive mode
  167. the entire range of available P-states is exposed by ``intel_pstate`` to the
  168. ``CPUFreq`` core. However, in this mode the driver does not register
  169. utilization update callbacks with the CPU scheduler and the ``scaling_cur_freq``
  170. information comes from the ``CPUFreq`` core (and is the last frequency selected
  171. by the current scaling governor for the given policy).
  172. .. _turbo:
  173. Turbo P-states Support
  174. ======================
  175. In the majority of cases, the entire range of P-states available to
  176. ``intel_pstate`` can be divided into two sub-ranges that correspond to
  177. different types of processor behavior, above and below a boundary that
  178. will be referred to as the "turbo threshold" in what follows.
  179. The P-states above the turbo threshold are referred to as "turbo P-states" and
  180. the whole sub-range of P-states they belong to is referred to as the "turbo
  181. range". These names are related to the Turbo Boost technology allowing a
  182. multicore processor to opportunistically increase the P-state of one or more
  183. cores if there is enough power to do that and if that is not going to cause the
  184. thermal envelope of the processor package to be exceeded.
  185. Specifically, if software sets the P-state of a CPU core within the turbo range
  186. (that is, above the turbo threshold), the processor is permitted to take over
  187. performance scaling control for that core and put it into turbo P-states of its
  188. choice going forward. However, that permission is interpreted differently by
  189. different processor generations. Namely, the Sandy Bridge generation of
  190. processors will never use any P-states above the last one set by software for
  191. the given core, even if it is within the turbo range, whereas all of the later
  192. processor generations will take it as a license to use any P-states from the
  193. turbo range, even above the one set by software. In other words, on those
  194. processors setting any P-state from the turbo range will enable the processor
  195. to put the given core into all turbo P-states up to and including the maximum
  196. supported one as it sees fit.
  197. One important property of turbo P-states is that they are not sustainable. More
  198. precisely, there is no guarantee that any CPUs will be able to stay in any of
  199. those states indefinitely, because the power distribution within the processor
  200. package may change over time or the thermal envelope it was designed for might
  201. be exceeded if a turbo P-state was used for too long.
  202. In turn, the P-states below the turbo threshold generally are sustainable. In
  203. fact, if one of them is set by software, the processor is not expected to change
  204. it to a lower one unless in a thermal stress or a power limit violation
  205. situation (a higher P-state may still be used if it is set for another CPU in
  206. the same package at the same time, for example).
  207. Some processors allow multiple cores to be in turbo P-states at the same time,
  208. but the maximum P-state that can be set for them generally depends on the number
  209. of cores running concurrently. The maximum turbo P-state that can be set for 3
  210. cores at the same time usually is lower than the analogous maximum P-state for
  211. 2 cores, which in turn usually is lower than the maximum turbo P-state that can
  212. be set for 1 core. The one-core maximum turbo P-state is thus the maximum
  213. supported one overall.
  214. The maximum supported turbo P-state, the turbo threshold (the maximum supported
  215. non-turbo P-state) and the minimum supported P-state are specific to the
  216. processor model and can be determined by reading the processor's model-specific
  217. registers (MSRs). Moreover, some processors support the Configurable TDP
  218. (Thermal Design Power) feature and, when that feature is enabled, the turbo
  219. threshold effectively becomes a configurable value that can be set by the
  220. platform firmware.
  221. Unlike ``_PSS`` objects in the ACPI tables, ``intel_pstate`` always exposes
  222. the entire range of available P-states, including the whole turbo range, to the
  223. ``CPUFreq`` core and (in the passive mode) to generic scaling governors. This
  224. generally causes turbo P-states to be set more often when ``intel_pstate`` is
  225. used relative to ACPI-based CPU performance scaling (see `below <acpi-cpufreq_>`_
  226. for more information).
  227. Moreover, since ``intel_pstate`` always knows what the real turbo threshold is
  228. (even if the Configurable TDP feature is enabled in the processor), its
  229. ``no_turbo`` attribute in ``sysfs`` (described `below <no_turbo_attr_>`_) should
  230. work as expected in all cases (that is, if set to disable turbo P-states, it
  231. always should prevent ``intel_pstate`` from using them).
  232. Processor Support
  233. =================
  234. To handle a given processor ``intel_pstate`` requires a number of different
  235. pieces of information on it to be known, including:
  236. * The minimum supported P-state.
  237. * The maximum supported `non-turbo P-state <turbo_>`_.
  238. * Whether or not turbo P-states are supported at all.
  239. * The maximum supported `one-core turbo P-state <turbo_>`_ (if turbo P-states
  240. are supported).
  241. * The scaling formula to translate the driver's internal representation
  242. of P-states into frequencies and the other way around.
  243. Generally, ways to obtain that information are specific to the processor model
  244. or family. Although it often is possible to obtain all of it from the processor
  245. itself (using model-specific registers), there are cases in which hardware
  246. manuals need to be consulted to get to it too.
  247. For this reason, there is a list of supported processors in ``intel_pstate`` and
  248. the driver initialization will fail if the detected processor is not in that
  249. list, unless it supports the `HWP feature <Active Mode_>`_. [The interface to
  250. obtain all of the information listed above is the same for all of the processors
  251. supporting the HWP feature, which is why they all are supported by
  252. ``intel_pstate``.]
  253. User Space Interface in ``sysfs``
  254. =================================
  255. Global Attributes
  256. -----------------
  257. ``intel_pstate`` exposes several global attributes (files) in ``sysfs`` to
  258. control its functionality at the system level. They are located in the
  259. ``/sys/devices/system/cpu/intel_pstate/`` directory and affect all CPUs.
  260. Some of them are not present if the ``intel_pstate=per_cpu_perf_limits``
  261. argument is passed to the kernel in the command line.
  262. ``max_perf_pct``
  263. Maximum P-state the driver is allowed to set in percent of the
  264. maximum supported performance level (the highest supported `turbo
  265. P-state <turbo_>`_).
  266. This attribute will not be exposed if the
  267. ``intel_pstate=per_cpu_perf_limits`` argument is present in the kernel
  268. command line.
  269. ``min_perf_pct``
  270. Minimum P-state the driver is allowed to set in percent of the
  271. maximum supported performance level (the highest supported `turbo
  272. P-state <turbo_>`_).
  273. This attribute will not be exposed if the
  274. ``intel_pstate=per_cpu_perf_limits`` argument is present in the kernel
  275. command line.
  276. ``num_pstates``
  277. Number of P-states supported by the processor (between 0 and 255
  278. inclusive) including both turbo and non-turbo P-states (see
  279. `Turbo P-states Support`_).
  280. The value of this attribute is not affected by the ``no_turbo``
  281. setting described `below <no_turbo_attr_>`_.
  282. This attribute is read-only.
  283. ``turbo_pct``
  284. Ratio of the `turbo range <turbo_>`_ size to the size of the entire
  285. range of supported P-states, in percent.
  286. This attribute is read-only.
  287. .. _no_turbo_attr:
  288. ``no_turbo``
  289. If set (equal to 1), the driver is not allowed to set any turbo P-states
  290. (see `Turbo P-states Support`_). If unset (equalt to 0, which is the
  291. default), turbo P-states can be set by the driver.
  292. [Note that ``intel_pstate`` does not support the general ``boost``
  293. attribute (supported by some other scaling drivers) which is replaced
  294. by this one.]
  295. This attrubute does not affect the maximum supported frequency value
  296. supplied to the ``CPUFreq`` core and exposed via the policy interface,
  297. but it affects the maximum possible value of per-policy P-state limits
  298. (see `Interpretation of Policy Attributes`_ below for details).
  299. ``hwp_dynamic_boost``
  300. This attribute is only present if ``intel_pstate`` works in the
  301. `active mode with the HWP feature enabled <Active Mode With HWP_>`_ in
  302. the processor. If set (equal to 1), it causes the minimum P-state limit
  303. to be increased dynamically for a short time whenever a task previously
  304. waiting on I/O is selected to run on a given logical CPU (the purpose
  305. of this mechanism is to improve performance).
  306. This setting has no effect on logical CPUs whose minimum P-state limit
  307. is directly set to the highest non-turbo P-state or above it.
  308. .. _status_attr:
  309. ``status``
  310. Operation mode of the driver: "active", "passive" or "off".
  311. "active"
  312. The driver is functional and in the `active mode
  313. <Active Mode_>`_.
  314. "passive"
  315. The driver is functional and in the `passive mode
  316. <Passive Mode_>`_.
  317. "off"
  318. The driver is not functional (it is not registered as a scaling
  319. driver with the ``CPUFreq`` core).
  320. This attribute can be written to in order to change the driver's
  321. operation mode or to unregister it. The string written to it must be
  322. one of the possible values of it and, if successful, the write will
  323. cause the driver to switch over to the operation mode represented by
  324. that string - or to be unregistered in the "off" case. [Actually,
  325. switching over from the active mode to the passive mode or the other
  326. way around causes the driver to be unregistered and registered again
  327. with a different set of callbacks, so all of its settings (the global
  328. as well as the per-policy ones) are then reset to their default
  329. values, possibly depending on the target operation mode.]
  330. That only is supported in some configurations, though (for example, if
  331. the `HWP feature is enabled in the processor <Active Mode With HWP_>`_,
  332. the operation mode of the driver cannot be changed), and if it is not
  333. supported in the current configuration, writes to this attribute will
  334. fail with an appropriate error.
  335. Interpretation of Policy Attributes
  336. -----------------------------------
  337. The interpretation of some ``CPUFreq`` policy attributes described in
  338. :doc:`cpufreq` is special with ``intel_pstate`` as the current scaling driver
  339. and it generally depends on the driver's `operation mode <Operation Modes_>`_.
  340. First of all, the values of the ``cpuinfo_max_freq``, ``cpuinfo_min_freq`` and
  341. ``scaling_cur_freq`` attributes are produced by applying a processor-specific
  342. multiplier to the internal P-state representation used by ``intel_pstate``.
  343. Also, the values of the ``scaling_max_freq`` and ``scaling_min_freq``
  344. attributes are capped by the frequency corresponding to the maximum P-state that
  345. the driver is allowed to set.
  346. If the ``no_turbo`` `global attribute <no_turbo_attr_>`_ is set, the driver is
  347. not allowed to use turbo P-states, so the maximum value of ``scaling_max_freq``
  348. and ``scaling_min_freq`` is limited to the maximum non-turbo P-state frequency.
  349. Accordingly, setting ``no_turbo`` causes ``scaling_max_freq`` and
  350. ``scaling_min_freq`` to go down to that value if they were above it before.
  351. However, the old values of ``scaling_max_freq`` and ``scaling_min_freq`` will be
  352. restored after unsetting ``no_turbo``, unless these attributes have been written
  353. to after ``no_turbo`` was set.
  354. If ``no_turbo`` is not set, the maximum possible value of ``scaling_max_freq``
  355. and ``scaling_min_freq`` corresponds to the maximum supported turbo P-state,
  356. which also is the value of ``cpuinfo_max_freq`` in either case.
  357. Next, the following policy attributes have special meaning if
  358. ``intel_pstate`` works in the `active mode <Active Mode_>`_:
  359. ``scaling_available_governors``
  360. List of P-state selection algorithms provided by ``intel_pstate``.
  361. ``scaling_governor``
  362. P-state selection algorithm provided by ``intel_pstate`` currently in
  363. use with the given policy.
  364. ``scaling_cur_freq``
  365. Frequency of the average P-state of the CPU represented by the given
  366. policy for the time interval between the last two invocations of the
  367. driver's utilization update callback by the CPU scheduler for that CPU.
  368. The meaning of these attributes in the `passive mode <Passive Mode_>`_ is the
  369. same as for other scaling drivers.
  370. Additionally, the value of the ``scaling_driver`` attribute for ``intel_pstate``
  371. depends on the operation mode of the driver. Namely, it is either
  372. "intel_pstate" (in the `active mode <Active Mode_>`_) or "intel_cpufreq" (in the
  373. `passive mode <Passive Mode_>`_).
  374. Coordination of P-State Limits
  375. ------------------------------
  376. ``intel_pstate`` allows P-state limits to be set in two ways: with the help of
  377. the ``max_perf_pct`` and ``min_perf_pct`` `global attributes
  378. <Global Attributes_>`_ or via the ``scaling_max_freq`` and ``scaling_min_freq``
  379. ``CPUFreq`` policy attributes. The coordination between those limits is based
  380. on the following rules, regardless of the current operation mode of the driver:
  381. 1. All CPUs are affected by the global limits (that is, none of them can be
  382. requested to run faster than the global maximum and none of them can be
  383. requested to run slower than the global minimum).
  384. 2. Each individual CPU is affected by its own per-policy limits (that is, it
  385. cannot be requested to run faster than its own per-policy maximum and it
  386. cannot be requested to run slower than its own per-policy minimum).
  387. 3. The global and per-policy limits can be set independently.
  388. If the `HWP feature is enabled in the processor <Active Mode With HWP_>`_, the
  389. resulting effective values are written into its registers whenever the limits
  390. change in order to request its internal P-state selection logic to always set
  391. P-states within these limits. Otherwise, the limits are taken into account by
  392. scaling governors (in the `passive mode <Passive Mode_>`_) and by the driver
  393. every time before setting a new P-state for a CPU.
  394. Additionally, if the ``intel_pstate=per_cpu_perf_limits`` command line argument
  395. is passed to the kernel, ``max_perf_pct`` and ``min_perf_pct`` are not exposed
  396. at all and the only way to set the limits is by using the policy attributes.
  397. Energy vs Performance Hints
  398. ---------------------------
  399. If ``intel_pstate`` works in the `active mode with the HWP feature enabled
  400. <Active Mode With HWP_>`_ in the processor, additional attributes are present
  401. in every ``CPUFreq`` policy directory in ``sysfs``. They are intended to allow
  402. user space to help ``intel_pstate`` to adjust the processor's internal P-state
  403. selection logic by focusing it on performance or on energy-efficiency, or
  404. somewhere between the two extremes:
  405. ``energy_performance_preference``
  406. Current value of the energy vs performance hint for the given policy
  407. (or the CPU represented by it).
  408. The hint can be changed by writing to this attribute.
  409. ``energy_performance_available_preferences``
  410. List of strings that can be written to the
  411. ``energy_performance_preference`` attribute.
  412. They represent different energy vs performance hints and should be
  413. self-explanatory, except that ``default`` represents whatever hint
  414. value was set by the platform firmware.
  415. Strings written to the ``energy_performance_preference`` attribute are
  416. internally translated to integer values written to the processor's
  417. Energy-Performance Preference (EPP) knob (if supported) or its
  418. Energy-Performance Bias (EPB) knob.
  419. [Note that tasks may by migrated from one CPU to another by the scheduler's
  420. load-balancing algorithm and if different energy vs performance hints are
  421. set for those CPUs, that may lead to undesirable outcomes. To avoid such
  422. issues it is better to set the same energy vs performance hint for all CPUs
  423. or to pin every task potentially sensitive to them to a specific CPU.]
  424. .. _acpi-cpufreq:
  425. ``intel_pstate`` vs ``acpi-cpufreq``
  426. ====================================
  427. On the majority of systems supported by ``intel_pstate``, the ACPI tables
  428. provided by the platform firmware contain ``_PSS`` objects returning information
  429. that can be used for CPU performance scaling (refer to the `ACPI specification`_
  430. for details on the ``_PSS`` objects and the format of the information returned
  431. by them).
  432. The information returned by the ACPI ``_PSS`` objects is used by the
  433. ``acpi-cpufreq`` scaling driver. On systems supported by ``intel_pstate``
  434. the ``acpi-cpufreq`` driver uses the same hardware CPU performance scaling
  435. interface, but the set of P-states it can use is limited by the ``_PSS``
  436. output.
  437. On those systems each ``_PSS`` object returns a list of P-states supported by
  438. the corresponding CPU which basically is a subset of the P-states range that can
  439. be used by ``intel_pstate`` on the same system, with one exception: the whole
  440. `turbo range <turbo_>`_ is represented by one item in it (the topmost one). By
  441. convention, the frequency returned by ``_PSS`` for that item is greater by 1 MHz
  442. than the frequency of the highest non-turbo P-state listed by it, but the
  443. corresponding P-state representation (following the hardware specification)
  444. returned for it matches the maximum supported turbo P-state (or is the
  445. special value 255 meaning essentially "go as high as you can get").
  446. The list of P-states returned by ``_PSS`` is reflected by the table of
  447. available frequencies supplied by ``acpi-cpufreq`` to the ``CPUFreq`` core and
  448. scaling governors and the minimum and maximum supported frequencies reported by
  449. it come from that list as well. In particular, given the special representation
  450. of the turbo range described above, this means that the maximum supported
  451. frequency reported by ``acpi-cpufreq`` is higher by 1 MHz than the frequency
  452. of the highest supported non-turbo P-state listed by ``_PSS`` which, of course,
  453. affects decisions made by the scaling governors, except for ``powersave`` and
  454. ``performance``.
  455. For example, if a given governor attempts to select a frequency proportional to
  456. estimated CPU load and maps the load of 100% to the maximum supported frequency
  457. (possibly multiplied by a constant), then it will tend to choose P-states below
  458. the turbo threshold if ``acpi-cpufreq`` is used as the scaling driver, because
  459. in that case the turbo range corresponds to a small fraction of the frequency
  460. band it can use (1 MHz vs 1 GHz or more). In consequence, it will only go to
  461. the turbo range for the highest loads and the other loads above 50% that might
  462. benefit from running at turbo frequencies will be given non-turbo P-states
  463. instead.
  464. One more issue related to that may appear on systems supporting the
  465. `Configurable TDP feature <turbo_>`_ allowing the platform firmware to set the
  466. turbo threshold. Namely, if that is not coordinated with the lists of P-states
  467. returned by ``_PSS`` properly, there may be more than one item corresponding to
  468. a turbo P-state in those lists and there may be a problem with avoiding the
  469. turbo range (if desirable or necessary). Usually, to avoid using turbo
  470. P-states overall, ``acpi-cpufreq`` simply avoids using the topmost state listed
  471. by ``_PSS``, but that is not sufficient when there are other turbo P-states in
  472. the list returned by it.
  473. Apart from the above, ``acpi-cpufreq`` works like ``intel_pstate`` in the
  474. `passive mode <Passive Mode_>`_, except that the number of P-states it can set
  475. is limited to the ones listed by the ACPI ``_PSS`` objects.
  476. Kernel Command Line Options for ``intel_pstate``
  477. ================================================
  478. Several kernel command line options can be used to pass early-configuration-time
  479. parameters to ``intel_pstate`` in order to enforce specific behavior of it. All
  480. of them have to be prepended with the ``intel_pstate=`` prefix.
  481. ``disable``
  482. Do not register ``intel_pstate`` as the scaling driver even if the
  483. processor is supported by it.
  484. ``passive``
  485. Register ``intel_pstate`` in the `passive mode <Passive Mode_>`_ to
  486. start with.
  487. This option implies the ``no_hwp`` one described below.
  488. ``force``
  489. Register ``intel_pstate`` as the scaling driver instead of
  490. ``acpi-cpufreq`` even if the latter is preferred on the given system.
  491. This may prevent some platform features (such as thermal controls and
  492. power capping) that rely on the availability of ACPI P-states
  493. information from functioning as expected, so it should be used with
  494. caution.
  495. This option does not work with processors that are not supported by
  496. ``intel_pstate`` and on platforms where the ``pcc-cpufreq`` scaling
  497. driver is used instead of ``acpi-cpufreq``.
  498. ``no_hwp``
  499. Do not enable the `hardware-managed P-states (HWP) feature
  500. <Active Mode With HWP_>`_ even if it is supported by the processor.
  501. ``hwp_only``
  502. Register ``intel_pstate`` as the scaling driver only if the
  503. `hardware-managed P-states (HWP) feature <Active Mode With HWP_>`_ is
  504. supported by the processor.
  505. ``support_acpi_ppc``
  506. Take ACPI ``_PPC`` performance limits into account.
  507. If the preferred power management profile in the FADT (Fixed ACPI
  508. Description Table) is set to "Enterprise Server" or "Performance
  509. Server", the ACPI ``_PPC`` limits are taken into account by default
  510. and this option has no effect.
  511. ``per_cpu_perf_limits``
  512. Use per-logical-CPU P-State limits (see `Coordination of P-state
  513. Limits`_ for details).
  514. Diagnostics and Tuning
  515. ======================
  516. Trace Events
  517. ------------
  518. There are two static trace events that can be used for ``intel_pstate``
  519. diagnostics. One of them is the ``cpu_frequency`` trace event generally used
  520. by ``CPUFreq``, and the other one is the ``pstate_sample`` trace event specific
  521. to ``intel_pstate``. Both of them are triggered by ``intel_pstate`` only if
  522. it works in the `active mode <Active Mode_>`_.
  523. The following sequence of shell commands can be used to enable them and see
  524. their output (if the kernel is generally configured to support event tracing)::
  525. # cd /sys/kernel/debug/tracing/
  526. # echo 1 > events/power/pstate_sample/enable
  527. # echo 1 > events/power/cpu_frequency/enable
  528. # cat trace
  529. gnome-terminal--4510 [001] ..s. 1177.680733: pstate_sample: core_busy=107 scaled=94 from=26 to=26 mperf=1143818 aperf=1230607 tsc=29838618 freq=2474476
  530. cat-5235 [002] ..s. 1177.681723: cpu_frequency: state=2900000 cpu_id=2
  531. If ``intel_pstate`` works in the `passive mode <Passive Mode_>`_, the
  532. ``cpu_frequency`` trace event will be triggered either by the ``schedutil``
  533. scaling governor (for the policies it is attached to), or by the ``CPUFreq``
  534. core (for the policies with other scaling governors).
  535. ``ftrace``
  536. ----------
  537. The ``ftrace`` interface can be used for low-level diagnostics of
  538. ``intel_pstate``. For example, to check how often the function to set a
  539. P-state is called, the ``ftrace`` filter can be set to to
  540. :c:func:`intel_pstate_set_pstate`::
  541. # cd /sys/kernel/debug/tracing/
  542. # cat available_filter_functions | grep -i pstate
  543. intel_pstate_set_pstate
  544. intel_pstate_cpu_init
  545. ...
  546. # echo intel_pstate_set_pstate > set_ftrace_filter
  547. # echo function > current_tracer
  548. # cat trace | head -15
  549. # tracer: function
  550. #
  551. # entries-in-buffer/entries-written: 80/80 #P:4
  552. #
  553. # _-----=> irqs-off
  554. # / _----=> need-resched
  555. # | / _---=> hardirq/softirq
  556. # || / _--=> preempt-depth
  557. # ||| / delay
  558. # TASK-PID CPU# |||| TIMESTAMP FUNCTION
  559. # | | | |||| | |
  560. Xorg-3129 [000] ..s. 2537.644844: intel_pstate_set_pstate <-intel_pstate_timer_func
  561. gnome-terminal--4510 [002] ..s. 2537.649844: intel_pstate_set_pstate <-intel_pstate_timer_func
  562. gnome-shell-3409 [001] ..s. 2537.650850: intel_pstate_set_pstate <-intel_pstate_timer_func
  563. <idle>-0 [000] ..s. 2537.654843: intel_pstate_set_pstate <-intel_pstate_timer_func
  564. .. _LCEU2015: http://events.linuxfoundation.org/sites/events/files/slides/LinuxConEurope_2015.pdf
  565. .. _SDM: http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-software-developer-system-programming-manual-325384.html
  566. .. _ACPI specification: http://www.uefi.org/sites/default/files/resources/ACPI_6_1.pdf