1. 07 Jan, 2023 3 commits
    • Lukasz Luba's avatar
      cpufreq, sched/util: Optimize operations with single CPU capacity lookup · 948fb4c4
      Lukasz Luba authored
      The max CPU capacity is the same for all CPUs sharing frequency domain.
      There is a way to avoid heavy operations in a loop for each CPU by
      leveraging this knowledge. Thus, simplify the looping code in the
      sugov_next_freq_shared() and drop heavy multiplications. Instead, use
      simple max() to get the highest utilization from these CPUs.
      
      This is useful for platforms with many (4 or 6) little CPUs. We avoid
      heavy 2*PD_CPU_NUM multiplications in that loop, which is called billions
      of times, since it's not limited by the schedutil time delta filter in
      sugov_should_update_freq(). When there was no need to change frequency
      the code bailed out, not updating the sg_policy::last_freq_update_time.
      Then every visit after delta_ns time longer than the
      sg_policy::freq_update_delay_ns goes through and triggers the next
      frequency calculation code. Although, if the next frequency, as outcome
      of that, would be the same as current frequency, we won't update the
      sg_policy::last_freq_update_time and the story will be repeated (in
      a very short period, sometimes a few microseconds).
      
      The max CPU capacity must be fetched every time we are called, due to
      difficulties during the policy setup, where we are not able to get the
      normalized CPU capacity at the right time.
      
      The fetched CPU capacity value is than used in sugov_iowait_apply() to
      calculate the right boost. This required a few changes in the local
      functions and arguments. The capacity value should hopefully be fetched
      once when needed and then passed over CPU registers to those functions.
      Signed-off-by: default avatarLukasz Luba <lukasz.luba@arm.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20221208160256.859-2-lukasz.luba@arm.com
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Patrick Bellasi <patrick.bellasi@arm.com>
      Cc: Vincent Guittot <vincent.guittot@linaro.org>
      Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      948fb4c4
    • Chengming Zhou's avatar
      sched/core: Reorganize ttwu_do_wakeup() and ttwu_do_activate() · 160fb0d8
      Chengming Zhou authored
      ttwu_do_activate() is used for a complete wakeup, in which we will
      activate_task() and use ttwu_do_wakeup() to mark the task runnable
      and perform wakeup-preemption, also call class->task_woken() callback
      and update the rq->idle_stamp.
      
      Since ttwu_runnable() is not a complete wakeup, don't need all those
      done in ttwu_do_wakeup(), so we can move those to ttwu_do_activate()
      to simplify ttwu_do_wakeup(), making it only mark the task runnable
      to be reused in ttwu_runnable() and try_to_wake_up().
      
      This patch should not have any functional changes.
      Suggested-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20221223103257.4962-2-zhouchengming@bytedance.com
      160fb0d8
    • Chengming Zhou's avatar
      sched/core: Micro-optimize ttwu_runnable() · efe09385
      Chengming Zhou authored
      ttwu_runnable() is used as a fast wakeup path when the wakee task
      is running on CPU or runnable on RQ, in both cases we can just
      set its state to TASK_RUNNING to prevent a sleep.
      
      If the wakee task is on_cpu running, we don't need to update_rq_clock()
      or check_preempt_curr().
      
      But if the wakee task is on_rq && !on_cpu (e.g. an IRQ hit before
      the task got to schedule() and the task been preempted), we should
      check_preempt_curr() to see if it can preempt the current running.
      
      This also removes the class->task_woken() callback from ttwu_runnable(),
      which wasn't required per the RT/DL implementations: any required push
      operation would have been queued during class->set_next_task() when p
      got preempted.
      
      ttwu_runnable() also loses the update to rq->idle_stamp, as by definition
      the rq cannot be idle in this scenario.
      Suggested-by: default avatarValentin Schneider <vschneid@redhat.com>
      Suggested-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Reviewed-by: default avatarValentin Schneider <vschneid@redhat.com>
      Reviewed-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Link: https://lore.kernel.org/r/20221223103257.4962-1-zhouchengming@bytedance.com
      efe09385
  2. 05 Jan, 2023 2 commits
  3. 02 Jan, 2023 1 commit
  4. 27 Dec, 2022 28 commits
  5. 25 Dec, 2022 2 commits
    • Linus Torvalds's avatar
      Linux 6.2-rc1 · 1b929c02
      Linus Torvalds authored
      1b929c02
    • Steven Rostedt (Google)'s avatar
      treewide: Convert del_timer*() to timer_shutdown*() · 292a089d
      Steven Rostedt (Google) authored
      Due to several bugs caused by timers being re-armed after they are
      shutdown and just before they are freed, a new state of timers was added
      called "shutdown".  After a timer is set to this state, then it can no
      longer be re-armed.
      
      The following script was run to find all the trivial locations where
      del_timer() or del_timer_sync() is called in the same function that the
      object holding the timer is freed.  It also ignores any locations where
      the timer->function is modified between the del_timer*() and the free(),
      as that is not considered a "trivial" case.
      
      This was created by using a coccinelle script and the following
      commands:
      
          $ cat timer.cocci
          @@
          expression ptr, slab;
          identifier timer, rfield;
          @@
          (
          -       del_timer(&ptr->timer);
          +       timer_shutdown(&ptr->timer);
          |
          -       del_timer_sync(&ptr->timer);
          +       timer_shutdown_sync(&ptr->timer);
          )
            ... when strict
                when != ptr->timer
          (
                  kfree_rcu(ptr, rfield);
          |
                  kmem_cache_free(slab, ptr);
          |
                  kfree(ptr);
          )
      
          $ spatch timer.cocci . > /tmp/t.patch
          $ patch -p1 < /tmp/t.patch
      
      Link: https://lore.kernel.org/lkml/20221123201306.823305113@linutronix.de/Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Acked-by: Pavel Machek <pavel@ucw.cz> [ LED ]
      Acked-by: Kalle Valo <kvalo@kernel.org> [ wireless ]
      Acked-by: Paolo Abeni <pabeni@redhat.com> [ networking ]
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      292a089d
  6. 23 Dec, 2022 4 commits