1. 01 11月, 2017 1 次提交
  2. 24 10月, 2017 1 次提交
    • R
      PM / QoS: Fix device resume latency PM QoS · 0cc2b4e5
      Rafael J. Wysocki 提交于
      The special value of 0 for device resume latency PM QoS means
      "no restriction", but there are two problems with that.
      
      First, device resume latency PM QoS requests with 0 as the
      value are always put in front of requests with positive
      values in the priority lists used internally by the PM QoS
      framework, causing 0 to be chosen as an effective constraint
      value.  However, that 0 is then interpreted as "no restriction"
      effectively overriding the other requests with specific
      restrictions which is incorrect.
      
      Second, the users of device resume latency PM QoS have no
      way to specify that *any* resume latency at all should be
      avoided, which is an artificial limitation in general.
      
      To address these issues, modify device resume latency PM QoS to
      use S32_MAX as the "no constraint" value and 0 as the "no
      latency at all" one and rework its users (the cpuidle menu
      governor, the genpd QoS governor and the runtime PM framework)
      to follow these changes.
      
      Also add a special "n/a" value to the corresponding user space I/F
      to allow user space to indicate that it cannot accept any resume
      latencies at all for the given device.
      
      Fixes: 85dc0b8a (PM / QoS: Make it possible to expose PM QoS latency constraints)
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=197323Reported-by: NReinette Chatre <reinette.chatre@intel.com>
      Tested-by: NReinette Chatre <reinette.chatre@intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NAlex Shi <alex.shi@linaro.org>
      Cc: All applicable <stable@vger.kernel.org>
      0cc2b4e5
  3. 30 8月, 2017 1 次提交
    • R
      cpuidle: Eliminate the CPUIDLE_DRIVER_STATE_START symbol · dc2251bf
      Rafael J. Wysocki 提交于
      On some architectures the first (index 0) idle state is a polling
      one and it doesn't really save energy, so there is the
      CPUIDLE_DRIVER_STATE_START symbol allowing some pieces of
      cpuidle code to avoid using that state.
      
      However, this makes the code rather hard to follow.  It is better
      to explicitly avoid the polling state, so add a new cpuidle state
      flag CPUIDLE_FLAG_POLLING to mark it and make the relevant code
      check that flag for the first state instead of using the
      CPUIDLE_DRIVER_STATE_START symbol.
      
      In the ACPI processor driver that cannot always rely on the state
      flags (like before the states table has been set up) define
      a new internal symbol ACPI_IDLE_STATE_START equivalent to the
      CPUIDLE_DRIVER_STATE_START one and drop the latter.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Tested-by: NSudeep Holla <sudeep.holla@arm.com>
      Acked-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      dc2251bf
  4. 30 6月, 2017 1 次提交
  5. 02 3月, 2017 2 次提交
  6. 27 2月, 2017 1 次提交
    • R
      cpuidle: menu: Avoid taking spinlock for accessing QoS values · 6dbf5cea
      Rafael J. Wysocki 提交于
      After commit 9908859a (cpuidle/menu: add per CPU PM QoS resume
      latency consideration) the cpuidle menu governor calls
      dev_pm_qos_read_value() on CPU devices to read the current resume
      latency QoS constraint values for them.  That function takes a spinlock
      to prevent the device's power.qos pointer from becoming NULL during
      the access which is a problem for the RT patchset where spinlocks are
      converted into mutexes and the idle loop stops working.
      
      However, it is not even necessary for the menu governor to take
      that spinlock, because the power.qos pointer accessed under it
      cannot be modified during the access anyway.
      
      For this reason, introduce a "raw" routine for accessing device
      QoS resume latency constraints without locking and use it in the
      menu governor.
      
      Fixes: 9908859a (cpuidle/menu: add per CPU PM QoS resume latency consideration)
      Acked-by: NAlex Shi <alex.shi@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      6dbf5cea
  7. 30 1月, 2017 2 次提交
  8. 21 10月, 2016 1 次提交
  9. 21 3月, 2016 1 次提交
    • R
      cpuidle: menu: Fall back to polling if next timer event is near · 0c313cb2
      Rafael J. Wysocki 提交于
      Commit a9ceb78b (cpuidle,menu: use interactivity_req to disable
      polling) changed the behavior of the fallback state selection part
      of menu_select() so it looks at interactivity_req instead of
      data->next_timer_us when it makes its decision.  That effectively
      caused polling to be used more often as fallback idle which led to
      significant increases of energy consumption in some cases.
      
      Commit e132b9b3 (cpuidle: menu: use high confidence factors
      only when considering polling) changed that logic again to be more
      predictable, but that didn't help with the increased energy
      consumption problem.
      
      For this reason, go back to making decisions on which state to fall
      back to based on data->next_timer_us which is the time we know for
      sure something will happen rather than a prediction (which may be
      inaccurate and turns out to be so often enough to be problematic).
      However, take the target residency of the first proper idle state
      (C1) into account, so that state is not used as the fallback one
      if its target residency is greater than data->next_timer_us.
      
      Fixes: a9ceb78b (cpuidle,menu: use interactivity_req to disable polling)
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Reported-and-tested-by: NDoug Smythies <dsmythies@telus.net>
      0c313cb2
  10. 17 3月, 2016 1 次提交
    • R
      cpuidle: menu: use high confidence factors only when considering polling · e132b9b3
      Rik van Riel 提交于
      The menu governor uses five different factors to pick the
      idle state:
       - the user configured latency_req
       - the time until the next timer (next_timer_us)
       - the typical sleep interval, as measured recently
       - an estimate of sleep time by dividing next_timer_us by an observed factor
       - a load corrected version of the above, divided again by load
      
      Only the first three items are known with enough confidence that
      we can use them to consider polling, instead of an actual CPU
      idle state, because the cost of being wrong about polling can be
      excessive power use.
      
      The latter two are used in the menu governor's main selection
      loop, and can result in choosing a shallower idle state when
      the system is expected to be busy again soon.
      
      This pushes a busy system in the "performance" direction of
      the performance<>power tradeoff, when choosing between idle
      states, but stays more strictly on the "power" state when
      deciding between polling and C1.
      Signed-off-by: NRik van Riel <riel@redhat.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      e132b9b3
  11. 17 2月, 2016 2 次提交
  12. 19 1月, 2016 1 次提交
  13. 15 1月, 2016 1 次提交
    • R
      cpuidle: menu: Fix menu_select() for CPUIDLE_DRIVER_STATE_START == 0 · 9c4b2867
      Rafael J. Wysocki 提交于
      Commit a9ceb78b (cpuidle,menu: use interactivity_req to disable
      polling) exposed a bug in menu_select() causing it to return -1
      on systems with CPUIDLE_DRIVER_STATE_START equal to zero, although
      it should have returned 0.  As a result, idle states are not entered
      by CPUs on those systems.
      
      Namely, on the systems in question data->last_state_idx is initially
      equal to -1 and the above commit modified the condition that would
      have caused it to be changed to 0 to be less likely to trigger which
      exposed the problem.  However, setting data->last_state_idx initially
      to -1 doesn't make sense at all and on the affected systems it should
      always be set to CPUIDLE_DRIVER_STATE_START (ie. 0) unconditionally,
      so make that happen.
      
      Fixes: a9ceb78b (cpuidle,menu: use interactivity_req to disable polling)
      Reported-and-tested-by: NSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      9c4b2867
  14. 17 11月, 2015 3 次提交
    • R
      cpuidle,menu: smooth out measured_us calculation · efddfd90
      Rik van Riel 提交于
      The cpuidle state tables contain the maximum exit latency for each
      cpuidle state. On x86, that is the exit latency for when the entire
      package goes into that same idle state.
      
      However, a lot of the time we only go into the core idle state,
      not the package idle state. This means we see a much smaller exit
      latency.
      
      We have no way to detect whether we went into the core or package
      idle state while idle, and that is ok.
      
      However, the current menu_update logic does have the potential to
      trip up the repeating pattern detection in get_typical_interval.
      If the system is experiencing an exit latency near the idle state's
      exit latency, some of the samples will have exit_us subtracted,
      while others will not. This turns a repeating pattern into mush,
      potentially breaking get_typical_interval.
      
      Furthermore, for smaller sleep intervals, we know the chance that
      all the cores in the package went to the same idle state are fairly
      small. Dividing the measured_us by two, instead of subtracting the
      full exit latency when hitting a small measured_us, will reduce the
      error.
      Signed-off-by: NRik van Riel <riel@redhat.com>
      Acked-by: NArjan van de Ven <arjan@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      efddfd90
    • R
      cpuidle,menu: use interactivity_req to disable polling · a9ceb78b
      Rik van Riel 提交于
      The menu governor carefully figures out how much time we typically
      sleep for an estimated sleep interval, or whether there is a repeating
      pattern going on, and corrects that estimate for the CPU load.
      
      Then it proceeds to ignore that information when determining whether
      or not to consider polling. This is not a big deal on most x86 CPUs,
      which have very low C1 latencies, and the patch should not have any
      effect on those CPUs.
      
      However, certain CPUs (eg. Atom) have much higher C1 latencies, and
      it would be good to not waste performance and power on those CPUs if
      we are expecting a very low wakeup latency.
      
      Disable polling based on the estimated interactivity requirement, not
      on the time to the next timer interrupt.
      Signed-off-by: NRik van Riel <riel@redhat.com>
      Acked-by: NArjan van de Ven <arjan@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      a9ceb78b
    • R
      cpuidle,x86: increase forced cut-off for polling to 20us · 7884084f
      Rik van Riel 提交于
      The cpuidle menu governor has a forced cut-off for polling at 5us,
      in order to deal with firmware that gives the OS bad information
      on cpuidle states, leading to the system spending way too much time
      in polling.
      
      However, at least one x86 CPU family (Atom) has chips that have
      a 20us break-even point for C1. Forcing the polling cut-off to
      less than that wastes performance and power.
      
      Increase the polling cut-off to 20us.
      
      Systems with a lower C1 latency will be found in the states table by
      the menu governor, which will pick those states as appropriate.
      Signed-off-by: NRik van Riel <riel@redhat.com>
      Acked-by: NArjan van de Ven <arjan@linux.intel.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      7884084f
  15. 05 5月, 2015 1 次提交
  16. 17 4月, 2015 1 次提交
  17. 17 12月, 2014 1 次提交
  18. 13 11月, 2014 1 次提交
    • D
      cpuidle: Invert CPUIDLE_FLAG_TIME_VALID logic · b82b6cca
      Daniel Lezcano 提交于
      The only place where the time is invalid is when the ACPI_CSTATE_FFH entry
      method is not set. Otherwise for all the drivers, the time can be correctly
      measured.
      
      Instead of duplicating the CPUIDLE_FLAG_TIME_VALID flag in all the drivers
      for all the states, just invert the logic by replacing it by the flag
      CPUIDLE_FLAG_TIME_INVALID, hence we can set this flag only for the acpi idle
      driver, remove the former flag from all the drivers and invert the logic with
      this flag in the different governor.
      Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      b82b6cca
  19. 27 8月, 2014 1 次提交
  20. 07 8月, 2014 4 次提交
  21. 28 7月, 2014 1 次提交
  22. 19 6月, 2014 1 次提交
  23. 01 5月, 2014 2 次提交
  24. 06 3月, 2014 5 次提交
  25. 23 8月, 2013 3 次提交
    • T
      cpuidle: Change struct menu_device field types · 51f245b8
      Tuukka Tikkanen 提交于
      Field predicted_us value can never exceed expected_us value, but it has
      a potentially larger type. As there is no need for additional 32 bits of
      zeroes on 32 bit plaforms, change the type of predicted_us to match the
      type of expected_us.
      
      Field correction_factor is used to store a value that cannot exceed the
      product of RESOLUTION and DECAY (default 1024*8 = 8192). The constants
      cannot in practice be incremented to such values, that they'd overflow
      unsigned int even on 32 bit systems, so the type is changed to avoid
      unnecessary 64 bit arithmetic on 32 bit systems.
      
      One multiplication of (now) 32 bit values needs an added cast to avoid
      truncation of the result and has been added.
      
      In order to avoid another multiplication from 32 bit domain to 64 bit
      domain, the new correction_factor calculation has been changed from
      new = old * (DECAY-1) / DECAY
      to
      new = old - old / DECAY,
      which with infinite precision would yeild exactly the same result, but
      now changes the direction of rounding. The impact is not significant as
      the maximum accumulated difference cannot exceed the value of DECAY,
      which is relatively small compared to product of RESOLUTION and DECAY
      (8 / 8192).
      Signed-off-by: NTuukka Tikkanen <tuukka.tikkanen@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      51f245b8
    • T
      cpuidle: Add a comment warning about possible overflow · decd51bb
      Tuukka Tikkanen 提交于
      The menu governor has a number of tunable constants that may be changed
      in the source. If certain combination of values are chosen, an overflow
      is possible when the correction_factor is being recalculated.
      
      This patch adds a warning regarding this possibility and describes the
      change needed for fixing the issue. The change should not be permanently
      enabled, as it will hurt performance when it is not needed.
      Signed-off-by: NTuukka Tikkanen <tuukka.tikkanen@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      decd51bb
    • T
      cpuidle: Fix variable domains in get_typical_interval() · 0e96d5ad
      Tuukka Tikkanen 提交于
      The menu governor uses a static function get_typical_interval() to
      try to detect a repeating pattern of wakeups. The previous interval
      durations are stored as an array of unsigned ints, but the arithmetic
      in the function is performed exclusively as 64 bit values, even when
      the value stored in a variable is known not to exceed unsigned int,
      which may be smaller and more efficient on some platforms.
      
      This patch changes the types of varibles used to store some
      intermediates, the maximum and and the cutoff threshold to unsigned
      ints. Average and standard deviation are still treated as 64 bit values,
      even when the values are known to be within the domain of unsigned int,
      to avoid casts to ensure correct integer promotion for arithmetic
      operations.
      Signed-off-by: NTuukka Tikkanen <tuukka.tikkanen@linaro.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      0e96d5ad