mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Andrea Righi <arighi@nvidia.com>
Cc: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>,
	Emil Tsalapatis <etsal@meta.com>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	David Dai <david.dai@linux.dev>,
	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: Thu, 17 Sep 2026 09:19:07 -1000	[thread overview]
Message-ID: <05995f56a36bf6285f738dafdcc63785@kernel.org> (raw)
In-Reply-To: <20260917070751.3617935-2-arighi@nvidia.com>

Hello, Andrea.

Looks good overall. A few things:

On Thu, Sep 17, 2026 at 09:02:52AM +0200, Andrea Righi wrote:
> +		/*
> +		 * kick_one_cpu() clears the lazy bit of every cpu it visited
> +		 * above; visit the remaining requests which contain lazy
> +		 * preemption, see scx_kick_cpu().
> +		 */
> +		for_each_cpu(cpu, pcpu->cpus_to_preempt_lazy)
> +			should_wait |= kick_one_cpu(cpu, pcpu, this_rq, ksyncs);

Can this fold into the loop above with for_each_cpu_or()? As is, a
lazy-only target keeps its cpus_to_kick_if_idle bit and gets locked a second
time by the idle loop.

> +__bpf_kfunc bool scx_bpf_task_set_slice_expiry(struct task_struct *p, bool lazy,
> +					       const struct bpf_prog_aux *aux)

The name reads a bit like it turns slice expiry on and off. Maybe something
like scx_bpf_task_set_lazy_resched(), with the ops flag and the task field
named to match?

> +	if (unlikely(flags & ~(SCX_KICK_IDLE | SCX_KICK_PREEMPT | SCX_KICK_WAIT |
> +			       SCX_KICK_PREEMPT_LAZY))) {
> +		scx_error(sch, "invalid kick flags 0x%llx", flags);
> +		return;
> +	}

Maybe add an enum with all the valid bits and test against that?

> +	if (unlikely((flags & SCX_KICK_IDLE) &&
> +		     (flags & (SCX_KICK_PREEMPT | SCX_KICK_PREEMPT_LAZY | SCX_KICK_WAIT)))) {
> +		scx_error(sch, "PREEMPT/WAIT cannot be used with SCX_KICK_IDLE");
> +		return;
> +	}

Does this need to move out of the IDLE branch? It's two tests on IDLE instead
of one, and as scx_error() aborts the scheduler anyway, the early return
doesn't buy much.

> +	 * ops.enable(), after which scx_bpf_task_set_slice_expiry() may override
> +	 * it per task.
> +	 * A task in user space still reschedules on the way back from the tick; a

Can you add a blank line between the paragraphs?

> + * compatibility wrapper is a no-op when the kfunc is unavailable. As with the
> + * setters above, discard the kfunc's authority result for consistency.
> + *
> + * Keep the wrapper until pre-v7.4 kernels fall out of the sched_ext scheduler
> + * support window.
> + */

Just noting the version it was added in is enough.

Thanks.

-- 
tejun

  reply	other threads:[~2026-09-17 19:27 UTC|newest]

Thread overview: 13+ 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 [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
  -- 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=05995f56a36bf6285f738dafdcc63785@kernel.org \
    --to=tj@kernel.org \
    --cc=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=david.dai@linux.dev \
    --cc=emil@etsalapatis.com \
    --cc=etsal@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --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®