Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp62664lql; Fri, 12 Apr 2024 04:00:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDfUdCfzYx6cZ5Pp8ikhXZoRExEo5Jlvx5m0iOiC431GtM+POhhseQk8Hina1uwnZ7i3qvSdofM5D6nY8r4JTUgi74xd3OLt6VEsiaaQ== X-Google-Smtp-Source: AGHT+IEKmMycOL4cg2lq8ei3+Ya3h5DFBK8041slhSykUUB4wFhiKw2Zyp8MhUlEH7dcl/jssQna X-Received: by 2002:a05:6102:a4b:b0:47a:39ce:76d3 with SMTP id i11-20020a0561020a4b00b0047a39ce76d3mr2354647vss.26.1712919651225; Fri, 12 Apr 2024 04:00:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712919651; cv=pass; d=google.com; s=arc-20160816; b=eMQGfdbEGc6zAIBEB/bU1Os4x8qv4RQVMEbUifs+AZWfc4rYO2wA/V125rMvlJmeJB IBi0LqwY37RCSzJAZMzDIsAapvNHymlHhODYvvOnno1yVLMmDS/SYbbs/Xc4EhNdWDcG 29QMEJynOhGM1Kw2sl9bNdV5cW9u4IQKIFcZKIs8zN4y+UBS+qezUXR+y3q8Z0lytXNK +Sf14GHw7oVrUGAC1WFNI52NgQAAXBi4aUCsNdVXFLGv0kARbf6575sOHeFGlCWtvPln mfTGNH1TZ0nw/qHo/K2vfaFZQghw+Xvvgu0AVgA6NE0cxu7Ea67P3PkE1qj3H2iJ74JY zsQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=feedback-id:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=C/ef+XZPQDhLhxFDsCSfVV+3txsq8fUcvydwgCLYKGo=; fh=6IJpMDTtnaUF/prfdx4BgoVnDsfGpssO00kDvv705Zs=; b=RT/SRA1KbXoCpMbgDANffBEWL3jfuPzWSs705E+jwgR2i7RKMyN98bwT1cenCTm3kR G1vYFjV27SrbeG87uOvcbMHutdBtsj7jiQ0By7dHc0mEhPt0rHrLqKS9g8x1vQHS5gO6 KSGsyFNrkPMEZauXl7BG399fOUscZ1ekxMGKrvCOHBorXwQkq/PX8TmVTcCZ1Fm6N4qd gPhoeTlc9ZodBzt2+CBhJL2VB+vt0v+VPB6kkcouhkkGgXDOgsW1+RPP7dZPIj2hYKJK WqlMTjTAkMjlfTCSXrDISdaCUa692GobgBjWZdnZ3DgxO2T/7l0sv8EA5UTGoHB8dv1l sf9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=shingroup.cn dmarc=pass fromdomain=shingroup.cn); spf=pass (google.com: domain of linux-kernel+bounces-142544-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142544-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=shingroup.cn Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id df31-20020a056102441f00b0047a36ab5862si498102vsb.208.2024.04.12.04.00.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 04:00:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142544-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=shingroup.cn dmarc=pass fromdomain=shingroup.cn); spf=pass (google.com: domain of linux-kernel+bounces-142544-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142544-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=shingroup.cn Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E4BF01C21765 for ; Fri, 12 Apr 2024 11:00:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5BA45490E; Fri, 12 Apr 2024 11:00:00 +0000 (UTC) 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: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpsz:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz5a-1 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 = irq_data_get_irq_chip_data(d); - cpumask_and(&amask, &priv->lmask, mask_val); - if (force) - cpu = cpumask_first(&amask); + cpu = cpumask_first_and(&priv->lmask, mask_val); else - cpu = cpumask_any_and(&amask, cpu_online_mask); + cpu = cpumask_first_and_and(&priv->lmask, mask_val, + cpu_online_mask); if (cpu >= nr_cpu_ids) return -EINVAL; -- 2.27.0