From nobody Tue Feb 10 23:52:59 2026 Received: from smtpbg150.qq.com (smtpbg150.qq.com [18.132.163.193]) (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 AFB02205E26; Sat, 20 Apr 2024 05:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=18.132.163.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713590207; cv=none; b=R78m0+rIL8ZqWGstaxMtd8HBS5ruhhcrhm6oNttmWeEgzkxLZK+5F6KY/DwgX40C1qmPu247yQ2Khu1YkaIhZYVeaQn1Stvvn7JxOMmy6q2fKRVJGLork1mmNNoc9+X9EbHG1tLhll9d4EfeU0ECY/e+shJi41HMCZn6OmDO9cY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713590207; c=relaxed/simple; bh=QCiswgDcN2bu7vT24ZZH99mPoKGsyGfGASAPrK1ZAqg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c+ER0PAtoCnTkbYHUysx/rPKckEzTGX6MvzIeGwqjYYHwWomVBYEIWXpsvdjiG74OQZAflgjH2nGUpDdAWAwjDAy/zSHMsqc8rlHoJUMxBOpuE5jZkRWbvgDUuikrHoxM3Jx4v71lEZtjIuoMf5TvApEYT5yLbYBNrOVMdkiqxM= 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.132.163.193 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: bizesmtpsz10t1713590163tbxfal X-QQ-Originating-IP: 4z5Ce7vmevKk0ZpNSIX4XoeS4cw4jCO0yDPWypaO99g= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 20 Apr 2024 13:16:02 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: OwlQr8knuI9pnCqr4AFwpinQdFPRSsaPpQAH5uRlMe0ThyzJXvjjwwNW1gaUf Z7wq606xM9akVpcO01FRLeYLN82y338oa9oRAOrZBpLbVZXac1GB+GKDDwK2NqULaM2fRiz epHmS2Ggq2h295aM1QKGPAvjq30C0/F6NBamk2uK0myLc5Atu7zIwzeamP3UtwCHfqPRszB S/JTcvivnexf/Bcn36XTxJAPZH52CYrLxlg/j4iFqnYK3oe33HPRhit2RkFJhEn0m4ezp+z A2MIuzS7gbslDXPlPUyuvVW8zoRn/6nYBAqz0BPdm+Rw2Zx+jUfXu/ARcVdD8xUmzD7Ha8Y MnFi8HOEfaXWXJNZZ7MB1JRKWZ2G0jxxVqnO6h7zPtshv3qgMqzSLTD57tOSHP+2FEGR7+V EMQsi7RNVr0= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 15652962948535279539 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 v2 1/7] sparc/srmmu: Remove on-stack cpumask var Date: Sat, 20 Apr 2024 13:15:41 +0800 Message-Id: <20240420051547.3681642-2-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240420051547.3681642-1-dawei.li@shingroup.cn> References: <20240420051547.3681642-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. Use cpumask_any_but() to avoid the need for a temporary cpumask on the stack. Signed-off-by: Dawei Li Reviewed-by: Sam Ravnborg --- 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 Tue Feb 10 23:52:59 2026 Received: from smtpbguseast3.qq.com (smtpbguseast3.qq.com [54.243.244.52]) (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 1A31FD502; Sat, 20 Apr 2024 05:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.243.244.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713590206; cv=none; b=sLFcIAiQLpNZb9mIRr88WynPPFA4ADGvqWSdCvusGdDQ+6tCRds12YWqAaL1N0QUg3fyxf230+/QvK2S99zV5abjM/Dp40z250Lf4oiKxidZysVgrf319WUvYK8xLa4hM/IMf02MEZA/Fnmz87JqqYEGYAjeGm/a7XQOh+H+EPc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713590206; c=relaxed/simple; bh=JGe2c7EleFIo3V/q444ZXbmbASsFH7KJPdST/F19raQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JrXlH4i+VZLuGPq03yZz+IjkvrpMYp8N8TeMUYrNi2oSp4VRx6T3eahmhyIchwo9eNXlUeBoPJThKEnMzi15glOaiWSUTaMciwwmF8BilYybpJug8ZMSUmtTbQFNB4qqF2DDrSNj51oCY8AIIyOAfZTMRPR9goqzXjvY7YKYHHE= 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.243.244.52 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: bizesmtp77t1713590168tnzg3hq9 X-QQ-Originating-IP: 7t3tP/fE+7jFt0UehO+VmUbKEQtfVTHezW4H9IIyYjw= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 20 Apr 2024 13:16:07 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: znfcQSa1hKadBZA75WUfKi7xxQVaADA9PWEDD6aBu+qV6q5ooibxQmrW7ULBB It5C/q7o1oJnz7vHm/03SCI1OdRg47vJPxBVOBC/UrpjQaJJAta2tJ48uJWuCp5P3BXg+Y4 K0UjAhLWTu1NqhaZd2HViWi4xJwNPDqGV+KHWjoFh1nLN7a9dwMASC0NC0MtIZbazUpYygX dz5/SbvC0+if+VVJZEmaJTgb+O5P6behwbAIb/YUWsV1WHxLYKU3+2uZhk6JQX+TA/3I+q1 hr+Eq6n6np2x6hMIeIu5jYZODIGBeg65lYbmtEoVdlAGNb+nH1htNX9awxz43xqwgVdtrgN FrgFbNwrfFXAzyph3erKBif6DzSGJ5QkjVkBs7sWXqT8kKJVLjlS5EbeH9glUT0Gy6M+1C/ 8M5kR8JYJ7Skdzg4OPzkng== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 18303500478085537175 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 v2 2/7] sparc/irq: Remove on-stack cpumask var Date: Sat, 20 Apr 2024 13:15:42 +0800 Message-Id: <20240420051547.3681642-3-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240420051547.3681642-1-dawei.li@shingroup.cn> References: <20240420051547.3681642-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. - 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 Reviewed-by: Sam Ravnborg --- 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 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 ? cpuid : map_to_cpu(irq); } =20 return cpuid; --=20 2.27.0 From nobody Tue Feb 10 23:52:59 2026 Received: from smtpbg156.qq.com (smtpbg156.qq.com [15.184.82.18]) (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 4DE89E55F; Sat, 20 Apr 2024 05:16:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=15.184.82.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713590208; cv=none; b=Ofcs3vorNw+3gICfl4iILo8uU0Z5Jbd5DyabAhHsF9U4UeE3TyVpp/OJp/joW2T3IW48sOFLkBQvw9Wfgb/Ex6xbC4JWt7ns5dDRzfDMzdxNxrZ7bMx2yTxxCYcz1BmgOTBmZNLFWK2ehUK+9XHFUxnq1smubneRfBcJDncIVdk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713590208; c=relaxed/simple; bh=J3xx7uCwxqDnvOjB2f/TyE777o+chO9jhWnCFlaoiFk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iNxWQFsUIuS5z9WwhBnO/fg7D0yXvxOVCCdJoZ9onUTH3L4pidKQzqjMY/K3L2RnKt6T/MHzaefrU8mUbcPZiWh2gBMJsjOcC6jDOmtqLsGzAd+OXcWqe1YyYGD8YHGK/rucZjB7Lk+wtFRpQGX6HXYxlA+ZiJW7XCb9KIjhT6c= 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=15.184.82.18 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: bizesmtp84t1713590173tizhh7rd X-QQ-Originating-IP: 8MtURKbY14c/8/zzXdbr2mv34MhaCyJmjCscKsCI8Ts= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 20 Apr 2024 13:16:12 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: 7YFKcddXagjUdEvd7pTyWsQ4VLtezgpliaI64kOzXjRCa35JZRCrMEOCTqGhV qng8CLtYjSU4vPeW/USn80ZBPzeHD5ntGK/QkI3/6S9881J7o1Sr7qqwipZAPGvAVaN+oDt nV3xJ7A/0dPzfaKjQZ379/v77zl5nQmZHQekOCI7hu3vHu622JrM1p3O7AlmMnNzCkwRGd0 FvyLmQgGhK8b8nhCbcis+qaayFaQOURFPBTQ7M8aYyryM34uJR0VDbpjNXmxjbKfzz5pdv+ FQ2JVxjwjsRwWJbz53Tsqvs0xQIOEjZkPtuTAYUlM3d9FGu6UWzBrzmXqc0ecBpSrMZtasp VBavlsaY+kUu7+IcSbIMKs4afXgfFL/Sd/RkWjRNsMd5JjNVb3dkYi3lVtr/B9jUbESTkJ2 jz5FYmU3rfc7AT47u3FsPw== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 15600578157613225618 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 v2 3/7] sparc/of: Remove on-stack cpumask var Date: Sat, 20 Apr 2024 13:15:43 +0800 Message-Id: <20240420051547.3681642-4-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240420051547.3681642-1-dawei.li@shingroup.cn> References: <20240420051547.3681642-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 Reviewed-by: Sam Ravnborg --- 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 Tue Feb 10 23:52:59 2026 Received: from smtpbgbr1.qq.com (smtpbgbr1.qq.com [54.207.19.206]) (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 C294B17BC9; Sat, 20 Apr 2024 05:16:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.207.19.206 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713590223; cv=none; b=rYUhNM7iP7W/Cg9JkDlDxrUre9HbFO1AWkYHR8Vtujd2YhZlSrrl8ZKdUDRA13Hz1gwhIOM90b2wpLU635eIvS8m+Tcm5ug39s6wexWrGVEksnhqlGF2PMpy/rfD2LGb6veEzcG/eoww5zOpbMD5kq/owzyiQreyAx9SE92GWak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713590223; c=relaxed/simple; bh=sFnCyAezPJqAAlu3qDvF7erthkLHTCeXNJjaVGL6Y6w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W8o1MLurG1Z1/Qe9I0zIgE8P6X90aTcOEkYqfvEnbcFwGOJDZfiCTNs77W8Oa6ArMhe3TqgMFISpf03YusdOr1NrcER/fpnSAFIVmir63b62OgAwsZkNODXiur8xZ3r9+DufpY5gbeYna0mTEPkk4FfJ75TYZCFdmHFdFm1fnvA= 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.19.206 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: bizesmtp79t1713590179t1j0ojyx X-QQ-Originating-IP: usNWeg3p56fbl6S4O5hLIa/2vcCL/sUddDTvjUu6ZQk= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 20 Apr 2024 13:16:17 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: kXE5muS/leEbbuoBaiU+TdzUdL8x1DtGffTVB18ZZSjdZkb7ukY1/vsQEbTcj /NXvomoV18BJGH7GSXpOT4kPYqdzRkXp2cswMMBLFO7EFgU3Pr1hY/7VYyesv4D1cvIMV6W HdN9MK0b25112qI1mqXixVzW4O7ZWSlEn4tPhnK/uhx+Yf+u0Bh5BtcHYZQEgfo1NFXX8wv W/UVodAkBuo5rh8V+NvcF7K0WOpS281MfHV1BPbqVX47V/rkPl6A6cTSDZ1r6yx7wUcs+we f+djCR4KWNJYQmJErZxhtT8GLtyti8qGk0+HpGKqXlwTnrDzJjwhzuCjhWrrKS2PHKS6ISU 0GrnJu3Zc/j1deuop76NewiI7M6R27Qb2R0pBGFD8+NcYaUMb8qQGjRaC+DfZCzFBL+r4mA eqVicjisW3I= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 13105262653113255618 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 v2 4/7] sparc/pci_msi: Remove on-stack cpumask var Date: Sat, 20 Apr 2024 13:15:44 +0800 Message-Id: <20240420051547.3681642-5-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240420051547.3681642-1-dawei.li@shingroup.cn> References: <20240420051547.3681642-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 Reviewed-by: Sam Ravnborg --- 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 Tue Feb 10 23:52:59 2026 Received: from smtpbguseast3.qq.com (smtpbguseast3.qq.com [54.243.244.52]) (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 8E70E17BCC; Sat, 20 Apr 2024 05:16:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=54.243.244.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713590222; cv=none; b=dnDbbRH+XXdl1TByYCkKZ09FfXuny1E/GLMMp7IXz3aTuUMxN3cQyHwoKF0mF0s6kqHe0e0r7dcrJNnV19Wima0PlzEIOLzSCugn8AK7NMt336iqgKV9F6lujGf2GQk4K0CWdYAFwmObVZ3YUkE2xHQxNqQ/cEkNhfSnwH1IdOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713590222; c=relaxed/simple; bh=WBVRxLIdWKwIhWvkYX40p+kNDCgLtSNi083tiZeIF84=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FccMjHRAxmXIyITDk4UkjQB2YgE4foAU6Oo0fbMfOeotY8U9tKi6JP1e+awe3svGYImf//v/LuDeg0+3tBxmmkqVfQ5IVUV/mVjz9Kcikx/8x+n47Cjoig4YXcYu6KNnD+WpLEFWNLyPgAGK/95dVSivLtgwuFZk8X6zRoldAJw= 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.243.244.52 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: bizesmtpsz5t1713590188tfw8vcz X-QQ-Originating-IP: TNQvptNIxgg5QGK1FQfunMTw1q79c5Uv8QKx3BF48ik= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 20 Apr 2024 13:16:26 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: E6xLhkkW4u1WF/joyXGZBmgPq4Ovo3WKIDIrTweysvZbw5XLBL8UAFeSYqUo0 DtDM10nNSTTpfqeWXh3On5re9mcvuSVgwBVIpuLvcTE9Y362B3eK1zkG8YyrHN8wRN9wts4 HLMNy0gCm6oM0AQyBZ49Fl5y6AJj5lV/z7Mt/ZYwiSEwItGLmFia81WnE9lWD0GpWZN5pZb dzJLKLFM0e2Qg/VxpJ5ctncxlAcSVdGAZCsn3Sc3ydUu6rqhnChi9clHllZt7OCH4u5PF62 gIXmnU6ZpzGc0+dsJPYm4mEPSCq6Qh8kVjGnd8CKDWZGZsbY9Hf3DGupHY34QeggwVaphas 1aZOtdoeHOF7Q+6WtMguW9IhmcMpT0THL9/CLZqtQeCFrwatuiAbxC86O+MxvBMx24eqgNZ rHK/hISZ/y1xk2+zeWdekg== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 16907030830474196779 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 v2 5/7] sparc: Remove on-stack cpumask var Date: Sat, 20 Apr 2024 13:15:45 +0800 Message-Id: <20240420051547.3681642-6-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240420051547.3681642-1-dawei.li@shingroup.cn> References: <20240420051547.3681642-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. 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 From nobody Tue Feb 10 23:52:59 2026 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 D60EE17BCB; Sat, 20 Apr 2024 05:17:01 +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=1713590224; cv=none; b=r/0K30fK6G4hNtEzZXwaq4D/WpvNKlaXq8wJCo3IpytRYv228q6yHQ/G/SpAK1NSGrgBzPbU/bsJi0Tm5Xhh/kKIRCsp01GAuSuiVeWKf3LIZbQSK4u3CpAj7iu++2la/7IYyYQKEbHxnV08w0Y/8tGQ3XoF7JtV+Rghv3ivtPk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713590224; c=relaxed/simple; bh=jLfNnCBXksQdRcun7e+P6Gzbclr84PhONO9mQqHTh0w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qVzWwwMgp6BA2tnYYtS+7QWaXRLihhHjL5XyNgpNz92OjH0q/rv/yEoQ48JNFEPC7Dj+DY108qwvnKaV9b3iXeM6BiYqsA31/X738quKAnoKfX8dxD7RT+OR+P8I648cvJ4J0kbUt5goGFMx+hEM3d+gBzhgG3eSHMvar2t18fY= 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: bizesmtp87t1713590193tckay5hz X-QQ-Originating-IP: YKD5jxrExFmZCeXNPd1zDEkYWQBcJUhZJZw3aGY2xlg= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 20 Apr 2024 13:16:32 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: RLrSOnjbvYFlqV1mdTGOKnCqxqWyu0oq4qmWlQWNmG2Y1zZZLysBSSxH4ilo0 RnHKsK7/CxOdCv1/mmM6zDJRHwYnOGSXxTwuoo3QRp8FlBkMIb57lzMh2bTxZHaY6lJEMpP FchEoK7g2OYvxH1I1SGY/sHS1eQ/1GlGUE1BFbl8aQ6pH/EMVg3J9bT2epRR8XkLIYZsQPw 9tt8Sp5/q0E0rUWMdxz5mYBTmI4JmZO4/vnspF+oXe6QCK8vNRCVwGocp7TGdIShklug1Ua 9wrjdEiyLV93fdVnTV83/30GqomX5vOWhuBsNO8cMm3+vINyiseLRC9oILcqNe39q2LEtYV wOxsQdJf5CQVD97aN+Jr8j6le/eyIsZKOzftovHieVsOoX9jmMVM31xXJqbppHZhTABxE/q XDADwWjn82fSfAgFCrWP/g== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 6810044621724373392 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 v2 6/7] sparc/leon: Remove on-stack cpumask var Date: Sat, 20 Apr 2024 13:15:46 +0800 Message-Id: <20240420051547.3681642-7-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240420051547.3681642-1-dawei.li@shingroup.cn> References: <20240420051547.3681642-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_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 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kerne= l.c index 4c61da491fee..0070655041bb 100644 --- a/arch/sparc/kernel/leon_kernel.c +++ b/arch/sparc/kernel/leon_kernel.c @@ -106,13 +106,10 @@ 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 =3D cpumask_first_and(affinity, cpu_online_mask); =20 - cpumask_and(&mask, cpu_online_mask, affinity); - if (cpumask_equal(&mask, cpu_online_mask) || cpumask_empty(&mask)) - return boot_cpu_id; - else - return cpumask_first(&mask); + return cpumask_subset(cpu_online_mask, affinity) || cpu >=3D nr_cpu_ids ? + boot_cpu_id : cpu; } #else #define irq_choose_cpu(affinity) boot_cpu_id --=20 2.27.0 From nobody Tue Feb 10 23:52:59 2026 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 E4130208A3; Sat, 20 Apr 2024 05:17:05 +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=1713590228; cv=none; b=p0zd+rUEqTUCto+3s6SHn4zNCPbWFZNNr9AzRNXeD0V7cNmcwYlz3NUlQQcYlGiBknZ1FUwj8QhYlfnHp3vsrOSKz0XitT0YA3jfdftqd3pl0+NZqULguQIpJKsUX27FtrbVlxAnLgmwPSG8cZV8hJ4B/K7yFMRyYQQWCuba1wU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713590228; c=relaxed/simple; bh=3dgA1lID60LmbCnzBP9JsvU5Mc4ui3cakk0foe6t9eo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=K6O9p5ZQ+GBSnSSAZcitDTgLv6/2GjjPNivPn6aG3vGna8ltJzsB9iQIBv8hpNefu1wMsg/KLYW0EHXu2ioyaLsDavhMbigqopEfo+mX5Tv/GfK5eqaBP4Q7JSLxwLAcIcNndKSKETSi/RSg6x9AMwnbFr3WgVwOfP75cbPSpXM= 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: bizesmtp80t1713590204tn4lchfu X-QQ-Originating-IP: Pqo650+zqqf/lX5qSgW/Py8QatIBaphqDT9dCcdp/nQ= Received: from localhost ( [112.0.147.129]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 20 Apr 2024 13:16:43 +0800 (CST) X-QQ-SSF: 01400000000000903000000A0000000 X-QQ-FEAT: KdN0SWBFoH5g57I01NPcKiJN+8WNEmlH9ZWI9i/KHAoU/NtBUcSfBueYbY48I bq66ozRf67BXBl0nBHEL3VugORbLGVCJCxwhhkxK/8NR1K03ESv375NEEqm9W0skZuxRUMd FTgkLyrTucfqEh2J/iyjx0TblCA1aoU3wk+kb+V8zFtGmDTgXDGbvLFERkMgGaXdeB1LYlS rV6+lSgEYw8BQAWlNJ3TIxbm+z6q7r0RcssNufl+lIt/PDhTFVPGK9HjBVc7ZnkkpriGj34 rkRc8Ny3wGoN6kPwdGzI6WK9KmfKJHXFt764+oNI/P7BL472NUDBcYGLS308lXS+QRI9cS2 IsSRwUxuB9KkRFXfuhrRcxzEyPUX8EliiOM2Sk51HKrX0G9TqUowSBnqB1vwzVGYO3LAMF9 3azSv3wKN9dEjZ6+5Dvo5AK2OGL1qyA9 X-QQ-GoodBg: 2 X-BIZMAIL-ID: 3589547492236992514 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 v2 7/7] sparc/smp: Remove on-stack cpumask var Date: Sat, 20 Apr 2024 13:15:47 +0800 Message-Id: <20240420051547.3681642-8-dawei.li@shingroup.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240420051547.3681642-1-dawei.li@shingroup.cn> References: <20240420051547.3681642-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. - Change prototype of sparc32_ipi_ops::cross_call() so that it takes const cpumask * arg and all its callers accordingly. - As for all cross_call() implementations, divide cpumask_test_cpu() call into several sub calls to avoid on-stack cpumask var. Signed-off-by: Dawei Li --- arch/sparc/include/asm/smp_32.h | 12 ++++++------ arch/sparc/kernel/kernel.h | 11 +++++++++++ arch/sparc/kernel/leon_smp.c | 11 ++++------- arch/sparc/kernel/sun4d_smp.c | 10 ++++------ arch/sparc/kernel/sun4m_smp.c | 10 ++++------ 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/arch/sparc/include/asm/smp_32.h b/arch/sparc/include/asm/smp_3= 2.h index 2cf7971d7f6c..9b6a166f6a57 100644 --- a/arch/sparc/include/asm/smp_32.h +++ b/arch/sparc/include/asm/smp_32.h @@ -54,7 +54,7 @@ void smp_bogo(struct seq_file *); void smp_info(struct seq_file *); =20 struct sparc32_ipi_ops { - void (*cross_call)(void *func, cpumask_t mask, unsigned long arg1, + void (*cross_call)(void *func, const cpumask_t *mask, unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4); void (*resched)(int cpu); @@ -65,29 +65,29 @@ extern const struct sparc32_ipi_ops *sparc32_ipi_ops; =20 static inline void xc0(void *func) { - sparc32_ipi_ops->cross_call(func, *cpu_online_mask, 0, 0, 0, 0); + sparc32_ipi_ops->cross_call(func, cpu_online_mask, 0, 0, 0, 0); } =20 static inline void xc1(void *func, unsigned long arg1) { - sparc32_ipi_ops->cross_call(func, *cpu_online_mask, arg1, 0, 0, 0); + sparc32_ipi_ops->cross_call(func, cpu_online_mask, arg1, 0, 0, 0); } static inline void xc2(void *func, unsigned long arg1, unsigned long arg2) { - sparc32_ipi_ops->cross_call(func, *cpu_online_mask, arg1, arg2, 0, 0); + sparc32_ipi_ops->cross_call(func, cpu_online_mask, arg1, arg2, 0, 0); } =20 static inline void xc3(void *func, unsigned long arg1, unsigned long arg2, unsigned long arg3) { - sparc32_ipi_ops->cross_call(func, *cpu_online_mask, + sparc32_ipi_ops->cross_call(func, cpu_online_mask, arg1, arg2, arg3, 0); } =20 static inline void xc4(void *func, unsigned long arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4) { - sparc32_ipi_ops->cross_call(func, *cpu_online_mask, + sparc32_ipi_ops->cross_call(func, cpu_online_mask, arg1, arg2, arg3, arg4); } =20 diff --git a/arch/sparc/kernel/kernel.h b/arch/sparc/kernel/kernel.h index a8fb7c0bf053..36747e8f7e36 100644 --- a/arch/sparc/kernel/kernel.h +++ b/arch/sparc/kernel/kernel.h @@ -4,6 +4,7 @@ =20 #include #include +#include =20 #include #include @@ -75,6 +76,16 @@ int sparc32_classify_syscall(unsigned int syscall); #endif =20 #ifdef CONFIG_SPARC32 + +#ifdef CONFIG_SMP +static inline bool cpu_for_ipi(const cpumask_t *mask, unsigned int cpu) +{ + return cpumask_test_cpu(cpu, mask) && + cpumask_test_cpu(cpu, cpu_online_mask) && + cpu !=3D smp_processor_id(); +} +#endif /* CONFIG_SMP */ + /* setup_32.c */ struct linux_romvec; void sparc32_start_kernel(struct linux_romvec *rp); diff --git a/arch/sparc/kernel/leon_smp.c b/arch/sparc/kernel/leon_smp.c index 1ee393abc463..291884c8d82a 100644 --- a/arch/sparc/kernel/leon_smp.c +++ b/arch/sparc/kernel/leon_smp.c @@ -372,7 +372,7 @@ static struct smp_funcall { static DEFINE_SPINLOCK(cross_call_lock); =20 /* Cross calls must be serialized, at least currently. */ -static void leon_cross_call(void *func, cpumask_t mask, unsigned long arg1, +static void leon_cross_call(void *func, const cpumask_t *mask, unsigned lo= ng arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4) { @@ -403,14 +403,11 @@ static void leon_cross_call(void *func, cpumask_t mas= k, unsigned long arg1, { register int i; =20 - cpumask_clear_cpu(smp_processor_id(), &mask); - cpumask_and(&mask, cpu_online_mask, &mask); for (i =3D 0; i <=3D high; i++) { - if (cpumask_test_cpu(i, &mask)) { + if (cpu_for_ipi(mask, i)) { ccall_info.processors_in[i] =3D 0; ccall_info.processors_out[i] =3D 0; leon_send_ipi(i, LEON3_IRQ_CROSS_CALL); - } } } @@ -420,7 +417,7 @@ static void leon_cross_call(void *func, cpumask_t mask,= unsigned long arg1, =20 i =3D 0; do { - if (!cpumask_test_cpu(i, &mask)) + if (!cpu_for_ipi(mask, i)) continue; =20 while (!ccall_info.processors_in[i]) @@ -429,7 +426,7 @@ static void leon_cross_call(void *func, cpumask_t mask,= unsigned long arg1, =20 i =3D 0; do { - if (!cpumask_test_cpu(i, &mask)) + if (!cpu_for_ipi(mask, i)) continue; =20 while (!ccall_info.processors_out[i]) diff --git a/arch/sparc/kernel/sun4d_smp.c b/arch/sparc/kernel/sun4d_smp.c index 9a62a5cf3337..7dc57ca05728 100644 --- a/arch/sparc/kernel/sun4d_smp.c +++ b/arch/sparc/kernel/sun4d_smp.c @@ -281,7 +281,7 @@ static struct smp_funcall { static DEFINE_SPINLOCK(cross_call_lock); =20 /* Cross calls must be serialized, at least currently. */ -static void sun4d_cross_call(void *func, cpumask_t mask, unsigned long arg= 1, +static void sun4d_cross_call(void *func, const cpumask_t *mask, unsigned l= ong arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4) { @@ -315,10 +315,8 @@ static void sun4d_cross_call(void *func, cpumask_t mas= k, unsigned long arg1, { register int i; =20 - cpumask_clear_cpu(smp_processor_id(), &mask); - cpumask_and(&mask, cpu_online_mask, &mask); for (i =3D 0; i <=3D high; i++) { - if (cpumask_test_cpu(i, &mask)) { + if (cpu_for_ipi(mask, i)) { ccall_info.processors_in[i] =3D 0; ccall_info.processors_out[i] =3D 0; sun4d_send_ipi(i, IRQ_CROSS_CALL); @@ -331,7 +329,7 @@ static void sun4d_cross_call(void *func, cpumask_t mask= , unsigned long arg1, =20 i =3D 0; do { - if (!cpumask_test_cpu(i, &mask)) + if (!cpu_for_ipi(mask, i)) continue; while (!ccall_info.processors_in[i]) barrier(); @@ -339,7 +337,7 @@ static void sun4d_cross_call(void *func, cpumask_t mask= , unsigned long arg1, =20 i =3D 0; do { - if (!cpumask_test_cpu(i, &mask)) + if (!cpu_for_ipi(mask, i)) continue; while (!ccall_info.processors_out[i]) barrier(); diff --git a/arch/sparc/kernel/sun4m_smp.c b/arch/sparc/kernel/sun4m_smp.c index 056df034e79e..3f43f64e3489 100644 --- a/arch/sparc/kernel/sun4m_smp.c +++ b/arch/sparc/kernel/sun4m_smp.c @@ -170,7 +170,7 @@ static struct smp_funcall { static DEFINE_SPINLOCK(cross_call_lock); =20 /* Cross calls must be serialized, at least currently. */ -static void sun4m_cross_call(void *func, cpumask_t mask, unsigned long arg= 1, +static void sun4m_cross_call(void *func, const cpumask_t *mask, unsigned l= ong arg1, unsigned long arg2, unsigned long arg3, unsigned long arg4) { @@ -191,10 +191,8 @@ static void sun4m_cross_call(void *func, cpumask_t mas= k, unsigned long arg1, { register int i; =20 - cpumask_clear_cpu(smp_processor_id(), &mask); - cpumask_and(&mask, cpu_online_mask, &mask); for (i =3D 0; i < ncpus; i++) { - if (cpumask_test_cpu(i, &mask)) { + if (cpu_for_ipi(mask, i)) { ccall_info.processors_in[i] =3D 0; ccall_info.processors_out[i] =3D 0; sun4m_send_ipi(i, IRQ_CROSS_CALL); @@ -210,7 +208,7 @@ static void sun4m_cross_call(void *func, cpumask_t mask= , unsigned long arg1, =20 i =3D 0; do { - if (!cpumask_test_cpu(i, &mask)) + if (!cpu_for_ipi(mask, i)) continue; while (!ccall_info.processors_in[i]) barrier(); @@ -218,7 +216,7 @@ static void sun4m_cross_call(void *func, cpumask_t mask= , unsigned long arg1, =20 i =3D 0; do { - if (!cpumask_test_cpu(i, &mask)) + if (!cpu_for_ipi(mask, i)) continue; while (!ccall_info.processors_out[i]) barrier(); --=20 2.27.0