From owner-freebsd-hackers@FreeBSD.ORG Thu Feb 12 21:22:09 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 B3E2810656C7 for ; Thu, 12 Feb 2009 21:22:09 +0000 (UTC) (envelope-from xcllnt@mac.com) Received: from asmtpout021.mac.com (asmtpout021.mac.com [17.148.16.96]) by mx1.freebsd.org (Postfix) with ESMTP id 9D9D98FC16 for ; Thu, 12 Feb 2009 21:22:09 +0000 (UTC) (envelope-from xcllnt@mac.com) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Received: from rajreddy-lnx.jnpr.net (natint3.juniper.net [66.129.224.36]) by asmtp021.mac.com (Sun Java(tm) System Messaging Server 6.3-7.03 (built Aug 7 2008; 32bit)) with ESMTPSA id <0KEY00E65Z7O2F50@asmtp021.mac.com> for freebsd-hackers@freebsd.org; Thu, 12 Feb 2009 12:21:25 -0800 (PST) Message-id: From: Marcel Moolenaar To: Jille Timmermans In-reply-to: <49944F8F.5080104@quis.cx> Date: Thu, 12 Feb 2009 12:21:24 -0800 References: <200902121549.n1CFnLdt002361@fire.js.berklix.net> <49944F8F.5080104@quis.cx> X-Mailer: Apple Mail (2.930.3) Cc: freebsd-hackers@freebsd.org, Julian Stacey , 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 21:22:10 -0000 On Feb 12, 2009, at 8:34 AM, Jille Timmermans wrote: > Julian Stacey schreef: >>> 1) Is it worth my time trying to rearrange structs? >> I wondered whether as a sensitivity test, some version of gcc (or >> its competitor ?) might have capability to automatically re-order >> variables ? but found nothing in man gcc "Optimization Options". > There is a __packed attribute, I don't know what it exactly does and > whether it is an improvement. > __packed is always a gross pessimization. The side-effect of packing a structure is that the alignment of the structure drops to 1. That means that any field will be read 1 byte at a time and reconstructed by logical operations. For best results, __packed should be used with __aligned(X), in case __packed is needed of course to address the side- effect. Of course multi-byte fields that are unaligned in the structure as the result of packing, will still be read in parts. In other words: don't use __packed when you don't have to. -- Marcel Moolenaar xcllnt@mac.com