Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1139425imm; Sat, 7 Jul 2018 18:06:38 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdPyb1wb78mjJNxpcuQlZ2BShzvQkmdDawToVSy2VARvTLKlvLjJqAHVowzg8HgRUgjlX4w X-Received: by 2002:a65:5cc5:: with SMTP id b5-v6mr13915610pgt.425.1531011998759; Sat, 07 Jul 2018 18:06:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531011998; cv=none; d=google.com; s=arc-20160816; b=C4SzQXI5JwbYrqZRAoMVgI0qhpTNrNjCv94S2X7IGhAty1KN3jRJkd5gD0t3bm3EEB wVm5jwDsS764YMYz2ZPheR1TxdcAP66yMk1HI6hRsPpc11PmH4quVHs5I4a8l/9rk7Jh ZwKkNBNpUheJz8g83BR0Sld6X3itc7j/K9Qxef1P32XsgmxRB9XqeqonyYfw/DNwHJfJ xpA5VXWMikmb50cyH/HVw9s4AkvpkfiNxKQKQtTngfdYYFcHG15C+7llz/Xq1VRkL/1I XjH0Gz6SMEcdd09dGC+/6VLkTJSQ8qsu2x3TI3PBibF+iSDvHZORYdukD/eRm7BvoaAm MYqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=JaLOZrhDC7pOVo8leTCFp5Gyj1GpMkgu/clx2R05lUQ=; b=nPwFxHacMtcjPrySsyb3gW9MDvI/E3wy1idaa9CImZtCCPYWDmGQBQND0j4pXiVzDr usmiQ4V6bbY+qCrxDEPsmsBXfV+pDE3tunfvuBdMAf+WahExNZ4qSC+WMmOAsH0nDqEm x8u5gt6IdD3tw8Ya76+5zsC7Rolm4C3mw+smSd98cygkdhrTtEz/hd9kR6Uss+KLFtcV 8RCivvD0k94lJyAZsC930VHjE6YuNF7/SLA9iPQd36rNdQ2yZpRbK9W5360ytrMlVP93 mzNTgsVC1lMVFna9WeWcOJPiWHavTbPjI7NR7r3kwzEn2fKdADyB/zq410hrJ07e1JQB BtJQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a10-v6si11423227pli.122.2018.07.07.18.06.24; Sat, 07 Jul 2018 18:06:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754425AbeGHBFs (ORCPT + 99 others); Sat, 7 Jul 2018 21:05:48 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:44454 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754249AbeGHBFq (ORCPT ); Sat, 7 Jul 2018 21:05:46 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.1072006|-1;CH=green;FP=0|0|0|0|0|-1|-1|-1;HT=e02c03296;MF=ren_guo@c-sky.com;NM=1;PH=DS;RN=14;RT=14;SR=0;TI=SMTPD_---.CNfJfBg_1531011911; Received: from localhost(mailfrom:ren_guo@c-sky.com fp:SMTPD_---.CNfJfBg_1531011911) by smtp.aliyun-inc.com(10.147.40.233); Sun, 08 Jul 2018 09:05:11 +0800 Date: Sun, 8 Jul 2018 09:05:11 +0800 From: Guo Ren To: Andrea Parri Cc: Peter Zijlstra , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, daniel.lezcano@linaro.org, jason@lakedaemon.net, arnd@arndb.de, c-sky_gcc_upstream@c-sky.com, gnu-csky@mentor.com, thomas.petazzoni@bootlin.com, wbx@uclibc-ng.org, green.hu@gmail.com, Will Deacon Subject: Re: [PATCH V2 11/19] csky: Atomic operations Message-ID: <20180708010511.GB18424@guoren-Inspiron-7460> References: <860b8db036b33d7b3648cb1f4ec827a53dc1a01b.1530465326.git.ren_guo@c-sky.com> <20180705175059.GE2530@hirez.programming.kicks-ass.net> <20180706110129.GC8707@guoren> <20180706115614.GV2476@hirez.programming.kicks-ass.net> <20180706121716.GO2512@hirez.programming.kicks-ass.net> <20180707080845.GA346@guoren> <20180707201024.GB3225@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180707201024.GB3225@andrea> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 07, 2018 at 10:10:24PM +0200, Andrea Parri wrote: > On Sat, Jul 07, 2018 at 04:08:47PM +0800, Guo Ren wrote: > > On Fri, Jul 06, 2018 at 02:17:16PM +0200, Peter Zijlstra wrote: > > > CPU0 CPU1 > > > > WRITE_ONCE(x, 1) WRITE_ONCE(y, 1) > > r0 = xchg(&y, 2) r1 = xchg(&x, 2) > > > > must not allow: r0==0 && r1==0 > > So we must add a smp_mb between WRITE_ONCE() and xchg(), right? > > The state (r0==0 && r1==0) _must_ not be allowed in the above snippet (so, > even without the additional smp_mb() between WRITE_ONCE() and xchg()). In > informal terms, xchg() provides the smp_mb(). Got it, thx. > Compare implementations of xchg() and xchg_relaxed(). The following could > also be helpful (in addition to the references pointed out earlier): > > Documentation/atomic_t.txt Thx for the tip. Guo Ren