From owner-freebsd-arch@FreeBSD.ORG Fri Jul 28 17:05:14 2006 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0DB5B16A505 for ; Fri, 28 Jul 2006 17:05:14 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.194]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4653843D7E for ; Fri, 28 Jul 2006 17:04:23 +0000 (GMT) (envelope-from asmrookie@gmail.com) Received: by wx-out-0102.google.com with SMTP id t5so300878wxc for ; Fri, 28 Jul 2006 10:04:22 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; 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=ApHCH6f9+0sWsQhWEGddvzoyDONUstLlshtbvyk7VT6Pd4XAzcY9dfQ3h9YNKdMYm1QfqQSWNslXkLpP1rsLM7nYrtuaoPpMwMSMMyexvRZiMEQ8lZw0mpAO6aiftjPK9x4jwemk87gVteDYj7VaHA6E5Q2++aqmoro9eiJ8MnY= Received: by 10.70.38.9 with SMTP id l9mr2439224wxl; Fri, 28 Jul 2006 10:04:22 -0700 (PDT) Received: by 10.70.11.18 with HTTP; Fri, 28 Jul 2006 10:04:22 -0700 (PDT) Message-ID: <3bbf2fe10607281004o6727e976h19ee7e054876f914@mail.gmail.com> Date: Fri, 28 Jul 2006 19:04:22 +0200 From: "Attilio Rao" Sender: asmrookie@gmail.com To: "John Baldwin" In-Reply-To: <3bbf2fe10607261127p3f01a6c3w80027754f7d4e594@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <3bbf2fe10607250813w8ff9e34pc505bf290e71758@mail.gmail.com> <3bbf2fe10607250814m1a476f09p2d962dedc0c99be1@mail.gmail.com> <200607251232.51230.jhb@freebsd.org> <3bbf2fe10607251004wf94e238xb5ea7a31c973817f@mail.gmail.com> <3bbf2fe10607261127p3f01a6c3w80027754f7d4e594@mail.gmail.com> X-Google-Sender-Auth: fdef080e21fdb949 Cc: freebsd-arch@freebsd.org Subject: Re: [PATCH] Mantaining turnstile aligned to 128 bytes in i386 CPUs 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: Fri, 28 Jul 2006 17:05:14 -0000 2006/7/26, Attilio Rao : > 2006/7/25, Attilio Rao : > > 2006/7/25, John Baldwin : > > > On Tuesday 25 July 2006 11:14, Attilio Rao wrote: > > > > 2006/7/25, Attilio Rao : > > > > > Hi, > > > > > Intel documentation points out that having a 128-bytes aligned > > > > > syncronizing primitive (which fits in a cache line) will minimize the > > > > > traffic for cache bus, so this patch implements an alignment for i386 > > > > > on turnstiles. > > > > > > > > > > Any comments, feedbacks? > > > > > > > > Oh, sorry, I've unforgotten the diff. > > > > > > > > Attilio > > > > > > I think a better approach would be to stick turnstiles (and sleepqueues) in a > > > UMA zone and specify cache-size alignment to the zone. However, turnstiles > > > aren't really sychronization primitives in that you don't spin on a variable > > > inside the structure, and I think it's the spinning and avoiding bouncing > > > cache lines around that Intel's documentation is really about. In that case, > > > the things you want aligned are things like mutexes, rwlocks, etc. > > > > Well, I think that this is referred in particular to the latter issue > > you mentioned. > > Spinning is not really concerned to cache bus issues (more, in > > particular, datapath latency). > > With this point of view, turnstiles (as sleepqueues) are passed around > > CPUs more than a mutex/rwlock (or a cv), I guess, so I was thinking > > that it's better optimizing turnstile than the real syncronizing > > primitive itself. > > This is a patch which let turnstiles/sleepqueues using an UMA zone. > > I've tried in my 6.1R branch and it works quite fine, so this HEAD > version might be alright (I've not tried yet, so please test): > http://users.gufi.org/~rookie/works/patches/uma_sync.diff > > It, obviously, set default alignment for i386 at 128 bytes. > Any comments, feedbacks, ideas, are welcome. > > Attilio > > PS: I know that I could simplify *_alloc(), *_free() routines > implementing init/fini but it is simpler and more optimized having > things like so. After some thinking, I think it's better using init/fini methods (since they hide the sizeof(struct turnstile) with size parameter). Feedbacks and comments are welcome: http://users.gufi.org/~rookie/works/patches/uma_sync_init.diff Thanks, Attilio -- Peace can only be achieved by understanding - A. Einstein