Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2796269lqt; Tue, 23 Apr 2024 01:36:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBHxn0B4IlRN7sJw75vtfUzLl9RzPTPhQMN36PIqRiO5v266WEvFYsCAT3LSrG6NHcSePIBgz+m7eXvSgWE+MNpY8cPFc2VOYTOvfNSg== X-Google-Smtp-Source: AGHT+IGBS8a55iAScYn9Ne2Lxd6RrndYE13nD+27Q9D7Q4Or9lTvI8QHBN94GUh7Rqt8sYnHTqTE X-Received: by 2002:a05:6830:3445:b0:6ea:30bc:a6b5 with SMTP id b5-20020a056830344500b006ea30bca6b5mr14772738otu.22.1713861369568; Tue, 23 Apr 2024 01:36:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713861369; cv=pass; d=google.com; s=arc-20160816; b=j3sZpOzVBAD8ZaAEOjL5JT7a5+pFu+qQ7vx+EO85OATI/8RegU8khrW+pxxOBvlaFu OEaDCjFYNqdC41yiIprGwcqBuh69KAd0DhHlufBcIQ6+ElQhUGBolsuSNLUVMlRNq1sy mN9J9sBwRE+SAWjJaPrP6HfQ2E9JDQ1tpJpOqXW2L/bjjFQKRCnTfaS1pSBoYViN7LC/ H9MpJYfhX8lpAkxsJoEXwNiX6hylAcqm3B/QvsbVHiWTZaTTK/8amolKnKa2DxRavmkS l8sU7JukKEYHDvoMYq7DR4t4yQxp8E7d0FvWRNeaenQXujSt9F0NvC8E5anS1fu5dnl1 Yahg== 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=uSvdEvGENX610IlwJqU5GFIg1zzf/l1TjYWmDbqMLZM=; fh=G+96+g6i3+MsNX6tI5HdBwIuZ4Gw9WUIhLzaUYuKmBE=; b=g6TKeL/2zrHlhpMQPoUUq7RIX8wtR2GlUP7hL103s9LXHtF8sRUnWIcwg9KyQu5dVK UQQn7dt51md0joRwL7Rjr06+wsaCZJQ0y8LUY1FQzzZHD6Nmssy6M/v62JJV8/v1SC0R 8+GGVOvBfZhzQ08cQgfHSw/5bw4k+eVh8m5J6YBBhM5Tr8+H5tPOaiPZOz92w7cvceJf 6MGDPYNSIG6d+05xow0f1BVY0kwlk34VyiPFaui1zqc1x6z24ozFJ0EQlwXeg54MZb9H fBVerfX3Yq9jkxrzOyy1kK7cZr9R9uPVszRmUeddwD5RKERGVyZDSSlfpTOrDx6h0oly WYFQ==; 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-154691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154691-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m70-20020a633f49000000b005f7a9c5ff88si7714133pga.425.2024.04.23.01.36.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 01:36:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::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-154691-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154691-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 DAD6A284583 for ; Tue, 23 Apr 2024 08:32:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E556755E4F; Tue, 23 Apr 2024 08:32:02 +0000 (UTC) Received: from smtpbgsg1.qq.com (smtpbgsg1.qq.com [54.254.200.92]) (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 93E6D5914A; Tue, 23 Apr 2024 08:31:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.254.200.92 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713861122; cv=none; b=q2XZ2Rs0P00mnjQ+Y/e4H6ibRts31sTgjVRvEyPzr7oiECxREVVOVT7aCAWu0w4SAbzYWt/G0Wg626hE6AIOvFS0YxzDX0C0tlar4bHaSJ/Lve9B6mEvOxY7ilkIMGhBsHm+fWfPu6NZwyJVXeqFemIFELlEHKdvuCmopgZbGAw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713861122; c=relaxed/simple; bh=HWaOv2WaYtGj0iTIw2G2YzAPc0ZR6ectSGNf9jiMO48=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=M6jNjwaofswmkNxCZRThwZbOmxZFuwWH6n4eM/MlmIefoH5AYogruzAD+32ZNJTai418GlzX/Se2xgxdc3gRMEE0RTVx3tvl4CiEVG6dlTX85dyZ6MZrwozukxZ92ZiNCXMQ6N9vaEYIlmpq2sKsbrdRfC9Lb7EL3e4l2IoSC2E= 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.254.200.92 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: bizesmtpsz7t1713861094tqgo9ne X-QQ-Originating-IP: lutf5bzmJ+wbPedIhfSab7lj8PN8lQro23AoaHRKdWM= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 23 Apr 2024 16:31:33 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: uGhnJwy6xZIizkFrb/rVCurMDKP/+zTB8OFqsvNeXejTj8VZ9Sxq8g+ekbZUt PMba5l+JTWxdLtFbdtdCDmH34yN51tjkxmHh1s2QrrTCHn2wO+I6GnCo1bgbkKxtw/ZqFg2 tANj+CHcr/JctFwzpeP3bugRDzA0VPk6NdOP5fvDnFg5GvEXtfCbHameZpNmzU5CC2VGXdO 9V8bzKevFVcgNjZWH/Qh0IfnEOFC8elDcpcQrvNZVTk5DxC3cDhRpywfWAyknsb3ea5/tOR DH4CgpC09gvWomJ+jvCOyPp38Kc/ZpitxJKqUmh91NU88pU3/7I09pOrZYXlYdxxm/ELOuc tTU9LpVYpTM5V0Uh4yQYa9ckPrW8ENfEIAQ4TBjzodHZi8SJYYCFTXTTZfziOY2uSFKDUIT fzCXbr5VavSmxRTybMT/cfUodPiO0rTV X-QQ-GoodBg: 2 X-BIZMAIL-ID: 4735814251220725647 From: Dawei Li To: davem@davemloft.net, andreas@gaisler.com Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, sam@ravnborg.org, Dawei Li Subject: [PATCH v3 6/6] sparc/leon: Remove on-stack cpumask var Date: Tue, 23 Apr 2024 16:30:43 +0800 Message-Id: <20240423083043.3735921-7-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240423083043.3735921-1-dawei.li@shingroup.cn> References: <20240423083043.3735921-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_subset() and cpumask_first_and() to avoid the need for a temporary cpumask on the stack. Signed-off-by: Dawei Li --- arch/sparc/kernel/leon_kernel.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c index 4c61da491fee..a43cf794bb1e 100644 --- a/arch/sparc/kernel/leon_kernel.c +++ b/arch/sparc/kernel/leon_kernel.c @@ -106,13 +106,12 @@ unsigned long leon_get_irqmask(unsigned int irq) #ifdef CONFIG_SMP static int irq_choose_cpu(const struct cpumask *affinity) { - cpumask_t mask; + unsigned int cpu = cpumask_first_and(affinity, cpu_online_mask); - cpumask_and(&mask, cpu_online_mask, affinity); - if (cpumask_equal(&mask, cpu_online_mask) || cpumask_empty(&mask)) + if (cpumask_subset(cpu_online_mask, affinity) || cpu >= nr_cpu_ids) return boot_cpu_id; else - return cpumask_first(&mask); + return cpu; } #else #define irq_choose_cpu(affinity) boot_cpu_id -- 2.27.0