From: Jisheng Zhang <jszhang@kernel.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Thomas Gleixner <tglx@linutronix.de>,
Schaffner Tobias <tobias.schaffner@siemens.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>, Arnd Bergmann <arnd@arndb.de>
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-arch@vger.kernel.org
Subject: [PATCH RT 1/3] asm-generic/preempt: also check preempt_lazy_count for should_resched() etc.
Date: Thu, 11 May 2023 00:24:04 +0800 [thread overview]
Message-ID: <20230510162406.1955-2-jszhang@kernel.org> (raw)
In-Reply-To: <20230510162406.1955-1-jszhang@kernel.org>
lazy preempt count is great mechanism to help ordinary SCHED_OTHER
tasks' throughput Under PREEMPT_RT. But current implementation relies
on each arch-specific code to check the preempt_lazy_count in
should_resched() and __preempt_count_dec_and_test(), if the arch, e.g
riscv use the asm-generic preempt implementation, it losts the great
lazy preempt mechanism.
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
include/asm-generic/preempt.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/asm-generic/preempt.h b/include/asm-generic/preempt.h
index b4d43a4af5f7..b583e7c38ccf 100644
--- a/include/asm-generic/preempt.h
+++ b/include/asm-generic/preempt.h
@@ -59,6 +59,11 @@ static __always_inline void __preempt_count_sub(int val)
*preempt_count_ptr() -= val;
}
+#ifdef CONFIG_PREEMPT_LAZY
+#define preempt_lazy_count() (current_thread_info()->preempt_lazy_count)
+#else
+#define preempt_lazy_count() (0)
+#endif
static __always_inline bool __preempt_count_dec_and_test(void)
{
/*
@@ -66,7 +71,7 @@ static __always_inline bool __preempt_count_dec_and_test(void)
* operations; we cannot use PREEMPT_NEED_RESCHED because it might get
* lost.
*/
- return !--*preempt_count_ptr() && tif_need_resched();
+ return !--*preempt_count_ptr() && !preempt_lazy_count() && tif_need_resched();
}
/*
@@ -75,6 +80,7 @@ static __always_inline bool __preempt_count_dec_and_test(void)
static __always_inline bool should_resched(int preempt_offset)
{
return unlikely(preempt_count() == preempt_offset &&
+ !preempt_lazy_count() &&
tif_need_resched());
}
--
2.40.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2023-05-10 16:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 16:24 [PATCH RT 0/3] riscv: add PREEMPT_RT support Jisheng Zhang
2023-05-10 16:24 ` Jisheng Zhang [this message]
2023-05-10 16:24 ` [PATCH RT 2/3] riscv: add lazy preempt support Jisheng Zhang
2023-05-10 16:24 ` [PATCH RT 3/3] riscv: Allow to enable RT Jisheng Zhang
2023-10-23 16:33 ` [PATCH RT 0/3] riscv: add PREEMPT_RT support Schaffner, Tobias
2023-10-23 16:40 ` Jisheng Zhang
2023-10-24 6:18 ` Sebastian Andrzej Siewior
2023-10-31 14:43 ` Jisheng Zhang
2023-10-31 15:34 ` Sebastian Andrzej Siewior
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=20230510162406.1955-2-jszhang@kernel.org \
--to=jszhang@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=arnd@arndb.de \
--cc=bigeasy@linutronix.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=tglx@linutronix.de \
--cc=tobias.schaffner@siemens.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;
as well as URLs for NNTP newsgroup(s).