• Tejun Heo's avatar
    sched_ext: Implement tickless support · 22a92020
    Tejun Heo authored
    Allow BPF schedulers to indicate tickless operation by setting p->scx.slice
    to SCX_SLICE_INF. A CPU whose current task has infinte slice goes into
    tickless operation.
    
    scx_central is updated to use tickless operations for all tasks and
    instead use a BPF timer to expire slices. This also uses the SCX_ENQ_PREEMPT
    and task state tracking added by the previous patches.
    
    Currently, there is no way to pin the timer on the central CPU, so it may
    end up on one of the worker CPUs; however, outside of that, the worker CPUs
    can go tickless both while running sched_ext tasks and idling.
    
    With schbench running, scx_central shows:
    
      root@test ~# grep ^LOC /proc/interrupts; sleep 10; grep ^LOC /proc/interrupts
      LOC:     142024        656        664        449   Local timer interrupts
      LOC:     161663        663        665        449   Local timer interrupts
    
    Without it:
    
      root@test ~ [SIGINT]# grep ^LOC /proc/interrupts; sleep 10; grep ^LOC /proc/interrupts
      LOC:     188778       3142       3793       3993   Local timer interrupts
      LOC:     198993       5314       6323       6438   Local timer interrupts
    
    While scx_central itself is too barebone to be useful as a
    production scheduler, a more featureful central scheduler can be built using
    the same approach. Google's experience shows that such an approach can have
    significant benefits for certain applications such as VM hosting.
    
    v4: Allow operation even if BPF_F_TIMER_CPU_PIN is not available.
    
    v3: Pin the central scheduler's timer on the central_cpu using
        BPF_F_TIMER_CPU_PIN.
    
    v2: Convert to BPF inline iterators.
    Signed-off-by: default avatarTejun Heo <tj@kernel.org>
    Reviewed-by: default avatarDavid Vernet <dvernet@meta.com>
    Acked-by: default avatarJosh Don <joshdon@google.com>
    Acked-by: default avatarHao Luo <haoluo@google.com>
    Acked-by: default avatarBarret Rhoden <brho@google.com>
    22a92020
sched.h 96.3 KB