Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1125388imm; Sat, 7 Jul 2018 17:41:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpekOmpSjo9tbDkWHUZ5C1J81GvLzUUtkFGz9GgyOJX0Q8yH8Xrvwlei8ESNsZhsSUieFBFt X-Received: by 2002:a17:902:a515:: with SMTP id s21-v6mr15261923plq.192.1531010460195; Sat, 07 Jul 2018 17:41:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531010460; cv=none; d=google.com; s=arc-20160816; b=uQAqC16KVkf/K/jnJ4KOyoCD4DItVb23w6YUXPGhJrIrpy0HmegXTbQcBoAyBYDWSp h4cu3RL6evtgSNrp8kDStgyu/mf22JO5IiCiSjVn0JTpi7uZDgqEppE22W5+yui7yifI QIJoo186bQs7HFzG/c7DsxOoYcb/crHP7stSb/zP019+uQnN3wyoJ6U7ec0pbAyFYKWU Ch/mbSObSkk4znQhEmbX2GdPezvjNfHn76Cxh4NO8Ll9MZot3rTsdlKvqrGv/MHNzOXC Js/gRPdgjHWR3uq1srKAaLMH3OLTgrjHdwpu8AXNk8POLkTy6Id2ZHZvL/iU9Whc2UOK GjoA== 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=47wlV2luYCXWnn1+XsfxWKnHka1kyNhkd8eIwdUQudY=; b=OAK32NAAWOWThieLLKliXyl3+LuLbbsNlPDk1tvwAiRdaUVWv/1yum3XrY8e29pkjl b14wSmZ02Dzedprgxx+N7dkkVnJis/qAxrpp59h7e6cXlEoiQpIye/l2iTrwFc5LCWrx Rnm9oZkA0TkDHXaF87JCCAt31gye6d8zKgeUWbX8E4mnocGGYqPxiOeRhJFp9/v94QIY YxUGEXxjJCbGHoqL1oMiQKrdgzd75OVqmY13Q/Y3F8i/aTSeVHq7zBCRYGnb5+/f1eiq 4bG2n1lEwkSX5wkQIJx+iRCHm5H4Whf55PwUn4rAHYO5YfLaf8EPSn3GNRwEvZk/gffI BtIQ== 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 e5-v6si10308510pgs.449.2018.07.07.17.40.43; Sat, 07 Jul 2018 17:41:00 -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 S1754391AbeGHAkF (ORCPT + 99 others); Sat, 7 Jul 2018 20:40:05 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:45467 "EHLO smtp2200-217.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754249AbeGHAkE (ORCPT ); Sat, 7 Jul 2018 20:40:04 -0400 X-Alimail-AntiSpam: AC=CONTINUE;BC=0.1040389|-1;CH=green;FP=0|0|0|0|0|-1|-1|-1;HT=e01e04486;MF=ren_guo@c-sky.com;NM=1;PH=DS;RN=14;RT=14;SR=0;TI=SMTPD_---.CNeo8kl_1531010368; Received: from localhost(mailfrom:ren_guo@c-sky.com fp:SMTPD_---.CNeo8kl_1531010368) by smtp.aliyun-inc.com(10.147.43.95); Sun, 08 Jul 2018 08:39:29 +0800 Date: Sun, 8 Jul 2018 08:39:28 +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: <20180708003927.GA18424@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> <20180707074209.GA32147@guoren> <20180707195437.GA3225@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180707195437.GA3225@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 09:54:37PM +0200, Andrea Parri wrote: > Hi Guo, > > On Sat, Jul 07, 2018 at 03:42:10PM +0800, Guo Ren wrote: > > On Fri, Jul 06, 2018 at 01:56:14PM +0200, Peter Zijlstra wrote: > > > CPU0 CPU1 > > > > > > r1 = READ_ONCE(x); WRITE_ONCE(y, 1); > > > r2 = xchg(&y, 2); smp_store_release(&x, 1); > > > > > > must not allow: r1==1 && r2==0 > > CPU1 smp_store_release could be finished before WRITE_ONCE, so r1=1 && > > r2=0? > > The emphasis is on the "must": your implementation __must__ prevent this > from happening (say, by inserting memory barriers in smp_store_release()); > if your implementation allows the state (r1==1 && r2==0), then the imple- > mentation is incorrect. Ok, Got it. > I'd suggest you have a look at the Linux-kernel memory consistency model > documentation and the associated tools, starting with: > > Documentation/memory-barriers.txt > tools/memory-model/ Thx for the tips. > (and please do not hesitate to ask questions about them, if something is > unclear). I'll. Thx again. Guo Ren