From owner-freebsd-hackers@FreeBSD.ORG Mon Jul 5 17:15:09 2010 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 0CC881065674; Mon, 5 Jul 2010 17:15:09 +0000 (UTC) (envelope-from bzeeb-lists@lists.zabbadoz.net) Received: from mail.cksoft.de (mail.cksoft.de [IPv6:2001:4068:10::3]) by mx1.freebsd.org (Postfix) with ESMTP id 9015C8FC12; Mon, 5 Jul 2010 17:15:08 +0000 (UTC) Received: from localhost (amavis.fra.cksoft.de [192.168.74.71]) by mail.cksoft.de (Postfix) with ESMTP id 5DE3D41C750; Mon, 5 Jul 2010 19:15:07 +0200 (CEST) X-Virus-Scanned: amavisd-new at cksoft.de Received: from mail.cksoft.de ([192.168.74.103]) by localhost (amavis.fra.cksoft.de [192.168.74.71]) (amavisd-new, port 10024) with ESMTP id F+RBi0PD9wXR; Mon, 5 Jul 2010 19:15:06 +0200 (CEST) Received: by mail.cksoft.de (Postfix, from userid 66) id F0BF341C7A4; Mon, 5 Jul 2010 19:15:05 +0200 (CEST) Received: from maildrop.int.zabbadoz.net (maildrop.int.zabbadoz.net [10.111.66.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.int.zabbadoz.net (Postfix) with ESMTP id 9CCCE4448EC; Mon, 5 Jul 2010 17:12:42 +0000 (UTC) Date: Mon, 5 Jul 2010 17:12:42 +0000 (UTC) From: "Bjoern A. Zeeb" X-X-Sender: bz@maildrop.int.zabbadoz.net To: Andriy Gapon In-Reply-To: <4C320E6E.4040007@freebsd.org> Message-ID: <20100705171155.K14969@maildrop.int.zabbadoz.net> References: <4C246CD0.3020606@freebsd.org> <20100702082754.S14969@maildrop.int.zabbadoz.net> <4C320E6E.4040007@freebsd.org> X-OpenPGP-Key: 0x14003F198FEFA3E77207EE8D2B58B8F83CCF1842 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-hackers@freebsd.org, Konstantin Belousov , Navdeep Parhar , Peter Wemm Subject: Re: elf obj load: skip zero-sized sections early 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: Mon, 05 Jul 2010 17:15:09 -0000 On Mon, 5 Jul 2010, Andriy Gapon wrote: > on 02/07/2010 11:29 Bjoern A. Zeeb said the following: >> On Fri, 25 Jun 2010, Andriy Gapon wrote: >> >> Hey, >> >>> Proposed patch skips zero sized sections without going into trouble of >>> allocating section entry (progtab), doing zero-sized memory allocs and >>> copies. >>> I observe that sometimes zero-sized set_pcpu sections are produced in >>> module >>> objects, maybe when a module doesn't create any per cpu data of its >>> one, but >>> references external pcpu data. Not sure. > [snip] >>> This work is based on np@'s investigation and original patch: >>> http://lists.freebsd.org/pipermail/freebsd-hackers/2009-November/030093.html >>> >> >> Have you guys figured this out already? > > By 'this' - do you mean why that zero-sized section is produced at all? > Does it really matter why that happens? Well, no, I was thinking of the workaround and going ahead to commit somehting;) > I stated my guess already. Now I see that it is enough to simply include > sys/pcpu.h for this to happen. Inline assembly at the start of the said header > unconditionally creates the section. If DPCPU_DEFINE is never used in a module, > then set_pcpu section remains empty. Neither compiler nor linker have any reason > to drop empty sections in the build process for amd64 modules. > > I am not sure if ".section set_pcpu" assembly can be made conditional or moved > some place else, so that the section is only created when DPCPU_DEFINE is actually > used. The same applies to VIMAGE btw. Same technique. /bz -- Bjoern A. Zeeb From August on I will have a life. It's now up to you to do the maths and count to 64. -- Bondorf, Germany, 14th June 2010