Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Jan 2015 00:27:18 -0500
From:      Allan Jude <allanjude@freebsd.org>
To:        freebsd-hackers@freebsd.org
Subject:   Re: [PATCH] Display progress during getmemsize() so the kernel doesn't look like it hanged
Message-ID:  <54B35B36.4040504@freebsd.org>
In-Reply-To: <D0D89A8E.129518%rpokala@panasas.com>
References:  <D0D89A8E.129518%rpokala@panasas.com>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On 2015-01-12 00:24, Pokala, Ravi wrote:
> Hi folks,
> 
> Several of us have noticed that there's a long pause at the start of
> booting the kernel on amd64 systems with large amounts of RAM. During this
> pause, the kernel is mapping in the memory ranges, but does not emit any
> progress indicators. Because this can take quite a while, it can look like
> the kernel has hung. I filed PR 196650 about this issue; this patch just
> prints out a dot for every GB that's mapped in. We've been using this
> patch for years at Panasas, and I'm hoping someone can submit it for me.
> 
> Thanks,
> 
> Ravi
> 
> 
> Index: sys/amd64/amd64/machdep.c
> ===================================================================
> --- sys/amd64/amd64/machdep.c	(revision 276903)
> +++ sys/amd64/amd64/machdep.c	(working copy)
> @@ -1575,6 +1575,9 @@
>  	u_long physmem_start, physmem_tunable, memtest;
>  	pt_entry_t *pte;
>  	quad_t dcons_addr, dcons_size;
> +	u_int32_t page_counter;
> +	int PAGES_PER_MB = ((1024 * 1024) / PAGE_SIZE);
> +	int PAGES_PER_GB = (PAGES_PER_MB * 1024);
>  
>  	bzero(physmap, sizeof(physmap));
>  	basemem = 0;
> @@ -1678,6 +1681,8 @@
>  	 * physmap is in bytes, so when converting to page boundaries,
>  	 * round up the start address and round down the end address.
>  	 */
> +	printf("Mapping system memory");
> +	page_counter = 0;
>  	for (i = 0; i <= physmap_idx; i += 2) {
>  		vm_paddr_t end;
>  
> @@ -1688,6 +1693,14 @@
>  			int tmp, page_bad, full;
>  			int *ptr = (int *)CADDR1;
>  
> +			/*
> +			 * Print a "." every GB, to show we're making progress
> +			 */
> +			page_counter++;
> +			if ((page_counter % PAGES_PER_GB) == 0) {
> +				printf(".");
> +			}
> +
>  			full = FALSE;
>  			/*
>  			 * block out kernel memory as not available.
> @@ -1792,6 +1805,9 @@
>  				break;
>  		}
>  	}
> +	printf("\nMapped %d GB + %d MB total\n",
> +	    (page_counter / PAGES_PER_GB),
> +	    ((page_counter % PAGES_PER_GB) / PAGES_PER_MB));
>  	*pte = 0;
>  	invltlb();
>  
> 
> 
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
> 

Which version(s) of FreeBSD were you seeing this delay on?

I know older versions had it, quite badly.

setting hw.memtest.tests=0 in /boot/loader.conf makes most of the delay
go away, and the default on -CURRENT is now 0 instead of 1.

IIRC, in 10, it defaults to 1, but is switched to 0 in the case of
virtual machines, because touching every page of memory ruined memory
over-commit type features.

Is this feature still useful with memtest.tests=0?


-- 
Allan Jude


[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (MingW32)

iQIcBAEBAgAGBQJUs1s7AAoJEJrBFpNRJZKfXCAP/jzLD28j26Af1RnPN8UdyZHg
BOoB2CEhuq6h7VLUl+8Ec6mJ6+JgCJYeBiuVPj6h5VGjec/jVwH2S2CVuGzOYJy5
FfzjBZnRShTEVFqN9ySZRgg1q1R7HxHEm/e27Z8EDLLvqPUfqp2rg1s3QW48lDcS
/psZj/LiIMplltpXw4GBSIiaJeDamHLJAfy1FN2edcMl1vh2qZkhSqO9tvwVPP3S
UcjUNwftDw03cKrA6+76M50RCqfI0nwjg6+M3inahbWQH/dqzi1gNFm1N3F69paY
+2M5QYqUSD7r68yzhEFASZR4D/uuv95mdHNGCiINUBTtQYzLZmsRgIs7E1bN0r6D
kYNSuAbNTdc/gLOieaSjPevEs0R0aLEqM14Yb//76mljEytvi8NUYYjuxtnpwm3o
TAL2cxiPAJ/z8wob5VzPL8sva+2aoWPqeHfpH6/LDrCBw1xRkeNFIUKoYmxlBjyG
2mg4+C2TdkWbBrTVaK7v5+W8hDY7gOMSPP+EuBi3F/ez6OodNpwZHGRIKhIFeqsb
V0g40P6dL5Zg228wIBpBK+p3wcSzeTSh44VKQaRlt1ju6YeGgeNB1qFagL7kRj3K
qfforsPsp0NZoKTHMQC1No5OEBRenXjpIJS56c6CL2DLH7qCa1zwre6En3yof90n
DzlleLrOezbK1gmWSoy8
=teXD
-----END PGP SIGNATURE-----

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