Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Jan 2024 01:25:01 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: b4d11915c73f - stable/14 - intrng: switch from MAXCPU to mp_ncpus
Message-ID:  <202401110125.40B1P1KN089284@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=b4d11915c73f199501672b278be86e1f63790036

commit b4d11915c73f199501672b278be86e1f63790036
Author:     Elliott Mitchell <ehem+freebsd@m5p.com>
AuthorDate: 2023-09-26 17:06:04 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-01-11 01:23:56 +0000

    intrng: switch from MAXCPU to mp_ncpus
    
    MAXCPU could be on the large side, while the hardware may not have
    many processors at all. As such only allocate counters for processors
    which actually exist, rather than always allocating for the maximum
    potentially allowed number.
    
    Reviewed by:    markj, emaste
    Differential Revision:  https://reviews.freebsd.org/D41462
    
    (cherry picked from commit 2f0b059eeafc545a4ab1835d6a5290e1e2ebb47f)
---
 sys/kern/subr_intr.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/sys/kern/subr_intr.c b/sys/kern/subr_intr.c
index 6535c42f2404..49fe20cdc890 100644
--- a/sys/kern/subr_intr.c
+++ b/sys/kern/subr_intr.c
@@ -175,11 +175,11 @@ intr_irq_init(void *dummy __unused)
 
 	/*
 	 * - 2 counters for each I/O interrupt.
-	 * - MAXCPU counters for each IPI counters for SMP.
+	 * - mp_maxid + 1 counters for each IPI counters for SMP.
 	 */
 	nintrcnt = intr_nirq * 2;
 #ifdef SMP
-	nintrcnt += INTR_IPI_COUNT * MAXCPU;
+	nintrcnt += INTR_IPI_COUNT * (mp_maxid + 1);
 #endif
 
 	intrcnt = mallocarray(nintrcnt, sizeof(u_long), M_INTRNG,
@@ -312,18 +312,18 @@ intr_ipi_setup_counters(const char *name)
 	mtx_lock(&isrc_table_lock);
 
 	/*
-	 * We should never have a problem finding MAXCPU contiguous counters,
-	 * in practice. Interrupts will be allocated sequentially during boot,
-	 * so the array should fill from low to high index. Once reserved, the
-	 * IPI counters will never be released. Similarly, we will not need to
-	 * allocate more IPIs once the system is running.
+	 * We should never have a problem finding mp_maxid + 1 contiguous
+	 * counters, in practice. Interrupts will be allocated sequentially
+	 * during boot, so the array should fill from low to high index. Once
+	 * reserved, the IPI counters will never be released. Similarly, we
+	 * will not need to allocate more IPIs once the system is running.
 	 */
-	bit_ffc_area(intrcnt_bitmap, nintrcnt, MAXCPU, &index);
+	bit_ffc_area(intrcnt_bitmap, nintrcnt, mp_maxid + 1, &index);
 	if (index == -1)
 		panic("Failed to allocate %d counters. Array exhausted?",
-		    MAXCPU);
-	bit_nset(intrcnt_bitmap, index, index + MAXCPU - 1);
-	for (i = 0; i < MAXCPU; i++) {
+		    mp_maxid + 1);
+	bit_nset(intrcnt_bitmap, index, index + mp_maxid);
+	for (i = 0; i < mp_maxid + 1; i++) {
 		snprintf(str, INTRNAME_LEN, "cpu%d:%s", i, name);
 		intrcnt_setname(str, index + i);
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401110125.40B1P1KN089284>