From owner-freebsd-arch@FreeBSD.ORG Mon Jan 22 00:37:28 2007 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6E60616A403 for ; Mon, 22 Jan 2007 00:37:28 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.188]) by mx1.freebsd.org (Postfix) with ESMTP id 06A5913C441 for ; Mon, 22 Jan 2007 00:37:27 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: by nf-out-0910.google.com with SMTP id m19so328215nfc for ; Sun, 21 Jan 2007 16:37:26 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=tEjAB2t9qr+LVDwafeRsVtBHmivzW3qxlHYa3ZvFRNHLi6JHu+gY/5XJD7DGstJ9Km/G30WgBHXamVe4eFCvouu9SkxbdINSSq7Vkpv1pioz4QBo+daJqMck5SOqdZPBI4bsTV8UuSNjFEobOzI1ur6HUsG1zg+Q9JSxmxEdsV4= Received: by 10.49.58.13 with SMTP id l13mr5158843nfk.1169426246050; Sun, 21 Jan 2007 16:37:26 -0800 (PST) Received: by 10.48.238.14 with HTTP; Sun, 21 Jan 2007 16:37:25 -0800 (PST) Message-ID: <3bbf2fe10701211637n12b78989l25ba45621585ffa1@mail.gmail.com> Date: Mon, 22 Jan 2007 01:37:25 +0100 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "Luigi Rizzo" In-Reply-To: <20070121154901.B84480@xorpc.icir.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20070121140019.A83688@xorpc.icir.org> <20070121152251.A84413@xorpc.icir.org> <3bbf2fe10701211530o7c2e8977k2df02a546cb4cb8f@mail.gmail.com> <20070121154901.B84480@xorpc.icir.org> X-Google-Sender-Auth: 712d95112c9269c6 Cc: Ivan Voras , freebsd-arch@freebsd.org Subject: Re: bzero & bcopy alignment X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jan 2007 00:37:28 -0000 2007/1/22, Luigi Rizzo : > On Mon, Jan 22, 2007 at 12:30:40AM +0100, Attilio Rao wrote: > > 2007/1/22, Luigi Rizzo : > > > On Sun, Jan 21, 2007 at 11:25:14PM +0100, Ivan Voras wrote: > > > > Luigi Rizzo wrote: > > > > > On Sun, Jan 21, 2007 at 10:41:09PM +0100, Ivan Voras wrote: > > > > >> Following recent discussion on alignment of bzero() and bcopy(), I've > > > > >> added some statistics collecting code to bzero() and bcopy() for > > > > >> practice (on a RELENG_6 box), and here are the cumulative results for > > > > >> argument alignment: > > > > > > > > > > i think these profiles depend heavily on the hardware > > > > > and usage patterns. > > > > > > > > Yes, I agree. For what it's worth, this was on vmware, almost no network > > > > activity. > > > > > > > > > e.g. some network drivers force you to aligned buffers > > > > > which results in misaligned payload requesting in > > > > > turn an unaligned bcopy. Not that one can help with this, > > > > > but i think that is also important to locate the locations > > > > > in the source where the poorly aligned (1-2, maybe > > > > > 4 and 8 to some degree) ops occur. > > > > > > > > Any magic tricks to identify the caller of "current" function in the kernel? > > > > > > i suppose i would remap those function as > > > > > > #define bcopy(a, b, c) \ > > > do { \ > > > track_bcopy(__PRETTY_FUNCTION__, __FILE__, __LINE__, a, b, c); > > > original_bcopy(a, b, c); > > > } > > > > > > and the same for bzero, and then use function track_bcopy() > > > to simply record the instances in some data structure that you > > > can then export in some way to userland for stats gathering. > > > In the simplest form you could e.g. filter unaligned accesses > > > and just dump them to a buffer exported via sysctl; > > > if you want to make things smarter/more efficient, you could > > > hash __FILE__, __LINE__ to avoid duplicates (and probably, > > > because these are constant strings, you can just compare > > > the string pointers without having to do a full strcmp). > > > > A better approach (at least for ia32, I'm not aware what is the > > situation on the other architectures) would be using the vectorized > > entry for this family of function (i386/include/md_var.h). > > you still need the macro wrappers to acquire __FILE__ and __LINE__ > information. BTW, you should treact bzero/bcopy and friends with a lot of care since they are used in the very early stages of boot (so your track_bcopy would no do any sort of magics). Attilio -- Peace can only be achieved by understanding - A. Einstein