From owner-svn-src-head@FreeBSD.ORG Wed Oct 24 19:06:03 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 092C7530; Wed, 24 Oct 2012 19:06:03 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id E7AAC8FC18; Wed, 24 Oct 2012 19:06:01 +0000 (UTC) Received: by mail-lb0-f182.google.com with SMTP id b5so1659516lbd.13 for ; Wed, 24 Oct 2012 12:06:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=xGzHQJQlQlT8O+1JxsFAzSCCFYndWOBcIBs0qoZbL1c=; b=fXD1Q6HDDUGYbDAANp3pIHOjuFNyPoDiKtVncdFEjODrsm2QIDG9jIvraa9DShkAF8 NB0uDtKbhjw+yUNe8whKk9gc1mZpw7+Uh3hnmkzrGsxwaeGcjfgjPQYCaPipMFco7ypk eb2kDnY9Pq13B6JiDK5bnc78FYSHh9dFjALMGczDbX75FHrGoMRwji0+srz3yHnOTdWj CKGp/IfLe21wn4TrzgO15ilBTIPf0i0vywvH3SB59pde4XBBiUlVvDCOdSA7QPmDyYcl /qfMBI++t+OEo4DKUo5+aGC039kxoTgpGoqQSYGxfOgnICoQSJXLQebcdve+zO5c5fM+ WIxw== MIME-Version: 1.0 Received: by 10.112.41.36 with SMTP id c4mr6416229lbl.75.1351105560441; Wed, 24 Oct 2012 12:06:00 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.112.30.37 with HTTP; Wed, 24 Oct 2012 12:06:00 -0700 (PDT) In-Reply-To: References: <201210241836.q9OIafqo073002@svn.freebsd.org> <201210241443.25988.jhb@freebsd.org> Date: Wed, 24 Oct 2012 20:06:00 +0100 X-Google-Sender-Auth: Wfjq43DqREXdt4V1omWoTkc4kfU Message-ID: Subject: Re: svn commit: r242014 - head/sys/kern From: Attilio Rao To: Jim Harris Content-Type: text/plain; charset=UTF-8 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, John Baldwin X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: attilio@FreeBSD.org List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Oct 2012 19:06:03 -0000 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 Attilio -- Peace can only be achieved by understanding - A. Einstein