<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/kernel/sched/ext.c, branch linux-6.15.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.15.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.15.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2025-07-24T06:58:43Z</updated>
<entry>
<title>sched/ext: Prevent update_locked_rq() calls with NULL rq</title>
<updated>2025-07-24T06:58:43Z</updated>
<author>
<name>Breno Leitao</name>
</author>
<published>2025-07-16T17:38:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=237c43037b336e36a49eb9f2daac1c7719ec7f8b'/>
<id>urn:sha1:237c43037b336e36a49eb9f2daac1c7719ec7f8b</id>
<content type='text'>
commit e14fd98c6d66cb76694b12c05768e4f9e8c95664 upstream.

Avoid invoking update_locked_rq() when the runqueue (rq) pointer is NULL
in the SCX_CALL_OP and SCX_CALL_OP_RET macros.

Previously, calling update_locked_rq(NULL) with preemption enabled could
trigger the following warning:

    BUG: using __this_cpu_write() in preemptible [00000000]

This happens because __this_cpu_write() is unsafe to use in preemptible
context.

rq is NULL when an ops invoked from an unlocked context. In such cases, we
don't need to store any rq, since the value should already be NULL
(unlocked). Ensure that update_locked_rq() is only called when rq is
non-NULL, preventing calling __this_cpu_write() on preemptible context.

Suggested-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Fixes: 18853ba782bef ("sched_ext: Track currently locked rq")
Signed-off-by: Breno Leitao &lt;leitao@debian.org&gt;
Acked-by: Andrea Righi &lt;arighi@nvidia.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: stable@vger.kernel.org # v6.15
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>sched_ext: Make scx_group_set_weight() always update tg-&gt;scx.weight</title>
<updated>2025-07-06T09:04:24Z</updated>
<author>
<name>Sasha Levin</name>
</author>
<published>2025-07-02T01:58:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=34a0b138017a5df13e82979b64ac3b27351e4fe0'/>
<id>urn:sha1:34a0b138017a5df13e82979b64ac3b27351e4fe0</id>
<content type='text'>
[ Upstream commit c50784e99f0e7199cdb12dbddf02229b102744ef ]

Otherwise, tg-&gt;scx.weight can go out of sync while scx_cgroup is not enabled
and ops.cgroup_init() may be called with a stale weight value.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Fixes: 819513666966 ("sched_ext: Add cgroup support")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>sched_ext, sched/core: Don't call scx_group_set_weight() prematurely from sched_create_group()</title>
<updated>2025-06-27T10:13:34Z</updated>
<author>
<name>Tejun Heo</name>
</author>
<published>2025-06-16T20:13:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f27730de39c341f845cda78e853d9e2710d8807d'/>
<id>urn:sha1:f27730de39c341f845cda78e853d9e2710d8807d</id>
<content type='text'>
commit 33796b91871ad4010c8188372dd1faf97cf0f1c0 upstream.

During task_group creation, sched_create_group() calls
scx_group_set_weight() with CGROUP_WEIGHT_DFL to initialize the sched_ext
portion. This is premature and ends up calling ops.cgroup_set_weight() with
an incorrect @cgrp before ops.cgroup_init() is called.

sched_create_group() should just initialize SCX related fields in the new
task_group. Fix it by factoring out scx_tg_init() from sched_init() and
making sched_create_group() call that function instead of
scx_group_set_weight().

v2: Retain CONFIG_EXT_GROUP_SCHED ifdef in sched_init() as removing it leads
    to build failures on !CONFIG_GROUP_SCHED configs.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Fixes: 819513666966 ("sched_ext: Add cgroup support")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>sched_ext: bpf_iter_scx_dsq_new() should always initialize iterator</title>
<updated>2025-05-07T16:24:07Z</updated>
<author>
<name>Tejun Heo</name>
</author>
<published>2025-05-05T21:30:39Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=428dc9fc0873989d73918d4a9cc22745b7bbc799'/>
<id>urn:sha1:428dc9fc0873989d73918d4a9cc22745b7bbc799</id>
<content type='text'>
BPF programs may call next() and destroy() on BPF iterators even after new()
returns an error value (e.g. bpf_for_each() macro ignores error returns from
new()). bpf_iter_scx_dsq_new() could leave the iterator in an uninitialized
state after an error return causing bpf_iter_scx_dsq_next() to dereference
garbage data. Make bpf_iter_scx_dsq_new() always clear $kit-&gt;dsq so that
next() and destroy() become noops.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Fixes: 650ba21b131e ("sched_ext: Implement DSQ iterator")
Cc: stable@vger.kernel.org # v6.12+
Acked-by: Andrea Righi &lt;arighi@nvidia.com&gt;
</content>
</entry>
<entry>
<title>sched_ext: Fix rq lock state in hotplug ops</title>
<updated>2025-04-29T18:01:32Z</updated>
<author>
<name>Andrea Righi</name>
</author>
<published>2025-04-28T21:43:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e38be1c7647c8c78304ce6d931b3b654e27948b3'/>
<id>urn:sha1:e38be1c7647c8c78304ce6d931b3b654e27948b3</id>
<content type='text'>
The ops.cpu_online() and ops.cpu_offline() callbacks incorrectly assume
that the rq involved in the operation is locked, which is not the case
during hotplug, triggering the following warning:

  WARNING: CPU: 1 PID: 20 at kernel/sched/sched.h:1504 handle_hotplug+0x280/0x340

Fix by not tracking the target rq as locked in the context of
ops.cpu_online() and ops.cpu_offline().

