linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: paulmck@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Andy Lutomirski <luto@kernel.org>,
	"Schander, Johanna 'Mimoja' Amelie" <mimoja@amazon.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	X86 ML <x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
	hewenliang4@huawei.com, hushiyuan@huawei.com,
	luolongjun@huawei.com, hejingxian <hejingxian@huawei.com>
Subject: Re: [PATCH] use x86 cpu park to speedup smp_init in kexec situation
Date: Wed, 08 Dec 2021 16:57:07 +0000	[thread overview]
Message-ID: <f67ce85c73941bd5d35e8af84765c70f56ddcdf7.camel@infradead.org> (raw)
In-Reply-To: <0824902894565e850b79e494c38a7856f8358b99.camel@infradead.org>

[-- Attachment #1: Type: text/plain, Size: 2822 bytes --]

On Wed, 2021-12-08 at 15:10 +0000, David Woodhouse wrote:
> @@ -4266,13 +4266,13 @@ void rcu_cpu_starting(unsigned int cpu)
>                 rcu_disable_urgency_upon_qs(rdp);
>                 /* Report QS -after- changing ->qsmaskinitnext! */
>                 rcu_report_qs_rnp(mask, rnp, rnp->gp_seq, flags);
> +               /* Er, why didn't we drop the lock here? */
> -       } else {
> -               raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
>         }
> 

Oh, I see... how about this straw man then...

From 083c8fb2656e9fc60a17c9bfd538fcee4c5ebacc Mon Sep 17 00:00:00 2001
From: David Woodhouse <dwmw@amazon.co.uk>
Date: Tue, 16 Feb 2021 15:04:34 +0000
Subject: [PATCH 1/4] rcu: Expand locking around rcu_cpu_starting() to cover
 rnp->ofl_seq bump

To allow architectures to bring APs online in parallel, we need only one
of them to be going through rcu_cpu_starting() at a time. Expand the
coverage of the existing per-node lock to cover the manipulation of
rnp->ofl_seq too.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 kernel/rcu/tree.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
index ef8d36f580fc..544198c674f2 100644
--- a/kernel/rcu/tree.c
+++ b/kernel/rcu/tree.c
@@ -4246,11 +4246,11 @@ void rcu_cpu_starting(unsigned int cpu)
 
 	rnp = rdp->mynode;
 	mask = rdp->grpmask;
+	raw_spin_lock_irqsave_rcu_node(rnp, flags);
 	WRITE_ONCE(rnp->ofl_seq, rnp->ofl_seq + 1);
 	WARN_ON_ONCE(!(rnp->ofl_seq & 0x1));
 	rcu_dynticks_eqs_online();
 	smp_mb(); // Pair with rcu_gp_cleanup()'s ->ofl_seq barrier().
-	raw_spin_lock_irqsave_rcu_node(rnp, flags);
 	WRITE_ONCE(rnp->qsmaskinitnext, rnp->qsmaskinitnext | mask);
 	newcpu = !(rnp->expmaskinitnext & mask);
 	rnp->expmaskinitnext |= mask;
@@ -4261,6 +4261,11 @@ void rcu_cpu_starting(unsigned int cpu)
 	rdp->rcu_onl_gp_seq = READ_ONCE(rcu_state.gp_seq);
 	rdp->rcu_onl_gp_flags = READ_ONCE(rcu_state.gp_flags);
 
+	smp_mb(); // Pair with rcu_gp_cleanup()'s ->ofl_seq barrier().
+	WRITE_ONCE(rnp->ofl_seq, rnp->ofl_seq + 1);
+	WARN_ON_ONCE(rnp->ofl_seq & 0x1);
+	smp_mb(); /* Ensure RCU read-side usage follows above initialization. */
+
 	/* An incoming CPU should never be blocking a grace period. */
 	if (WARN_ON_ONCE(rnp->qsmask & mask)) { /* RCU waiting on incoming CPU? */
 		rcu_disable_urgency_upon_qs(rdp);
@@ -4269,10 +4274,6 @@ void rcu_cpu_starting(unsigned int cpu)
 	} else {
 		raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
 	}
-	smp_mb(); // Pair with rcu_gp_cleanup()'s ->ofl_seq barrier().
-	WRITE_ONCE(rnp->ofl_seq, rnp->ofl_seq + 1);
-	WARN_ON_ONCE(rnp->ofl_seq & 0x1);
-	smp_mb(); /* Ensure RCU read-side usage follows above initialization. */
 }
 
 /*
-- 
2.31.1


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5174 bytes --]

  reply	other threads:[~2021-12-08 16:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87ft22dxop.fsf@nanos.tec.linutronix.de>
     [not found] ` <27357c74bdc3b52bdf59e6f48cd8690495116d64.camel@infradead.org>
     [not found]   ` <877dnedt7l.fsf@nanos.tec.linutronix.de>
     [not found]     ` <87zh09tcqz.fsf@nanos.tec.linutronix.de>
2021-02-16 13:53       ` [PATCH] use x86 cpu park to speedup smp_init in kexec situation David Woodhouse
2021-02-16 15:10         ` David Woodhouse
2021-02-16 21:18           ` David Woodhouse
2021-12-08 14:14           ` David Woodhouse
2021-12-08 14:50             ` Paul E. McKenney
2021-12-08 15:10               ` David Woodhouse
2021-12-08 16:57                 ` David Woodhouse [this message]
2021-12-08 17:35                   ` Paul E. McKenney
2021-12-08 18:32                     ` David Woodhouse
2021-12-08 19:03                       ` Paul E. McKenney
2021-12-08 20:35                         ` David Woodhouse
2021-12-08 21:09                           ` Paul E. McKenney
2020-12-15 14:46 shenkai (D)
2020-12-15 16:31 ` Andy Lutomirski
2020-12-15 21:20   ` Thomas Gleixner
2020-12-16  8:45     ` shenkai (D)
2020-12-16 10:12       ` Thomas Gleixner
2020-12-16 14:18         ` shenkai (D)
2020-12-16 15:31           ` Thomas Gleixner
2020-12-17 14:53             ` shenkai (D)
2021-01-07 15:18             ` David Woodhouse
2021-01-19 12:12     ` David Woodhouse
2021-01-21 14:55       ` Thomas Gleixner
2021-01-21 15:42         ` David Woodhouse
2021-01-21 17:34           ` David Woodhouse
2021-02-01 10:36         ` David Woodhouse

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=f67ce85c73941bd5d35e8af84765c70f56ddcdf7.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=bp@alien8.de \
    --cc=hejingxian@huawei.com \
    --cc=hewenliang4@huawei.com \
    --cc=hpa@zytor.com \
    --cc=hushiyuan@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luolongjun@huawei.com \
    --cc=luto@kernel.org \
    --cc=mimoja@amazon.com \
    --cc=mingo@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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).