From nobody Sat May 18 06:31:24 2024 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 2AC9615E217; Thu, 18 Apr 2024 10:50:36 +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=1713437442; cv=none; b=JeCTJvJZAK23qYndQKvAwCxPE2vWC8sxtYYl/wtiLUOLIRA4JEjEgHWKmn8Ykb9zYwoOP1QJSASQAieebJ528CYDU4iOWxc2PKsaeS1Lfhtvewsb+21VURsVOI967IZ/fwrHFEsB28khRzPa5yMS/TeEVgnIcwGRXpZkdZkKaA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713437442; c=relaxed/simple; bh=QCiswgDcN2bu7vT24ZZH99mPoKGsyGfGASAPrK1ZAqg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VTdAgbRMEtGbBTqGFsIJ8kb0rsemu394dhy8KNch7WmQVdCWcUji5n0PSr2/W3qC8WPmk8C3Y8dfaqSeY8NfSNWVS/R0wNyYMvQ1pjE2Yv7rZK2GUiN9j/PGQUaM1SfQ3W2Vahkj/9IaJSZbo5fKasHPcsTzc8mWUWFCaWQURNk= 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: bizesmtp82t1713437406t45jvzb7 X-QQ-Originating-IP: pEXvRM19b7upCM+fX9YdXWbEzjRXRZIJQhdLs2Q5RBM= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 18 Apr 2024 18:50:05 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: 7YFKcddXaggfOZmy1nBedkwTPeeppd0uj9KwyxJOD37uhSD0tytPREuyoB+QB G4XjMxb0W6DCZrZHw8Z4rnFNCPeV233kpQUjFNNOcoh5wWgZXRndIb/Lrg5x9Xe0Y7la+pr tGLd3NCCWFluxBKN9pFWCzCayoTEBbNeUXWPbGE55YDcJ6Zg6eNvoM9039hAAHt/M61RA33 wu/OM8Ln/+YchbXAZt2s7V/wbNvtwbo7wSSF/gK6PhpwR37vryHA1ENh/xtZSd9wbYJSXlk bvuOsk3r2UY90P8zB1mBg9WPEExQkc6De4RHQu16wrzrWFTM2wImWRpl1tZu4DgbA8wh9W2 M9eKUKcZs8vFM9rhh1EX4RNNoAifAHKSEVVsaZsTW+T8RooMWMEQeVAXQCexpwqCqc1C7JC BEYh4Tt+heWpO9eDjGd1Iw== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 9509053346379215880 From: Dawei Li To: davem@davemloft.net, andreas@gaisler.com Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, Dawei Li Subject: [PATCH 1/5] sparc/srmmu: Remove on-stack cpumask var Date: Thu, 18 Apr 2024 18:49:45 +0800 Message-Id: <20240418104949.3606645-2-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: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz5a-1 Content-Type: text/plain; charset="utf-8" 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_any_but() to avoid the need for a temporary cpumask on the stack. Signed-off-by: Dawei Li --- arch/sparc/mm/srmmu.c | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c index 852085ada368..86fd20c878ae 100644 --- a/arch/sparc/mm/srmmu.c +++ b/arch/sparc/mm/srmmu.c @@ -1653,13 +1653,15 @@ static void smp_flush_tlb_all(void) local_ops->tlb_all(); } =20 +static bool cpumask_any_but_current(struct mm_struct *mm) +{ + return cpumask_any_but(mm_cpumask(mm), smp_processor_id()) < nr_cpu_ids; +} + static void smp_flush_cache_mm(struct mm_struct *mm) { if (mm->context !=3D NO_CONTEXT) { - cpumask_t cpu_mask; - cpumask_copy(&cpu_mask, mm_cpumask(mm)); - cpumask_clear_cpu(smp_processor_id(), &cpu_mask); - if (!cpumask_empty(&cpu_mask)) + if (cpumask_any_but_current(mm)) xc1(local_ops->cache_mm, (unsigned long)mm); local_ops->cache_mm(mm); } @@ -1668,10 +1670,7 @@ static void smp_flush_cache_mm(struct mm_struct *mm) static void smp_flush_tlb_mm(struct mm_struct *mm) { if (mm->context !=3D NO_CONTEXT) { - cpumask_t cpu_mask; - cpumask_copy(&cpu_mask, mm_cpumask(mm)); - cpumask_clear_cpu(smp_processor_id(), &cpu_mask); - if (!cpumask_empty(&cpu_mask)) { + if (cpumask_any_but_current(mm)) { xc1(local_ops->tlb_mm, (unsigned long)mm); if (atomic_read(&mm->mm_users) =3D=3D 1 && current->active_mm =3D=3D mm) cpumask_copy(mm_cpumask(mm), @@ -1688,10 +1687,7 @@ static void smp_flush_cache_range(struct vm_area_str= uct *vma, struct mm_struct *mm =3D vma->vm_mm; =20 if (mm->context !=3D NO_CONTEXT) { - cpumask_t cpu_mask; - cpumask_copy(&cpu_mask, mm_cpumask(mm)); - cpumask_clear_cpu(smp_processor_id(), &cpu_mask); - if (!cpumask_empty(&cpu_mask)) + if (cpumask_any_but_current(mm)) xc3(local_ops->cache_range, (unsigned long)vma, start, end); local_ops->cache_range(vma, start, end); @@ -1705,10 +1701,7 @@ static void smp_flush_tlb_range(struct vm_area_struc= t *vma, struct mm_struct *mm =3D vma->vm_mm; =20 if (mm->context !=3D NO_CONTEXT) { - cpumask_t cpu_mask; - cpumask_copy(&cpu_mask, mm_cpumask(mm)); - cpumask_clear_cpu(smp_processor_id(), &cpu_mask); - if (!cpumask_empty(&cpu_mask)) + if (cpumask_any_but_current(mm)) xc3(local_ops->tlb_range, (unsigned long)vma, start, end); local_ops->tlb_range(vma, start, end); @@ -1720,10 +1713,7 @@ static void smp_flush_cache_page(struct vm_area_stru= ct *vma, unsigned long page) struct mm_struct *mm =3D vma->vm_mm; =20 if (mm->context !=3D NO_CONTEXT) { - cpumask_t cpu_mask; - cpumask_copy(&cpu_mask, mm_cpumask(mm)); - cpumask_clear_cpu(smp_processor_id(), &cpu_mask); - if (!cpumask_empty(&cpu_mask)) + if (cpumask_any_but_current(mm)) xc2(local_ops->cache_page, (unsigned long)vma, page); local_ops->cache_page(vma, page); } @@ -1734,10 +1724,7 @@ static void smp_flush_tlb_page(struct vm_area_struct= *vma, unsigned long page) struct mm_struct *mm =3D vma->vm_mm; =20 if (mm->context !=3D NO_CONTEXT) { - cpumask_t cpu_mask; - cpumask_copy(&cpu_mask, mm_cpumask(mm)); - cpumask_clear_cpu(smp_processor_id(), &cpu_mask); - if (!cpumask_empty(&cpu_mask)) + if (cpumask_any_but_current(mm)) xc2(local_ops->tlb_page, (unsigned long)vma, page); local_ops->tlb_page(vma, page); } @@ -1759,10 +1746,7 @@ static void smp_flush_page_to_ram(unsigned long page) =20 static void smp_flush_sig_insns(struct mm_struct *mm, unsigned long insn_a= ddr) { - cpumask_t cpu_mask; - cpumask_copy(&cpu_mask, mm_cpumask(mm)); - cpumask_clear_cpu(smp_processor_id(), &cpu_mask); - if (!cpumask_empty(&cpu_mask)) + if (cpumask_any_but_current(mm)) xc2(local_ops->sig_insns, (unsigned long)mm, insn_addr); local_ops->sig_insns(mm, insn_addr); } --=20 2.27.0 From nobody Sat May 18 06:31:24 2024 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: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpsz:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz5a-1 Content-Type: text/plain; charset="utf-8" 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 i= map, unsigned long cpuid) #ifdef CONFIG_SMP static int irq_choose_cpu(unsigned int irq, const struct cpumask *affinity) { - cpumask_t mask; int cpuid; =20 - cpumask_copy(&mask, affinity); - if (cpumask_equal(&mask, cpu_online_mask)) { + if (cpumask_equal(affinity, cpu_online_mask)) { cpuid =3D map_to_cpu(irq); } else { - cpumask_t tmp; - - cpumask_and(&tmp, cpu_online_mask, &mask); - cpuid =3D cpumask_empty(&tmp) ? map_to_cpu(irq) : cpumask_first(&tmp); + cpuid =3D cpumask_first_and(affinity, cpu_online_mask); + cpuid =3D cpuid < nr_cpu_ids ? : map_to_cpu(irq); } =20 return cpuid; --=20 2.27.0 From nobody Sat May 18 06:31:24 2024 Received: from smtpbg153.qq.com (smtpbg153.qq.com [13.245.218.24]) (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 77F5015E5C2; Thu, 18 Apr 2024 10:50:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.245.218.24 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713437452; cv=none; b=iPNiuK8bnI+Db+QrePvZJa/ATiM+hcwKYeGbM7rB3lkQoN/AFlG7uFkN9eafJToojiLYe737CkVDJu7/mpCQkIm+oVq2qdxkTg+smY4F5HKlTfSmw6PoB9rcap43Up8ptHmT7dO7/3117tBQjqh03ovu/kuVEbGG7JdSlC8D1WI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713437452; c=relaxed/simple; bh=J3xx7uCwxqDnvOjB2f/TyE777o+chO9jhWnCFlaoiFk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ohVEQ6wscHn9LCTXkMruryKKIIlEybuJkC6xYlelgRKQHs7WOQbTZwc9cOpH6FL4++3RfKuQiOUD3iEcmwkLz/5yYUYWYrGoRtuLACJVAdGfJRE+shDsXMtrmRrkOhU3QLekQV1JW1ud3PLexEPEztbUHR5flob4qfYvwfo8k20= 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=13.245.218.24 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: bizesmtp84t1713437417t2k4rod7 X-QQ-Originating-IP: xKe3o2C9ma2R+1d5dsTNCS/zyXVEzyvuAGXlGycOrdo= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 18 Apr 2024 18:50:15 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: su/QXNoXt7e/p5CGMAB7Jna4tdXuXnqktS4kyE2F+fHRJZoFhysXwhQXOmysx 2G5xGDRg+plZMZYup/7yt2X+c/jqRbyH6L0zo/X3ebLP/yFpANVoN53w87IXQbodjyQ5oa7 avhnND3huZSZk2cIIE6pqgkpKGHvrB0JQKZN0UK5TxP3KJQlkrdbbXRRdtPuD3STXjjo09o Y0dL284Ff7PMEzjmoQP3dhQT+1YznLv/NbkPxo/1xPvLHDGmHx7spdYLr49OJB8+Jv9tuy7 MrQFBe2F47XBRcdk7DtL0Sn0bRx4QQPcC+TTWEyizqsrD8DF+sjbTBn1Q0F/cpmZx62c9YM 0bXte7ShiU+h65aJr5SWpAoHwnQbDL89ERqA3Wfx7gV9rRm/upyNrQhA6S8uy5RI99jq8l+ WQnbUM/+8wvVcDvoLXL2pg== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 5834365455261671018 From: Dawei Li To: davem@davemloft.net, andreas@gaisler.com Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, Dawei Li Subject: [PATCH 3/5] sparc/of: Remove on-stack cpumask var Date: Thu, 18 Apr 2024 18:49:47 +0800 Message-Id: <20240418104949.3606645-4-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: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz5a-1 Content-Type: text/plain; charset="utf-8" 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. @cpumask of irq_set_affinity() is read-only and free of change, drop unneeded cpumask var. Signed-off-by: Dawei Li --- arch/sparc/kernel/of_device_64.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device= _64.c index c350c58c7f69..f98c2901f335 100644 --- a/arch/sparc/kernel/of_device_64.c +++ b/arch/sparc/kernel/of_device_64.c @@ -624,10 +624,7 @@ static unsigned int __init build_one_device_irq(struct= platform_device *op, out: nid =3D of_node_to_nid(dp); if (nid !=3D -1) { - cpumask_t numa_mask; - - cpumask_copy(&numa_mask, cpumask_of_node(nid)); - irq_set_affinity(irq, &numa_mask); + irq_set_affinity(irq, cpumask_of_node(nid)); } =20 return irq; --=20 2.27.0 From nobody Sat May 18 06:31:24 2024 Received: from smtpbg151.qq.com (smtpbg151.qq.com [18.169.211.239]) (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 8908315D5D6; Thu, 18 Apr 2024 10:50:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.169.211.239 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713437453; cv=none; b=QGyxnTToKFR2eeolnE3K32DU9EgL2RwiFyY9B70AcOgZDO8eEzFngFgcpw+bwpvjlh03sgpABVcm1OXH4uhcpYvpOmgUgik/S35zSa4N9WxvWcm20kEw2E4S6e+hLBlIB242gR9AIgULZMd1O6ABV14moqdUOoO3L+eZ7Z7MVi0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713437453; c=relaxed/simple; bh=sFnCyAezPJqAAlu3qDvF7erthkLHTCeXNJjaVGL6Y6w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P4KUe+jB7e1iYMhVE6r15LHVDEO38jOujcmbhfaCegVQnZpkyMll3/E0t1l01MQCs8/6LGPL42d7XoqRbjsQFadTr+X0/9B6j5VuEE87unYhMHfrqMP3XnZjLDQ4PoF3CsUW4d2Yhhy1OMBnaxSgYEMXP9hRsbHvDmPL1NmDbG8= 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.169.211.239 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: bizesmtpsz7t1713437422tf4erle X-QQ-Originating-IP: 8Uo1IzsnJjkMtFnQKv4tK4eu5qWHRps1RVeUcu6KYfo= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 18 Apr 2024 18:50:21 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: 0tC8hUyuo8W3jtPfm2nDYNIoEZJeXZ+DSrT8f8H7Vtwa2JQHxfseOnUkiCuXP 3OWD6gSevSTDh+hTCHBCyO8/fGBcn8DXpsfqUaMxriCcYQ7TvbDFyvKH3HhgT3ybmWXFoIa kj2Vx2tqN+yChMwPQve2Ytm9q+cXzdLNGsv1B5KqgGy/yyQIGmgw+2zp0/3BtiFeaYNb2BL H+pYf5yVkbOn2T8q35rh7ME+E1gLHAh8eWCfHGPAfq/HV5dgqPbFaWYnm9RASFQ4Q2u96mM X5m2x6+FdDeJ8er45CNf2Tmz5xyEc7is8SOH2SCGhZak662gtJrnN8Ocu5ieZfhWacrdMRG DWImbQTFgngA48Eiy5J7bda9KhFxDsLJrJBccV+0wt4MVvQGp2I6XhMT6fmAdehtUA46m+X ST/dzd5YvJ4= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 14906161043048154958 From: Dawei Li To: davem@davemloft.net, andreas@gaisler.com Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, Dawei Li Subject: [PATCH 4/5] sparc/pci_msi: Remove on-stack cpumask var Date: Thu, 18 Apr 2024 18:49:48 +0800 Message-Id: <20240418104949.3606645-5-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: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtpsz:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz5a-1 Content-Type: text/plain; charset="utf-8" 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. @cpumask of irq_set_affinity() is read-only and free of change, drop unneeded cpumask var. Signed-off-by: Dawei Li --- arch/sparc/kernel/pci_msi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/sparc/kernel/pci_msi.c b/arch/sparc/kernel/pci_msi.c index fc7402948b7b..acb2f83a1d5c 100644 --- a/arch/sparc/kernel/pci_msi.c +++ b/arch/sparc/kernel/pci_msi.c @@ -287,10 +287,7 @@ static int bringup_one_msi_queue(struct pci_pbm_info *= pbm, =20 nid =3D pbm->numa_node; if (nid !=3D -1) { - cpumask_t numa_mask; - - cpumask_copy(&numa_mask, cpumask_of_node(nid)); - irq_set_affinity(irq, &numa_mask); + irq_set_affinity(irq, cpumask_of_node(nid)); } err =3D request_irq(irq, sparc64_msiq_interrupt, 0, "MSIQ", --=20 2.27.0 From nobody Sat May 18 06:31:24 2024 Received: from smtpbgbr2.qq.com (smtpbgbr2.qq.com [54.207.22.56]) (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 159C915E5CE; Thu, 18 Apr 2024 10:50:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.207.22.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713437462; cv=none; b=hylpwdp5Nmazadiy0OgZjvezRkcTczcn4uaMWnF/kjSgU2QdXoeHi2tN8eSd2zE/dz2dVfWzWubYQ5JUIYj49c+2MmnxHf5xCVgWkkCA8NCzEFMTd0ALezpgolBY9i3Fsb4LycBj8iimo49r5xYOwv7pb9ZccsXke9CSjybAigI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713437462; c=relaxed/simple; bh=WBVRxLIdWKwIhWvkYX40p+kNDCgLtSNi083tiZeIF84=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fnRGtYme9OVMocRXu5P/61iDzIDzpyYMKdc05qVxdV/JEflcRHKX4Rih3BUoAIOBoq82/O9r42rEkkUzQJJhkvMS0oHzxfbebZw6XDPiBppb6nzcum53yrE+y/BFzvvbBFWyGu1htL9n06V+SGyNaouJRJF6SmSSorVzGE//ee0= 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.207.22.56 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: bizesmtp84t1713437427tx0r3mqm X-QQ-Originating-IP: rYl7aVSFMInFEJldnKJN23SbhrmIjafTmB1/3rjQe6U= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 18 Apr 2024 18:50:26 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: W+onFc5Tw4NcMRc6QjsEEEWUHz1Dtd6wntwnHBFMv84a1FNBfmtd9FZStN0R2 pRuiVh5Lt5J9wTXP4CQmlu//N65YJM560JYcenFgkSZ05ACquRteIQyqZt1kfSIv4ssg1ay krqKI7k0wgODYU+qmaUu7fRFfxU1JW/zuD17MH8q1dH++dnPS5aeboX1rlXwNgZjUC5HgvB 0ulamcokuYP3VI82BzrOpn1EyPKaOOQSyxtZot6ZPtCw4Wzw6e3WRcCT+jMctf2mGslBL58 WaDY4mt3Zyk+QPpmu9Q3FkB/OcGubiqIxXVxwTrbOpcTeJTKYWc6EH97Xmji9YyYvo77Fdj hU/7frTVLIfTSI0j1/j8+gyNXLmO79tUHpXe+HLldtbKd0RQ4P4mPvauZ0x9Q4cS9Yb3Yjh giPuUAwE5DZckGRWffT69w== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 17361949652161301272 From: Dawei Li To: davem@davemloft.net, andreas@gaisler.com Cc: sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, Dawei Li Subject: [PATCH 5/5] sparc: Remove on-stack cpumask var Date: Thu, 18 Apr 2024 18:49:49 +0800 Message-Id: <20240418104949.3606645-6-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: quoted-printable X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:shingroup.cn:qybglogicsvrgz:qybglogicsvrgz5a-1 Content-Type: text/plain; charset="utf-8" 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. Since the cpumask var resides in __init function, which means it's free of any concurrenct access, it can be safely marked with static to get rid of allocation on stack. while at it, mark it with __initdata to keep it from persistently consumed memory. Signed-off-by: Dawei Li --- arch/sparc/mm/init_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index 1ca9054d9b97..088d9c103dcc 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -1438,7 +1438,7 @@ static int __init numa_attach_mlgroup(struct mdesc_ha= ndle *md, u64 grp, static int __init numa_parse_mdesc_group(struct mdesc_handle *md, u64 grp, int index) { - cpumask_t mask; + static cpumask_t mask __initdata; int cpu; =20 numa_parse_mdesc_group_cpus(md, grp, &mask); --=20 2.27.0