From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 C28222472AA for ; Wed, 18 Mar 2026 16:55:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773852911; cv=none; b=VElmKBgfTwMpkGfD8TWzh8Ps5ODz84rmL9LPHziECTH2zBmCJptM00qScdmN1CjPDGDehz28twASnU3S2krsqZcTY3diKin82mBeMUI4uH3bDGfd1yPwsMVLzd9QAAvOtNIKb5+BURXissGuy8aKwsC6kzLnM6uSGq1lr0wkHow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773852911; c=relaxed/simple; bh=cSa+e8oDCvx8cxjvw6zOAdMUpVFwT/UPhyFf0WSmqdg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KTIzz318BNQhg0zbV+MkHXr34I4sTbMHlHKVBnxKkkt7eV5rN1CF7KCE86N4BnCZEyu5LshENud9zmTkBhTq3Id/Gzcrz2UYkx/RTiJ0Bm3Og1Jf3YpA6yqWgNo7RTyiCUN5Gm6va+D989gy0JfnuzoElZ3xFNlz09RaEI4rW5c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=PmqByAIt; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=NV/YjMTx; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PmqByAIt"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="NV/YjMTx" Date: Wed, 18 Mar 2026 17:55:03 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1773852904; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hPyqmCLJoZ6nND3spjfxQ2WfNqF1iXkKWh7MuY81CQU=; b=PmqByAItCDWjJmaAShzLPBv+H8i8L14OAzqMjZDA2xTwi1HSq5OltNQr0cqcwwrGfYdNGh 2ElgffFLVSIAzLs9rGuctIsaGrwvlAb9oIsUIPhVdcv/KzequJeM5WNlZIABDyA7IQAb+Q tmni0KW36/xzpbI8xmSsg+fM0bala2VbO5MISdZU5ir1FXl/oO7E8NddwqpUT+by2AQwV9 q9txWBCzHNvXpvhUuzp9+paxEv/ATH2lBpDWEPSpb8umRSa/cm3DkOoPtCHzH/Gw7+eHbH 7kYXYIyOnzpVXEzXJeZk5zAJ64KuKYeuw1XAC4nYuVeEBTV2s3Se7VkX/ZagZw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1773852904; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hPyqmCLJoZ6nND3spjfxQ2WfNqF1iXkKWh7MuY81CQU=; b=NV/YjMTxYEdTH+0heQDgV6HjflIkrUBnkY5/hjByUrkN8ehAl3Fw0iCNOvWuj2ghxg5fGH sExru8J/FICHl2Dw== From: Sebastian Andrzej Siewior To: Chuyi Zhou Cc: tglx@linutronix.de, mingo@redhat.com, luto@kernel.org, peterz@infradead.org, paulmck@kernel.org, muchun.song@linux.dev, bp@alien8.de, dave.hansen@linux.intel.com, pbonzini@redhat.com, clrkwllms@kernel.org, rostedt@goodmis.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 06/12] smp: Enable preemption early in smp_call_function_many_cond Message-ID: <20260318165503.KTk9t8lK@linutronix.de> References: <20260318045638.1572777-1-zhouchuyi@bytedance.com> <20260318045638.1572777-7-zhouchuyi@bytedance.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: <20260318045638.1572777-7-zhouchuyi@bytedance.com> On 2026-03-18 12:56:32 [+0800], Chuyi Zhou wrote: > --- a/kernel/smp.c > +++ b/kernel/smp.c > @@ -907,9 +920,11 @@ static void smp_call_function_many_cond(const struct cpumask *mask, > } > } So now I understand why we have this cpumask on stack. Could we, on a preemptible kernel, where we have a preemption counter, in the case of preemptible() allocate a cpumask and use it here? If the allocation fails or we are not on a preemptbile kernel then we don't do this optimized wait with enabled preemption. There is no benefit of doing all this if the caller has already preemption disabled. > - rcu_read_unlock(); > - if (preemptible_wait) > + if (!preemptible_wait) > + put_cpu(); > + else > free_cpumask_var(cpumask_stack); > + rcu_read_unlock(); > } > > /** Sebastian