[RFC,1/2] rcu: Do prepare and cleanup idle depending on in_nmi()
diff mbox series

Message ID 1529484440-20634-1-git-send-email-byungchul.park@lge.com
State New, archived
Headers show
Series
  • [RFC,1/2] rcu: Do prepare and cleanup idle depending on in_nmi()
Related show

Commit Message

Byungchul Park June 20, 2018, 8:47 a.m. UTC
Get rid of dependency on ->dynticks_nmi_nesting.

Signed-off-by: Byungchul Park <byungchul.park@lge.com>
---
 kernel/rcu/tree.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

Comments

Byungchul Park June 20, 2018, 4:37 p.m. UTC | #1
On Thu, Jun 21, 2018 at 1:14 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
> On Thu, 21 Jun 2018 01:11:36 +0900
> Byungchul Park <max.byungchul.park@gmail.com> wrote:
>
>> > Byungchul, is there any reason to make this change other than preparation
>> > for your second patch?
>>
>> Sorry again I didn't explain it fully in advance. The only reason is to
>> prepare for the 2nd. It was harder to read the patch when I made them
>> into one. But I can make them into one if you don't think so.
>
> Please keep them as separate patches. It's fine to say in one patch
> that it is needed for a following patch. Not exactly in those words
> though.
>
> Each patch should be a stand alone patch, such that a git blame comes
> to it, we don't need to go searching further to see why a change was
> made.
>
> What a change log should say is something like.
>
> "In order to do X, we need to do Y, because of Z" Where X is a
> description of what is to come, Y is a description of what the current
> commit is doing, and Z is the rational for that change.

Very good comment and tip. You're helping me remind a good way
to describe a change log.

>From now on, I wanna try my best to write change logs in the form:

   "In order to do X, we need to do Y, because of Z"

I will. Thanks a lot, Steve.

>
> Thanks,
>
> -- Steve

Patch
diff mbox series

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index deb2508..59ae94e 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -797,6 +797,11 @@  void rcu_nmi_exit(void)
 		return;
 	}
 
+	if (!in_nmi()) {
+		rcu_prepare_for_idle();
+		rcu_dynticks_task_enter();
+	}
+
 	/* This NMI interrupted an RCU-idle CPU, restore RCU-idleness. */
 	trace_rcu_dyntick(TPS("Startirq"), rdtp->dynticks_nmi_nesting, 0, rdtp->dynticks);
 	WRITE_ONCE(rdtp->dynticks_nmi_nesting, 0); /* Avoid store tearing. */
@@ -824,14 +829,8 @@  void rcu_nmi_exit(void)
  */
 void rcu_irq_exit(void)
 {
-	struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks);
-
 	lockdep_assert_irqs_disabled();
-	if (rdtp->dynticks_nmi_nesting == 1)
-		rcu_prepare_for_idle();
 	rcu_nmi_exit();
-	if (rdtp->dynticks_nmi_nesting == 0)
-		rcu_dynticks_task_enter();
 }
 
 /*
@@ -944,6 +943,11 @@  void rcu_nmi_enter(void)
 	if (rcu_dynticks_curr_cpu_in_eqs()) {
 		rcu_dynticks_eqs_exit();
 		incby = 1;
+
+		if (!in_nmi()) {
+			rcu_dynticks_task_exit();
+			rcu_cleanup_after_idle();
+		}
 	}
 	trace_rcu_dyntick(incby == 1 ? TPS("Endirq") : TPS("++="),
 			  rdtp->dynticks_nmi_nesting,
@@ -977,14 +981,8 @@  void rcu_nmi_enter(void)
  */
 void rcu_irq_enter(void)
 {
-	struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks);
-
 	lockdep_assert_irqs_disabled();
-	if (rdtp->dynticks_nmi_nesting == 0)
-		rcu_dynticks_task_exit();
 	rcu_nmi_enter();
-	if (rdtp->dynticks_nmi_nesting == 1)
-		rcu_cleanup_after_idle();
 }
 
 /*