mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Changwoo Min <changwoo@igalia.com>
To: Tejun Heo <tj@kernel.org>
Cc: void@manifault.com, arighi@nvidia.com, david.dai@linux.dev,
	Gavin Guo <gavinguo@igalia.com>,
	kernel-dev@igalia.com, sched-ext@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/8] sched_ext: Add scx_bpf_sched_id() and scx_bpf_task_sched_id()
Date: Sun, 6 Dec 2026 14:38:35 +0900	[thread overview]
Message-ID: <0b34d5b7-356c-4877-918a-72edd270ec08@igalia.com> (raw)
In-Reply-To: <19cdfb6abd7a81ad42e57cdff168db38@kernel.org>



On 12/5/26 2:17 AM, Tejun Heo wrote:
> Hello, Changwoo.
> 
> On Thu, Dec 03, 2026 at 01:56:13PM +0900, Changwoo Min wrote:
>> + * Return the instance id of the scheduler @p is on, see scx_bpf_sched_id(), 0
>> + * if @p is not on any. Without the rq lock of @p, @p may move to another
>> + * scheduler right after.
>> + */
>> +__bpf_kfunc u64 scx_bpf_task_sched_id(struct task_struct *p)
>> +{
>> +	struct scx_sched *sch;
>> +
>> +	guard(rcu)();
>> +	sch = scx_task_sched_rcu(p);
>> +	return sch ? sch->id : 0;
> 
> AFAICS, without CONFIG_EXT_SUB_SCHED, scx_task_sched_rcu() returns scx_root
> whatever @p is, so this returns the root's id for a task which isn't on any
> scheduler too, e.g. one which is already dead.
> 
Right. v3 replaces the kfunc with scx_task_sched_id(), a CO-RE helper in
compat.bpf.h, following Andrea's suggestion. It returns 0 unless the
task is in INIT, READY or ENABLED, as a scheduler owns a task only after
ops.init_task(). So the !CONFIG_EXT_SUB_SCHED case reports the root's id
only for tasks the root owns.

Regards,
Changwoo

  reply	other threads:[~2026-12-06  5:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  4:56 [PATCH v2 0/8] sched_ext: Add p->scx.bpf_priv for O(1) task context lookup Changwoo Min
2026-12-03  4:56 ` [PATCH v2 1/8] sched_ext: Reset task fields after ops.exit_task() Changwoo Min
2026-12-04  6:10   ` Andrea Righi
2026-12-04 17:04   ` Tejun Heo
2026-12-03  4:56 ` [PATCH v2 2/8] sched_ext: Mark a task enabled before ops.enable() Changwoo Min
2026-12-04  6:10   ` Andrea Righi
2026-12-04 17:02   ` Tejun Heo
2026-12-06  5:38     ` Changwoo Min
2026-12-03  4:56 ` [PATCH v2 3/8] sched_ext: Add scx_bpf_sched_id() and scx_bpf_task_sched_id() Changwoo Min
2026-12-04  6:44   ` Andrea Righi
2026-12-06  5:38     ` Changwoo Min
2026-12-04 17:17   ` Tejun Heo
2026-12-06  5:38     ` Changwoo Min [this message]
2026-12-03  4:56 ` [PATCH v2 4/8] selftests/sched_ext: Test " Changwoo Min
2026-12-03  4:56 ` [PATCH v2 5/8] sched_ext: Add p->scx.bpf_priv for O(1) task context lookup Changwoo Min
2026-12-04 17:09   ` Tejun Heo
2026-12-06  5:38     ` Changwoo Min
2026-12-03  4:56 ` [PATCH v2 6/8] sched_ext: scx_qmap: Cache task_ctx in p->scx.bpf_priv Changwoo Min
2026-12-03  4:56 ` [PATCH v2 7/8] selftests/sched_ext: Test p->scx.bpf_priv across class changes Changwoo Min
2026-12-03  4:56 ` [PATCH v2 8/8] selftests/sched_ext: Test task field reset across sub-scheduler handoffs Changwoo Min
2026-12-04 17:19 ` [PATCH v2 0/8] sched_ext: Add p->scx.bpf_priv for O(1) task context lookup Tejun Heo
2026-12-06  5:38   ` Changwoo Min

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=0b34d5b7-356c-4877-918a-72edd270ec08@igalia.com \
    --to=changwoo@igalia.com \
    --cc=arighi@nvidia.com \
    --cc=david.dai@linux.dev \
    --cc=gavinguo@igalia.com \
    --cc=kernel-dev@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=void@manifault.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®