1. 17 9月, 2020 1 次提交
  2. 26 8月, 2020 1 次提交
  3. 30 7月, 2020 1 次提交
    • N
      cpuidle: change enter_s2idle() prototype · efe97112
      Neal Liu 提交于
      Control Flow Integrity(CFI) is a security mechanism that disallows
      changes to the original control flow graph of a compiled binary,
      making it significantly harder to perform such attacks.
      
      init_state_node() assign same function callback to different
      function pointer declarations.
      
      static int init_state_node(struct cpuidle_state *idle_state,
                                 const struct of_device_id *matches,
                                 struct device_node *state_node) { ...
              idle_state->enter = match_id->data; ...
              idle_state->enter_s2idle = match_id->data; }
      
      Function declarations:
      
      struct cpuidle_state { ...
              int (*enter) (struct cpuidle_device *dev,
                            struct cpuidle_driver *drv,
                            int index);
      
              void (*enter_s2idle) (struct cpuidle_device *dev,
                                    struct cpuidle_driver *drv,
                                    int index); };
      
      In this case, either enter() or enter_s2idle() would cause CFI check
      failed since they use same callee.
      
      Align function prototype of enter() since it needs return value for
      some use cases. The return value of enter_s2idle() is no
      need currently.
      Signed-off-by: NNeal Liu <neal.liu@mediatek.com>
      Reviewed-by: NSami Tolvanen <samitolvanen@google.com>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      efe97112
  4. 09 1月, 2020 1 次提交
  5. 27 12月, 2019 1 次提交
    • R
      cpuidle: Allow idle states to be disabled by default · 75a80267
      Rafael J. Wysocki 提交于
      In certain situations it may be useful to prevent some idle states
      from being used by default while allowing user space to enable them
      later on.
      
      For this purpose, introduce a new state flag, CPUIDLE_FLAG_OFF, to
      mark idle states that should be disabled by default, make the core
      set CPUIDLE_STATE_DISABLED_BY_USER for those states at the
      initialization time and add a new state attribute in sysfs,
      "default_status", to inform user space of the initial status of
      the given idle state ("disabled" if CPUIDLE_FLAG_OFF is set for it,
      "enabled" otherwise).
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      75a80267
  6. 29 11月, 2019 1 次提交
    • R
      cpuidle: Drop disabled field from struct cpuidle_state · ba1e78a1
      Rafael J. Wysocki 提交于
      After recent cpuidle updates the "disabled" field in struct
      cpuidle_state is only used by two drivers (intel_idle and shmobile
      cpuidle) for marking unusable idle states, but that may as well be
      achieved with the help of a state flag, so define an "unusable" idle
      state flag, CPUIDLE_FLAG_UNUSABLE, make the drivers in question use
      it instead of the "disabled" field and make the core set
      CPUIDLE_STATE_DISABLED_BY_DRIVER for the idle states with that flag
      set.
      
      After the above changes, the "disabled" field in struct cpuidle_state
      is not used any more, so drop it.
      
      No intentional functional impact.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      ba1e78a1
  7. 20 11月, 2019 2 次提交
  8. 19 11月, 2019 1 次提交
  9. 12 11月, 2019 1 次提交
    • R
      cpuidle: Use nanoseconds as the unit of time · c1d51f68
      Rafael J. Wysocki 提交于
      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: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NDoug Smythies <dsmythies@telus.net>
      Tested-by: NDoug Smythies <dsmythies@telus.net>
      c1d51f68
  10. 06 11月, 2019 1 次提交
    • R
      cpuidle: Consolidate disabled state checks · 99e98d3f
      Rafael J. Wysocki 提交于
      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: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      99e98d3f
  11. 11 9月, 2019 1 次提交
  12. 10 8月, 2019 1 次提交
    • L
      PSCI: cpuidle: Refactor CPU suspend power_state parameter handling · 9ffeb6d0
      Lorenzo Pieralisi 提交于
      Current PSCI code handles idle state entry through the
      psci_cpu_suspend_enter() API, that takes an idle state index as a
      parameter and convert the index into a previously initialized
      power_state parameter before calling the PSCI.CPU_SUSPEND() with it.
      
      This is unwieldly, since it forces the PSCI firmware layer to keep track
      of power_state parameter for every idle state so that the
      index->power_state conversion can be made in the PSCI firmware layer
      instead of the CPUidle driver implementations.
      
      Move the power_state handling out of drivers/firmware/psci
      into the respective ACPI/DT PSCI CPUidle backends and convert
      the psci_cpu_suspend_enter() API to get the power_state
      parameter as input, which makes it closer to its firmware
      interface PSCI.CPU_SUSPEND() API.
      
      A notable side effect is that the PSCI ACPI/DT CPUidle backends
      now can directly handle (and if needed update) power_state
      parameters before handing them over to the PSCI firmware
      interface to trigger PSCI.CPU_SUSPEND() calls.
      Signed-off-by: NLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Acked-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Reviewed-by: NUlf Hansson <ulf.hansson@linaro.org>
      Reviewed-by: NSudeep Holla <sudeep.holla@arm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Ulf Hansson <ulf.hansson@linaro.org>
      Cc: Sudeep Holla <sudeep.holla@arm.com>
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Signed-off-by: NWill Deacon <will@kernel.org>
      9ffeb6d0
  13. 31 7月, 2019 1 次提交
  14. 30 7月, 2019 2 次提交
  15. 10 4月, 2019 1 次提交
    • U
      cpuidle: Export the next timer expiration for CPUs · 6f9b83ac
      Ulf Hansson 提交于
      To be able to predict the sleep duration for a CPU entering idle, it
      is essential to know the expiration time of the next timer.  Both the
      teo and the menu cpuidle governors already use this information for
      CPU idle state selection.
      
      Moving forward, a similar prediction needs to be made for a group of
      idle CPUs rather than for a single one and the following changes
      implement a new genpd governor for that purpose.
      
      In order to support that feature, add a new function called
      tick_nohz_get_next_hrtimer() that will return the next hrtimer
      expiration time of a given CPU to be invoked after deciding
      whether or not to stop the scheduler tick on that CPU.
      
      Make the cpuidle core call tick_nohz_get_next_hrtimer() right
      before invoking the ->enter() callback provided by the cpuidle
      driver for the given state and store its return value in the
      per-CPU struct cpuidle_device, so as to make it available to code
      outside of cpuidle.
      
      Note that at the point when cpuidle calls tick_nohz_get_next_hrtimer(),
      the governor's ->select() callback has already returned and indicated
      whether or not the tick should be stopped, so in fact the value
      returned by tick_nohz_get_next_hrtimer() always is the next hrtimer
      expiration time for the given CPU, possibly including the tick (if
      it hasn't been stopped).
      Co-developed-by: NLina Iyer <lina.iyer@linaro.org>
      Co-developed-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Acked-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      [ rjw: Subject & changelog ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      6f9b83ac
  16. 18 1月, 2019 1 次提交
  17. 13 12月, 2018 1 次提交
  18. 04 10月, 2018 1 次提交
    • R
      cpuidle: menu: Fix wakeup statistics updates for polling state · 5f26bdce
      Rafael J. Wysocki 提交于
      If the CPU exits the "polling" state due to the time limit in the
      loop in poll_idle(), this is not a real wakeup and it just means
      that the "polling" state selection was not adequate.  The governor
      mispredicted short idle duration, but had a more suitable state been
      selected, the CPU might have spent more time in it.  In fact, there
      is no reason to expect that there would have been a wakeup event
      earlier than the next timer in that case.
      
      Handling such cases as regular wakeups in menu_update() may cause the
      menu governor to make suboptimal decisions going forward, but ignoring
      them altogether would not be correct either, because every time
      menu_select() is invoked, it makes a separate new attempt to predict
      the idle duration taking distinct time to the closest timer event as
      input and the outcomes of all those attempts should be recorded.
      
      For this reason, make menu_update() always assume that if the
      "polling" state was exited due to the time limit, the next proper
      wakeup event for the CPU would be the next timer event (not
      including the tick).
      
      Fixes: a37b969a "cpuidle: poll_state: Add time limit to poll_idle()"
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      5f26bdce
  19. 18 9月, 2018 1 次提交
    • F
      cpuidle: Remove unnecessary wrapper cpuidle_get_last_residency() · 6a5f95b5
      Fieah Lim 提交于
      cpuidle_get_last_residency() is just a wrapper for retrieving
      the last_residency member of struct cpuidle_device.  It's also
      weirdly the only wrapper function for accessing cpuidle_* struct
      member (by my best guess is it could be a leftover from v2.x).
      
      Anyhow, since the only two users (the ladder and menu governors)
      can access dev->last_residency directly, and it's more intuitive to
      do it that way, let's just get rid of the wrapper.
      
      This patch tidies up CPU idle code a bit without functional changes.
      Signed-off-by: NFieah Lim <kw@fieahl.im>
      [ rjw: Changelog cleanup ]
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      6a5f95b5
  20. 31 5月, 2018 1 次提交
  21. 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
  22. 29 3月, 2018 1 次提交
    • R
      PM: cpuidle/suspend: Add s2idle usage and time state attributes · 64bdff69
      Rafael J. Wysocki 提交于
      Add a new attribute group called "s2idle" under the sysfs directory
      of each cpuidle state that supports the ->enter_s2idle callback
      and put two new attributes, "usage" and "time", into that group to
      represent the number of times the given state was requested for
      suspend-to-idle and the total time spent in suspend-to-idle after
      requesting that state, respectively.
      
      That will allow diagnostic information related to suspend-to-idle
      to be collected without enabling advanced debug features and
      analyzing dmesg output.
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      64bdff69
  23. 12 2月, 2018 1 次提交
  24. 02 1月, 2018 1 次提交
    • P
      cpuidle: Add new macro to enter a retention idle state · db50a74d
      Prashanth Prakash 提交于
      If a CPU is entering a low power idle state where it doesn't lose any
      context, then there is no need to call cpu_pm_enter()/cpu_pm_exit().
      Add a new macro(CPU_PM_CPU_IDLE_ENTER_RETENTION) to be used by cpuidle
      drivers when they are entering retention state. By not calling
      cpu_pm_enter and cpu_pm_exit we reduce the latency involved in
      entering and exiting the retention idle states.
      
      CPU_PM_CPU_IDLE_ENTER_RETENTION assumes that no state is lost and
      hence CPU PM notifiers will not be called. We may need a broader
      change if we need to support partial retention states effeciently.
      
      On ARM64 based Qualcomm Server Platform we measured below overhead for
      for calling cpu_pm_enter and cpu_pm_exit for retention states.
      
      workload: stress --hdd #CPUs --hdd-bytes 32M  -t 30
              Average overhead of cpu_pm_enter - 1.2us
              Average overhead of cpu_pm_exit  - 3.1us
      Acked-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Acked-by: NSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: NPrashanth Prakash <pprakash@codeaurora.org>
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      db50a74d
  25. 30 8月, 2017 3 次提交
  26. 11 8月, 2017 1 次提交
  27. 31 1月, 2017 1 次提交
  28. 29 11月, 2016 1 次提交
  29. 21 10月, 2016 1 次提交
  30. 22 7月, 2016 1 次提交
  31. 03 6月, 2016 1 次提交
    • C
      cpuidle: Do not access cpuidle_devices when !CONFIG_CPU_IDLE · 9bd616e3
      Catalin Marinas 提交于
      The cpuidle_devices per-CPU variable is only defined when CPU_IDLE is
      enabled. Commit c8cc7d4d ("sched/idle: Reorganize the idle loop")
      removed the #ifdef CONFIG_CPU_IDLE around cpuidle_idle_call() with the
      compiler optimising away __this_cpu_read(cpuidle_devices). However, with
      CONFIG_UBSAN && !CONFIG_CPU_IDLE, this optimisation no longer happens
      and the kernel fails to link since cpuidle_devices is not defined.
      
      This patch introduces an accessor function for the current CPU cpuidle
      device (returning NULL when !CONFIG_CPU_IDLE) and uses it in
      cpuidle_idle_call().
      Signed-off-by: NCatalin Marinas <catalin.marinas@arm.com>
      Cc: 4.5+ <stable@vger.kernel.org> # 4.5+
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      9bd616e3
  32. 28 8月, 2015 1 次提交
  33. 19 5月, 2015 1 次提交
  34. 15 5月, 2015 2 次提交
  35. 03 4月, 2015 1 次提交