Re: [PATCH RFC 02/12] entry/idle: Add a common function for activites during idle entry/exit

From: Joel Fernandes
Date: Sun Aug 16 2020 - 22:17:19 EST


Hello Peter,

On Sat, Aug 15, 2020 at 10:14:41AM +0200, peterz@xxxxxxxxxxxxx wrote:
> On Fri, Aug 14, 2020 at 11:18:58PM -0400, Joel Fernandes (Google) wrote:
> > Currently only RCU hooks for idle entry/exit are called. In later
> > patches, kernel-entry protection functionality will be added.
> >
> > Signed-off-by: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx>
>
> NAK, rcu_idle_enter() is broken where it is now, it needs to be pushed
> in deeper:
>
> http://lkml.kernel.org/r/20200807193017.962482579@xxxxxxxxxxxxx

Thank you for pointing it out. Not a huge problem, a couple ways I can do it:
1. Move the calls to sched_core_unsafe_{enter,exit}() deeper into the idle loop.
2. Keep the calls to sched_core_unsafe_{enter,exit}() where they are now as
in this patch, but leave out the rcu_idle_{enter,exit}() calls alone so
they can be moved deeper as you mentioned.

#1 is not necessary for these patches to work and might be overkill.

I'll go the #2 route then. Let me know any other ideas you might have.

What I am trying to do here is to handle a case where task is switching to
idle (say it went to sleep) and wakes up later.

usermode -> syscall (kernel mode - so mark unsafe) -> idle (mark safe).

idle -> syscall wakes (kernel mode - so mark unsafe) -> usermode (mark safe).

Thank you,

- Joel