From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) (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 D5D5838A71D for ; Wed, 18 Mar 2026 14:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773844336; cv=none; b=HmjitMJSwvpcByT1RGo5E3SNcqs+yf1NM3leja5+aMeu5clhSCzpw3D+6DfTfoHjTq+iHf+VIXU51ebQeOOEsXH5/UvMZq/Ai6ZgVuXmsvFf0L31R888HmWC6I/PizwyZ5LXGW3ZNeii/VAnxxfvS9GfjBioZsJCDju+PyAJa9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773844336; c=relaxed/simple; bh=haq8ijDKBcEV7vVPy70pCMXZixnfv/AfriQ59n47CBk=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jRhKGJN4jB8uKZbEyMGtzO1/3EOtlWvMNQbOUT93Soq3HIjMHNtTbrsDQAOJg2yNvYQXd0eapr11u7w/BM3eLkGpv+e/YoidTWwNQiFUJ+Ii1ISPH3/hOjqplAn/hgIo16wYrKn5ht99qovzhbPDEeFeaK6OOXDEKYSR82AE61c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org; spf=pass smtp.mailfrom=goodmis.org; arc=none smtp.client-ip=216.40.44.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=goodmis.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=goodmis.org Received: from omf20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 92C4813B7AB; Wed, 18 Mar 2026 14:32:12 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: rostedt@goodmis.org) by omf20.hostedemail.com (Postfix) with ESMTPA id E232F20028; Wed, 18 Mar 2026 14:32:09 +0000 (UTC) Date: Wed, 18 Mar 2026 10:32:37 -0400 From: Steven Rostedt To: "Chuyi Zhou" Cc: , , , , , , , , , , , Subject: Re: [PATCH v3 03/12] smp: Remove get_cpu from smp_call_function_any Message-ID: <20260318103237.390815ae@gandalf.local.home> In-Reply-To: <20260318045638.1572777-4-zhouchuyi@bytedance.com> References: <20260318045638.1572777-1-zhouchuyi@bytedance.com> <20260318045638.1572777-4-zhouchuyi@bytedance.com> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit X-Stat-Signature: 7zswdtx3h5gumdikcf68zrfp85yqm7eh X-Rspamd-Server: rspamout08 X-Rspamd-Queue-Id: E232F20028 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Session-ID: U2FsdGVkX1+PSLCuMO8ot2TRx59TRsLfg6CtvBEHau8= X-HE-Tag: 1773844329-11081 X-HE-Meta: U2FsdGVkX1/hFt7MHIxpdi5hjmalK0BaoVc+t+4I42Z+TAec80yl8R69DHIIQHL2rqMsSeFYpBmjJjy0ucr6bAUnftgnONbN6iI3KOE3kFuh2VvVojrACzqJ1ONSH7arOuT+rCH4AmmhhvLbcqFf/6gujmtKzmirUk7kYmA5GfHbkWV3PlcMunXzOZdeFiRLTDSGsQ9jrWIAisLtam5q8z6he0Ez34UB2oxqnpHJKZr1nVJyQ5evP10lHu/M6NFoJsS0B8ESK/OZYTHtUtDupAhXU0oceIsFh4b3dH+jMFbqdSnn27PMolXi/So8JGsjw4o/8NBcHwBue8lJKW3AZN2ovtcVSL/gurQKMqoT7kd7TNifoKk8/W4P/NhquFjS On Wed, 18 Mar 2026 12:56:29 +0800 "Chuyi Zhou" wrote: > Now smp_call_function_single() would enable preemption before > csd_lock_wait() to reduce the critical section. To allow callers of > smp_call_function_any() to also benefit from this optimization, remove > get_cpu()/put_cpu() from smp_call_function_any(). > > Signed-off-by: Chuyi Zhou > Reviewed-by: Muchun Song > --- > kernel/smp.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/kernel/smp.c b/kernel/smp.c > index b603d4229f95..80daf9dd4a25 100644 > --- a/kernel/smp.c > +++ b/kernel/smp.c > @@ -761,16 +761,26 @@ EXPORT_SYMBOL_GPL(smp_call_function_single_async); > int smp_call_function_any(const struct cpumask *mask, > smp_call_func_t func, void *info, int wait) > { > + bool local = true; > unsigned int cpu; > int ret; > > - /* Try for same CPU (cheapest) */ > + /* > + * Prevent migration to another CPU after selecting the current CPU > + * as the target. > + */ > cpu = get_cpu(); > - if (!cpumask_test_cpu(cpu, mask)) > + > + /* Try for same CPU (cheapest) */ > + if (!cpumask_test_cpu(cpu, mask)) { > cpu = sched_numa_find_nth_cpu(mask, 0, cpu_to_node(cpu)); Hmm, isn't this looking for another CPU that is closest to the current CPU? By allowing migration, it is possible that the task will migrate to another CPU where this will pick one that is much farther. I'm not sure if that's really an issue or not, as I believe it's mostly for performance reasons. Then again, why even keep preemption disabled for the current CPU case? Isn't disabling preemption more for performance than correctness? Perhaps migrate_disable() is all that is needed? -- Steve > + local = false; > + put_cpu(); > + } > > ret = smp_call_function_single(cpu, func, info, wait); > - put_cpu(); > + if (local) > + put_cpu(); > return ret; > } > EXPORT_SYMBOL_GPL(smp_call_function_any);