Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp62288lql; Fri, 12 Apr 2024 04:00:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV+kead3lREHOk3uK1/sTfdKXrYP7hbw/R/LOn4sbE72Wb1msH7sK5HEyBetKkfjmeCCHZvCpJGuRC3fTo7uQ0FFXZA2xRGA9R6hCGWoA== X-Google-Smtp-Source: AGHT+IGFsiLYG64NZJoMXFPdo+hODPn3TdsB5s69SdkPTj1Q/aIs9MGfqjuGwKW23i+xMfyQ2o83 X-Received: by 2002:a05:6214:598a:b0:69b:541b:9088 with SMTP id qp10-20020a056214598a00b0069b541b9088mr5116199qvb.8.1712919624607; Fri, 12 Apr 2024 04:00:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712919624; cv=pass; d=google.com; s=arc-20160816; b=MhR3unt5vKkN9gwWjIWujDT9of12LL3b1IQq8MSeTXPwZI6mtb1OpYxpGD53Kwvauz q7NO7u0ZyYWd2TXy0p2rrjZxNS9SBxdewxc8Le0S3Nvge72Okcv3ctCH3qykpzSqheNy xbuI3wwoHgNUXSHv8Tw6jWESVY99mYItv6cpoi8lhMAuYFID1xJ6TME5iNv1AMBSM3K3 +ELFmHlW8f48hzzqpvUdwbK5KaQmQwtFnlm6kes/vONPFD5uSIfOZ69Ke1XU53mbU5e+ HoezBNJN05eYow9V1NllFtpxaHbiLSp8E5LJoeQk9OFpoK0W97XPqDnWIuWhf4Ekohj4 tNkw== 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=WrvyeQTAreDUuGObZzq+acq/E4wyKJO7+poYZG8YbyM=; fh=6IJpMDTtnaUF/prfdx4BgoVnDsfGpssO00kDvv705Zs=; b=WGjXsVx4ET2JefwGYUKmpj7qRZ1Zx7+KuuMlgoI3Wt3RZqhJkW7vL3Vy+7aBGJ/dE5 k9zLOVJhpwnoUjlIGlhu5FxPJMXWBMtSWFRCl6nqCI5zbtiHAbLncvSZKkeK+9qIFlNS YFNAi68p42Mw92AjVzhS/sMncv5nJI+OmrVze5L2FtyouRBtk74Ie1/vgI/bt/L3PNPp yOwa0XbMe07NjQRW8f68w2N/6yi844ezMLMPFHT0Y/SNB1FV3/mZRj1dgpHgSDJ0D0k+ aoxiPLs7FXa5TFsFz9JqnsjJi7BOscVrnvdz/TzonN96rL4FW65Ndt7IOtrVS85jyPYc T/fg==; 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-142542-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142542-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 et14-20020a056214176e00b0069b304f19e5si3290729qvb.508.2024.04.12.04.00.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 04:00:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142542-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-142542-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142542-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 E8E4C1C23350 for ; Fri, 12 Apr 2024 11:00:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B55C55644E; Fri, 12 Apr 2024 10:59:35 +0000 (UTC) Received: from smtpbgeu1.qq.com (smtpbgeu1.qq.com [52.59.177.22]) (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 846C754F83 for ; Fri, 12 Apr 2024 10:59:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.59.177.22 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712919575; cv=none; b=pqA44nC+ciXKjLjSMwSijcFgT2ZNqYadweN7PKRr0FpNSreLV43x1OdycoQvvdQW//Rka2r2ApQpogVQgkBq44kBIgpDaSdqY5+yaDDIULd7fuPFPPQz7znTwDI/mSeCNQVIBVIsuOZvdT4i8yysAw7y1sprMWMlJ9Apxzmv8nI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712919575; c=relaxed/simple; bh=YU9GY9kwwCwrYvzSsJ4J9pmYsZAzvBbQ+w74pN74GBI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mZ+HH0TvKXKyDaFpw9CddZTM+ktQlfMHdgEQPUxcq3Bc3LDoncC4QekRFzWov+2ucxPx3YASdUviOQ2qeasARQMF/oIKCd5lZkV65Qunp6xsaJy85HP3mz/+ZLYGlN8SOBCrPX/XjdHhqqs3a2tiaHGwJpTA0d1cIjagt1dE5QE= 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=52.59.177.22 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: bizesmtpsz8t1712919561ta68hir X-QQ-Originating-IP: ZWB/B4IyZ0qUnNOZL+Tpusla3oVf3Lb8ZOYZb7lrUJE= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 12 Apr 2024 18:59:19 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: RrZlkntZBfm95kGRViz3aLor3/0FhwLyKZAXNIWQAgktxGh8r1b1zwap8vw9f Sm7//RYKxkWd50EwrJamIXK/afovqE2m1EnTP1keOpm2u6LKwYAlec6U8lCuxCFoNbEqLFK JMJYDu/+a/G8St6t/wgv1GGjPxkI12MNlRFKu/YLQxitghtm0MLzWi9QUUI/P1HxoCslPtG yiTwRDkVWzneMoNTAnx5Tfc18AlWPitA/HWMHCoYtigHAn4Cw6CV1ao9mECd3JmzvltHDTg 10w60sutnatI1p88Xyy6bihEWyLqaqDDw44AE0gCacHTJW0+vIS2anqKRyZN7JuzAqTQxIt fyMMzqxGr6r7A2hxvDU670s6a7nmYTc7a0XrqSgkqepMamFlhOk6zrP0lklCnYEHvuvdhFC ODD5wSMhesmr5DJ8GCH79rEIhfQoowb3 X-QQ-GoodBg: 2 X-BIZMAIL-ID: 845724314838511748 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 4/6] irqchip/loongson-eiointc: Avoid explicit cpumask allocation on stack Date: Fri, 12 Apr 2024 18:58:37 +0800 Message-Id: <20240412105839.2896281-5-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-loongson-eiointc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-loongson-eiointc.c b/drivers/irqchip/irq-loongson-eiointc.c index b64cbe3052e8..c9f30e96b5b5 100644 --- a/drivers/irqchip/irq-loongson-eiointc.c +++ b/drivers/irqchip/irq-loongson-eiointc.c @@ -92,19 +92,16 @@ static int eiointc_set_irq_affinity(struct irq_data *d, const struct cpumask *af unsigned int cpu; unsigned long flags; uint32_t vector, regaddr; - struct cpumask intersect_affinity; struct eiointc_priv *priv = d->domain->host_data; raw_spin_lock_irqsave(&affinity_lock, flags); - cpumask_and(&intersect_affinity, affinity, cpu_online_mask); - cpumask_and(&intersect_affinity, &intersect_affinity, &priv->cpuspan_map); - - if (cpumask_empty(&intersect_affinity)) { + cpu = cpumask_first_and_and(&priv->cpuspan_map, affinity, + cpu_online_mask); + if (cpu >= nr_cpu_ids) { raw_spin_unlock_irqrestore(&affinity_lock, flags); return -EINVAL; } - cpu = cpumask_first(&intersect_affinity); vector = d->hwirq; regaddr = EIOINTC_REG_ENABLE + ((vector >> 5) << 2); -- 2.27.0