Fixes: 18853ba782bef ("sched_ext: Track currently locked rq")
Reported-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Andrea Righi &lt;arighi@nvidia.com&gt;
Tested-by: Changwoo Min &lt;changwoo@igalia.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>sched_ext: Remove duplicate BTF_ID_FLAGS definitions</title>
<updated>2025-04-25T18:41:02Z</updated>
<author>
<name>Andrea Righi</name>
</author>
<published>2025-04-25T17:57:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e7dcd1304b9ac08c428c84fdb96ce6a04ff2114f'/>
<id>urn:sha1:e7dcd1304b9ac08c428c84fdb96ce6a04ff2114f</id>
<content type='text'>
Some kfuncs specific to the idle CPU selection policy are registered in
both the scx_kfunc_ids_any and scx_kfunc_ids_idle blocks, even though
they should only be defined in the latter.

Remove the duplicates from scx_kfunc_ids_any.

Fixes: 337d1b354a297 ("sched_ext: Move built-in idle CPU selection policy to a separate file")
Signed-off-by: Andrea Righi &lt;arighi@nvidia.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>sched_ext: Fix missing rq lock in scx_bpf_cpuperf_set()</title>
<updated>2025-04-22T19:28:12Z</updated>
<author>
<name>Andrea Righi</name>
</author>
<published>2025-04-22T08:26:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a11d6784d7316a6c77ca9f14fb1a698ebbb3c1fb'/>
<id>urn:sha1:a11d6784d7316a6c77ca9f14fb1a698ebbb3c1fb</id>
<content type='text'>
scx_bpf_cpuperf_set() can be used to set a performance target level on
any CPU. However, it doesn't correctly acquire the corresponding rq
lock, which may lead to unsafe behavior and trigger the following
warning, due to the lockdep_assert_rq_held() check:

[   51.713737] WARNING: CPU: 3 PID: 3899 at kernel/sched/sched.h:1512 scx_bpf_cpuperf_set+0x1a0/0x1e0
...
[   51.713836] Call trace:
[   51.713837]  scx_bpf_cpuperf_set+0x1a0/0x1e0 (P)
[   51.713839]  bpf_prog_62d35beb9301601f_bpfland_init+0x168/0x440
[   51.713841]  bpf__sched_ext_ops_init+0x54/0x8c
[   51.713843]  scx_ops_enable.constprop.0+0x2c0/0x10f0
[   51.713845]  bpf_scx_reg+0x18/0x30
[   51.713847]  bpf_struct_ops_link_create+0x154/0x1b0
[   51.713849]  __sys_bpf+0x1934/0x22a0

Fix by properly acquiring the rq lock when possible or raising an error
if we try to operate on a CPU that is not the one currently locked.

Fixes: d86adb4fc0655 ("sched_ext: Add cpuperf support")
Signed-off-by: Andrea Righi &lt;arighi@nvidia.com&gt;
Acked-by: Changwoo Min &lt;changwoo@igalia.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>sched_ext: Track currently locked rq</title>
<updated>2025-04-22T19:27:50Z</updated>
<author>
<name>Andrea Righi</name>
</author>
<published>2025-04-22T08:26:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=18853ba782bef65fc81ef2b3370382e5b479c5eb'/>
<id>urn:sha1:18853ba782bef65fc81ef2b3370382e5b479c5eb</id>
<content type='text'>
Some kfuncs provided by sched_ext may need to operate on a struct rq,
but they can be invoked from various contexts, specifically, different
scx callbacks.

While some of these callbacks are invoked with a particular rq already
locked, others are not. This makes it impossible for a kfunc to reliably
determine whether it's safe to access a given rq, triggering potential
bugs or unsafe behaviors, see for example [1].

To address this, track the currently locked rq whenever a sched_ext
callback is invoked via SCX_CALL_OP*().

This allows kfuncs that need to operate on an arbitrary rq to retrieve
the currently locked one and apply the appropriate action as needed.

[1] https://lore.kernel.org/lkml/20250325140021.73570-1-arighi@nvidia.com/

Suggested-by: Tejun Heo &lt;tj@kernel.org&gt;
Signed-off-by: Andrea Righi &lt;arighi@nvidia.com&gt;
Acked-by: Changwoo Min &lt;changwoo@igalia.com&gt;
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
<entry>
<title>sched_ext: Mark SCX_OPS_HAS_CGROUP_WEIGHT for deprecation</title>
<updated>2025-04-08T18:53:52Z</updated>
<author>
<name>Tejun Heo</name>
</author>
<published>2025-04-08T18:31:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bc08b15b54b8aadbc8a8f413271c07a3f4bead87'/>
<id>urn:sha1:bc08b15b54b8aadbc8a8f413271c07a3f4bead87</id>
<content type='text'>
SCX_OPS_HAS_CGROUP_WEIGHT was only used to suppress the missing cgroup
weight support warnings. Now that the warnings are removed, the flag doesn't
do anything. Mark it for deprecation and remove its usage from scx_flatcg.

v2: Actually include the scx_flatcg update.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Suggested-and-reviewed-by: Andrea Righi &lt;arighi@nvidia.com&gt;
</content>
</entry>
<entry>
<title>sched_ext: Remove cpu.weight / cpu.idle unimplemented warnings</title>
<updated>2025-04-08T18:00:49Z</updated>
<author>
<name>Tejun Heo</name>
</author>
<published>2025-04-07T23:20:04Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e776b26e3701945e0d20a11dc30ecd4da98e8d67'/>
<id>urn:sha1:e776b26e3701945e0d20a11dc30ecd4da98e8d67</id>
<content type='text'>
sched_ext generates warnings when cpu.weight / cpu.idle are set to
non-default values if the BPF scheduler doesn't implement weight support.
These warnings don't provide much value while adding constant annoyance. A
BPF scheduler may not implement any particular behavior and there's nothing
particularly special about missing cgroup weight support. Drop the warnings.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
</content>
</entry>
</feed>
