mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Tao Cui <cui.tao@linux.dev>
Cc: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>,
	Emil Tsalapatis <etsal@meta.com>,
	Cheng-Yang Chou <yphbchou0911@gmail.com>,
	sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] sched_ext: Add lazy preemption support
Date: Fri, 18 Sep 2026 08:37:40 +0200	[thread overview]
Message-ID: <aqzcNFzP-qwYwhgp@gpd4> (raw)
In-Reply-To: <c20825cf-9bc6-455f-815a-77f0d5c3e76b@linux.dev>

Hi Tao,

On Fri, Sep 18, 2026 at 11:35:25AM +0800, Tao Cui wrote:
> Hi Andrea,
> 
> 在 2026/9/17 15:02, Andrea Righi 写道:
> > The fair scheduling class can request lazy rescheduling, deferring an
> > in-kernel scheduling boundary until returning to user space or until the
> > next scheduler tick. sched_ext only exposes immediate preemption,
> > preventing BPF schedulers from making the same trade-off.
> > 
> > Add SCX_ENQ_PREEMPT_LAZY and SCX_KICK_PREEMPT_LAZY. Both expire the
> > current sched_ext task slice but request lazy rescheduling. Immediate
> > preemption, WAIT and plain kicks take precedence when requests are
> > combined, while a lazy enqueue to a non-local DSQ retains the
> > head-insertion semantics of SCX_ENQ_PREEMPT.
> > 
> > Add SCX_OPS_LAZY_SLICE_EXPIRY as the default expiry policy for newly
> > enabled tasks and initialize it before ops.enable(). Add
> > scx_bpf_task_set_slice_expiry() so the owning scheduler can override the
> > policy per task from any callback while preserving sub-scheduler task
> > ownership boundaries. Bypass continues to force immediate expiry.
> > 
> > For an infinite-slice task whose tick is stopped, set the lazy
> > reschedule request before restoring the scheduler tick dependency. This
> > lets the dependency update's IPI serve the request on return to user
> > space and guarantees that the next tick promotes it otherwise. Use
> > pinned rq locking for remote kick delivery so RQCF_UPDATED reflects
> > clock updates since lock acquisition.
> > 
> > Accumulate kick requests independently and resolve precedence while
> > holding the target rq lock. Reject invalid SCX_KICK_IDLE combinations
> > and unknown kick flags, which were previously silently ignored.
> > 
> 
> I tested v6 on sched_ext/for-7.4 in a 4-CPU KVM guest: wakeup latency
> of a 1ms-period timer task under a scx_simple-based probe scheduler
> (SCX_OPS_LAZY_SLICE_EXPIRY) with a busy loop on the same CPU.
> 
>                      avg     p50     p99
>   CFS (no scx)        60      59      66
>   no wake preempt  20919   20982   21002
>   SCX_ENQ_PREEMPT     59      58      64
>   SCX_ENQ_PREEMPT_LAZY 59     59      64
>   CFS (control)       60      59      68
> 
> (usecs, 2000 iterations each)
> 
> Lazy and immediate preemption are identical here and on par with CFS,
> i.e. no wakeup latency regression in the common case, matching the
> intended semantics. SCX_OPS_LAZY_SLICE_EXPIRY also cut the context
> switch rate of 6 busy hogs from ~1000/s (CFS) to ~215/s. Repeated
> cgroup knob churn (cpu.weight/cpu.idle) ran clean, no warnings in
> dmesg.
> 
> Overall the series looks well-behaved in these scenarios. Thanks for
> working on this!
> 
> Tested-by: Tao Cui <cuitao@kylinos.cn>

Thanks for testing and sharing the results!

-Andrea

  reply	other threads:[~2026-09-18  6:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17  7:02 [PATCHSET v6 sched_ext/for-7.4] " Andrea Righi
2026-09-17  7:02 ` [PATCH 1/2] " Andrea Righi
2026-09-17 19:19   ` Tejun Heo
2026-09-18  6:27     ` Andrea Righi
2026-09-18  3:35   ` Tao Cui
2026-09-18  6:37     ` Andrea Righi [this message]
2026-09-17  7:02 ` [PATCH 2/2] selftests/sched_ext: Add lazy preemption tests Andrea Righi
2026-09-17 19:19   ` Tejun Heo
2026-09-18  6:30     ` Andrea Righi
  -- strict thread matches above, loose matches on Subject: below --
2026-09-15 19:45 [PATCHSET v5 sched_ext/for-7.4] sched_ext: Add lazy preemption support Andrea Righi
2026-09-15 19:45 ` [PATCH 1/2] " Andrea Righi
2026-09-16 21:03   ` Tejun Heo
2026-09-15  9:00 [PATCHSET v4 sched_ext/for-7.4] " Andrea Righi
2026-09-15  9:00 ` [PATCH 1/2] " Andrea Righi
2026-09-14 14:44 [PATCHSET v3 sched_ext/for-7.4] " Andrea Righi
2026-09-14 14:44 ` [PATCH 1/2] " Andrea Righi
2026-09-14  8:47 [PATCHSET v2 sched_ext/for-7.4] " Andrea Righi
2026-09-14  8:47 ` [PATCH 1/2] " Andrea Righi
2026-09-11 19:56 [PATCHSET sched_ext/for-7.4] " Andrea Righi
2026-09-11 19:56 ` [PATCH 1/2] " Andrea Righi
2026-09-13 16:50   ` Tejun Heo
2026-09-14  6:05     ` Andrea Righi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aqzcNFzP-qwYwhgp@gpd4 \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=cui.tao@linux.dev \
    --cc=etsal@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    --cc=yphbchou0911@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®