Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3218728imu; Sat, 24 Nov 2018 00:22:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/X65oiF19iacuY8WR3hnXa37KQMb3pk68bTrnlXcPwJcenPZsX3ykPl8nJg9uC8sh8iiYYM X-Received: by 2002:a63:8149:: with SMTP id t70mr11712264pgd.172.1543047741697; Sat, 24 Nov 2018 00:22:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543047741; cv=none; d=google.com; s=arc-20160816; b=k2WWPf6UOXMNXj6WsZddbxT2PT+lVe/QwY3I4SbG9XHzxper0GsCrqnMiBiQrS1UWI 0UvjQcWB/4Zq/zCvuJm4FTGzx4hlewifB2wP94dE3K3EoNuzZWCCqILXlDD81UCIKd0t iRl7NkKMdUvUUDXtK3RS9mOMkGq4TFlm1iD4ysuBNv9jnthvCdLZ2L+rd2cha9KULLKU UvHmbWtzZbi+KHy3bJFlatrhLJ55NEEJ1gQyuJz7kMfzHPHmjA/1XsMNAnxXxRbB78TM yc63m1gdZG+3wlb6qr9UpoEcdF2OrqadRsfcj3cuULUN0U4m70ZMSclSD+YVMqEloECf 5wkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=fEq4RqT70jnmTa3IKYe4/U/zaOtqREGi3bax/UtEVq4=; b=q9R1Eg5qnCRcw5hKIaFy5BftfQleTSW7H4Al6jYOfRLRkLorxlDY1/q4fXLHsSxKk/ k7tIEU5jgW34BCDLxeZ8FhYp/uiQkt87Y/eTqS4XEXkMAFF3Wkc8S6EibkVK/A+jGVe/ DSnJIhI5CKiteELUF/+fdg13/cSCUtJ2p29zvepu9iK/GZ9S7/jKpzeFTBqjd/rblq8J ArqsCrEKjoIQf24LyVeR1ViJdQmBv1mgicFBGbdJDpCE5BStk2eX1J2QIxdZBDf3XCg/ nSqMLai6IpSRon+ZOHIJzxDJcsgWNSLzAQBPSfvQGGft2To2RS5DzjI90wxDU5FqOVpp OueA== 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 a1si56442282pgk.495.2018.11.24.00.22.07; Sat, 24 Nov 2018 00:22:21 -0800 (PST) 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 S2503110AbeKWUoK (ORCPT + 99 others); Fri, 23 Nov 2018 15:44:10 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:49322 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387971AbeKWUoK (ORCPT ); Fri, 23 Nov 2018 15:44:10 -0500 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id DE75DEEA67961; Fri, 23 Nov 2018 18:00:32 +0800 (CST) Received: from [10.151.23.176] (10.151.23.176) by smtp.huawei.com (10.3.19.212) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 23 Nov 2018 18:00:26 +0800 Subject: Re: [PATCH 05/10] staging: erofs: add a full barrier in erofs_workgroup_unfreeze To: Andrea Parri CC: Greg Kroah-Hartman , , , Chao Yu , LKML , , Miao Xie References: <20181120143425.43637-1-gaoxiang25@huawei.com> <20181120143425.43637-6-gaoxiang25@huawei.com> <20181122102230.GF3189@kroah.com> <1d1fd688-0cb5-cbac-9213-f56f7e356bca@huawei.com> <20181122185058.GA3466@andrea> <20181123094739.GA3487@andrea> From: Gao Xiang Message-ID: <5bf95ae0-cecb-c220-653b-704baee1cd8e@huawei.com> Date: Fri, 23 Nov 2018 18:00:25 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20181123094739.GA3487@andrea> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.151.23.176] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrea, On 2018/11/23 17:51, Andrea Parri wrote: > Correct. This is informally documented in Documentation/atomic_t.txt > and formalized within tools/memory-model/. > > >> I don't know whether my understanding is correct, If I am wrong..please correct me, or >> I need to add more detailed code comments to explain in the code? > Yes, please; please review the above points (including 1. and 3.) and > try to address them with inline comments. Maybe (if that matches the > *behavior*/guarantee you have in mind...) something like: > > [in erofs_workgroup_unfreeze()] > > /* > * Orders the store/load to/from [???] and the store to > * ->refcount performed by the atomic_set() below. > * > * Matches the atomic_cmpxchg() in erofs_workgroup_get(). > * > * Guarantees that if a successful atomic_cmpxchg() reads > * the value stored by the atomic_set() then [???]. > */ > smp_mb(); > atomic_set(&grp->refcount, v); > > > [in erofs_workgroup_get()] > > /* > * Orders the load from ->refcount performed by the > * atomic_cmpxchg() below and the store/load [???]. > * > * See the comment for the smp_mb() in > * erofs_workgroup_unfreeze(). > */ > if (unlikely(atomic_cmpxchg(&grp->refcount, o, o + 1) != o)) > goto repeat; > OK, I will add these comments in the next version patchset, will be sent later. Thanks for your suggestion. :) Thanks, Gao Xiang > Thanks, > Andrea > >