Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp1217997lqb; Thu, 18 Apr 2024 03:51:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9qoBTT4s2X82f50C9U+YQt9W5rF5k8XqJ/3GpKyojfmqPz5Tr6dzUZ5QzmIZ2QEVUmkAuL/bPspOEYcbIG0bh5D0E4LWEqdFKT/glVw== X-Google-Smtp-Source: AGHT+IEXAhFTNaNpCJIBDC2jtArtsI3GWMVcBpXkYUJgWCqiA+Vj/ndjaFB+D+Yfbvp099LT8rrZ X-Received: by 2002:a17:90a:ee93:b0:2a2:97cd:9c94 with SMTP id i19-20020a17090aee9300b002a297cd9c94mr2268657pjz.40.1713437488123; Thu, 18 Apr 2024 03:51:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713437488; cv=pass; d=google.com; s=arc-20160816; b=ZsXugaC7k1gpuWzHXWJ8/1aw51txAkaSyQmUEl/obeojG/DnKF8uZziuJQK8GvCWX3 i8yc6fBfo7UijrnxujJ7UyRsWkPio19BNdY4580GnS+i7y9QLV3CtmHVpLCR82NiWEp/ eojbg1O9j8krZyNbsSl1B/dPMhge1MU8sRLMfUNkXdRd4YVhxENijVuadyPRdQZxBTFq zhQWrORt9ceylQKm4IOnbn5uR2hk4/QYB3xRAj2jF3wxdbGml6Twjv005C3l9elKd9v0 YMVu1kEMAGfGMCeJNsNYJRw2xc4Eg8hDUs0oZZtCnP6GstAAyWslIVM0w2VCmWI7/nWB IjAA== 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=rcfADoUHwsIRkeqFOC9wLj2ZrB6Gsdzw5/PDq8wIyy0=; fh=wqGtaQRaft9D0zUHMyMQXhnocNBrwjPdMyctoUHVbL0=; b=bLfj9bYQFmD1uQyJs3vsJ1iIFCyqQaocNjvz+OtkhdVWY57S9w2MQpV/iXTnbzQPuv N9ZGaUmrLMdDHFqRVWUQvUhngiP0aqW3WE1b75kFSU07ztNdXevVXgbBKBijKbA4zXe0 I4o771wV39dtXvHT349lDF4s/Znpf6i7EdDT9edsZuONsxdL884xvb7ufJQbMzhuPGsW 3YEXa73nSPG6RJYqDQT1LAQAvsT2SXZy4d+7ctT/FBhzSdzanLn/ZnAj+sXHWgdvTABf q+IIwiH6qmU/1FEIRP6jlhkA3uycDZFLdBYtkmpVfvyZ/bTa+o4wmaIlafE1R0eCE8Ge svJg==; 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-149913-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149913-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 q6-20020a17090a938600b002a280773045si1244693pjo.91.2024.04.18.03.51.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Apr 2024 03:51:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149913-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-149913-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149913-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 C0EAE2819C9 for ; Thu, 18 Apr 2024 10:51:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6539115E803; Thu, 18 Apr 2024 10:50:43 +0000 (UTC) Received: from smtpbgeu2.qq.com (smtpbgeu2.qq.com [18.194.254.142]) (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 0A35915E1F0; Thu, 18 Apr 2024 10:50:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.194.254.142 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713437442; cv=none; b=kaktEsyTVWxZFg9Jt4h4NOhR1vV0eUYClPBW2oWJ5jo8QJCq0yp2CBaZO8NeesLYjGh2PonwXCpPUS4Q2dGKDOHm74c+tUlakEV52PzmjjUT8m4EUpRaf5ie4un3u39zKFymCV819Fb4lM3msH3GKeXhT3NdfGS/AL9PVT81FLA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713437442; c=relaxed/simple; bh=v+TsHhOic2mg/W7XaFw3VXmkSiLUX6C2ryCfDoKko/M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iCcC/hzL9VpRS0Ogy7nemnSKOP5kTGPHGXR8j7MgHjKsvcewmd9fmI2Jzq/+HjflPSh2oAC+Vp6hGBEJtjkh3MlDrO6o+xAuDy2K2LmUwMcSZzQ2sAQ/bV8LMAhC1WJkNmfmJ3T3fZa3poONGp0LQlPgcjVWC3eP6Okx6L8/fh0= 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=18.194.254.142 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: bizesmtpsz8t1713437412tqw6p93 X-QQ-Originating-IP: WpIr14ItWW3kn7iY60aK0PXSNTpq8Q1puqksk+zM4H0= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 18 Apr 2024 18:50:10 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: ILHsT53NKPgF/epwiDI/4li9pVuruvg8/g0sLIWJRf2YdA0Z9a72l36WAi2Tp 17Mu6Tdm3hRyqu7SMKiCMfuHMMVKSImTiX0pUMsUc5uqRNlUAu7dPls0/AsxD1+5TZ0eSmF jtrOa8lsApsYN5w6adzLqiHt24ZghiivAVyKsHjFeczCyNY+JLri5u6LWEEwlr72Bfw/v9B 4djHd7gQegJb0CzsKq4wR+c+SorgrlB7rngLTr2bbxi3xmGuuqjL61kuvydJHS6ASNP1h7f K32FJUi6aAD5+QRYwHwNRi4X4pBTxO7gmsXhEr3LN0plsNubY6hPqoLkSUosbShfJV32uAj QKfHsusLVt6d0hiB+LxcrL5LWN6IBjJ0NMG+NIw2Q4pTgiPtslesrh/Jnk8f4HJxcvtLHWH aHxSl6E4fn8mvNT5hfFRLQ== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 3648981726944684466 From: Dawei Li To: davem@davemloft.net, andreas@gaisler.com Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, Dawei Li Subject: [PATCH 2/5] sparc/irq: Remove on-stack cpumask var Date: Thu, 18 Apr 2024 18:49:46 +0800 Message-Id: <20240418104949.3606645-3-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240418104949.3606645-1-dawei.li@shingroup.cn> References: <20240418104949.3606645-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. - Both 2 arguments of cpumask_equal() is constant and free of change, no need to allocate extra cpumask variables. - Merge cpumask_and(), cpumask_first() and cpumask_empty() into cpumask_first_and(). Signed-off-by: Dawei Li --- arch/sparc/kernel/irq_64.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c index 5280e325d4d6..bc96f1bcd2fc 100644 --- a/arch/sparc/kernel/irq_64.c +++ b/arch/sparc/kernel/irq_64.c @@ -349,17 +349,13 @@ static unsigned int sun4u_compute_tid(unsigned long imap, unsigned long cpuid) #ifdef CONFIG_SMP static int irq_choose_cpu(unsigned int irq, const struct cpumask *affinity) { - cpumask_t mask; int cpuid; - cpumask_copy(&mask, affinity); - if (cpumask_equal(&mask, cpu_online_mask)) { + if (cpumask_equal(affinity, cpu_online_mask)) { cpuid = map_to_cpu(irq); } else { - cpumask_t tmp; - - cpumask_and(&tmp, cpu_online_mask, &mask); - cpuid = cpumask_empty(&tmp) ? map_to_cpu(irq) : cpumask_first(&tmp); + cpuid = cpumask_first_and(affinity, cpu_online_mask); + cpuid = cpuid < nr_cpu_ids ? : map_to_cpu(irq); } return cpuid; -- 2.27.0