Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp63184lql; Fri, 12 Apr 2024 04:01:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWEHMXss2yP28cJ82nTBFVZ2qA/nCHBR/Yml91E14WJxMqEyvdfJQEAetaC89M0DzYv/CP4BOIKAF7gYLu7s9nJcVuJgT+ppjWFmRoBZw== X-Google-Smtp-Source: AGHT+IE/ENHc9ph41ek6983wmQr20Mp/BAG1oSWWeEPjcS3caW9c5u/PDLLZksyFTeyS61Z4RR4D X-Received: by 2002:a05:6a20:d49b:b0:1a9:a3ed:1786 with SMTP id im27-20020a056a20d49b00b001a9a3ed1786mr1757008pzb.38.1712919699128; Fri, 12 Apr 2024 04:01:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712919699; cv=pass; d=google.com; s=arc-20160816; b=vVeoaK/XR2E6NcIAZOk1F/xpi6H+sO8Pyack3QnQuFyST8Cg2cLH6ajEijU2z8EJzD nLx1hKxlDhAvHwAAhFX+d3WAKPiTzKQ/16F9pW6RNG4OceWNeVSx4y60zh/8kX2N4U5H CvD/JasYECjMKqcpOyPtFAtpaFUA1ShRjt4iYJoRPznPKx0S/zHlZQe+DanwT42vkiDD d4ITjNtiMcEXQ5ubo9egG/2ymSLLEJDl2O8kFBUfuyx4C0rFA5q25LV6P6rNVoxihrZZ HLUWq4zFD8lVMwoo9fVbRhOTtUG/LU94fncyZWdZDxMzofugkAgzRY8OzO4Mqfcy6AiT IOGw== 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=seUAdcADTDtFdNmXCQBDtgW819u1HiRZZL/H711T514=; fh=6IJpMDTtnaUF/prfdx4BgoVnDsfGpssO00kDvv705Zs=; b=ak2QujExXG9APfmohve4b8bJoaiZ6PL5Pzv4X5XxlkJpWtoucc3+pgVZCh9fbbLlvI J1wAXao2AdqVebDfVrdZMYD9Xs+kVvjijlmYlOcyKWdSMacjZCKC01QMLg26v1z3lMYV MDLT/lx65utcr6xbN7PJkygmj0SuMHtftwLMN9i+CLYg2O932vqtlN0BwcS3L3fHe16i ObWcARcg1ssaQ+DZqMQ6rCJipZ/USSOY0TTmLUdgEirvCjVXn+16N3KtodSljQDiiFyb 61fQOu5lkDIq+egSAOnExBy4puCow3QKLIXNN/KQnX4tTskg2W/OsSiKg5yYpi5EBWit KArQ==; 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-142539-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142539-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=shingroup.cn Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id y5-20020aa78545000000b006ecfc6ea644si3107888pfn.223.2024.04.12.04.01.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 04:01:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142539-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-142539-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142539-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2073AB22633 for ; Fri, 12 Apr 2024 10:59:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B0F2A5474D; Fri, 12 Apr 2024 10:59:26 +0000 (UTC) Received: from smtpbgjp3.qq.com (smtpbgjp3.qq.com [54.92.39.34]) (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 E1C2F40C15 for ; Fri, 12 Apr 2024 10:59:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.92.39.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712919566; cv=none; b=NOF76q9ALABopXwxmnzzUfogu0uQLH7qg0zP7wJbEo7JeEnStDI93viwaIt9AHIEX4dJBaKeF/9wiyhKrwQwA6vkgA6TcauW3SyHnM65quaTnIBzSeWoH2Q5F0FyXyWfWqefpH7CmC7I7kHxxsbT+lxH2zxMZNlN8cnRic+8ThM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712919566; c=relaxed/simple; bh=Y2Fr2z85GiqrsspK1EWPARCrG8qEAgI0otN5jcdYGbA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pvZ0q5PDKE/SYXKWk+UM3XAtElrcbL/3ddn/jgZUMjBFbrdHI9pB0aGGbFoCwA7NVZkmyLTZMDvkguPg7tApfcxA8nzZcWYgi0gZjVkzT41UO6Y3gKLF6PR0RaQAPbn8wN6devTFSiTFpXty6MZKvpPmf/H7Folx4goI6rURgJs= 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.92.39.34 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: bizesmtpsz12t1712919554t1sc4f X-QQ-Originating-IP: XtOo9MhHpQmv59Q3FjqVGhMpUYTa/sen1b4+R/N3Lyg= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 12 Apr 2024 18:59:12 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: vrqOr+ppv0swERXAarxGZQvyAMZZ/l6B37dFgG2uQThzhiA2EgalD6ig2x8OV NSQ75IlmVX14Xw2yeqH+ooyMOCVMRuqE6/VRs6tGFwE+f6A/aOB8LJl1+k1lZGTERf36BF4 9IU5PXB9teHLdp0oWbRPjFJFJEUp5Cqxjoj5MEInMdenxQdYYvO0qg1JJoc7ov9kXkWOITT z+sMmqpVKdwFA6E1iiUi3dTJjTlbYDhME+SwkD7oWhx2zob5q9iQZ0LlPpxsDZ0/ufsF++V 4LBjVzJhfblyUIslnzRaqm3Dkg/idVALMz306M7CEkk17p2bYeSJLUQWywONh73BCpI88pc /9u6T2QfAuX/ZvO00x42zBDIgY09+6A9cLXXM85TYmzcU6pVx9RuhFK9zOj6LCrCLl1HoDV 3UcfBM8Is3Flu7zkZtLRBA== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 10109608025486522936 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 3/6] irqchip/gic-v3-its: Avoid explicit cpumask allocation on stack Date: Fri, 12 Apr 2024 18:58:36 +0800 Message-Id: <20240412105839.2896281-4-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. Remove cpumask var on stack and use proper cpumask API to address it. Signed-off-by: Dawei Li --- drivers/irqchip/irq-gic-v3-its.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index fca888b36680..a821396c4261 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -3826,7 +3826,7 @@ static int its_vpe_set_affinity(struct irq_data *d, bool force) { struct its_vpe *vpe = irq_data_get_irq_chip_data(d); - struct cpumask common, *table_mask; + struct cpumask *table_mask; unsigned long flags; int from, cpu; @@ -3850,8 +3850,11 @@ static int its_vpe_set_affinity(struct irq_data *d, * If we are offered another CPU in the same GICv4.1 ITS * affinity, pick this one. Otherwise, any CPU will do. */ - if (table_mask && cpumask_and(&common, mask_val, table_mask)) - cpu = cpumask_test_cpu(from, &common) ? from : cpumask_first(&common); + if (table_mask && cpumask_intersects(mask_val, table_mask)) { + cpu = cpumask_test_cpu(from, mask_val) && + cpumask_test_cpu(from, table_mask) ? + from : cpumask_first_and(mask_val, table_mask); + } else cpu = cpumask_first(mask_val); -- 2.27.0