[RFC PATCH v7 18/23] entry/idle: Enter and exit kernel protection during idle entry and exit

From: Julien Desfossez
Date: Fri Aug 28 2020 - 15:54:29 EST


From: "Joel Fernandes (Google)" <joel@xxxxxxxxxxxxxxxxx>

Make use of the generic_idle_{enter,exit} helper function added in
earlier patches to enter and exit kernel protection.

On exiting idle, protection will be reenabled.

Signed-off-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx>
---
include/linux/entry-common.h | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index 2ea0e09b00d5..c833f2fda542 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -374,6 +374,9 @@ void noinstr irqentry_exit(struct pt_regs *regs, irqentry_state_t state);
*/
static inline void generic_idle_enter(void)
{
+ /* Entering idle ends the protected kernel region. */
+ sched_core_unsafe_exit();
+
rcu_idle_enter();
}

@@ -383,6 +386,9 @@ static inline void generic_idle_enter(void)
static inline void generic_idle_exit(void)
{
rcu_idle_exit();
+
+ /* Exiting idle (re)starts the protected kernel region. */
+ sched_core_unsafe_enter();
}

#endif
--
2.17.1