Re: [rfc] removing -mpreferred-stack-boundary=2 flag for i386?

From: Alexander Best <arundel_at_freebsd.org>
Date: Sat, 24 Dec 2011 11:47:14 +0000
On Sat Dec 24 11, Bruce Evans wrote:
> On Fri, 23 Dec 2011, Adrian Chadd wrote:
> 
> >Well, the whole kernel is bloated at the moment, sorry.
> >
> >I've been trying to build the _bare minimum_ required to bootstrap
> >-HEAD on these embedded boards and I can't get the kernel down below 5
> >megabytes - ie, one with FFS (with options disabled), MIPS, INET (no
> >INET6), net80211, ath (which admittedly is big, but I need it no
> >matter what, right?) comes in at:
> >
> >-r-xr-xr-x  1 root  wheel   5307021 Nov 29 19:14 kernel.LSSR71
> >
> >And with INET6, on another board (and this includes MSDOS and the
> >relevant geom modules):
> >
> >-r-xr-xr-x  1 root  wheel   5916759 Nov 28 12:00 kernel.RSPRO
> >
> >.. honestly, that's what should be addressed. That's honestly a bit 
> >ridiculous.
> 
> It's disgusting, but what problems does it cause apart from minor slowness
> from cache misses?
> 
> I used to monitor the size of a minimal i386 kernel:
> 
> % machine		i386
> % cpu		I686_CPU
> % ident		MIN
> % options 	SCHED_4BSD
> 
> In FreeBSD-5-CURRENT between 5.1R and 5.2R, this had size:
> 
>    text	   data	    bss	    dec	    hex	filename
>  931241	  86524	  62356	1080121	 107b39	/sysc/i386/compile/min/kernel
> 
> A minimal kernel is not useful, but maybe you can add some i/o to it
> without bloating it too much.
> 
> This almost builds in -current too.  I had to add the following:
> - NO_MODULES to de-bloat the compile time
> - MK_CTF=no to build -current on FreeBSD.9.  The kernel .mk files are
>   still broken (depend on nonstandard/new features in sys.mk).

strange. the build(7) man page claims that:

"
     WITH_CTF          If defined, the build process will run the DTrace CTF
                       conversion tools on built objects.  Please note that
                       this WITH_ option is handled differently than all other
                       WITH_ options (there is no WITHOUT_CTF, or correspond-
                       ing MK_CTF in the build system).
"

... so setting MK_CTF to anything shouldn't have (according to the man page).

cheers.
alex

> - comment out a line in if.c that refers to Vloif.  if.c is standard
>   but the loop device is optional.
> 
> A few more changes to remove non-minimalities that are not defaults
> made little difference:
> 
> % machine		i386
> % cpu		I686_CPU
> % ident		MIN
> % options 	SCHED_4BSD
> % 
> % # XXX kill default misconfigurations.
> % makeoptions	NO_MODULES=yes
> % makeoptions	COPTFLAGS="-O -pipe"
> % 
> % # XXX from here on is to try to kill everything in DEFAULTS.
> % 
> % # nodevice		isa	# needed for DELAY...
> % # nooptions 	ISAPNP		# needed ...
> % 
> % nodevice		npx
> % 
> % nodevice		mem
> % nodevice		io
> % 
> % nodevice		uart_ns8250
> % 
> % nooptions 	GEOM_PART_BSD
> % nooptions 	GEOM_PART_EBR
> % nooptions 	GEOM_PART_EBR_COMPAT
> % nooptions 	GEOM_PART_MBR
> % 
> % # nooptions 	NATIVE		# needed ...
> % # nodevice		atpic	# needed ...
> % 
> % nooptions 	NEW_PCIB
> % 
> % nooptions		VFS_ALLOW_NONMPSAFE
> 
>    text	   data	    bss	    dec	    hex	filename
> 1663902	 110632	 136892	1911426	 1d2a82	kernel
> 
> (This was about 100K larger with -O2 and all DEFAULTS).  The bloat since
> FreeBSD-5 is only 70%.
> 
> Here are some sizes for my standard kernel (on i386).  The newer
> versions have about the same number of features since they don't support
> so many old isa devices or so many NICs:
> 
>    text	   data	    bss	    dec	    hex	filename
> 1483269	 106972	 172524	1762765	 1ae5cd	FreeBSD-3/kernel
> 1917408	 157472	 194228	2269108	 229fb4	FreeBSD-4/kernel
> 2604498	 198948	 237720	3041166	 2e678e	FreeBSD-5.1.5/kernel
> 2833842	 206856	 242936	3283634	 321ab2 
> FreeBSD-5.1.5/kernel-with-acpi
> 2887573	 192456	 288696	3368725	 336715	FreeBSD-5.1.5/kernel
>                                         with my changes, -O2 and usb
> 					added relative to the above
> 2582782	 195756	 298936	3077474	 2ef562	previous, with some excessive
>                                         inlining avoided, and without -O2,
> 					and with ipfilter
> 1998276	 159436	 137748	2295460	 2306a4	kernel.4
>                                         a more up to date and less hacked on
> 					FreeBSD-4
> 4365549	 262656	 209588	4837793	 49d1a1	kernel.7
> 4406155	 266496	 496532	5169183	 4ee01f	kernel.7.invariants
> 3953248	 242464	 207252	4402964	 432f14	kernel.7.noacpi
> 4418063	 268288	 240084	4926435	 4b2be3	kernel.7.smp
>                                         various fairly stock FreeBSD-7R
> 					kernels
> 3669544	 262848	 249712	4182104	 3fd058	kernel.c
> 4174317	 258240	 540144	4972701	 4be09d	kernel.c.invariants
> 3964455	 250656	 249808	4464919	 442117	kernel.c.noacpi
> 3213928	 240160	 240596	3694684	 38605c	kernel.c.noacpi-ule
> 4285040	 268288	 286160	4839488	 49d840	kernel.c.smp
>                                         current before FreeBSD-8R
> 					not all built at the same time or
> 					with the same options.  The 20%
> 					bloat between kernel.c.noacpi.ule
> 					and kernel.c.noacpi is mainly
> 					from not killing the default of
> 					-O2.
> 4742714	 315008	 401692	5459414	 534dd6	kernel.8
> 4816900	 319200	1813916	6950016	 6a0c80	kernel.8.invariants
> 4490209	 304832	 395260	5190301	 4f329d	kernel.8.noacpi
> 4795475	 323680	 475420	5594575	 555dcf	kernel.8.smp
>                                         various fairly stock FreeBSD-8R
> 					kernels
> 4979632	 287020	 488404	5755056	 57d0b0	kernel.cur
> 5062953	 289196	1902676	7254825	 6eb329	kernel.cur.invariants
> 5361809	 295052	 576984	6233845	 5f1ef5	kernel.cur.smp
> 
> amd64 kernels are only bout 4% larger if i386 kernels are built with
> equivalant CFLAGS (-march=athlon64 for athlon64 CPU), but I usually
> optimize i386 kernels for space and portability by compiling them
> with -mtune=old.
> 
> Bruce
Received on Sat Dec 24 2011 - 10:47:14 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:22 UTC