Subject: Re: Kernel optimizations!
To: Tracy Nelson <tnelson158@attbi.com>
From: Sung N. Cho <sucho2@vt.edu>
List: netbsd-help
Date: 05/09/2002 22:51:25
On Friday 10 May 2002 12:46 am, Tracy Nelson wrote:
> From: "Sung N. Cho" <sucho2@vt.edu>
>
> > I was wondering, shouldn't turning on the optimization for gcc make the
> > kernel bigger?
>
> Depends on how the original kernel was compiled.  If it was compiled with
> debugging info (-g flag), then it will certainly get smaller.  It's also
> possible to optimize for size instead of speed, which would of course make
> the kernel smaller also.  If you kernel was compiled with -O2 before,
> though, it should have gotten bigger (since -O3 performes loop unrolling
> and otherwise trades space for speed).
>
> Is it possible you removed some options in your kernel config file?  I know
> that when I ran the adjustkernel script and recompiled with only the
> devices I need to support, my kernel size dropped from 4.7M to 2.5M.
>
> Cheers!
> -- Tracy


Hi,

Both kernels, one compiled with -O2 and the other with -O3 had same config 
file.  And, debugging wasn't enabled on both kernels.  The size of the kernel 
compiled with -O2 was 2.4M and one with -O3 was 1.8M.  I don't know why this 
kernel compiled with -O3 got smaller, unless it didn't compile it properly or 
something!  But, the new kernel works just fine, so I'm assuming it did 
compile correctly.  Has anyone experienced similar problem?  

Here's my config file:

# "MYKERNEL"
# Sung's custom kernel configuration file for laptop. 
#

include "arch/i386/conf/std.i386"

maxusers	32		# estimated number of users

# CPU support.  At least one is REQUIRED.
options 	I686_CPU

# CPU-related options.
options 	USER_LDT	# user-settable LDT; used by WINE
options 	MTRR		# memory-type range register syscall support
options 	DUMMY_NOPS

# delay between "rebooting ..." message and hardware reset, in milliseconds
options 	CPURESET_DELAY=2000

# Misc. i386-specific options
options 	XSERVER		# X server support in console drivers

# Standard system options
options 	UCONSOLE	# users can use TIOCCONS (for xconsole)
options 	INSECURE	# disable kernel security levels

options 	RTC_OFFSET=0	# hardware clock is this many mins. west of GMT
options 	NTP		# NTP phase/frequency locked loop

options 	KTRACE		# system call tracing via ktrace(1)

options 	SYSVMSG		# System V-like message queues
options 	SYSVSEM		# System V-like semaphores
options 	SEMMNI=10	# number of semaphore identifiers
options 	SEMMNS=60	# number of semaphores in system
options 	SEMUME=10	# max number of undo entries per process
options 	SEMMNU=30	# number of undo structures in system
options 	SYSVSHM		# System V-like memory sharing
options 	SHMMAXPGS=1024	# 1024 pages is the default

options 	LKM		# loadable kernel modules

# Diagnostic/debugging support options
options 	DDB		# in-kernel debugger
options 	DDB_HISTORY_SIZE=512	# enable history editing in DDB

# Compatibility options
options 	COMPAT_15	# NetBSD 1.5,
options 	COMPAT_43	# and 4.3BSD
options 	COMPAT_LINUX	# binary compatibility with Linux

# File systems
file-system 	FFS		# UFS
file-system 	NFS		# Network File System client
file-system 	CD9660		# ISO 9660 + Rock Ridge file system
file-system 	MSDOSFS		# MS-DOS file system
file-system 	KERNFS		# /kern
file-system 	PROCFS		# /proc

# File system options
options 	QUOTA		# UFS quotas
options 	SOFTDEP		# FFS soft updates support.
options 	NFSSERVER	# Network File System server

# Networking options
options 	INET		# IP + ICMP + TCP + UDP
options 	PFIL_HOOKS	# pfil(9) packet filter hooks

