Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp988574imm; Fri, 11 May 2018 09:20:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrNIWLApBpjkWgYnds6E/n/9HyWnd8zSoBDPfeIbvZP+MCyTaUNTR1oESopNfWnTs7deJRW X-Received: by 2002:a17:902:7109:: with SMTP id a9-v6mr6167769pll.271.1526055642931; Fri, 11 May 2018 09:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526055642; cv=none; d=google.com; s=arc-20160816; b=Q2WMMsba5fLsAefzOsoUIUUJRQU6MGbBtevt2ZiYwZ6ee0bf/rue77F34CDUEN3I4S okpbtJ/bbZUFe9xwU7dbsUUT/c6GWxKNvPMi0HWO2V+pmaWv3tu8EraIgwMmBe13N3wV +L8ExT72ak4m1BV4J+kBJ2cIUrh9GFqC/RMo9tUsxC0pVB2PuDCeXZ7FD3eAMKJM7hZp 3xppKrvzXZw6ZOjpRuOX0Ic9HNUmifN/caHcPlovjlQVSE/U6DXKdUL7jz75WYI3UWC3 x35KFGTQ3zcKzlTAcjssPDDMNRpZ+Vw/SgTwB6SjQ0wi9gshEsjTFeczPQhvrWt7hggv R23w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=fwPJMDig4d/AqllcUa9fW3fNLwpDr6vDP0I5UFRZK9E=; b=Y1THyThN1C1ES3BR2yROoUxIcmNFup4pWLrn5bMAiKgg8oedj8/h2T4mrrvRX+t3qW OrQ61Nx8vFOKlSMrJqq568Eleptbi+wHkQyy14itTYXN412Fgh2f4TAMK1WXj1BJYvVx QXe2SU2yt6Nyz67xmbvkCPY/YiGPM62IMOMFKXtMav0V6cORx5Uh50Uh0ywLmKuMCwPy vWrKBZXoxCmy9dd8mtxIPaPmiGnFnp3723LnTkg6odY29ZqOld4DsmBu/EKj4kFCLKm8 MMsgXQgw/1O2/KABrEea5wXnI0tIT+6s1jUi+JhOCrm86JouvGbVWJfSI3UUbe0Qi4hj Xadw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8-v6si2861034pgs.312.2018.05.11.09.20.19; Fri, 11 May 2018 09:20:42 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752046AbeEKQTs (ORCPT + 99 others); Fri, 11 May 2018 12:19:48 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57318 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751859AbeEKQTr (ORCPT ); Fri, 11 May 2018 12:19:47 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4BGJgeg090724 for ; Fri, 11 May 2018 12:19:47 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hwbv5gbx7-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 11 May 2018 12:19:43 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 May 2018 12:19:28 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 11 May 2018 12:19:25 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4BGJOjc55771274; Fri, 11 May 2018 16:19:24 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 35342B204E; Fri, 11 May 2018 13:21:23 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.85.188.179]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id EF46DB204D; Fri, 11 May 2018 13:21:22 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id 416EF16C2AF0; Fri, 11 May 2018 09:20:53 -0700 (PDT) Date: Fri, 11 May 2018 09:20:53 -0700 From: "Paul E. McKenney" To: Peter Zijlstra Cc: Xiao Guangrong , rostedt@goodmis.org, Lai Jiangshan , stefani@seibold.net, "linux-kernel@vger.kernel.org" Subject: Re: Is read barrier missed in kfifo? Reply-To: paulmck@linux.vnet.ibm.com References: <5382d3a8-08e0-5429-0cd3-36f9c69197e1@gmail.com> <20180511083242.GJ12217@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180511083242.GJ12217@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18051116-2213-0000-0000-000002A323CC X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009006; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000260; SDB=6.01030799; UDB=6.00526835; IPR=6.00809930; MB=3.00021049; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-11 16:19:26 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051116-2214-0000-0000-00005A14DAE0 Message-Id: <20180511162053.GY26088@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-11_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=9 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805110154 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 11, 2018 at 10:32:42AM +0200, Peter Zijlstra wrote: > On Fri, May 11, 2018 at 03:25:18PM +0800, Xiao Guangrong wrote: > > > > Hi, > > > > Currently, there is no read barrier between reading the index > > (kfifo.in) and fetching the real data from the fifo. > > > > I am afraid that will cause the vfifo is observed as not empty > > however the data is not actually ready for read. Right? > > That code is decidedly dodgy indeed. I can only see smp_wmb() but no > matching barriers at all -- therefore the code is almost certainly as > good as not having any barriers at all. > > I would suggest you try and convert the code to smp_store_release() and > smp_load_acquire() while you're at it. Isn't this one of the places where we rely on control dependencies? Thanx, Paul