From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from va-2-112.ptr.blmpb.com (va-2-112.ptr.blmpb.com [209.127.231.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C79B21DE2D8 for ; Thu, 19 Mar 2026 03:46:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.127.231.112 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773892020; cv=none; b=uTZvvuPMz0v8+DifUnJDCiTGYcHc7T8hcUL20A2OMsFPSfbtprKxKS8JFzWvPA7IZthiCV8IpP2QISb12Sb/xEmGco29uCa+GiLFdqWQ7OWLSvVOgqfMuB/pg9k0r/iNbT71IfC0Wt12gw7XC2Lj3Oxp3TjTSosnar/8YJuvY6s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773892020; c=relaxed/simple; bh=3eGefcOeGdh8k4O3lWxz2aRa3JbXO9TdyzXkKLEdEhs=; h=Date:Mime-Version:Content-Type:Cc:From:Subject:In-Reply-To:To: Message-Id:References; b=Vu3kTb8hugGRQ+LQzpPWCOVMJBmPIrJUANrJ/DDscge6AFcBDMXP1iYKF6c9AiKuaaMWcoPGaFroZiPP/F7e7YRF/vXFXWpFlZv9lJ1cvGgrN4P6OnC5n0To5/FyWprEEpmpCYgobFtM/3/MthcbRbv4tiRvFRW93vDf/k7u17I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=hMxhzeQC; arc=none smtp.client-ip=209.127.231.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="hMxhzeQC" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=2212171451; d=bytedance.com; t=1773892005; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=5Psvwf6IkZ5S33GcSm1Ept3QyTlRa/MpwGEMNSTCBp8=; b=hMxhzeQCWLpihteTcyAwmYwdz2V6OCAr+afmE9zeWVv9fev6mxVFUQUpR2WZk+joaqTwVS RyIR2SmNso6DU6qQ8F4PZY6esq9Xv4f4qdrWslYFM4wc3VaDu9bMtFDLxLptacz2k2wZkz VX0LUWbDw6f5Mepj2Y8If/QGd2jeengXu3GQVASEFoJLjZiOWX+b/DD9CBHXnEFy/mgZVX gd7ViEuO+26DpAJcDZ0qRpSZHdOTg7Lf99RJzX+qylm+mSQ1rRjXrVUoYxCPA4u44w4agq KVwJKw9nzHnXHfSi5UNqg/cwiv1iSYWjWhxwSLNcqormaOhl5HUsXGbX3KS7SA== Date: Thu, 19 Mar 2026 11:46:28 +0800 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 Cc: , , , , , , , , , , , From: "Chuyi Zhou" Subject: Re: [PATCH v3 06/12] smp: Enable preemption early in smp_call_function_many_cond X-Lms-Return-Path: In-Reply-To: <20260318165503.KTk9t8lK@linutronix.de> To: "Sebastian Andrzej Siewior" Message-Id: <5f5f9609-4eb1-4cf2-a83e-e0b2c4dbd8ef@bytedance.com> References: <20260318045638.1572777-1-zhouchuyi@bytedance.com> <20260318045638.1572777-7-zhouchuyi@bytedance.com> <20260318165503.KTk9t8lK@linutronix.de> X-Original-From: Chuyi Zhou User-Agent: Mozilla Thunderbird =E5=9C=A8 2026/3/19 00:55, Sebastian Andrzej Siewior =E5=86=99=E9=81=93: > 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 struc= t cpumask *mask, >> } >> } >=20 > 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. >=20 > There is no benefit of doing all this if the caller has already > preemption disabled. >=20 IIUC, we can enable this feature only when=20 `IS_ENABLED(CONFIG_PREEMPTION) && preemptible()`. This way, the optimization can also take effect for=20 CONFIG_CPUMASK_OFFSTACK=3Dy without breaking the RT principle that forbids= =20 memory allocation inside preemption-disabled critical sections. Thanks. >> - rcu_read_unlock(); >> - if (preemptible_wait) >> + if (!preemptible_wait) >> + put_cpu(); >> + else >> free_cpumask_var(cpumask_stack); >> + rcu_read_unlock(); >> } >> =20 >> /** >=20 > Sebastian