From owner-svn-src-all@freebsd.org Mon Jan 30 15:37:05 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E06AACC8085; Mon, 30 Jan 2017 15:37:05 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: from mail-qk0-x243.google.com (mail-qk0-x243.google.com [IPv6:2607:f8b0:400d:c09::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B0DB51658; Mon, 30 Jan 2017 15:37:05 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: by mail-qk0-x243.google.com with SMTP id e1so19397553qkh.1; Mon, 30 Jan 2017 07:37:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=U8+O3G3MyVI8KLIYE6Qxmz6WbiSdZwbgFrbB2Fim1iY=; b=kmHWcV61rNtIi7kCZ6S/uKXn6CPqzWgf8p08+6SnltDVFdwPnLBZjWd7ti08O2Ylo5 iuxRXALzvhdGHrErHCb0eBifGz8hFt90xnAkrIYFLoXa+qT4t5h5IU6nEypBiNoEHFCy pMVUsM0dQQwvNhasIVj3Y1VbsAeIP1B5mLpb9EhPn6x39/HZICzIEOeJH41pqi88+rSg EmwftfRbnG5kURZ6+yLBiRyCIKT9uqj3itktWfD5K2p43QIdEhoqhUOCdn8FTR4EK+Gq VdBXoNUmBBN8uzgM/DSW+8Wg7Y/v+VuA1U8VfJw3cbq1kOii5rl8d2vYwpOD8Rircma0 NmUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=U8+O3G3MyVI8KLIYE6Qxmz6WbiSdZwbgFrbB2Fim1iY=; b=XQ2YlbEHoxCUHm4FoXi5DS/Rv/oPnSoYrE523WXgGLO5ay9mxbGn0RJ7lGOSzCvzE2 7LbmBsx+VyikdUDEr5+JlG1t37GMDZ5EwgiApBl4F0dd6iGBR/d4BjPJYqSECLRevbj4 L1BvbRk8ATCBlJXlYeT9Oy1Olug8nJZze5vJzkWiP9H0VCU+DmdDs4pk1axjU1Atex2c WRuQ0cHqwd+h9avw63B5Sm1y/Z+GRthAohL/ngoreizl8f5vq6nrG0twd3pG9wh9Irmg vdrOMLRtqhbchF2DHYC2f064uiGBdDKXiYs4KaRdtJFGQ3a9e8co+bi8s5qiQLa9cFxV 0uhg== X-Gm-Message-State: AIkVDXL09tfnE0Bc604h0IT+ZujAnceywgeG5bkeTr65rXv0Qq27ZLegYF3EDYgf7+mYtUROJtBHsczFpGRHAQ== X-Received: by 10.55.5.66 with SMTP id 63mr23796315qkf.163.1485790624832; Mon, 30 Jan 2017 07:37:04 -0800 (PST) MIME-Version: 1.0 Sender: chmeeedalf@gmail.com Received: by 10.12.157.69 with HTTP; Mon, 30 Jan 2017 07:37:04 -0800 (PST) In-Reply-To: References: <201701300215.v0U2Fsl0006455@repo.freebsd.org> <20170130105345.GL3018@kib.kiev.ua> From: Justin Hibbits Date: Mon, 30 Jan 2017 09:37:04 -0600 X-Google-Sender-Auth: 0GOHapSvjeQpu4XIe49L53f7NrQ Message-ID: Subject: Re: svn commit: r312973 - head/sys/powerpc/include To: Konstantin Belousov Cc: src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 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: Mon, 30 Jan 2017 15:37:06 -0000 On Mon, Jan 30, 2017 at 9:32 AM, Justin Hibbits wrote: > On Mon, Jan 30, 2017 at 4:53 AM, Konstantin Belousov > wrote: >>> +#ifdef __GNUCLIKE_ASM >>> + __asm __volatile ( >>> + "1:\tlwarx %0, 0, %3\n\t" /* load old value */ >>> + "cmplw %4, %0\n\t" /* compare */ >>> + "bne 2f\n\t" /* exit if not equal */ >>> + "stwcx. %5, 0, %3\n\t" /* attempt to store */ >>> + "bne- 1b\n\t" /* spin if failed */ >>> + "li %0, 1\n\t" /* success - retval = 1 */ >>> + "b 3f\n\t" /* we've succeeded */ >>> + "2:\n\t" >>> + "stwcx. %0, 0, %3\n\t" /* clear reservation (74xx) */ >>> + "stwx %0, 0, %7\n\t" >>> + "li %0, 0\n\t" /* failure - retval = 0 */ >>> + "3:\n\t" >>> + : "=&r" (ret), "=m" (*p), "=m" (*cmpval) >>> + : "r" (p), "r" (*cmpval), "r" (newval), "m" (*p), "r"(cmpval) >>> + : "cr0", "memory"); >>> +#endif >> >> It seems that in case of failed conditional store, the code retries. >> Note that this is not incorrect but also not a desirable behaviour >> with fcmpset: the function should return error and leave the retry >> to the caller. There is no point in having embedded loop. (stupid gmail web UI being so slow it registered me clicking Send when I clicked the ...) Thanks, Kib. I discussed this with mjg on IRC, and it was kind of a toss-up how to implement it, so I took the easiest route. I'll update it tonight and remove the loop. There is an instruction on newer ISAs that would reduce this inline asm even further, 'mfocrf', but it doesn't exist on all supported PowerPC architectures, so it will be just a minor tweak. - Justin