From owner-svn-src-head@FreeBSD.ORG Wed Oct 24 19:00:25 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 6F53FE5D; Wed, 24 Oct 2012 19:00:25 +0000 (UTC) (envelope-from jim.harris@gmail.com) Received: from mail-qa0-f47.google.com (mail-qa0-f47.google.com [209.85.216.47]) by mx1.freebsd.org (Postfix) with ESMTP id DE1958FC0A; Wed, 24 Oct 2012 19:00:24 +0000 (UTC) Received: by mail-qa0-f47.google.com with SMTP id i29so3357163qaf.13 for ; Wed, 24 Oct 2012 12:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=iWrc8OkzAQ+LHFNo83XhmT5ZV/n/FN4ZEI5PDIiEyYM=; b=tFjf6MWpZf3o/Fg4ARgjL9VtxeneeaCzUFcKxwNK50FrsBTqSwnc/z+NO3u3W2ru62 grvZq7tDame7rrLHAk/jB8sVjWSxW8yM5uegw/0ERmaM56zd0oth4Mc7RFND/0ywNI8J dEgmjGcauKVq2ls21QXmFXsGXJ+r420qT/X4qhVB+Bk3wPfmQYq74kd7W4epEMZQmmm3 s1dg6uNcHspDVnRfE6SaggfDoOIVgLlKuMHoALyzHKkIaLNXhlWxUSoJLRmTt5nZS4XK UzWQa9jl5SWXASz3cGh2b5cxJnwozqQJhC10Owv3598nWNoWgRWSzh6JUY4ItzmLNU4S B3qA== MIME-Version: 1.0 Received: by 10.49.95.73 with SMTP id di9mr9319090qeb.37.1351105223941; Wed, 24 Oct 2012 12:00:23 -0700 (PDT) Received: by 10.49.35.37 with HTTP; Wed, 24 Oct 2012 12:00:23 -0700 (PDT) In-Reply-To: <201210241443.25988.jhb@freebsd.org> References: <201210241836.q9OIafqo073002@svn.freebsd.org> <201210241443.25988.jhb@freebsd.org> Date: Wed, 24 Oct 2012 12:00:23 -0700 Message-ID: Subject: Re: svn commit: r242014 - head/sys/kern From: Jim Harris To: John Baldwin Content-Type: text/plain; charset=ISO-8859-1 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list 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:00:25 -0000 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. I could have aligned tdq_cg instead of using the char array to get the same effect. I chose the padding only because there was precedence for it in sys/vm/vm_page.h - struct vpglocks.