Date: Tue, 25 Jul 2006 17:14:47 +0200 From: "Attilio Rao" <attilio@freebsd.org> To: freebsd-arch@freebsd.org Subject: Re: [PATCH] Mantaining turnstile aligned to 128 bytes in i386 CPUs Message-ID: <3bbf2fe10607250814m1a476f09p2d962dedc0c99be1@mail.gmail.com> In-Reply-To: <3bbf2fe10607250813w8ff9e34pc505bf290e71758@mail.gmail.com> References: <3bbf2fe10607250813w8ff9e34pc505bf290e71758@mail.gmail.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
2006/7/25, Attilio Rao <attilio@freebsd.org>:
> 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
--
Peace can only be achieved by understanding - A. Einstein
[-- Attachment #2 --]
--- subr_turnstile.c Wed Jul 26 01:10:33 2006
+++ patch/subr_turnstile.c Wed Jul 26 01:14:21 2006
@@ -81,6 +81,18 @@
#endif
/*
+ * For the i386 processors family, having a 128-bytes aligned turnstile
+ * (which exactly fits in a cacheline) would minimize cache/memory
+ * traffic for turnstile moves in SMP environment. Having a
+ * lowest-aligned byte structure will assure to not affect other archs.
+ */
+#if defined(__i386__) && defined(SMP)
+#define TURNSTILE_ALIGN 0x80
+#else
+#define TURNSTILE_ALIGN 0x01
+#endif
+
+/*
* Constants for the hash table of turnstile chains. TC_SHIFT is a magic
* number chosen because the sleep queue's use the same value for the
* shift. Basically, we ignore the lower 8 bits of the address.
@@ -120,7 +132,7 @@
LIST_HEAD(, turnstile) ts_free; /* (c) Free turnstiles. */
struct lock_object *ts_lockobj; /* (c) Lock we reference. */
struct thread *ts_owner; /* (c + q) Who owns the lock. */
-};
+} __aligned(TURNSTILE_ALIGN);
struct turnstile_chain {
LIST_HEAD(, turnstile) tc_turnstiles; /* List of turnstiles. */
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3bbf2fe10607250814m1a476f09p2d962dedc0c99be1>
