From nobody Thu Apr 2 02:40:39 2026 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 BBE91368272 for ; Tue, 31 Mar 2026 02:14:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774923297; cv=none; b=XLFJhi3/Q+zRP42Z6t8snabjIjc40p4B4C1kXG+V3T58Qcmq7OcBaCB44vjvYJK/AyWknUmSJtF4OgQxw80YAbNdgHLZOUleSRY+YI4hqtoBXb8eulGwaAFULsmLTYXaun0xHehWBD2+WD3YJc3EpvRyr+Cn/YwK1jsVf3uBZeg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774923297; c=relaxed/simple; bh=lq3b7BEifEyLFAFMNfdpLJ7nzFwn9qYMHE1xHq/129M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tax3/0nN91rHgo7oGKaZ3qYs0RxAYc4VM7D/v/IGOdnrVcqnZnuu7mdsei/fAvLDIJN8qeYnAQ/o4g6S1/Fksk6Zjomc1871tvjsr4n3rj6j7EBf4q665z1GAst3Y+fySwAfC2ru/EGcpK9egv5k0mZoey3KKLynhIx0ezNkiOI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WL7ce7jc; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WL7ce7jc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774923296; x=1806459296; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lq3b7BEifEyLFAFMNfdpLJ7nzFwn9qYMHE1xHq/129M=; b=WL7ce7jcjZP8sSBHHCIUXXBBgmtGu4C7cKNTMBI/ZntOu454V9M+DkwH 6ZC4D8sFfiVdeHtZGjIugWiN8QO+drx58u2RsKgSSSmm+3UFXoBW/2ibC 2OlO+L7fWMyDg3PHW130XiS1dHp/I/PKfE/V7bYlANIip0pDukySfFTqH La3gBZ5tW1L2x3Cpn1/6yy2m9DzsOn9Pdw2fTXAvPJNlX8EEnzUJc5SJ9 szGgklHa4tVH2c3IqQs7WLITO5RcSYVoyYqO+l3vWzaz+w7/vq0Yt/54Y aaz45bfHtA8BJYTJtfT4c7VVOZvcL0fmUSeFkNOrpunsmZfUARpcNDAlm A==; X-CSE-ConnectionGUID: J9b0o9hzSQunXPqtXqdGTg== X-CSE-MsgGUID: SUozWIRWTeKkIphWnSlpZQ== X-IronPort-AV: E=McAfee;i="6800,10657,11744"; a="93508058" X-IronPort-AV: E=Sophos;i="6.23,151,1770624000"; d="scan'208";a="93508058" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2026 19:07:40 -0700 X-CSE-ConnectionGUID: zCkvLtEYQUqy2DAGDRrKLw== X-CSE-MsgGUID: 5SJR8udMQaC6CmTMIYne5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,151,1770624000"; d="scan'208";a="221358680" Received: from chang-linux-3.sc.intel.com (HELO chang-linux-3) ([172.25.66.172]) by fmviesa006.fm.intel.com with ESMTP; 30 Mar 2026 19:07:40 -0700 From: "Chang S. Bae" To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, peterz@infradead.org, david.kaplan@amd.com, chang.seok.bae@intel.com Subject: [PATCH v2 03/11] stop_machine: Refactor multi-CPU stop glue code Date: Tue, 31 Mar 2026 01:42:41 +0000 Message-ID: <20260331014251.86353-4-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260331014251.86353-1-chang.seok.bae@intel.com> References: <20260331014251.86353-1-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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" stop_machine_cpuslocked() currently configures struct multi_stop_data and invokes the multi-stop operation. An upcoming stop_machine() variant will have different configurations but the latter part will be shareable. Extract the common part into stop_multi_cpus() to highlight each unique front-end. No functional change. Signed-off-by: Chang S. Bae --- V1 -> V2: New patch --- kernel/stop_machine.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 15268f1207e9..092c65c002ff 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c @@ -584,18 +584,8 @@ static int __init cpu_stop_init(void) } early_initcall(cpu_stop_init); =20 -int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data, - const struct cpumask *cpus) +static int stop_multi_cpus(struct multi_stop_data *msdata) { - struct multi_stop_data msdata =3D { - .fn =3D fn, - .data =3D data, - .num_threads =3D num_online_cpus(), - .active_cpus =3D cpus, - }; - - lockdep_assert_cpus_held(); - if (!stop_machine_initialized) { /* * Handle the case where stop_machine() is called @@ -605,19 +595,34 @@ int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *d= ata, unsigned long flags; int ret; =20 - WARN_ON_ONCE(msdata.num_threads !=3D 1); + WARN_ON_ONCE(msdata->num_threads !=3D 1); =20 local_irq_save(flags); hard_irq_disable(); - ret =3D (*fn)(data); + ret =3D msdata->fn(msdata->data); local_irq_restore(flags); =20 return ret; } =20 /* Set the initial state and stop all online cpus. */ - set_state(&msdata, MULTI_STOP_PREPARE); - return stop_cpus(cpu_online_mask, multi_cpu_stop, &msdata); + set_state(msdata, MULTI_STOP_PREPARE); + return stop_cpus(cpu_online_mask, multi_cpu_stop, msdata); +} + +int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data, + const struct cpumask *cpus) +{ + struct multi_stop_data msdata =3D { + .fn =3D fn, + .data =3D data, + .num_threads =3D num_online_cpus(), + .active_cpus =3D cpus, + }; + + lockdep_assert_cpus_held(); + + return stop_multi_cpus(&msdata); } =20 int stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus) --=20 2.51.0