From owner-freebsd-current@FreeBSD.ORG Tue Jan 4 19:18:00 2011 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BF294106564A for ; Tue, 4 Jan 2011 19:18:00 +0000 (UTC) (envelope-from rdivacky@vlk.vlakno.cz) Received: from vlakno.cz (lev.vlakno.cz [77.93.215.190]) by mx1.freebsd.org (Postfix) with ESMTP id 366608FC16 for ; Tue, 4 Jan 2011 19:17:59 +0000 (UTC) Received: from lev.vlakno.cz (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 37BD89CB070 for ; Tue, 4 Jan 2011 19:59:31 +0100 (CET) X-Virus-Scanned: amavisd-new at vlakno.cz Received: from vlakno.cz ([127.0.0.1]) by lev.vlakno.cz (lev.vlakno.cz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l7etxJdLvGAB for ; Tue, 4 Jan 2011 19:59:30 +0100 (CET) Received: from vlk.vlakno.cz (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 45B0C9CB2F5 for ; Tue, 4 Jan 2011 19:59:30 +0100 (CET) Received: (from rdivacky@localhost) by vlk.vlakno.cz (8.14.4/8.14.4/Submit) id p04IxUx2064599 for current@freebsd.org; Tue, 4 Jan 2011 19:59:30 +0100 (CET) (envelope-from rdivacky) Date: Tue, 4 Jan 2011 19:59:30 +0100 From: Roman Divacky To: current@freebsd.org Message-ID: <20110104185930.GA62775@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EeQfGwPcQSOJBaQU" Content-Disposition: inline User-Agent: Mutt/1.4.2.3i Cc: Subject: [RFC]: unnecessary padding in various kernel structures X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jan 2011 19:18:00 -0000 --EeQfGwPcQSOJBaQU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline hi, clang (svn version) has ability to detect unnecessary padding in structures. I ran this on kernel build on i386 (stripped GENERIC) and amd64 (full GENERIC), preprocessed this and posted on web. The lists contain the file of the definition, name of the structure, size of the unnecessary padding and reason for the alignment. The last field is how many times this was hit during the build of the kernel. The lists are sorted by the size of the padding. Examples (i386): dev/usb/controller/ohci.h:64:8: 2 times padding size of 'struct ohci_hcca' with 120 bytes to alignment boundary sys/pcpu.h:156:8: 58 times padding size of 'struct pcpu' with 108 bytes to alignment boundary sys/pcpu.h:199:2: 58 times padding struct 'struct pcpu' with 84 bytes to align 'pc_monitorbuf' dev/usb/controller/ehci.h:170:8: 1 times padding size of 'struct ehci_qtd' with 58 bytes to alignment boundary kern/sched_ule.c:206:8: 1 times padding size of 'struct tdq' with 41 bytes to alignment boundary Examples(amd64): net/flowtable.c:179:11: 1 times padding struct 'struct flowtable' with 124 bytes to align 'ft_udp_idle' dev/usb/controller/ohci.h:64:8: 2 times padding size of 'struct ohci_hcca' with 120 bytes to alignment boundary net/flowtable.c:160:8: 1 times padding size of 'struct flowtable' with 108 bytes to alignment boundary vm/uma_int.h:184:8: 6 times padding size of 'struct uma_cache' with 96 bytes to alignment boundary vm/uma_int.h:338:19: 5 times padding struct 'struct uma_zone' with 92 bytes to align 'uz_cpu' net/flowtable.c:149:8: 1 times padding size of 'struct flowtable_stats' with 64 bytes to alignment boundary Full lists can be found here: http://lev.vlakno.cz/~rdivacky/kernel-unecessary-padding-i386.txt http://lev.vlakno.cz/~rdivacky/kernel-unecessary-padding-amd64.txt Instances of some of these structures can be in memory many times. And thus we can be losing a lot of memory without noticing it. Can you guys look at the biggest offenders or some other interesting structures in the lists and do something about it? Maybe be simple reshuffling we can improve things a lot! Thank you Roman --EeQfGwPcQSOJBaQU Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (FreeBSD) iEYEARECAAYFAk0jbhIACgkQLVEj6D3CBEwNoACeKhwUuyn+Qslahs2drb6OKfSX brQAn3CySLHNNPn4FL0BCZbX4myDC7Hd =KvrJ -----END PGP SIGNATURE----- --EeQfGwPcQSOJBaQU--