1. Oct 30, 2022
    • Suren Baghdasaryan's avatar
      sched/psi: Stop relying on timer_pending() for poll_work rescheduling · 710ffe67
      Suren Baghdasaryan authored
      Psi polling mechanism is trying to minimize the number of wakeups to
      run psi_poll_work and is currently relying on timer_pending() to detect
      when this work is already scheduled. This provides a window of opportunity
      for psi_group_change to schedule an immediate psi_poll_work after
      poll_timer_fn got called but before psi_poll_work could reschedule itself.
      Below is the depiction of this entire window:
      
      poll_timer_fn
        wake_up_interruptible(&group->poll_wait);
      
      psi_poll_worker
        wait_event_interruptible(group->poll_wait, ...)
        psi_poll_work
          psi_schedule_poll_work
            if (timer_pending(&group->poll_timer)) return;
            ...
            mod_timer(&group->poll_timer, jiffies + delay);
      
      Prior to 461daba0 we used to rely on poll_scheduled atomic which was
      reset and set back inside psi_poll_work and therefore this race window
      was much smaller.
      The larger window causes increased number of wakeups and our partners
      report visible power regression of ~10mA after applying 461daba0.
      Bring back the poll_scheduled atomic and make this race window even
      narrower by resetting poll_scheduled only when we reach polling expiration
      time. This does not completely eliminate the possibility of extra wakeups
      caused by a race with psi_group_change however it will limit it to the
      worst case scenario of one extra wakeup per every tracking window (0.5s
      in the worst case).
      This patch also ensures correct ordering between clearing poll_scheduled
      flag and obtaining changed_states using memory barrier. Correct ordering
      between updating changed_states and setting poll_scheduled is ensured by
      atomic_xchg operation.
      By tracing the number of immediate rescheduling attempts performed by
      psi_group_change and the number of these attempts being blocked due to
      psi monitor being already active, we can assess the effects of this change:
      
      Before the patch:
                                                 Run#1    Run#2      Run#3
      Immediate reschedules attempted:           684365   1385156    1261240
      Immediate reschedules blocked:             682846   1381654    1258682
      Immediate reschedules (delta):             1519     3502       2558
      Immediate reschedules (% of attempted):    0.22%    0.25%      0.20%
      
      After the patch:
                                                 Run#1    Run#2      Run#3
      Immediate reschedules attempted:           882244   770298    426218
      Immediate reschedules blocked:             881996   769796    426074
      Immediate reschedules (delta):             248      502       144
      Immediate reschedules (% of attempted):    0.03%    0.07%     0.03%
      
      The number of non-blocked immediate reschedules dropped from 0.22-0.25%
      to 0.03-0.07%. The drop is attributed to the decrease in the race window
      size and the fact that we allow this race only when psi monitors reach
      polling window expiration time.
      
      Fixes: 461daba0
      
       ("psi: eliminate kthread_worker from psi trigger scheduling mechanism")
      Reported-by: default avatarKathleen Chang <yt.chang@mediatek.com>
      Reported-by: default avatarWenju Xu <wenju.xu@mediatek.com>
      Reported-by: default avatarJonathan Chen <jonathan.jmchen@mediatek.com>
      Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Tested-by: default avatarSH Chen <show-hong.chen@mediatek.com>
      Link: https://lore.kernel.org/r/20221028194541.813985-1-surenb@google.com
      710ffe67
    • Chengming Zhou's avatar
      sched/psi: Fix avgs_work re-arm in psi_avgs_work() · 2fcd7bba
      Chengming Zhou authored
      Pavan reported a problem that PSI avgs_work idle shutoff is not
      working at all. Because PSI_NONIDLE condition would be observed in
      psi_avgs_work()->collect_percpu_times()->get_recent_times() even if
      only the kworker running avgs_work on the CPU.
      
      Although commit 1b69ac6b
      
       ("psi: fix aggregation idle shut-off")
      avoided the ping-pong wake problem when the worker sleep, psi_avgs_work()
      still will always re-arm the avgs_work, so shutoff is not working.
      
      This patch changes to use PSI_STATE_RESCHEDULE to flag whether to
      re-arm avgs_work in get_recent_times(). For the current CPU, we re-arm
      avgs_work only when (NR_RUNNING > 1 || NR_IOWAIT > 0 || NR_MEMSTALL > 0),
      for other CPUs we can just check PSI_NONIDLE delta. The new flag
      is only used in psi_avgs_work(), so we check in get_recent_times()
      that current_work() is avgs_work.
      
      One potential problem is that the brief period of non-idle time
      incurred between the aggregation run and the kworker's dequeue will
      be stranded in the per-cpu buckets until avgs_work run next time.
      The buckets can hold 4s worth of time, and future activity will wake
      the avgs_work with a 2s delay, giving us 2s worth of data we can leave
      behind when shut off the avgs_work. If the kworker run other works after
      avgs_work shut off and doesn't have any scheduler activities for 2s,
      this maybe a problem.
      
      Reported-by: default avatarPavan Kondeti <quic_pkondeti@quicinc.com>
      Signed-off-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: default avatarSuren Baghdasaryan <surenb@google.com>
      Tested-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
      Link: https://lore.kernel.org/r/20221014110551.22695-1-zhouchengming@bytedance.com
      2fcd7bba
    • Hao Lee's avatar
      sched/psi: Fix possible missing or delayed pending event · e38f89af
      Hao Lee authored
      When a pending event exists and growth is less than the threshold, the
      current logic is to skip this trigger without generating event. However,
      from e6df4ead ("psi: fix possible trigger missing in the window"),
      our purpose is to generate event as long as pending event exists and the
      rate meets the limit, no matter what growth is.
      This patch handles this case properly.
      
      Fixes: e6df4ead
      
       ("psi: fix possible trigger missing in the window")
      Signed-off-by: default avatarHao Lee <haolee.swjtu@gmail.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarSuren Baghdasaryan <surenb@google.com>
      Link: https://lore.kernel.org/r/20220919072356.GA29069@haolee.io
      e38f89af
  2. Oct 27, 2022
  3. Oct 24, 2022
  4. Oct 23, 2022
    • Linus Torvalds's avatar
      Merge tag 'hwmon-for-v6.1-rc2' of... · d47136c2
      Linus Torvalds authored
      Merge tag 'hwmon-for-v6.1-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
      
      Pull hwmon fixes from Guenter Roeck:
      
       - corsair-psu: Fix typo in USB id description, and add USB ID for new
         PSU
      
       - pwm-fan: Fix fan power handling when disabling fan control
      
      * tag 'hwmon-for-v6.1-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
        hwmon: (corsair-psu) Add USB id of the new HX1500i psu
        hwmon: (pwm-fan) Explicitly switch off fan power when setting pwm1_enable to 0
        hwmon: (corsair-psu) fix typo in USB id description
      d47136c2
    • Linus Torvalds's avatar
      Merge tag 'i2c-for-6.1-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux · cda5d920
      Linus Torvalds authored
      Pull i2c fixes from Wolfram Sang:
       "RPM fix for qcom-cci, platform module alias for xiic, build warning
        fix for mlxbf, typo fixes in comments"
      
      * tag 'i2c-for-6.1-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
        i2c: mlxbf: depend on ACPI; clean away ifdeffage
        i2c: fix spelling typos in comments
        i2c: qcom-cci: Fix ordering of pm_runtime_xx and i2c_add_adapter
        i2c: xiic: Add platform module alias
      cda5d920
    • Linus Torvalds's avatar
      Merge tag 'pci-v6.1-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci · fd79882f
      Linus Torvalds authored
      Pull pci fixes from Bjorn Helgaas:
      
       - Revert a simplification that broke pci-tegra due to a masking error
      
       - Update MAINTAINERS for Kishon's email address change and TI
         DRA7XX/J721E maintainer change
      
      * tag 'pci-v6.1-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
        MAINTAINERS: Update Kishon's email address in PCI endpoint subsystem
        MAINTAINERS: Add Vignesh Raghavendra as maintainer of TI DRA7XX/J721E PCI driver
        Revert "PCI: tegra: Use PCI_CONF1_EXT_ADDRESS() macro"
      fd79882f
    • Linus Torvalds's avatar
      Merge tag 'media/v6.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media · 3272eb1a
      Linus Torvalds authored
      Pull missed media updates from Mauro Carvalho Chehab:
       "It seems I screwed-up my previous pull request: it ends up that only
        half of the media patches that were in linux-next got merged in -rc1.
      
        The script which creates the signed tags silently failed due to
        5.19->6.0 so it ended generating a tag with incomplete stuff.
      
        So here are the missing parts:
      
         - a DVB core security fix
      
         - lots of fixes and cleanups for atomisp staging driver
      
         - old drivers that are VB1 are being moved to staging to be
           deprecated
      
         - several driver updates - mostly for embedded systems, but there are
           also some things addressing issues with some PC webcams, in the UVC
           video driver"
      
      * tag 'media/v6.1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (163 commits)
        media: sun6i-csi: Move csi buffer definition to main header file
        media: sun6i-csi: Introduce and use video helper functions
        media: sun6i-csi: Add media ops with link notify callback
        media: sun6i-csi: Remove controls handler from the driver
        media: sun6i-csi: Register the media device after creation
        media: sun6i-csi: Pass and store csi device directly in video code
        media: sun6i-csi: Tidy up video code
        media: sun6i-csi: Tidy up v4l2 code
        media: sun6i-csi: Tidy up Kconfig
        media: sun6i-csi: Use runtime pm for clocks and reset
        media: sun6i-csi: Define and use variant to get module clock rate
        media: sun6i-csi: Always set exclusive module clock rate
        media: sun6i-csi: Tidy up platform code
        media: sun6i-csi: Refactor main driver data structures
        media: sun6i-csi: Define and use driver name and (reworked) description
        media: cedrus: Add a Kconfig dependency on RESET_CONTROLLER
        media: sun8i-rotate: Add a Kconfig dependency on RESET_CONTROLLER
        media: sun8i-di: Add a Kconfig dependency on RESET_CONTROLLER
        media: sun4i-csi: Add a Kconfig dependency on RESET_CONTROLLER
        media: sun6i-csi: Add a Kconfig dependency on RESET_CONTROLLER
        ...
      3272eb1a
  5. Oct 22, 2022