Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp811521rwd; Thu, 15 Jun 2023 02:19:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6z28Y0w7zqUvrld4ql7K0uNPMIX4pdnRcSazp25DQZQUqHm8Lrv2b+yE6RrFwr7CkTj6hT X-Received: by 2002:a92:c882:0:b0:340:b4b2:5fb8 with SMTP id w2-20020a92c882000000b00340b4b25fb8mr3306800ilo.10.1686820774173; Thu, 15 Jun 2023 02:19:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686820774; cv=none; d=google.com; s=arc-20160816; b=a1EAoCeM4RdRt69x5eQMukDF740hDxYf3bgJPC5VwCKoRjiUascSlGgLoqCQneuy1X bFRMxPladvlnlbcu1Nm/vtxhdGLMNppn2dns893YaeQyEC4kJ5d05OH0tYA2ayFxXw2J ScsCSECSklkFUGdR9NdbOxBXZNMuYIqviwC9vHx1YFQnXNR1keB+32OpwkaWVYQGhNDZ LxJ1GFoRKyk/ugI0YBEhlNpkvyZZCNqdTPFCX5U33CfkIppDWUuYU/VN8EIZsL1VnTYT o2uaCoETEjXygv9aCBJQOudqaCeK6srkHUZ735eI23DjpkSsl0/iv5J1Tnda5hsWpCnI dyXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Fe+VRkanewCfNokcW8tgDEMFQdyBOvcUG3s+qHI7UXQ=; b=anFbONQ9uyOPmD1gayezcainZtfq68kS76idRqvCmOuGUdEj6A3F0nOKdLwtAwGduB FJdyWi0RfWGJhq+2Iz9/0YazShoaO6Z6QNghAbekaYoX5aQoSor+msTJvKR5Pj814Ntz NmXPkmL5J9ah4bN27SYYyyWgfLN3EKgGBZQyvB8Y5m8gusL977HhDIUImOJ3KBrZTTfQ CwxgRAswIs9Mbn6Ybb0Fh7oUpYAJjOUOkNMhpBocpsENBOFDsMIzvKsPY5hQB3YjgQLM Pe9GmKec3zugTtr4tVlAafOL0+h+rP3m5jWb35PzD058x6JYcyb/6ijRpJGYU53e2Knm /GQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=grlx5SxB; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lr1-20020a17090b4b8100b00256610c2765si9651107pjb.125.2023.06.15.02.19.22; Thu, 15 Jun 2023 02:19:34 -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=@infradead.org header.s=desiato.20200630 header.b=grlx5SxB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243365AbjFOJDJ (ORCPT + 99 others); Thu, 15 Jun 2023 05:03:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244919AbjFOJDE (ORCPT ); Thu, 15 Jun 2023 05:03:04 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98D562711 for ; Thu, 15 Jun 2023 02:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Fe+VRkanewCfNokcW8tgDEMFQdyBOvcUG3s+qHI7UXQ=; b=grlx5SxBMAMtMYQbj4GkCyTFtf aXxZwNduRAcpDhHvVfqWLl0586dPYgosMlkU64G0R5WEUJNfmkMPOLvvSKjhhmNwFeep/W28h3Dsk KgnxcbAgaxMx2EOBQgr5VGWdh5Jja9CvmTc8r9dy2Q8OFb/7GPoazsw881YpenCMeTUABzbxM1LA+ kmfqzeDl6NNybMrpNhC43N4/6b/nKPb5sXajJVuckGyX7HOflISiyPlvOE0327J/cvmOjIT2nwnD+ 3HALsli5hGvErqEs6c8/zcTrzdukuKDFmsY+KE4WqsXtehsl3KSpVRz8N0OJD++Lw/Ynh+wCCtI1W UbO91sLw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q9isV-00Bl4G-0T; Thu, 15 Jun 2023 09:02:51 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id E01C13002A9; Thu, 15 Jun 2023 11:02:49 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C729F265FBBD4; Thu, 15 Jun 2023 11:02:49 +0200 (CEST) Date: Thu, 15 Jun 2023 11:02:49 +0200 From: Peter Zijlstra To: Thomas Gleixner 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 4/8] x86/smp: Acquire stopping_cpu unconditionally Message-ID: <20230615090249.GD1683497@hirez.programming.kicks-ass.net> References: <20230613115353.599087484@linutronix.de> <20230613121615.820042015@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230613121615.820042015@linutronix.de> 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_NONE,T_SCC_BODY_TEXT_LINE 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 Tue, Jun 13, 2023 at 02:17:59PM +0200, Thomas Gleixner wrote: > There is no reason to acquire the stopping_cpu atomic_t only when there is > more than one online CPU. > > Make it unconditional to prepare for fixing the kexec() problem when there > are present but "offline" CPUs which play dead in mwait_play_dead(). > > They need to be brought out of mwait before kexec() as kexec() can > overwrite text, pagetables, stacks and the monitored cacheline of the > original kernel. The latter causes mwait to resume execution which > obviously causes havoc on the kexec kernel which results usually in triple > faults. > > Move the acquire out of the num_online_cpus() > 1 condition so the upcoming > 'kick mwait' fixup is properly protected. > > Signed-off-by: Thomas Gleixner > Reviewed-by: Ashok Raj > --- > arch/x86/kernel/smp.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > --- a/arch/x86/kernel/smp.c > +++ b/arch/x86/kernel/smp.c > @@ -153,6 +153,12 @@ static void native_stop_other_cpus(int w > if (reboot_force) > return; > > + /* Only proceed if this is the first CPU to reach this code */ > + if (atomic_cmpxchg(&stopping_cpu, -1, safe_smp_processor_id()) != -1) > + return; > + > + atomic_set(&stop_cpus_count, num_online_cpus() - 1); > + if (({ int old = -1; !atomic_try_cmpxchg(&stopping_cpu, &old, safe_smp_processor_id()); })) return; Doesn't really roll of the tongue, does it :/ Also, I don't think anybody cares about performance at this point, so ignore I wrote this email. /me presses send anyway.