From owner-freebsd-hackers@FreeBSD.ORG Thu Feb 12 14:52:28 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C03281065677 for ; Thu, 12 Feb 2009 14:52:28 +0000 (UTC) (envelope-from redcrash@gmail.com) Received: from mail-bw0-f170.google.com (mail-bw0-f170.google.com [209.85.218.170]) by mx1.freebsd.org (Postfix) with ESMTP id 0F77B8FC13 for ; Thu, 12 Feb 2009 14:52:27 +0000 (UTC) (envelope-from redcrash@gmail.com) Received: by bwz18 with SMTP id 18so1328816bwz.19 for ; Thu, 12 Feb 2009 06:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=tn7pyRkjX3y8cML8BrZyXn6nFaW60gvL/31dwOEKKOc=; b=Aux9IJfjjrB2QVXx45XEMiPDwOwg5NiYFq6IE5MZ+iZq2RV4TNfpJujIkABRbNocEL FDBiKWrBkvzdeOAzpGWNatJC2z9zqWxH4UfLEXX4xjeGOOYgYnVukJRRAWhYkow9+0C2 PJhSCiECGObebHCAd1owkwnsLkg2yB51//AJ0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=N7DrA65cyUSuURFAVnK8ZJjSibe1Gf6Gg2B7X6vtNSUN2/JuOlxRQrwQym5A9enpY6 j4mlmYxbSc5Lznqy8fAqwqbndWdyr10rJoNejd8DpdDwQ5hqFYtRLzBvQxg4vY2tjXE2 EBwuN08vQQQQemV/+IMJurtKpOfSGiUtmEz+4= MIME-Version: 1.0 Received: by 10.223.113.194 with SMTP id b2mr1051067faq.80.1234448490389; Thu, 12 Feb 2009 06:21:30 -0800 (PST) In-Reply-To: <20090212141313.GD2723@deviant.kiev.zoral.com.ua> References: <20090212141313.GD2723@deviant.kiev.zoral.com.ua> Date: Thu, 12 Feb 2009 15:21:30 +0100 Message-ID: From: Harald Servat To: Kostik Belousov Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-hackers@freebsd.org, Andrew Brampton Subject: Re: pahole - Finding holes in kernel structs X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 14:52:29 -0000 On Thu, Feb 12, 2009 at 3:13 PM, Kostik Belousov wrote: > On Thu, Feb 12, 2009 at 02:08:22PM +0000, Andrew Brampton wrote: > > I found this useful tool called pahole[1]. It basically finds holes > > within structs, so for example on my 64bit machine this struct: > > > > struct test { > > int foo; > > const char *bar; > > int blah; > > } > > > > Would have a hole between foo and bar of 4 bytes because both for and > > bar have been aligned on a 8 byte boundary, and the struct would also > > have 4 bytes of padding on the end. However, if I simply moved blah > > between foo and bar then the struct has shrunk by 8 bytes, which could > > be a good thing. This could also help keep structs within single cache > > lines, and just generally keep memory usage to a minimum when the > > struct is used many times (for example in an array). > > > > So I ran the tool pahole over a 7.1 FreeBSD Kernel, and found that > Did you ported it to FreeBSD, or run on the Linux host ? > > > many of the struct had holes, and some of which could be rearranged to > > fill the gap. I've made the list available here[2]. So my questions > > are two fold: > > > > 1) Is it worth my time trying to rearrange structs? If so do you think > > many of my patches would be accepted? > > > > 2) Is there a way to find out the most heavily used structs? There are > > ~3600 structs, and ~2000 holes, it might be a waste of my time fixing > > the structs which are only used once. > > > > thanks > > Andrew > Interesting utility Andrew! Remember that size of some types depend on the memory ABI (32 or 64 bits), so this influences on the result of this utility. > > > [1] http://lwn.net/Articles/206805/ > > [2] http://bramp.net/projects/kernel.pahole.bz2 (~260kB) > > _______________________________________________ > > 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" >