From owner-svn-src-all@FreeBSD.ORG Wed Oct 24 20:25:16 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9FB0BD85 for ; Wed, 24 Oct 2012 20:25:16 +0000 (UTC) (envelope-from andre@freebsd.org) Received: from c00l3r.networx.ch (c00l3r.networx.ch [62.48.2.2]) by mx1.freebsd.org (Postfix) with ESMTP id 014EE8FC19 for ; Wed, 24 Oct 2012 20:25:15 +0000 (UTC) Received: (qmail 36527 invoked from network); 24 Oct 2012 22:03:02 -0000 Received: from c00l3r.networx.ch (HELO [127.0.0.1]) ([62.48.2.2]) (envelope-sender ) by c00l3r.networx.ch (qmail-ldap-1.03) with SMTP for ; 24 Oct 2012 22:03:02 -0000 Message-ID: <50884E9F.3090706@freebsd.org> Date: Wed, 24 Oct 2012 22:25:03 +0200 From: Andre Oppermann User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: attilio@FreeBSD.org Subject: Re: svn commit: r242014 - head/sys/kern References: <201210241836.q9OIafqo073002@svn.freebsd.org> <201210241443.25988.jhb@freebsd.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Jim Harris , John Baldwin X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Oct 2012 20:25:16 -0000 On 24.10.2012 21:06, Attilio Rao wrote: > On Wed, Oct 24, 2012 at 8:00 PM, Jim Harris wrote: >> On Wed, Oct 24, 2012 at 11:43 AM, John Baldwin wrote: >>> On Wednesday, October 24, 2012 2:36:41 pm Jim Harris wrote: >>>> Author: jimharris >>>> Date: Wed Oct 24 18:36:41 2012 >>>> New Revision: 242014 >>>> URL: http://svn.freebsd.org/changeset/base/242014 >>>> >>>> Log: >>>> Pad tdq_lock to avoid false sharing with tdq_load and tdq_cpu_idle. >>>> >>>> This enables CPU searches (which read tdq_load) to operate independently >>>> of any contention on the spinlock. Some scheduler-intensive workloads >>>> running on an 8C single-socket SNB Xeon show considerable improvement with >>>> this change (2-3% perf improvement, 5-6% decrease in CPU util). >>>> >>>> Sponsored by: Intel >>>> Reviewed by: jeff >>>> >>>> Modified: >>>> head/sys/kern/sched_ule.c >>>> >>>> Modified: head/sys/kern/sched_ule.c >>>> >>> ============================================================================== >>>> --- head/sys/kern/sched_ule.c Wed Oct 24 18:33:44 2012 (r242013) >>>> +++ head/sys/kern/sched_ule.c Wed Oct 24 18:36:41 2012 (r242014) >>>> @@ -223,8 +223,13 @@ static int sched_idlespinthresh = -1; >>>> * locking in sched_pickcpu(); >>>> */ >>>> struct tdq { >>>> - /* Ordered to improve efficiency of cpu_search() and switch(). */ >>>> + /* >>>> + * Ordered to improve efficiency of cpu_search() and switch(). >>>> + * tdq_lock is padded to avoid false sharing with tdq_load and >>>> + * tdq_cpu_idle. >>>> + */ >>>> struct mtx tdq_lock; /* run queue lock. */ >>>> + char pad[64 - sizeof(struct mtx)]; >>> >>> Can this use 'tdq_lock __aligned(CACHE_LINE_SIZE)' instead? >>> >> >> No - that doesn't pad it. I believe that only works if it's global, >> i.e. not part of a data structure. > > As I've already said in another thread __align() doesn't work on > object declaration, so what that won't pad it either if it is global > or part of a struct. > It is just implemented as __attribute__((aligned(X))): > http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Type-Attributes.html Actually it seems gcc itself doesn't really care and it up to the linker to honor that. -- Andre