From owner-freebsd-mips@FreeBSD.ORG Tue Jun 4 04:08:49 2013 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4610B442; Tue, 4 Jun 2013 04:08:49 +0000 (UTC) (envelope-from pkelsey@gmail.com) Received: from mail-bk0-x22f.google.com (mail-bk0-x22f.google.com [IPv6:2a00:1450:4008:c01::22f]) by mx1.freebsd.org (Postfix) with ESMTP id 4EEDF1962; Tue, 4 Jun 2013 04:08:48 +0000 (UTC) Received: by mail-bk0-f47.google.com with SMTP id jg9so1957392bkc.6 for ; Mon, 03 Jun 2013 21:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=to6zmT8ADvmoITeNfrPJrkIAgVgpUlojSrM7V1oplNY=; b=vfVG2Ao4eQcZms5aWRvBqZYTDeKRXgkS2OA6qJpHg2VHczR9YkOu+OYdx05gb/Q8e5 dk6ePR21/IRMzOk2avpWoj/g+4JzHRcxmJ5RnY73xq684q5nCF9yqDsr/lmd51TqA4YV 3l6Zxifi3a8GD7a+Qsm9RXVmz4fSzqqdKp0sE/V/ihxcr17pk3YP+NFqj60XC4RyDXLH KV+nWt7OJFanvMv2oZTGywI1R0Agvc7m3TPcHdxCYzmRHYMv1tqCrFTC/JSFhWjOdZg/ HqRZMoGr315Qm91sbBgjXsKUrdGc/RI+nZOnBpkroDrKi9MjIm3GqEK4iZ8dFluVIGqy 13Cg== MIME-Version: 1.0 X-Received: by 10.204.63.1 with SMTP id z1mr7346196bkh.148.1370318927404; Mon, 03 Jun 2013 21:08:47 -0700 (PDT) Sender: pkelsey@gmail.com Received: by 10.205.141.68 with HTTP; Mon, 3 Jun 2013 21:08:47 -0700 (PDT) In-Reply-To: References: Date: Tue, 4 Jun 2013 00:08:47 -0400 X-Google-Sender-Auth: m26drlMzlt_pTRy98rdfaB80jr0 Message-ID: Subject: Re: Kernelspace C11 atomics for MIPS From: Patrick Kelsey To: Adrian Chadd Content-Type: text/plain; charset=ISO-8859-1 Cc: Ed Schouten , "freebsd-mips@FreeBSD.org" , FreeBSD-arch X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2013 04:08:49 -0000 On Mon, Jun 3, 2013 at 11:57 PM, Adrian Chadd wrote: > On 3 June 2013 20:55, Juli Mallett wrote: > >> To drain the pipeline on certain deficient (and mostly older) CPUs by way of >> guesswork and a little vague magic. Most CPUs we support, I would guess, do >> not need this, and it continues to exist solely for hysterical reasons. > > How can I turn it off for my compiles? > >> I've certainly gotten rid of them and some other cargo cult synchronization >> on Octeon for testing and had it survive under considerable load, and >> occasionally with some slight speedups (for some more commonly-used or >> slower things than Just a Bunch Of NOPs.) > > Right. Well, since it's happening on every inlined lock, it's a bit silly. > >> The trouble is that proving they aren't necessary requires being rigorous >> and careful in understanding documentation and errata, and FUD about their >> possible necessity is somewhat-intimidating. It's not an easy kind of >> corruption/unreliability/etc., to prove the lack of empirically. > > I've checked the diassembly from gcc-4.mumble on linux; it doesn't > include NOPs like this as far as I can tell. > The sync + 8 nops is coming from the definition of mips_sync() in sys/mips/include/atomic.h. I agree with Juli that it appears to be a manual pipeline-flush holdover from earlier days - I'm guessing there's 8 nops because the R4000/4400 had both the sync instruction and an 8-stage pipeline. I'm further guessing this was an attempt at providing stronger ordering semantics than the sync instruction itself for the following mb()/wmb()/rmb() definitions that use it, as the sync instruction definition doesn't restrict execution of the before/after loads/stores with respect to the sync instruction itself.