#
# wscons options
#
options 	WSEMUL_VT100		# VT100 / VT220 emulation
options 	WSDISPLAY_COMPAT_PCVT		# emulate some ioctls
options 	WSDISPLAY_COMPAT_USL		# VT handling
options 	WSDISPLAY_COMPAT_RAWKBD		# can get raw scancodes
options 	WSDISPLAY_DEFAULTSCREENS=10

# Kernel root file system and dump configuration.
config		netbsd	root on ? type ?

#
# Device configuration
#

mainbus0 at root

apm0	at mainbus0			# Advanced power management

# Basic Bus Support

# PCI bus support
pci*	at mainbus? bus ?
pci*	at pchb? bus ?
pci*	at ppb? bus ?

# Configure PCI using BIOS information
options 	PCIBIOS			# PCI BIOS support
options 	PCIBIOS_BUS_FIXUP	# fixup PCI bus numbering
options         PCIBIOS_INTR_FIXUP      # fixup PCI bus interrupt routing

# PCI bridges
pchb*	at pci? dev ? function ?	# PCI-Host bridges
pcib*	at pci? dev ? function ?	# PCI-ISA bridges
ppb*	at pci? dev ? function ?	# PCI-PCI bridges

agp* 	at pchb?

# ISA bus support
isa*	at mainbus?
isa0	at pcib?

# CardBus bridge support
cbb*		at pci? dev ? function ?
cardslot*	at cbb?

# CardBus bus support
cardbus*	at cardslot?
pcmcia* 	at cardslot?

# Coprocessor Support

# Math Coprocessor support
npx0	at isa? port 0xf0 irq 13	# x86 math coprocessor

# Console Devices

# wscons
pckbc0		at isa?			# pc keyboard controller
pckbd*		at pckbc?		# PC keyboard
pms*		at pckbc?		# PS/2 mouse for wsmouse
vga*		at pci? dev ? function ?
wsdisplay*	at vga? console ?
wskbd* 		at pckbd? console ?
wsmouse*	at pms? mux 0

pcppi0		at isa?
sysbeep0	at pcppi?

# Parallel Printer Interfaces

# ISA parallel printer interfaces
lpt0	at isa? port 0x378 irq 7	# standard PC parallel ports

# IDE and related devices
pciide* at pci? dev ? function ? flags 0x0000
wd*	at pciide? channel ? drive ? flags 0x0000

# ATAPI bus support
atapibus* at pciide? channel ?
cd*	at atapibus? drive ? flags 0x0000	# ATAPI CD-ROM drives

# Miscellaneous mass storage devices

# ISA floppy
fdc0	at isa? port 0x3f0 irq 6 drq 2	# standard PC floppy controllers
fd*	at fdc? drive ?			# the drives themselves

# Network Interfaces

# PCMCIA network interfaces
ne*	at pcmcia? function ?		# NE2000-compatible Ethernet

# USB Controller and Devices

# PCI USB controllers
uhci*	at pci?	dev ? function ?	# Universal Host Controller (Intel)

# USB bus support
usb*	at uhci?

# USB Hubs
uhub*	at usb?
uhub*	at uhub? port ? configuration ? interface ?

# USB HID device
uhidev*	at uhub? port ? configuration ? interface ?

# USB Mice
ums*	at uhidev? reportid ?
wsmouse*	at ums? mux 0

# Audio Devices

# PCI audio devices
esm*	at pci? dev ? function ?    # ESS Maestro-1/2/2e PCI Audio Accelerator

# Audio support
audio*	at esm?

# The spkr driver provides a simple tone interface to the built in speaker.
spkr0	at pcppi?		# PC speaker

# Miscellaneous Devices

# Pseudo-Devices

# disk/mass storage pseudo-devices
pseudo-device	md		1	# memory disk device (ramdisk)
pseudo-device	vnd		4	# disk-like interface to files

# network pseudo-devices
pseudo-device	bpfilter	16	# Berkeley packet filter
pseudo-device	loop			# network loopback

# miscellaneous pseudo-devices
pseudo-device	pty			# pseudo-terminals
pseudo-device	sequencer	1	# MIDI sequencer
pseudo-device	rnd			# /dev/random and in-kernel generator

# wscons pseudo-devices
pseudo-device	wsmux			# mouse & keyboard multiplexor


Sung N. Cho