Re: [PATCH 3/3] livepatch: Avoid potential RCU stalls in klp transition

From
Yafang Shao <hidden>
Date
2025-02-12 02:43:10
Reply to
Josh Poimboeuf, 2025-02-12
On Wed, Feb 12, 2025 at 8:52 AM Josh Poimboeuf [off-list ref] wrote:
On Tue, Feb 11, 2025 at 02:24:37PM +0800, Yafang Shao wrote:
quoted
+++ b/kernel/livepatch/transition.c
@@ -491,9 +491,18 @@ void klp_try_complete_transition(void)
                      complete = false;
                      break;
              }
+
+             /* Avoid potential RCU stalls */
+             if (need_resched()) {
+                     complete = false;
+                     break;
+             }
      }
      read_unlock(&tasklist_lock);

+     /* The above operation might be expensive. */
+     cond_resched();
+
This is also nasty, yet another reason to use rcu_read_lock() if we can.
The RCU stalls still happen even if we use rcu_read_lock() as it is
still in the RCU read-side critical section.
Also, with the new lazy preemption model, I believe cond_resched() is
pretty much deprecated.
I'm not familiar with the newly introduced PREEMPT_LAZY, but it
appears to be a configuration option. Therefore, we still need this
cond_resched() for users who don't have PREEMPT_LAZY set as the
default.
Also, for future patch sets, please also add lkml to cc.  Thanks.
Sure.

--
Regards
Yafang
Thread (30 messages) 30 messages, 3 authors, last reply 2025-02-18
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help