From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 F226545517C for ; Wed, 29 Jul 2026 15:30:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785339057; cv=none; b=PCAxi5AKOyFf7PB/4XAsKdcZZ8s+CdOxO47K97Le7T6wEsSJqP0hPCg/5rJf1LK8v54PuQK2SAZBtyh/AO7m5fFZdQv39c1WoWDTAsin4kMTNy92tNDZOoTCx+jDJwDJ7Tu5rhqu0G4ThY8IEFBJVI9mQJO7qMbYTC9nxvXoNJo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785339057; c=relaxed/simple; bh=UV2A8iq+AWlbUkGvb6/hehc04B6Jd8OigmAmXMX11WI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=leQEStXVsTybNfeuOlMT7RHDeA2mgThHf3BjOcoFI7iCwxhnDz/r+cOLqpm2cNnrsmfvVMkvfdtagxpri6mcHXei4WO2/4VS2JBH9WbjDD3AVJB4rDBQAdrly+XAxfj1nlbeHV+UHaceaLje1L4G+lXGWfYm3LOdRP5boZqiiFk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=GNh/NPX+; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="GNh/NPX+" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66TFHaBe388610; Wed, 29 Jul 2026 15:30:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=OHc/ca TixbKA8+J4Cmzz19PIhdQvBy1e1ryP7r12Kgs=; b=GNh/NPX+y8hN3onfsOxHC7 xHd8+IClWDA5+XuyczSpqKM0FsC7GyCM0oBZtHJIPbTQjEPMpbmTHrdmkR6uYqVq tT2Jd5MLnAH3dYHl9Tf+qduRVm3glNXpLDzb/n8F4W+fhs4eoDNIKfhuoETyODI8 U9WmlXYK5AzMOXvu/O9bk45vTYVz9iAHYR60Ow985yeC7ks7FZgBH6TfSBO1Zvlt Y69djb8E0FiJABTCNt8FW43/HfBlTWJ8M/5AYJ+W/du3EdYdRGvVeuG6Y235D9yr BU1v1hnjRn9eUc3ZBqXY02bhkFpU5mflVO/04yhpMMsDxs6LUXEFu0HwiUmsY42w == Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4fmv0xueh9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Jul 2026 15:30:10 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 66TFQItU002203; Wed, 29 Jul 2026 15:30:09 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4fn7fqff6h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 29 Jul 2026 15:30:09 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 66TFU7Gp49742302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Jul 2026 15:30:07 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A649820043; Wed, 29 Jul 2026 15:30:07 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C2B5320040; Wed, 29 Jul 2026 15:30:04 +0000 (GMT) Received: from [9.39.24.89] (unknown [9.39.24.89]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 29 Jul 2026 15:30:04 +0000 (GMT) Message-ID: Date: Wed, 29 Jul 2026 21:00:03 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] stop_machine: Make stop_one_cpu_nowait() return void To: Yury Norov , Yury Norov Cc: Bradley Morgan , linux-kernel@vger.kernel.org, Oleg Nesterov , "Paul E . McKenney" , Peter Zijlstra , Phil Auld , Sebastian Andrzej Siewior , Tejun Heo , =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= , Valentin Schneider References: <20260729022355.325058-1-ynorov@nvidia.com> From: Shrikanth Hegde Content-Language: en-US In-Reply-To: <20260729022355.325058-1-ynorov@nvidia.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: EuvLq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ely3wSFcr1k8Dvo2CqKZEnfi6cgZtK/vrnsN8oqPItDYuWGlnLJFYVh7ylUO 2i+UEHMHg3QFwC5WcBg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-29_06,2026-07-29_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 clxscore=1011 phishscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 suspectscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607290123 Hi Yury. On 7/29/26 7:53 AM, Yury Norov wrote: > No caller checks the return value from stop_one_cpu_nowait(). All > callers require the callback to run and arrange for the target CPU's > stopper to remain enabled while queuing the work. In particular, commit > f0498d2a54e7 ("sched: Fix stop_one_cpu_nowait() vs hotplug") added > preemption protection to the scheduler callers so that queuing must > succeed once the target CPU has been observed online. > > Therefore, a failure is an unrecoverable violation rather than a condition > individual callers can recover from. Diagnose it with WARN_ON_ONCE() in > stop_one_cpu_nowait(). A check in the common helper covers current and > future callers consistently, while individual checks would duplicate > the same non-recoverable handling at every call site. > > Make the function return void because there is no longer a meaningful > result for callers to consume. > > On UP, warn if the supplied CPU is not the current CPU because the work > cannot be scheduled in that case. > > CC: Bradley Morgan > Signed-off-by: Yury Norov > --- > v1: https://lore.kernel.org/all/20260724232325.594212-1-ynorov@nvidia.com/ > v2: > - carefully include linux/bug.h (Bradley); > - update the CONTEXT section (Bradley). > > include/linux/stop_machine.h | 21 ++++++++++----------- > kernel/stop_machine.c | 14 ++++++-------- > 2 files changed, 16 insertions(+), 19 deletions(-) > > diff --git a/include/linux/stop_machine.h b/include/linux/stop_machine.h > index 01011113d226..84e7fb627ba4 100644 > --- a/include/linux/stop_machine.h > +++ b/include/linux/stop_machine.h > @@ -2,6 +2,7 @@ > #ifndef _LINUX_STOP_MACHINE > #define _LINUX_STOP_MACHINE > > +#include > #include > #include > #include > @@ -31,7 +32,7 @@ struct cpu_stop_work { > > int stop_one_cpu(unsigned int cpu, cpu_stop_fn_t fn, void *arg); > int stop_two_cpus(unsigned int cpu1, unsigned int cpu2, cpu_stop_fn_t fn, void *arg); > -bool stop_one_cpu_nowait(unsigned int cpu, cpu_stop_fn_t fn, void *arg, > +void stop_one_cpu_nowait(unsigned int cpu, cpu_stop_fn_t fn, void *arg, > struct cpu_stop_work *work_buf); > void stop_machine_park(int cpu); > void stop_machine_unpark(int cpu); > @@ -68,19 +69,17 @@ static void stop_one_cpu_nowait_workfn(struct work_struct *work) > preempt_enable(); > } > > -static inline bool stop_one_cpu_nowait(unsigned int cpu, > +static inline void stop_one_cpu_nowait(unsigned int cpu, > cpu_stop_fn_t fn, void *arg, > struct cpu_stop_work *work_buf) > { > - if (cpu == smp_processor_id()) { > - INIT_WORK(&work_buf->work, stop_one_cpu_nowait_workfn); > - work_buf->fn = fn; > - work_buf->arg = arg; > - schedule_work(&work_buf->work); > - return true; > - } > - > - return false; > + if (WARN_ON_ONCE(cpu != smp_processor_id())) > + return; > + > + INIT_WORK(&work_buf->work, stop_one_cpu_nowait_workfn); > + work_buf->fn = fn; > + work_buf->arg = arg; > + schedule_work(&work_buf->work); > } > > static inline void print_stop_info(const char *log_lvl, struct task_struct *task) { } > diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c > index 773d8e9ae30c..d085ba1f4b44 100644 > --- a/kernel/stop_machine.c > +++ b/kernel/stop_machine.c > @@ -7,6 +7,7 @@ > * Copyright (C) 2010 SUSE Linux Products GmbH > * Copyright (C) 2010 Tejun Heo > */ > +#include > #include > #include > #include > @@ -376,17 +377,14 @@ int stop_two_cpus(unsigned int cpu1, unsigned int cpu2, cpu_stop_fn_t fn, void * > * and will remain untouched until stopper starts executing @fn. > * > * CONTEXT: > - * Don't care. > - * > - * RETURNS: > - * true if cpu_stop_work was queued successfully and @fn will be called, > - * false otherwise. > + * Don't care, but the caller must ensure @cpu's stopper stays enabled > + * until the work is queued, e.g. by preempt_disable(). nit: * until the work is queued, i.e. ensuring preemption/irq disabled. ? Because, if irq are disabled it is equally good enough. #define preemptible() (preempt_count() == 0 && !irqs_disabled()) > */ > -bool stop_one_cpu_nowait(unsigned int cpu, cpu_stop_fn_t fn, void *arg, > - struct cpu_stop_work *work_buf) > +void stop_one_cpu_nowait(unsigned int cpu, cpu_stop_fn_t fn, void *arg, > + struct cpu_stop_work *work_buf) > { > *work_buf = (struct cpu_stop_work){ .fn = fn, .arg = arg, .caller = _RET_IP_, }; > - return cpu_stop_queue_work(cpu, work_buf); > + WARN_ON_ONCE(!cpu_stop_queue_work(cpu, work_buf)); > } > > static bool queue_stop_cpus_work(const struct cpumask *cpumask, Other than that, Reviewed-by: Shrikanth Hegde