Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1927368lqp; Tue, 16 Apr 2024 01:56:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVqrgFDpB40ZnAHhfMw+DiS9kvnoNpRZu87scaJe6PMTXgjf8hHEtQ8I0ppUCouWGFeYTBrAJC9Hb66QiTr6WnNhYaxccMpV9kn3h5VKg== X-Google-Smtp-Source: AGHT+IFfI6rn1ywCMH6HeJ1eBMw8mHI+Kc0KPD2+Sl93ekOSMzgrF/5MU4WFhTmCH+9eWtXy+AY1 X-Received: by 2002:a05:6a21:3511:b0:1aa:5a89:18d7 with SMTP id zc17-20020a056a21351100b001aa5a8918d7mr235063pzb.19.1713257790917; Tue, 16 Apr 2024 01:56:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713257790; cv=pass; d=google.com; s=arc-20160816; b=vFzEAL+vI+0djSpnz0MY1+WUU4yzjLAZ/C9wVLG1bUieBEfx7flv/+fzN8ZHbt3Afz y8xtcrQ86dKyeOcPaMn9QAY8MHVGNN8ZFxV58nauF+7IHdQdey9xeZPO87myHmFSps6b WXLFKbCTZFRc0/9V9y+oFqK7kUekSt0tFfnD9z+g1gprjTvRu3CQMiqJiS87uzxKGQKK 0CBkCpnZupaup0TtTZYLBtff+PLQpkESqnSp7Yd9G8ZuRlDUrUdNcSIitQYiZgvgYcEm iypP/+a3GdZwt8xhoHhu+1Hnmwnrjpk126w9Y02M/k9OheX/V15xiRvNgvlEyROvT7ea wQLA== 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=lXY385dKv5cZHG2EfLdMYWNFYGQF6idce5JQGybqX/Q=; fh=jY7gwwwm9TCzamW30esTQOtJrNF3m0oBBIyoF9sx+6c=; b=doVDLJXpO8AXs8CmdBXaAO4QG2aSKFFugyyx3bAHv8qf5H2m7xjno+whNFQWD+ReaN amqkkO9booF0FeQ9oxHpgLTnWQWYk02YMoGWmYnj2fdER3iGLjIKyr8jL1k2d4bNQKA6 qsGkPaZh7F2qggOwlCVk886LHGElnBbDAvwzhvoHEX8iLDRIzqG7WB6Z22Gqr9FnWFE3 O77V5LxKSfxsCnYXZoGHN3Oy7FYYTF3PwFUGPPYOas4Xc5WbGmp0bT/FFBtIiGgCcxY/ /wodVfUE/LBwQpl6QRXMDupvGMwHwp8KrRvDZip6IbkeozR+HN3mDBw4vLNmhcsnin+K bO3Q==; 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-146521-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146521-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=shingroup.cn Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id fh16-20020a17090b035000b002a06b6f521fsi700353pjb.127.2024.04.16.01.56.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 01:56:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146521-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-146521-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146521-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 99F82284220 for ; Tue, 16 Apr 2024 08:56:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7AF8084D10; Tue, 16 Apr 2024 08:56:17 +0000 (UTC) Received: from smtpbgau2.qq.com (smtpbgau2.qq.com [54.206.34.216]) (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 1736484A41 for ; Tue, 16 Apr 2024 08:56:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.206.34.216 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713257777; cv=none; b=BaHa8ZCmUA1Kl0LQtavqodzfMwD9lYqbi8DYE1tqJqvoJ9+3V4fBwE9dVFgyYkXUZzebfBP5ZkDftQttSgv+0yCJSXC32kQsbMJfXY3u1VymXKKCEEyUyoKofVS4N1lpOLAaJhpVP9IMPqCYauMwdvPdIudrg/qYB2AmqJ1KvK0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713257777; c=relaxed/simple; bh=mJVdhhBUdMA0yYpMEwV9fYT1Nc9uTwmOroHTOpBPLaA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l4WTbu4rJm+mGntUMSw6SMWJppL9uG40ww/TZgFn4uylWI5B7aVXRM5/D4wwNT0Phv6/Rpykqxe3BYHHCqOqSW6Y0t7O21NCcNn/eW6T5VYUTUIQVoTqLOncMY+jiYovxKBsEHqEXf4uJD6Uz0mQsbCOAzp5CV9jQEIFORGTqOk= 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.206.34.216 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: bizesmtpsz9t1713257735tyj1h5z X-QQ-Originating-IP: J1+XVaKYc4gINHAK8uWrRuN71TwNcJxTaQ1+BDrOPt4= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 16 Apr 2024 16:55:33 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: aEYUFldOyMrlL4xvOCm8kicnmgOcnKn7UTC/kO5QwMSgrbXFqqLFILxcKGBQG 8g8JFInrcgLGSkjUuFRyFK3dpcrhElOztBn0Yz+vxv9dRRFsdQ6w6brmEofjzPEdxoa38L+ K7ukP9XkdEgYA8GjB5Bp6bS9HCEM0yCDOhvQ9qs6thBvmS6Y9hdZ16N8v/Y6Q1yQ0fFmiAv VMDkukGzfOhevlawcgNHLxQry+u9zc6Vs2cmY4UmkngTnZGft9Ilh6+9PaYZI4JkZdkjFf8 qNnamZRPnUJrKNS/TM2ehxqnIEkRUXAF0vNKeatKpDEAuF1LhtBjK+QnukSd3smmAx+KsyO 1MIwA6cOAJOIx/1g+o2kz3j7MhVE7Gsy5Ycu3ra5S75uI6OZkh0RNYJwUKhxAANf1xBAyAk nnQ+WEYROU5Mje2KMVB1Lya5eb8Lj05W X-QQ-GoodBg: 2 X-BIZMAIL-ID: 6012901568914722649 From: Dawei Li To: tglx@linutronix.de, yury.norov@gmail.com, rafael@kernel.org 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, daniel.lezcano@linaro.org, linux-kernel@vger.kernel.org, Dawei Li Subject: [PATCH v2 3/7] irqchip/gic-v3-its: Avoid explicit cpumask allocation on stack Date: Tue, 16 Apr 2024 16:54:50 +0800 Message-Id: <20240416085454.3547175-4-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240416085454.3547175-1-dawei.li@shingroup.cn> References: <20240416085454.3547175-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 cpumask_any_and() to address it. Signed-off-by: Dawei Li --- drivers/irqchip/irq-gic-v3-its.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index fca888b36680..20f954211c61 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -3826,9 +3826,9 @@ 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; + unsigned int from, cpu = nr_cpu_ids; + struct cpumask *table_mask; unsigned long flags; - int from, cpu; /* * Changing affinity is mega expensive, so let's be as lazy as @@ -3850,10 +3850,15 @@ 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); - else + if (table_mask) + cpu = cpumask_any_and(mask_val, table_mask); + if (cpu < nr_cpu_ids) { + if (cpumask_test_cpu(from, mask_val) && + cpumask_test_cpu(from, table_mask)) + cpu = from; + } else { cpu = cpumask_first(mask_val); + } if (from == cpu) goto out; -- 2.27.0