From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 145DF35B63F for ; Tue, 27 Jan 2026 15:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.109.113.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769529010; cv=none; b=HKRZrF12dPWu4AayoeIh2gjHkbDGILICFSrUcQEHWpZUbL+Q7GfPe2fD3sDWRuPRYQqTP1ktWMZ/UitugU7t2fbSsr+JNM7YrVH8Mw/EpMQTBg/TQlSDN55o8sqTEXJY8BvNMLwUvTBNQVOsjPy58gxMFDZbjQiqQbTkOOXY9mA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769529010; c=relaxed/simple; bh=ccCPx205sx0/Bkso0wOnKlAk1ndU0vW/suxHPQoYIRA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=f5hNhlP6bKslJq3Sqo6n/d5R0Fz+c8GPk3clhTqX0WsDNSf3pyyWDYcDpJMf7KmcoFeXkrc9Y2O0tm1zJISKDeesFlcI/mn5g0BqsTNPKyGoYccpWEAWukG8YOhwR1MxYxwMUv2ah3x0mJoqlYzvRWwPXXLxI4U9HdAjAMH4zf4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de; spf=pass smtp.mailfrom=alien8.de; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b=Hz1DEogS; arc=none smtp.client-ip=65.109.113.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alien8.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b="Hz1DEogS" Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id B414740E01A3; Tue, 27 Jan 2026 15:50:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=pass (4096-bit key) header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id pwVMmhC465mt; Tue, 27 Jan 2026 15:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1769529003; bh=Nh7pZuW7hc4qHW4b5tbWE2/xHM4q+vhrndnmwSVh7Ww=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Hz1DEogSjaNGusAqzHCc2BwRxsa6Zwb7JERmz77UdaJ66bvfdRlsmPm+PgwACPvmK hVL1UZI8s1CN/VNxf8hPkQENCPK3Pv/AduO8j8UI8MYqy0JXGageMWHYn8AVCMkxP7 CXkegR7/43wEhgaeu5xTF2g4tNsbH4O4gAfPPuX5D1R4JrAHZvasxAEi2yCh6TQ4ts DellyJ3AFx8uk9KD/YTGs5Keil25LajyuIg5jgl9HmnN5zcf0BlosFg0sakQkhnupU 8m524pJqdBKpCvWxoMdPy+tjVX7htHPHscS7+w9PrtZg1gCFKT0c6aLKgDvp/kqpHI qE3E9504gDfwBsTxG71XRead9EudZQ36/rLBl5n0awrwTtH9E7LPwnb2L2OvdYUFyt WFnzu+0mt9KeDwIu5mB/38EebeiISO5uQ2hHEohrg2OSejRJxHeHo/r3zhxvkG7WPN A9BbmGzYgNHefPGk9OiFYMCMNj+/J9/51br5u702ORtwOra9C9oVvTI7Pv8/kdstH8 LVBrLL6auRlovg0IwGyujmLhuzP4NU6B+vtMKKmddlmqehLbcr3iCUG6Io7C3afO+7 uRqz1IZgVKrjit1BMEC1iQY87WBJWHaRMNnNJcJ5LwH8lVMj/yN/A3aGzap/nS4vBU BEo92DvM3/Yg2LCgozI9gp8E= Received: from zn.tnic (pd953023b.dip0.t-ipconnect.de [217.83.2.59]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with UTF8SMTPSA id DDDF140E0140; Tue, 27 Jan 2026 15:49:54 +0000 (UTC) Date: Tue, 27 Jan 2026 16:49:48 +0100 From: Borislav Petkov To: "Chang S. Bae" Cc: linux-kernel@vger.kernel.org, x86@kernel.org, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, peterz@infradead.org, david.kaplan@amd.com Subject: Re: [PATCH 1/7] stop_machine: Introduce stop_machine_nmi() Message-ID: <20260127154948.GLaXjenHeJ7Ay6OFJ5@fat_crate.local> References: <20260125014224.249901-1-chang.seok.bae@intel.com> <20260125014224.249901-2-chang.seok.bae@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20260125014224.249901-2-chang.seok.bae@intel.com> On Sun, Jan 25, 2026 at 01:42:16AM +0000, Chang S. Bae wrote: > +/** > + * stop_machine_nmi: freeze the machine and run this function in NMI context > + * @fn: the function to run > + * @data: the data ptr for the @fn() > + * @cpus: the cpus to run the @fn() on (NULL = any online cpu) s/cpu/CPU/g in all text. > + * > + * Like stop_machine() but runs the function in NMI context to avoid any risk of > + * interruption due to NMIs. > + * > + * Protects against CPU hotplug. > + */ > +int stop_machine_nmi(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus); > + > +/** > + * stop_machine_cpuslocked_nmi: freeze and run this function in NMI context > + * @fn: the function to run > + * @data: the data ptr for the @fn() > + * @cpus: the cpus to run the @fn() on (NULL = any online cpu) > + * > + * Same as above. Must be called from within a cpus_read_lock() protected > + * region. Avoids nested calls to cpus_read_lock(). > + */ > +int stop_machine_cpuslocked_nmi(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus); > /** > * stop_core_cpuslocked: - stop all threads on just one core > * @cpu: any cpu in the targeted core > @@ -160,6 +183,14 @@ int stop_core_cpuslocked(unsigned int cpu, cpu_stop_fn_t fn, void *data); > > int stop_machine_from_inactive_cpu(cpu_stop_fn_t fn, void *data, > const struct cpumask *cpus); > + > +bool noinstr stop_machine_nmi_handler(void); > +DECLARE_STATIC_KEY_FALSE(stop_machine_nmi_handler_enable); Why is the static key in the header if you have an accessor below? > +static __always_inline bool stop_machine_nmi_handler_enabled(void) > +{ > + return static_branch_unlikely(&stop_machine_nmi_handler_enable); > +} Just make the accessor the only thing that external code calls. ... > +DEFINE_STATIC_KEY_FALSE(stop_machine_nmi_handler_enable); > +static DEFINE_PER_CPU(struct stop_machine_nmi_ctrl, stop_machine_nmi_ctrl); > + > +static void enable_nmi_handler(struct multi_stop_data *msdata) > +{ > + this_cpu_write(stop_machine_nmi_ctrl.msdata, msdata); > + this_cpu_write(stop_machine_nmi_ctrl.nmi_enabled, true); > +} Why do we have to enable the NMI handler? > +void __weak arch_send_self_nmi(void) > +{ > + /* Arch code must implement this to support stop_machine_nmi() */ > +} -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette