1. 20 Nov, 2019 1 commit
    • Daniel Lezcano's avatar
      cpuidle: Allow idle injection to apply exit latency limit · c55b51a0
      Daniel Lezcano authored
      In some cases it may be useful to specify an exit latency limit for
      the idle state to be used during CPU idle time injection.
      
      Instead of duplicating the information in struct cpuidle_device
      or propagating the latency limit in the call stack, replace the
      use_deepest_state field with forced_latency_limit_ns to represent
      that limit, so that the deepest idle state with exit latency within
      that limit is forced (i.e. no governors) when it is set.
      
      A zero exit latency limit for forced idle means to use governors in
      the usual way (analogous to use_deepest_state equal to "false" before
      this change).
      
      Additionally, add play_idle_precise() taking two arguments, the
      duration of forced idle and the idle state exit latency limit, both
      in nanoseconds, and redefine play_idle() as a wrapper around that
      new function.
      
      This change is preparatory, no functional impact is expected.
      Suggested-by: default avatarRafael J. Wysocki <rafael@kernel.org>
      Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
      [ rjw: Subject, changelog, cpuidle_use_deepest_state() kerneldoc, whitespace ]
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      c55b51a0
  2. 19 Nov, 2019 1 commit
  3. 14 Nov, 2019 1 commit
  4. 13 Nov, 2019 2 commits
    • Rafael J. Wysocki's avatar
      cpuidle: teo: Avoid using "early hits" incorrectly · 63f202e5
      Rafael J. Wysocki authored
      If the current state with the maximum "early hits" metric in
      teo_select() is also the one "matching" the expected idle duration,
      it will be used as the candidate one for selection even if its
      "misses" metric is greater than its "hits" metric, which is not
      correct.
      
      In that case, the candidate state should be shallower than the
      current one and its "early hits" metric should be the maximum
      among the idle states shallower than the current one.
      
      To make that happen, modify teo_select() to save the index of
      the state whose "early hits" metric is the maximum for the
      range of states below the current one and go back to that state
      if it turns out that the current one should be rejected.
      
      Fixes: 159e4856 ("cpuidle: teo: Fix "early hits" handling for disabled idle states")
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      63f202e5
    • Rafael J. Wysocki's avatar
      cpuidle: teo: Exclude cpuidle overhead from computations · b6495b7f
      Rafael J. Wysocki authored
      One purpose of the computations in teo_update() is to determine
      whether or not the (saved) time till the next timer event and the
      measured idle duration fall into the same "bin", so avoid using
      values that include the cpuidle overhead to obtain the latter.
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      b6495b7f
  5. 11 Nov, 2019 1 commit
    • Rafael J. Wysocki's avatar
      cpuidle: Use nanoseconds as the unit of time · c1d51f68
      Rafael J. Wysocki authored
      Currently, the cpuidle subsystem uses microseconds as the unit of
      time which (among other things) causes the idle loop to incur some
      integer division overhead for no clear benefit.
      
      In order to allow cpuidle to measure time in nanoseconds, add two
      new fields, exit_latency_ns and target_residency_ns, to represent the
      exit latency and target residency of an idle state in nanoseconds,
      respectively, to struct cpuidle_state and initialize them with the
      help of the corresponding values in microseconds provided by drivers.
      Additionally, change cpuidle_governor_latency_req() to return the
      idle state exit latency constraint in nanoseconds.
      
      Also meeasure idle state residency (last_residency_ns in struct
      cpuidle_device and time_ns in struct cpuidle_driver) in nanoseconds
      and update the cpuidle core and governors accordingly.
      
      However, the menu governor still computes typical intervals in
      microseconds to avoid integer overflows.
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarDoug Smythies <dsmythies@telus.net>
      Tested-by: default avatarDoug Smythies <dsmythies@telus.net>
      c1d51f68
  6. 06 Nov, 2019 1 commit
    • Rafael J. Wysocki's avatar
      cpuidle: Consolidate disabled state checks · 99e98d3f
      Rafael J. Wysocki authored
      There are two reasons why CPU idle states may be disabled: either
      because the driver has disabled them or because they have been
      disabled by user space via sysfs.
      
      In the former case, the state's "disabled" flag is set once during
      the initialization of the driver and it is never cleared later (it
      is read-only effectively).  In the latter case, the "disable" field
      of the given state's cpuidle_state_usage struct is set and it may be
      changed via sysfs.  Thus checking whether or not an idle state has
      been disabled involves reading these two flags every time.
      
      In order to avoid the additional check of the state's "disabled" flag
      (which is effectively read-only anyway), use the value of it at the
      init time to set a (new) flag in the "disable" field of that state's
      cpuidle_state_usage structure and use the sysfs interface to
      manipulate another (new) flag in it.  This way the state is disabled
      whenever the "disable" field of its cpuidle_state_usage structure is
      nonzero, whatever the reason, and it is the only place to look into
      to check whether or not the state has been disabled.
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      99e98d3f
  7. 25 Oct, 2019 1 commit
    • Yin Fengwei's avatar
      ACPI: processor_idle: Skip dummy wait if kernel is in guest · fa583f71
      Yin Fengwei authored
      In function acpi_idle_do_entry(), an ioport access is used for
      dummy wait to guarantee hardware behavior. But it could trigger
      unnecessary VMexit if kernel is running as guest in virtualization
      environment.
      
      If it's in virtualization environment, the deeper C state enter
      operation (inb()) will trap to hypervisor. It's not needed to do
      dummy wait after the inb() call. So we could just remove the
      dummy io port access to avoid unnecessary VMexit.
      
      And keep dummy io port access to maintain timing for native
      environment.
      Signed-off-by: default avatarYin Fengwei <fengwei.yin@intel.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      fa583f71
  8. 24 Oct, 2019 2 commits
  9. 22 Oct, 2019 1 commit
  10. 20 Oct, 2019 6 commits
  11. 19 Oct, 2019 23 commits