Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp163220lqd; Tue, 23 Apr 2024 19:56:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXxhDD89RrtAmE1VXoTFjhTyiX3Q2wpBYX15QFy5d48IGod4zd68uJfct17deov/2WfjTxAJ5uv0jStzG1vxc+6tZscqe9+B05lMuxpKQ== X-Google-Smtp-Source: AGHT+IG95DN4ghcoptvjOnWgpIhYs6y/QD9+0MXKiUsuNcKlJzSAKQvrSVmydyOcP9RlSJZ3UbEf X-Received: by 2002:a05:6a00:148d:b0:6ea:73d3:d3a with SMTP id v13-20020a056a00148d00b006ea73d30d3amr1615049pfu.22.1713927410974; Tue, 23 Apr 2024 19:56:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713927410; cv=pass; d=google.com; s=arc-20160816; b=iupEZB/SaQJdHrJE8oKi+EMRIJicwFNt3eWelFj1TdNkF5IDkSV5KJgkGhEjM11ovc D7PA3sNs30YwcAVZhplyhZ61mIWlZOKbKrPpHKQ6jJtBUmtZv3B13Livqwyv+9WtFgxz TUg6+2hpn31EFmGykYH4IECsxspiSmkSGZIsr3LBaIh9XtmMjplabrAL/L86FWSMw+4A a5XpH3lUxumlDR+RCS8yq4yXUiM89kESdHVD1OVKk9ioJvMXlfOHdcM0M4dZ43z3kpRo 4fv5yUXPEhw3u3JQnpuHhhf90qA1z1CaBBUl+DSOSl6yRipLyXQD1x+LQnmUv2Sx7qjb zTXQ== 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=dQiYj70UAHc6pq2oMiEd8Va7PQ82edvvaWvRtGu+4+c=; fh=G+96+g6i3+MsNX6tI5HdBwIuZ4Gw9WUIhLzaUYuKmBE=; b=oOhgzNqcQit5Jpj91Hk3CC48lgLpFiTTFG9NZEFK22sQt6yHEkw225njkUbtVclyxk LIVx98+gFIU1mkx2JM9LMM6d9qCfwk50HiBIN+ctw9vKhzSRJebR3S5XsTgnKhEsF+do uqY8lbeA3wKZ59EqS+VTW+H+IZDVPr1GNh3JMK/c3FIaWODVh1IvFEhXvrc8suL3fXsw 7qyLR97vSyM+KM9jcfW9mMsX2Bg9P9qZYrJRlJ4Mz7GFsD5pLbDXoi93uM4NDaQr3XIy VLbb/Oe4lephuLERtDgMD4Z3KWVU9ZlPC1lbeIKV0q6GSi1WBUiSozi0+JpRui0VfuTW CF4g==; 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-156178-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156178-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 o2-20020a63e342000000b005f0c099f66esi6555228pgj.633.2024.04.23.19.56.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 19:56:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156178-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-156178-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156178-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 97C562868E0 for ; Wed, 24 Apr 2024 02:56:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9C4B13048C; Wed, 24 Apr 2024 02:56:36 +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 5436A83CD6; Wed, 24 Apr 2024 02:56:31 +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=1713927396; cv=none; b=eBsuxbB3dSihpNHPpH5bbMeD0rlGZ1PK0NlgoRJRF6984SfuQxPRb0AwnGWAUhrqnQnGNp0Dl6v+wWqY3K+IeVDzhUEM7hr3EzvI8jjKRMizJRlpM9+6xiIkGf0RtjlYkSj57QvhrnZbi9OFBt/v0zxLhr1VwiW8l2X8L9bQU3M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713927396; c=relaxed/simple; bh=N6XTfdxhJpxdxT4fVSZa/iMWuusbHZ+zYGBsuw2wehU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RcFys5OkvNooH02opqoBKl0HzMYJe84lM/RkQUzOGuNpFUPEQxeVAFFU0WxmtXeznE1YQ4qExNhCokzIA2D1wlrBsYgx1PWhfxDUbBCSDSar6xPdEfA7+XAwuQ8GrT0du3HMJE3Bj23f0lxATnlSK7u2ei5kxBVKwzjt7FP0XN4= 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: bizesmtp82t1713927368tef5l9jp X-QQ-Originating-IP: vQmXng/c3dGqL6fSQ4IxNGeevQoaOnnsVqltFEHgBq4= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 24 Apr 2024 10:56:06 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: xo0edGM1fUg8OrjGWNCZct+YyvqES/JAHSbFFKFnwFlgur39ypV4UskcVQyYP my9UL+zR8lm+96oqM4Iez/ISdHGwwW6dLM65UV+wSB5NDzjH5Id1DhhMi6/fPe0GxJfmQyu DNGqR2JeKx9TBeNMMZWlVTOlKk2B0JXCyHzvyMn/PGgFHhtCLaWVOmBArTKpzuRklSuecJZ O5lowNPUopa1JQUpq+mWuoSA4tfng6Oq25+HOJrHgPyIDQS0OsUaDG+Fk9LVv4xahfUi+ej rebCGQXKbsD1vjwF+CZgHPN02Lf09kTzmZ7QcSGdpyKDhbic9GjP/KQ0abj0H0VS2WJ5H7A wauoaOfWOTvz+NqKf6niy4S/RiGgIra3PnsaMtI/osZqIle5QS7XKMWC9DEWdg9P8XQDUEg n2cZ1D4jsNxfsWO2LHa+Uw== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 14914195552382651279 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 v4 2/5] sparc/irq: Remove on-stack cpumask var Date: Wed, 24 Apr 2024 10:55:45 +0800 Message-Id: <20240424025548.3765250-3-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240424025548.3765250-1-dawei.li@shingroup.cn> References: <20240424025548.3765250-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: bizesmtp: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(). Reviewed-by: Sam Ravnborg 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..01ee800efde3 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 ? cpuid : map_to_cpu(irq); } return cpuid; -- 2.27.0