From: Philippe Gerum <rpm@xenomai.org>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Xenomai <xenomai@lists.linux.dev>
Subject: Re: SCHED_SPORADIC in Xenomai 3
Date: Thu, 11 Jun 2026 10:53:36 +0200 [thread overview]
Message-ID: <87mrx1bgq7.fsf@xenomai.org> (raw)
In-Reply-To: <2becb808-b1ef-4d3e-b1e7-121697cef154@siemens.com> (Jan Kiszka's message of "Thu, 11 Jun 2026 09:56:02 +0200")
Jan Kiszka <jan.kiszka@siemens.com> writes:
> On 11.06.26 09:49, Philippe Gerum wrote:
>> Jan Kiszka <jan.kiszka@siemens.com> writes:
>>
>>> diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
>>> index d527b6be2c..6dfbf83220 100644
>>> --- a/kernel/cobalt/sched.c
>>> +++ b/kernel/cobalt/sched.c
>>> @@ -895,6 +895,7 @@ static inline void do_lazy_user_work(struct xnthread *curr)
>>>
>>> int ___xnsched_run(struct xnsched *sched)
>>> {
>>> + struct xnsched_class *prev_schedclass __maybe_unused;
>>> bool switched = false, leaving_inband;
>>> struct xnthread *prev, *next, *curr;
>>> spl_t s;
>>> @@ -933,6 +934,13 @@ int ___xnsched_run(struct xnsched *sched)
>>>
>>> prev = curr;
>>>
>>> +#ifdef CONFIG_XENO_OPT_SCHED_CLASSES
>>> + prev_schedclass = prev->sched_class;
>>> + if (prev_schedclass->weight < next->sched_class->weight &&
>>> + prev_schedclass->sched_out)
>>> + prev_schedclass->sched_out(prev);
>>> +#endif
>>
>> I would call the scheduling out hook unconditionally, the sched class
>> has all the information required to sort this out, do the right thing,
>> which the generic scheduler does not.
>
> That would mean moving the accounting out of the pick callback
> unconditionally as well - leaving some smaller synergies on the road.
This hook would have to be called when the current thread blocks, which
should not be filtered out by the class weight check. Moreover, if next
!= curr, we know for sure that curr is either blocked, yields on a
round-robin tick or gets preempted on priority basis. In the latter
case, the sched class weight is accounted for when picking next. If
current is still runnable, prev_schedclass->weight has to be lower than
next->sched_class->weight for preemption to take place anyway.
IOW, the following change would be appropriate:
>>> + if (prev_schedclass->sched_out)
>>> + prev_schedclass->sched_out(prev);
--
Philippe.
next prev parent reply other threads:[~2026-06-11 8:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 6:24 SCHED_SPORADIC in Xenomai 3 Jan Kiszka
2026-06-10 7:21 ` Jan Kiszka
2026-06-10 7:33 ` Jan Kiszka
2026-06-10 18:17 ` Jan Kiszka
2026-06-11 5:38 ` Jan Kiszka
2026-06-11 7:49 ` Philippe Gerum
2026-06-11 7:56 ` Jan Kiszka
2026-06-11 8:53 ` Philippe Gerum [this message]
2026-06-11 7:36 ` Philippe Gerum
2026-06-11 7:33 ` Philippe Gerum
2026-06-11 7:42 ` Jan Kiszka
2026-06-11 7:56 ` Philippe Gerum
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=87mrx1bgq7.fsf@xenomai.org \
--to=rpm@xenomai.org \
--cc=jan.kiszka@siemens.com \
--cc=xenomai@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.