NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/57657: NetBSD crashes if the number of CPUs is not of the form N*[1..8]



The following reply was made to PR kern/57657; it has been noted by GNATS.

From: mlelstv%serpens.de@localhost (Michael van Elst)
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/57657: NetBSD crashes if the number of CPUs is not of the form N*[1..8]
Date: Sun, 15 Oct 2023 10:05:32 -0000 (UTC)

 logix%foobar.franken.de@localhost writes:
 
 >Booting NetBSD in KVM (on a RHEL 9.2 host) with 1..40 virtual CPUs succeeds if and only if the number of CPUs is of the form N*[1..8], i.e., only for 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40 CPUs.  For any other number the following panic happens:
 
 >Stopped in pid 0.0 (system) at  netbsd:breakpoint+0x5:  leave
 >breakpoint() at netbsd:breakpoint+0x5
 >vpanic at netbsd:vpanic+0x173
 >kern_assert() at netbsd:kern_assert+0x4b
 >uvm_pagealloc_pgb() at netbsd:uvm_pagealloc_pgb+0x2e
 >uvm_pagealloc_pgfl() at netbsd:uvm_pagealloc_pgfl+0x63
 
 
 That's a bug in uvm_page_rebucket(). This patch helps (the
 line numbers are a bit off):
 
 Index: uvm_page.c
 ===================================================================
 RCS file: /cvsroot/src/sys/uvm/uvm_page.c,v
 retrieving revision 1.254
 diff -p -u -r1.254 uvm_page.c
 --- uvm_page.c	23 Sep 2023 18:20:20 -0000	1.254
 +++ uvm_page.c	14 Oct 2023 21:37:39 -0000
 @@ -868,7 +883,7 @@ uvm_page_recolor(int newncolors)
  void
  uvm_page_rebucket(void)
  {
 -	u_int min_numa, max_numa, npackage, shift;
 +	u_int min_numa, max_numa, npackage, div;
  	struct cpu_info *ci, *ci2, *ci3;
  	CPU_INFO_ITERATOR cii;
  
 @@ -906,12 +921,11 @@ uvm_page_rebucket(void)
  
  	/*
  	 * Figure out how to arrange the packages & buckets, and the total
 -	 * number of buckets we need.  XXX 2 may not be the best factor.
 +	 * number of buckets we need.
  	 */
 -	for (shift = 0; npackage > PGFL_MAX_BUCKETS; shift++) {
 -		npackage >>= 1;
 -	}
 - 	uvm_page_redim(uvmexp.ncolors, npackage);
 +
 +	div = howmany(npackage, PGFL_MAX_BUCKETS);
 + 	uvm_page_redim(uvmexp.ncolors, howmany(npackage, div));
  
   	/*
   	 * Now tell each CPU which bucket to use.  In the outer loop, scroll
 @@ -927,7 +941,7 @@ uvm_page_rebucket(void)
  		 */
  		ci3 = ci2;
  		do {
 -			ci3->ci_data.cpu_uvm->pgflbucket = npackage >> shift;
 +			ci3->ci_data.cpu_uvm->pgflbucket = npackage / div;
  			ci3 = ci3->ci_sibling[CPUREL_PACKAGE];
  		} while (ci3 != ci2);
  		npackage++;
 @@ -935,7 +949,7 @@ uvm_page_rebucket(void)
  	} while (ci2 != ci->ci_sibling[CPUREL_PACKAGE1ST]);
  
  	aprint_debug("UVM: using package allocation scheme, "
 -	    "%d package(s) per bucket\n", 1 << shift);
 +	    "%d package(s) per bucket\n", div);
  }
  
  /*
 


Home | Main Index | Thread Index | Old Index