Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp137280rwd; Wed, 14 Jun 2023 13:28:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ52suFoaP6A7BQ25eEOfcr9EAs9b32kox770LQQsMvKeOHDyxWY0RGc+31jGtrQ9HE6Thmx X-Received: by 2002:a05:6a20:54a8:b0:10f:472f:ffbb with SMTP id i40-20020a056a2054a800b0010f472fffbbmr3445271pzk.7.1686774500785; Wed, 14 Jun 2023 13:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686774500; cv=none; d=google.com; s=arc-20160816; b=ZOblPr4+nSNxnRn0oTV4lNhHfKfbyjT0Bb77lefE+RPGFiQLpzX33qN0LCozWgqm6e VwaMyQjhnZ/PH14xkAdEpzmPPSQ4xAKNoEYrrl4zv1W7XGVFKhYuAMtJ+ttzxkqFazOp TA5gGwnNLmrisqOlPbMvvJ4pNhoo6ZQYZrKPGHP7cCTGiCmutRrpkIFcRFIWWNhTAWeM A+e8tHtnemv+7IP0FY5oOHn/iDqPVaAisrZNM0uNrTd7jIwi6sgNVuxLA5EYlx1PHAKx QEc+S7/rqot9MNnVcj9D9MIRgbp28bdrMLGXz1ZVlAFp8XdCfeQk+Jp08sDaRDDTPLBD EOHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=8rktf2uLTnKAQUHaIFj/SYHVmzsJNecM/MARwTsCRF4=; b=QxH9VekDyG88HWLGOUMrPlp02NZOAyco922acMXHumawhfaNXes/IZ57k9FTUOqllA 070VXZT+/T7WF8p3zmjpZ8CeeVlGe1Nu7sDktHKF0BaQpGSsZo1i/BboeRc6y2svBzb5 ntYtnJMldXZZbuah10LVMKQQDwB626HAvGI1HvGucjnJPaQ+9DpTUfaDSc5Z72b1y+CQ 4r3UYtwtv0hqWWv04BgWNd0j4Lg/U7jCYgjPFNtJ2bT0P5DOCknuxdRzot549CGyyDZf WidWcpJda0Kf4wOD46UIJcEIF4MKoOjVWfDmq6YdEJaHdSWia0n2BrsYuxAIvVrqvLCX scvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZrB4WUtg; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v69-20020a638948000000b0051b70b1f1f5si684228pgd.608.2023.06.14.13.28.08; Wed, 14 Jun 2023 13:28:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ZrB4WUtg; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233697AbjFNTxa (ORCPT + 99 others); Wed, 14 Jun 2023 15:53:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234459AbjFNTx0 (ORCPT ); Wed, 14 Jun 2023 15:53:26 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CF20171C for ; Wed, 14 Jun 2023 12:53:25 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1686772402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8rktf2uLTnKAQUHaIFj/SYHVmzsJNecM/MARwTsCRF4=; b=ZrB4WUtgCvQQVvs23UV6Ikhcfn/btIxZ+0FGiE7k9jn0+c+wU8+4cnUBp2AcOoF4AilMQ9 DWdWZhG2ZeB4NjrICE6jIPmecNqWuyW4wGSXaQlbTXrTSablPSz+Fg2P6FiJyazVXkv9Gm W50uaUzPPIDmCUkXMCpBfIKhUuO9tCWHxQghFm2v5Uz0Zab9U+rxOM5tVfUPLuWWSaWeBr FUkO6lrWUO5YVlyVIXq9kQhxP7gPgochNMO/8EH11XX1vVkhKBUwMj6r5B5KKH/0WHLOBJ FOaSo2T8rRH6C3Um7qSiiBEF+yYFg+JwYFGPGugrYyZ4NAq4ynwwczyhCEy45A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1686772402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8rktf2uLTnKAQUHaIFj/SYHVmzsJNecM/MARwTsCRF4=; b=I5cXD3geq77dGR0+r5QOZ9ZUdK8NDwTLKSBMvNXJ4Ia445PRfQpaDiCiIilxcWbDBt8N4H PYd6NTqCyYOZNXAg== To: Ashok Raj Cc: LKML , x86@kernel.org, Mario Limonciello , Tom Lendacky , Tony Battersby , Ashok Raj , Tony Luck , Arjan van de Veen , Eric Biederman , Ashok Raj Subject: Re: [patch V2 1/8] x86/smp: Make stop_other_cpus() more robust In-Reply-To: References: <20230613115353.599087484@linutronix.de> <20230613121615.639116359@linutronix.de> Date: Wed, 14 Jun 2023 21:53:21 +0200 Message-ID: <87ilbp95xq.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 14 2023 at 12:42, Ashok Raj wrote: > On Tue, Jun 13, 2023 at 02:17:55PM +0200, Thomas Gleixner wrote: >> >> WBINVD is an expensive operation and if multiple CPUs issue it at the same >> time the resulting delays are even larger. > > Is this situation similar to what happened with the unexpected wakeups from > mwait_play_dead()? > > i.e the wbinvd() takes a while, and when CPU0 moves ahead, the previous > kernel marches past the wbinvd() instruction since we didn't wait to ensure > this has indeed completed? This is about reboot and I don't know how wbinvd() interacts with that. But yes, this could be an issue vs. kexec() too. > native_machine_halt() > { > machine_shutdown()->stop_other_cpus() > stop_this_cpu();<---- Unbalanced atomic_dec()? > } > > But the last stop_this_cpu() in native_machine_halt() would > make the count go negative? Maybe that's OK since no one is waiting for it > to go zero at that point? Correct it's the CPU which stopped the others. >> timeout = USEC_PER_MSEC * 10; >> - while (num_online_cpus() > 1 && (wait || timeout--)) >> + while (atomic_read(&stop_cpus_count) > 0 && (wait || timeout--)) >> udelay(1); >> } > > If we go down the INIT path, life is less complicated.. > > After REBOOT_VECTOR IPI, if stop_cpus_count > 0, we send NMI to all CPUs. > Won't this completely update the atomic_dec() since CPUs in hlt() will also > take the NMI correct? I'm not sure if this is problematic. > > Or should we reinitialize stop_cpus_count before the NMI hurrah Bah. Didn't think about HLT. Let me go back to the drawing board. Good catch! >> + /* >> + * Ensure that the cache line is invalidated on the other CPUs. See >> + * comment vs. SME in stop_this_cpu(). >> + */ >> + atomic_set(&stop_cpus_count, INT_MAX); > > Didn't understand why INT_MAX here? Any random number will do. The only purpose is to ensure that there is no dirty cache line on the other (stopped) CPUs. Now let me look into this NMI cruft. Thanks, tglx