1. 05 7月, 2019 1 次提交
  2. 25 8月, 2018 1 次提交
    • R
      cpuidle: menu: Retain tick when shallow state is selected · 757ab15c
      Rafael J. Wysocki 提交于
      The case addressed by commit 5ef499cd (cpuidle: menu: Handle
      stopped tick more aggressively) in the stopped tick case is present
      when the tick has not been stopped yet too.  Namely, if only two CPU
      idle states, shallow state A with target residency significantly
      below the tick boundary and deep state B with target residency
      significantly above it, are available and the predicted idle
      duration is above the tick boundary, but below the target residency
      of state B, state A will be selected and the CPU may spend indefinite
      amount of time in it, which is not quite energy-efficient.
      
      However, if the tick has not been stopped yet and the governor is
      about to select a shallow idle state for the CPU even though the idle
      duration predicted by it is above the tick boundary, it should be
      fine to wake up the CPU early, so the tick can be retained then and
      the governor will have a chance to select a deeper state when it runs
      next time.
      
      [Note that when this really happens, it will make the idle duration
       predictor believe that the CPU might be idle longer than predicted,
       which will make it more likely to predict longer idle durations going
       forward, but that will also cause deeper idle states to be selected
       going forward, on average, which is what's needed here.]
      
      Fixes: 87c9fe6e (cpuidle: menu: Avoid selecting shallow states with stopped tick)
      Reported-by: NLeo Yan <leo.yan@linaro.org>
      Cc: 4.17+ <stable@vger.kernel.org> # 4.17+: 5ef499cd (cpuidle: menu: Handle ...)
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      757ab15c
  3. 20 8月, 2018 1 次提交
    • R
      cpuidle: menu: Handle stopped tick more aggressively · 5ef499cd
      Rafael J. Wysocki 提交于
      Commit 87c9fe6e (cpuidle: menu: Avoid selecting shallow states
      with stopped tick) missed the case when the target residencies of
      deep idle states of CPUs are above the tick boundary which may cause
      the CPU to get stuck in a shallow idle state for a long time.
      
      Say there are two CPU idle states available: one shallow, with the
      target residency much below the tick boundary and one deep, with
      the target residency significantly above the tick boundary.  In
      that case, if the tick has been stopped already and the expected
      next timer event is relatively far in the future, the governor will
      assume the idle duration to be equal to TICK_USEC and it will select
      the idle state for the CPU accordingly.  However, that will cause the
      shallow state to be selected even though it would have been more
      energy-efficient to select the deep one.
      
      To address this issue, modify the governor to always use the time
      till the closest timer event instead of the predicted idle duration
      if the latter is less than the tick period length and the tick has
      been stopped already.  Also make it extend the search for a matching
      idle state if the tick is stopped to avoid settling on a shallow
      state if deep states with target residencies above the tick period
      length are available.
      
      In addition, make it always indicate that the tick should be stopped
      if it has been stopped already for consistency.
      
      Fixes: 87c9fe6e (cpuidle: menu: Avoid selecting shallow states with stopped tick)
      Reported-by: NLeo Yan <leo.yan@linaro.org>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: 4.17+ <stable@vger.kernel.org> # 4.17+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      5ef499cd
  4. 17 8月, 2018 1 次提交
  5. 15 8月, 2018 1 次提交
  6. 31 5月, 2018 2 次提交
  7. 09 4月, 2018 2 次提交
  8. 06 4月, 2018 1 次提交
    • R
      cpuidle: Return nohz hint from cpuidle_select() · 45f1ff59
      Rafael J. Wysocki 提交于
      Add a new pointer argument to cpuidle_select() and to the ->select
      cpuidle governor callback to allow a boolean value indicating
      whether or not the tick should be stopped before entering the
      selected state to be returned from there.
      
      Make the ladder governor ignore that pointer (to preserve its
      current behavior) and make the menu governor return 'false" through
      it if:
       (1) the idle exit latency is constrained at 0, or
       (2) the selected state is a polling one, or
       (3) the expected idle period duration is within the tick period
           range.
      
      In addition to that, the correction factor computations in the menu
      governor need to take the possibility that the tick may not be
      stopped into account to avoid artificially small correction factor
      values.  To that end, add a mechanism to record tick wakeups, as
      suggested by Peter Zijlstra, and use it to modify the menu_update()
      behavior when tick wakeup occurs.  Namely, if the CPU is woken up by
      the tick and the return value of tick_nohz_get_sleep_length() is not
      within the tick boundary, the predicted idle duration is likely too
      short, so make menu_update() try to compensate for that by updating
      the governor statistics as though the CPU was idle for a long time.
      
      Since the value returned through the new argument pointer of
      cpuidle_select() is not used by its caller yet, this change by
      itself is not expected to alter the functionality of the code.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      45f1ff59
  9. 08 11月, 2017 1 次提交
  10. 01 11月, 2017 1 次提交
  11. 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
  12. 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
  13. 30 6月, 2017 1 次提交
  14. 02 3月, 2017 2 次提交
  15. 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
  16. 30 1月, 2017 2 次提交
  17. 21 10月, 2016 1 次提交
  18. 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
  19. 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
  20. 17 2月, 2016 2 次提交
  21. 19 1月, 2016 1 次提交
  22. 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
  23. 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
  24. 05 5月, 2015 1 次提交
  25. 17 4月, 2015 1 次提交
  26. 17 12月, 2014 1 次提交
  27. 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
  28. 27 8月, 2014 1 次提交
  29. 07 8月, 2014 4 次提交
  30. 28 7月, 2014 1 次提交