sched_ext: Print deprecation warnings only once
Subsystems (3)
PATCH 1/1 sched_ext: Print deprecation warnings only once
The deprecation notices for direct p->scx.slice/dsq_vtime writes and for ops->cpu_acquire/release() use plain pr_warn(), so they repeat on every scheduler (re)load and flood the kernel log.
The slice/dsq_vtime notice is emitted from the BPF verifier's btf_struct_access callback, which runs once per write access and is re-evaluated as the verifier explores paths, so loading a single scheduler can print it several times. The cpu_acquire/release notice is printed on every scheduler enable.
Switch both to pr_warn_once() so each deprecation is reported a single time, and add the missing newline to the slice/dsq_vtime message.
--- kernel/sched/ext/ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/ext/ext.c +2 -2
@@ -6988,7 +6988,7 @@ static int validate_ops(struct scx_sched *sch, const struct sched_ext_ops *ops)* run past the BPF allocation. Skip for cid-form. */ if (!sch->is_cid_type && (ops->cpu_acquire || ops->cpu_release)) -pr_warn ("ops->cpu_acquire/release() are deprecated, use sched_switch TP instead\n" ); +pr_warn_once ("ops->cpu_acquire/release() are deprecated, use sched_switch TP instead\n" );/* * Sub-scheduler support is tied to the cid-form struct_ops. A sub-sched
@@ -7806,7 +7806,7 @@ static int bpf_scx_btf_struct_access(struct bpf_verifier_log *log, off + size <= offsetofend(struct task_struct, scx.slice)) || (off >= offsetof(struct task_struct, scx.dsq_vtime) && off + size <= offsetofend(struct task_struct, scx.dsq_vtime))) { -pr_warn ("sched_ext: Writing directly to p->scx.slice/dsq_vtime is deprecated, use scx_bpf_task_set_slice/dsq_vtime()" ); +pr_warn_once ("sched_ext: Writing directly to p->scx.slice/dsq_vtime is deprecated, use scx_bpf_task_set_slice/dsq_vtime()\n" );return SCALAR_VALUE ; }
---
base-commit: 4e5dfb7c84012007c3c7061126491bbc92d71bf1
change-id: 20260623-scx_warning-0df49c442afb
Best regards,
Signature · 1 line
Breno Leitao <[email protected]>
Quoted 11 lines · Breno Leitao
The deprecation notices for direct p->scx.slice/dsq_vtime writes and for ops->cpu_acquire/release() use plain
pr_warn(), so they repeat on every scheduler (re)load and flood the kernel log.Quoted 1 line
The slice/dsq_vtime notice is emitted from the BPF verifier's
btf_struct_accesscallback, which runs once per write access and is re-evaluated as the verifier explores paths, so loading a single scheduler can print it several times. The cpu_acquire/release notice is printed on every scheduler enable.Switch both to
pr_warn_once()so each deprecation is reported a single time, and add the missing newline to the slice/dsq_vtime message.
I guess this should be warned for once per BPF scheduler like sch->warned_deprecated_rq
Quoted 34 lines
Signed-off-by Breno Leitao <[email protected]>--- kernel/sched/ext/ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/sched/ext/ext.c +2
-3@@ -6988,7 +6988,7 @@ static int validate_ops(struct scx_sched *sch, const struct sched_ext_ops *ops)* run past the BPF allocation. Skip for cid-form. */ if (!sch->is_cid_type && (ops->cpu_acquire || ops->cpu_release)) -pr_warn ("ops->cpu_acquire/release() are deprecated, use sched_switch TP instead\n" ); +pr_warn_once ("ops->cpu_acquire/release() are deprecated, use sched_switch TP instead\n" );/* * Sub-scheduler support is tied to the cid-form struct_ops. A sub-sched @@ -7806,7 +7806,7 @@ static int bpf_scx_btf_struct_access(struct bpf_verifier_log *log, off + size <= offsetofend(struct task_struct, scx.slice)) || (off >= offsetof(struct task_struct, scx.dsq_vtime) && off + size <= offsetofend(struct task_struct, scx.dsq_vtime))) { -pr_warn ("sched_ext: Writing directly to p->scx.slice/dsq_vtime is deprecated, use scx_bpf_task_set_slice/dsq_vtime()" ); +pr_warn_once ("sched_ext: Writing directly to p->scx.slice/dsq_vtime is deprecated, use scx_bpf_task_set_slice/dsq_vtime()\n" );return SCALAR_VALUE ; } ---base-commit:
4e5dfb7c84012007c3c7061126491bbc92d71bf1
change-id: 20260623-scx_warning-0df49c442afbBest regards,
Andrea Righi
reviewerHi Breno and Christian,
Quoted 10 lines · Christian Loehle
Quoted 9 lines · Breno Leitao
The deprecation notices for direct p->scx.slice/dsq_vtime writes and for ops->cpu_acquire/release() use plain
pr_warn(), so they repeat on every scheduler (re)load and flood the kernel log.Quoted 1 line
The slice/dsq_vtime notice is emitted from the BPF verifier's
btf_struct_accesscallback, which runs once per write access and is re-evaluated as the verifier explores paths, so loading a single scheduler can print it several times. The cpu_acquire/release notice is printed on every scheduler enable.
Quoted 5 lines
Quoted 2 lines
Switch both to
pr_warn_once()so each deprecation is reported a single time, and add the missing newline to the slice/dsq_vtime message.I guess this should be warned for once per BPF scheduler like
sch->warned_deprecated_rq
Yeah, I agree. The thing is that we can load multiple different BPF schedulers, and we'd want to get these messages for each of them. So ideally we need something like sch->warned_deprecated_rq.
Thanks,
-Andrea
Quoted 36 lines
Quoted 35 lines
Signed-off-by Breno Leitao <[email protected]>--- kernel/sched/ext/ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/sched/ext/ext.c +2
-3@@ -6988,7 +6988,7 @@ static int validate_ops(struct scx_sched *sch, const struct sched_ext_ops *ops)* run past the BPF allocation. Skip for cid-form. */ if (!sch->is_cid_type && (ops->cpu_acquire || ops->cpu_release)) -pr_warn ("ops->cpu_acquire/release() are deprecated, use sched_switch TP instead\n" ); +pr_warn_once ("ops->cpu_acquire/release() are deprecated, use sched_switch TP instead\n" );/* * Sub-scheduler support is tied to the cid-form struct_ops. A sub-sched @@ -7806,7 +7806,7 @@ static int bpf_scx_btf_struct_access(struct bpf_verifier_log *log, off + size <= offsetofend(struct task_struct, scx.slice)) || (off >= offsetof(struct task_struct, scx.dsq_vtime) && off + size <= offsetofend(struct task_struct, scx.dsq_vtime))) { -pr_warn ("sched_ext: Writing directly to p->scx.slice/dsq_vtime is deprecated, use scx_bpf_task_set_slice/dsq_vtime()" ); +pr_warn_once ("sched_ext: Writing directly to p->scx.slice/dsq_vtime is deprecated, use scx_bpf_task_set_slice/dsq_vtime()\n" );return SCALAR_VALUE ; } ---base-commit:
4e5dfb7c84012007c3c7061126491bbc92d71bf1
change-id: 20260623-scx_warning-0df49c442afbBest regards,
Quoted 16 lines · Andrea Righi
Hi Breno and Christian,
Quoted 13 lines · Christian Loehle
Quoted 11 lines · Breno Leitao
The deprecation notices for direct p->scx.slice/dsq_vtime writes and for ops->cpu_acquire/release() use plain
pr_warn(), so they repeat on every scheduler (re)load and flood the kernel log.Quoted 1 line
The slice/dsq_vtime notice is emitted from the BPF verifier's
btf_struct_accesscallback, which runs once per write access and is re-evaluated as the verifier explores paths, so loading a single scheduler can print it several times. The cpu_acquire/release notice is printed on every scheduler enable.Switch both to
pr_warn_once()so each deprecation is reported a single time, and add the missing newline to the slice/dsq_vtime message.
Quoted 6 lines
Quoted 2 lines
I guess this should be warned for once per BPF scheduler like
sch->warned_deprecated_rqYeah, I agree. The thing is that we can load multiple different BPF schedulers, and we'd want to get these messages for each of them. So ideally we need something like
sch->warned_deprecated_rq.
Agreed, pr_warn_once() is too coarse - it mutes the notice for every scheduler loaded after the first one since boot.
For ops->cpu_acquire/release() this is easy: the notice comes from validate_ops(), which has the scx_sched, so I'll gate it on a per-scheduler warned_deprecated_cpu_rel flag, just like warned_deprecated_rq.
The slice/dsq_vtime notice is the one I wanted to ask about. It's emitted from bpf_scx_btf_struct_access(), the .btf_struct_access verifier callback.
That runs at program load/verification time, before the struct_ops is registered and the scx_sched is allocated (that only happens later in scx_enable()). Any idea on what to do in this case?
Thanks,
--breno
Andrea Righi
reviewerHi Breno,
Quoted 32 lines · Breno Leitao
Quoted 16 lines · Andrea Righi
Hi Breno and Christian,
Quoted 13 lines · Christian Loehle
Quoted 11 lines · Breno Leitao
The deprecation notices for direct p->scx.slice/dsq_vtime writes and for ops->cpu_acquire/release() use plain
pr_warn(), so they repeat on every scheduler (re)load and flood the kernel log.Quoted 1 line
The slice/dsq_vtime notice is emitted from the BPF verifier's
btf_struct_accesscallback, which runs once per write access and is re-evaluated as the verifier explores paths, so loading a single scheduler can print it several times. The cpu_acquire/release notice is printed on every scheduler enable.Switch both to
pr_warn_once()so each deprecation is reported a single time, and add the missing newline to the slice/dsq_vtime message.Quoted 6 lines
Quoted 2 lines
I guess this should be warned for once per BPF scheduler like
sch->warned_deprecated_rqYeah, I agree. The thing is that we can load multiple different BPF schedulers, and we'd want to get these messages for each of them. So ideally we need something like
sch->warned_deprecated_rq.Agreed,
pr_warn_once()is too coarse - it mutes the notice for every scheduler loaded after the first one since boot.For ops->cpu_acquire/release() this is easy: the notice comes from
validate_ops(), which has thescx_sched, so I'll gate it on a per-schedulerwarned_deprecated_cpu_relflag, just likewarned_deprecated_rq.
Quoted 7 lines
The slice/dsq_vtime notice is the one I wanted to ask about. It's emitted from
bpf_scx_btf_struct_access(), the .btf_struct_access verifier callback.That runs at program load/verification time, before the
struct_opsis registered and thescx_schedis allocated (that only happens later inscx_enable()). Any idea on what to do in this case?
Hm... actually thinking more about it, the existing behavior seems fine already.
The ops->cpu_acquire/release() warning is only emitted from validate_ops(), which runs when the scheduler is registered. It's not in the runtime callback path, so we should already get one warning per scheduler registration. That means we don't need a warned_deprecated_cpu_rel flag.
For slice/dsq_vtime, the warning is emitted when the verifier sees write accesses to those fields. It can fire multiple times while loading one sched_ext scheduler, depending on how many such accesses the verifier observes, but this also seems correct.
If we want to prevent potential log spam maybe we can just change those pr_warn() to pr_warn_ratelimited()?
Thanks,
-Andrea
Hello Andrea,
Quoted 1 line · Andrea Righi
Hm... actually thinking more about it, the existing behavior seems fine already.
I have very few hosts in the Meta fleet that are unnecessarily spammy:
# dmesg | grep -c "ops->cpu_acquire/release() are deprecated, use sched_switch TP instead" 73 # dmesg | grep -c "sched_ext: Writing directly to p->scx.slice/dsq_vtime is deprecated, use scx_bpf_task_set_slice/dsq_vtime()" 855
And they are unnecessary, given they show up many times within the same second, like, 42x times in last second:
# dmesg | grep "sched_ext: Writing directly to p->scx.slice/dsq_vtime is deprecated" | grep 806105 | wc -l 42 # dmesg | grep "sched_ext: Writing directly to p->scx.slice/dsq_vtime is deprecated" | grep 806105 | head # [806105.018400] sched_ext: Writing directly to p->scx.slice/dsq_vtime is deprecated, use scx_bpf_task_set_slice/dsq_vtime() # [806105.042160] sched_ext: Writing directly to p->scx.slice/dsq_vtime is deprecated, use scx_bpf_task_set_slice/dsq_vtime() # [806105.065668] sched_ext: Writing directly to p->scx.slice/dsq_vtime is deprecated, use scx_bpf_task_set_slice/dsq_vtime() ...
Quoted 6 lines
The ops->cpu_acquire/release() warning is only emitted from
validate_ops(), which runs when the scheduler is registered. It's not in the runtime callback path, so we should already get one warning per scheduler registration. That means we don't need awarned_deprecated_cpu_relflag.
Quoted 7 lines
For slice/dsq_vtime, the warning is emitted when the verifier sees write accesses to those fields. It can fire multiple times while loading one
sched_extscheduler, depending on how many such accesses the verifier observes, but this also seems correct.If we want to prevent potential log spam maybe we can just change those
pr_warn()topr_warn_ratelimited()?
Ack, let me transform these pr_warn() in pr_warn_ratelimted() then.
THanks