From nobody Fri Feb 13 07:05:55 2026 Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) (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 34DD5548E3 for ; Fri, 12 Apr 2024 10:59:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.207.22.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712919600; cv=none; b=WPES0sUxHLH+2e42eti1g+uUFSvfW6sUQSOIiuALKBSOWxxyYM169UZVqp+YMxLeFauGrFFSICtth8JczjHOvcgsT+MLOK35LHSfluXXmdut7BWBTXHF1F1tk9FXlLOPBZI5k15KWnEwgh2Qf+efDC+dQbUV7aRwKdNA0vPbFgY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712919600; c=relaxed/simple; bh=07NTM88QwRzoo390ZLemINoqh6/jCN/PfEP7yU0wEwI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PtaSO6fF5bIN/MYCa2SB4S4zu5n5HAAIt1j4AVFHPnkGEqTszQTPdzJvqcVH+BMqRkTCVx5ZASOwvH0NH950Pa4BrBDIJcxTDt5HmuKrxnWfEYNnk4L9Kt6Qn5/jsCMSEg7C/cDvcZ7DgdqzdWFi3Vk1z8PmnGWbu17PvULgIms= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shingroup.cn; spf=pass smtp.mailfrom=shingroup.cn; arc=none smtp.client-ip=54.207.22.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=shingroup.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=shingroup.cn X-QQ-mid: bizesmtpsz2t1712919573t6idgx7 X-QQ-Originating-IP: epgQDvPTX2f4nlnGaXUhvRLzY2bOY8814GkkAA2Z0gE= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 12 Apr 2024 18:59:31 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: aEYUFldOyMp/nydjx6hhyShFrAjETMenuO2m1lkToK8BDMN65Wz87U1LGva1P SJTxf4Tys6KTeVMEnKTjN+lnkdO9yEuULZWIp0ivGAYN0ye4g/JW/eCpgKAXXc7gs8f2u2/ oOhl3Iv5F1Mmvel5E/u2SV1DrvTAUOBQNDcwE+APnG+EU5+LeJAladVFSygvYvQmI58v6Fa /7LBGexoai35+1NGyhmsFqVaUVm63IsCoLqM9CxbmzTy2KHPY3iJIULqdWKzqEdlVDYGrEs gRvLgWIVMfR780jHJA1ADL2afvR42kvanTByg7gVYVEgovPui4/LRgyCRwHzmhEDUKj02OU UatbOK/N6Jh94CbV338lW1zS5t/yNKVW2FyHbQ4pJQVfuN6etlydIUV2q+hhYlrJHl01Kt9 6B9N1DNgnTVU78jfyC8DdaHHfZ97Y5g5 X-QQ-GoodBg: 2 X-BIZMAIL-ID: 11278858222069621144 From: Dawei Li To: tglx@linutronix.de, yury.norov@gmail.com Cc: akpm@linux-foundation.org, maz@kernel.org, florian.fainelli@broadcom.com, chenhuacai@kernel.org, jiaxun.yang@flygoat.com, anup@brainfault.org, palmer@dabbelt.com, samuel.holland@sifive.com, linux@rasmusvillemoes.dk, linux-kernel@vger.kernel.org, Dawei Li Subject: [PATCH 6/6] irqchip/sifive-plic: Avoid explicit cpumask allocation on stack Date: Fri, 12 Apr 2024 18:58:39 +0800 Message-Id: <20240412105839.2896281-7-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240412105839.2896281-1-dawei.li@shingroup.cn> References: <20240412105839.2896281-1-dawei.li@shingroup.cn> 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 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpsz:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz5a-1 Content-Type: text/plain; charset="utf-8" In general it's preferable to avoid placing cpumasks on the stack, as for large values of NR_CPUS these can consume significant amounts of stack space and make stack overflows more likely. Use cpumask_first_and_and() to avoid the need for a temporary cpumask on the stack. Signed-off-by: Dawei Li --- drivers/irqchip/irq-sifive-plic.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-sifive-plic.c b/drivers/irqchip/irq-sifive= -plic.c index f3d4cb9e34f7..bf5d2fc6396e 100644 --- a/drivers/irqchip/irq-sifive-plic.c +++ b/drivers/irqchip/irq-sifive-plic.c @@ -164,15 +164,13 @@ static int plic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, bool force) { unsigned int cpu; - struct cpumask amask; struct plic_priv *priv =3D irq_data_get_irq_chip_data(d); =20 - cpumask_and(&amask, &priv->lmask, mask_val); - if (force) - cpu =3D cpumask_first(&amask); + cpu =3D cpumask_first_and(&priv->lmask, mask_val); else - cpu =3D cpumask_any_and(&amask, cpu_online_mask); + cpu =3D cpumask_first_and_and(&priv->lmask, mask_val, + cpu_online_mask); =20 if (cpu >=3D nr_cpu_ids) return -EINVAL; --=20 2.27.0