From: Prakash Sangappa <prakash.sangappa@oracle.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"mathieu.desnoyers@efficios.com" <mathieu.desnoyers@efficios.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"bigeasy@linutronix.de" <bigeasy@linutronix.de>,
"kprateek.nayak@amd.com" <kprateek.nayak@amd.com>
Subject: Re: [PATCH V3 1/4] Sched: Scheduler time slice extension
Date: Tue, 6 May 2025 01:23:55 +0000 [thread overview]
Message-ID: <E47F0700-73FE-4D85-A5FA-CE14D0C41CE4@oracle.com> (raw)
In-Reply-To: <20250505123423.3494a18b@gandalf.local.home>
> On May 5, 2025, at 9:34 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Mon, 5 May 2025 15:58:12 +0000
> Prakash Sangappa <prakash.sangappa@oracle.com> wrote:
>
>> Yes the application would only call they system call to yield cpu, if the extension is granted.
>>
>> The ‘RSEQ_CS_FLAG_DELAY_RESCHED’ bit in the ‘rseq’ structure is cleared when the
>> time extension is granted. This would indicate to the application that a time extension was
>> granted. The application is expected to call the system call if this bit got cleared.
>>
>> However, It is possible that the thread gets rescheduled within the extended time window due
>> to another wakeup or runtime expiry, which the user thread would not know unless we add
>> another bit to indicate it got rescheduled in the extended time. Also, if the task’s critical section
>> ran longer and the hrtick rescheduled the thread, the application would not know.
>>
>> Or we need to guarantee the thread will not get rescheduled in the extended time?
>>
>> I believe it would be same with your patch also.
>
> So, my patch had a bit that got set when an extension happened.
>
> Bit zero was set by the kernel.
>
> Bits 1-31 was a counter (so that the code could nest).
>
> On exiting the critical section a task would call something like:
>
> static inline bool dec_extend(volatile unsigned *ptr)
> {
> if (*ptr & ~1)
> asm volatile("subl %b1,%0"
> : "+m" (*(volatile char *)ptr)
> : "iq" (0x2)
> : "memory");
>
> return *ptr == 1;
> }
>
> [..]
> if (dec_extend(&rseq_map->cr_counter)) {
> rseq_map->cr_counter = 0;
> yield();
> }
>
> That is, the user space task would increment the counter by two when
> entering a critical section and decrement it by two when exiting. If the
> counter ends up as 1, then it not only is out of all nested critical
> sections, it also knows it was extended and will schedule out.
>
> My kernel patches would set the bit if it extended the time slice, but if
> it then scheduled the task, it would clear it again. That way when the task
> is scheduled back on the CPU it will not call yield() again.
>
I see, you set the flag in ‘rseq’ struct when extension was granted and clear it in
rseq_delay_resched_tick(). In your case you had rseq_delay_resched_tick()
being called from hrtick_clear(). hrtick_clear() gets called from __schedule() if sched_feat()
is set.
In my patchset, it just clears the RSEQ_CS_FLAG_DELAY_RESCHED bit to indicate
when extension was granted.
In order to allow the application to call sched_yield() to yield the cpu, only if the thread was not
already rescheduled in the extended time, we would need the support as you have in your patch set.
Does it have to be sched_yield()? Or can the application call some other (fast)system call to yield the cpu
(getppid(2) ) if extended time was granted?
It appears by default sched feature HRTICK/HRTICK_DL is disabled so hrtick_clear()
Will not get called from __schedule(). I have noticed that enabling these sched
feature to let hrtick_clear() get called from __schedule(), adds overhead.
So not sure if we need to enable the sched_feat(HRTICK//HRTICK_DL) to use the scheduler time extension.
Maybe rseq_delay_resched_tick() with this support, would have to be called in __schedule() path but not
thru hrtick_clear(),
-Prakash
> -- Steve
next prev parent reply other threads:[~2025-05-06 1:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-02 1:59 [PATCH V3 0/4] " Prakash Sangappa
2025-05-02 1:59 ` [PATCH V3 1/4] Sched: " Prakash Sangappa
2025-05-02 9:05 ` Peter Zijlstra
2025-05-02 13:06 ` Steven Rostedt
2025-05-05 1:51 ` Prakash Sangappa
2025-05-05 14:48 ` Steven Rostedt
2025-05-05 15:58 ` Prakash Sangappa
2025-05-05 16:34 ` Steven Rostedt
2025-05-05 16:45 ` Steven Rostedt
2025-05-06 1:23 ` Prakash Sangappa [this message]
2025-05-06 13:13 ` Steven Rostedt
2025-05-02 15:39 ` Mathieu Desnoyers
2025-05-05 1:46 ` Prakash Sangappa
2025-05-05 1:42 ` Prakash Sangappa
2025-05-02 12:34 ` Sebastian Andrzej Siewior
2025-05-02 14:35 ` Peter Zijlstra
2025-05-02 15:27 ` Sebastian Andrzej Siewior
2025-05-02 1:59 ` [PATCH V3 2/4] Sched: Tunable to specify duration of " Prakash Sangappa
2025-05-02 1:59 ` [PATCH V3 3/4] Sched: Add scheduler stat for cpu " Prakash Sangappa
2025-05-02 1:59 ` [PATCH V3 4/4] Sched: Add tracepoint for sched " Prakash Sangappa
2025-05-02 9:14 ` Peter Zijlstra
2025-05-02 11:02 ` Sebastian Andrzej Siewior
2025-05-02 11:10 ` Peter Zijlstra
2025-05-02 12:31 ` Sebastian Andrzej Siewior
2025-05-05 1:43 ` Prakash Sangappa
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=E47F0700-73FE-4D85-A5FA-CE14D0C41CE4@oracle.com \
--to=prakash.sangappa@oracle.com \
--cc=bigeasy@linutronix.de \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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®