Sched_ext development
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: sashiko-reviews@lists.linux.dev
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH 1/2] sched_ext: Add lazy preemption support
Date: Mon, 14 Sep 2026 14:18:53 +0200	[thread overview]
Message-ID: <aqfmLZXNue5VhK1w@gpd4> (raw)
In-Reply-To: <20260914090640.A47A81F000FF@smtp.kernel.org>

On Mon, Sep 14, 2026 at 09:06:40AM +0000, sashiko-bot@kernel.org wrote:
...
> > @@ -1515,6 +1515,23 @@ static void call_task_dequeue(struct scx_sched *sch, struct rq *rq,
> >  	p->scx.flags &= ~SCX_TASK_IN_CUSTODY;
> >  }
> >  
> > +/*
> > + * A task with an infinite slice may be running with its tick stopped. Lazy
> > + * rescheduling doesn't send an IPI, so restore the tick dependency first to
> > + * guarantee that the lazy request is promoted by a real scheduler tick.
> > + */
> > +static void scx_resched_curr_lazy(struct rq *rq)
> > +{
> > +	if (rq->scx.flags & SCX_RQ_CAN_STOP_TICK) {
> > +		rq->scx.flags &= ~SCX_RQ_CAN_STOP_TICK;
> > +		update_rq_clock(rq);
> > +		update_other_load_avgs(rq);
> 
> [Severity: Medium]
> Does this trigger a SCHED_WARN_ON(rq->clock_update_flags & RQCF_UPDATED)
> double-clock update warning?
> 
> It looks like update_rq_clock() can be called from paths where the clock
> has already been updated or the rq lock was taken without pinning.
> 
> For example, during a task enqueue, enqueue_task() updates the clock and
> sets RQCF_UPDATED. The call chain then reaches rq_owned_post_enq() ->
> scx_resched_curr_lazy(), calling update_rq_clock() while RQCF_UPDATED is
> still set.
> 
> It also appears reachable via kick_one_cpu(), which acquires the runqueue
> lock using raw_spin_rq_lock_irqsave() rather than rq_pin_lock(). This means
> RQCF_UPDATED is not cleared from the previous lock hold, and calling
> scx_resched_curr_lazy() here updates the clock without a valid pin context.

This seems legit. The enqueue path may have already updated the rq clock before
reaching sched_resched_curr_lazy(), while the kick path doesn't currently
establish new rq pin context. I think we can avoid the redundant clock update
when the clock is already current and using a pinned rq lock helpers in
kick_one_cpu().

I'll fix this in v3.

-Andrea

  reply	other threads:[~2026-09-14 12:19 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14  8:47 [PATCHSET v2 sched_ext/for-7.4] sched_ext: Add lazy preemption support Andrea Righi
2026-09-14  8:47 ` [PATCH 1/2] " Andrea Righi
2026-09-14  9:06   ` sashiko-bot
2026-09-14 12:18     ` Andrea Righi [this message]
2026-09-14  8:47 ` [PATCH 2/2] selftests/sched_ext: Add lazy preemption tests Andrea Righi
2026-09-14  9:01   ` sashiko-bot
2026-09-14 12:21     ` Andrea Righi
2026-09-14 14:55   ` Cheng-Yang Chou
2026-09-15 13:35     ` Andrea Righi
  -- strict thread matches above, loose matches on Subject: below --
2026-09-18 17:13 [PATCHSET v7 sched_ext/for-7.4] sched_ext: Add lazy preemption support Andrea Righi
2026-09-18 17:13 ` [PATCH 1/2] " Andrea Righi
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
2026-09-15 19:45 [PATCHSET v5 sched_ext/for-7.4] " Andrea Righi
2026-09-15 19:45 ` [PATCH 1/2] " Andrea Righi
2026-09-15 19:57   ` sashiko-bot
2026-09-15 20:09     ` 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 14:58   ` sashiko-bot
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=aqfmLZXNue5VhK1w@gpd4 \
    --to=arighi@nvidia.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sched-ext@lists.linux.dev \
    /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