From owner-svn-src-head@FreeBSD.ORG Mon Oct 29 13:13:53 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 9BB27955; Mon, 29 Oct 2012 13:13:53 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 789268FC08; Mon, 29 Oct 2012 13:13:52 +0000 (UTC) Received: by mail-la0-f54.google.com with SMTP id e12so4779807lag.13 for ; Mon, 29 Oct 2012 06:13:51 -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=1VXbBd055rsRk0k+NOR+oTT1fOqBs+pn0UO7HudE0bA=; b=L0So07s5wPG9j7/zBCmByiYZcW0R5Qeei50vrmDhvnQ8nryMWJfNNGyB1FZSNIlZAK oH+JDL92SBqlpZaz3Nc5o0AvdygDuxpy1AfZqfCZ92FIZTICNl/SA/BBAW9CUXWy9e+F mN54q0K1eT2WXdfNpK15Fqi0XtGrdk+EX9csy4w8/pqbv1EXtQikNjztirGBYhmhETSk 9NsA6Bvon+hls2okip03h6oUy0AVNX1XmzjZcEs2enIadvfAmTIn4Gl2Q3N2wQpb++4N CjZog/caAnsCobj6IXV3+85jY7C+ZNeAdPOyrrsrU9vMM0umZNdB/BdnBxgPuFa0VZE6 cbaA== MIME-Version: 1.0 Received: by 10.152.123.103 with SMTP id lz7mr26974534lab.21.1351516430910; Mon, 29 Oct 2012 06:13:50 -0700 (PDT) Sender: asmrookie@gmail.com Received: by 10.112.30.37 with HTTP; Mon, 29 Oct 2012 06:13:50 -0700 (PDT) In-Reply-To: <20121029050221.GM70741@FreeBSD.org> References: <201210290135.q9T1ZHUJ047280@svn.freebsd.org> <20121029050221.GM70741@FreeBSD.org> Date: Mon, 29 Oct 2012 13:13:50 +0000 X-Google-Sender-Auth: 818PEocCNr0rrUGyD0a_nMDD9-c Message-ID: Subject: Re: svn commit: r242274 - head/sys/sys From: Attilio Rao To: Gleb Smirnoff Content-Type: text/plain; charset=UTF-8 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 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: Mon, 29 Oct 2012 13:13:53 -0000 On 10/29/12, Gleb Smirnoff wrote: > On Mon, Oct 29, 2012 at 01:35:17AM +0000, Attilio Rao wrote: > A> Author: attilio > A> Date: Mon Oct 29 01:35:17 2012 > A> New Revision: 242274 > A> URL: http://svn.freebsd.org/changeset/base/242274 > A> > A> Log: > A> Compiler have a precise knowledge of the content of sched_pin() and > A> sched_unpin() as they are functions static and inline. This way it > A> can do two dangerous things: > A> - Reorder instructions around both of them, taking out from the safe > A> path operations that are supposed to be (ie. per-cpu accesses) > A> - Cache the value of td_pinned in CPU registers not making visible > A> in kernel context to the scheduler once it is scanning the runqueue, > A> as td_pinned is not marked volatile. > A> > A> In order to avoid both possible bugs explicitly, protect the safe path > A> with compiler memory barriers. This will prevent reordering and > caching > A> by the compiler about td_pinned operations. > A> > A> Generally this could lead to suboptimal code traversing the pinnings > A> but this is not the case as can be easilly verified: > A> > http://lists.freebsd.org/pipermail/svn-src-projects/2012-October/005797.html > > Now __compiler_membar() can be removed from kern_rmlock.c:360 No, they are there to protect td_critnest which has nothing to do with sched_pin(). Attilio -- Peace can only be achieved by understanding - A. Einstein