Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4351208imm; Mon, 14 May 2018 06:24:46 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrG0YUGf3G3dOqBnQEwH3LP1/6VmCLSZoEtBZhC24yc4RSuaSn+MMUtIyheJ7nYDZ7w91dQ X-Received: by 2002:a65:42cd:: with SMTP id l13-v6mr8384566pgp.74.1526304286257; Mon, 14 May 2018 06:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526304286; cv=none; d=google.com; s=arc-20160816; b=SMg+vsNgjROvvfIDbQJRNt41CvTZY8JHFC4OMGPj4csSJLdFGdNB7/6gegfmTToDqn Qx7lGpem1sEvNZ83EqDEy926hoVCuMDt/jpMrsmQgDcSXXV7n241O+1HDEfuwnnHHaq/ ZL0WZkagwGuQjoRA+Q4XAiLexySwgPw5yMkQMl8zupfJftAKLYPDzRp5Hr4Hp23gC3BS 0sWDmjNIzt58FcOHZjJ/ZCdomg6q16kKvnzVKFZmw+DfwdYTI0WiAtXnIbTl/11yxnT/ IE9LbusiTEJCYrGIzYZVBON6033atNvFLbURTZSdM4STOfV7KS+U9UEpll3ZQuZQjoUr OEsQ== 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=CWoaj6P2XfVT4xq79vLUSqAurwb8aTeE3kv/bsCifGw=; b=BILPzMsLIg4wN4fmMyyzGioC0ZjkQzVcT/8jkH9O9Ca0x8YgAvjUuXsW0d/0YcqLv9 D3RhfTtveeDiRN3EiUcXWpSPzL8cTLDqEtggMp1kGbr4rXutCRKXUt+vuRofoF1Psidu gekO+44FOxAmtPzWMzg5Sv0M4chwHQKeBA+m04mqVGX1HT9WDxmtSSlzGypbKSw3lWpq hIZosJsRtoOcxzoI9XaBRv0pebRtKEZZ/UXiiQb6NfTuLPQjWeA1SYx3SDS9CeMNHVgw OnUk7QRyDJVtuBUQy0utVUyvuJweMZ4XRA7khvsPAByLeiT4yVuxI6Y+bxvpFq1pRi/O GJzA== 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 e9-v6si7442101pgr.477.2018.05.14.06.24.31; Mon, 14 May 2018 06:24:46 -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 S1753716AbeENNYR (ORCPT + 99 others); Mon, 14 May 2018 09:24:17 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:42254 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752296AbeENNYQ (ORCPT ); Mon, 14 May 2018 09:24:16 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4EDJGQn065836 for ; Mon, 14 May 2018 09:24:16 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hyannt36t-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 14 May 2018 09:24:15 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 14 May 2018 09:24:14 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 14 May 2018 09:24:10 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4EDOAC853149938; Mon, 14 May 2018 13:24:10 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 65BC6B2050; Mon, 14 May 2018 10:26:08 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.85.188.179]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 31879B2046; Mon, 14 May 2018 10:26:08 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id EFF9E16C247B; Mon, 14 May 2018 06:25:41 -0700 (PDT) Date: Mon, 14 May 2018 06:25:41 -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> <20180511162053.GY26088@linux.vnet.ibm.com> <20180514065755.GM12217@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180514065755.GM12217@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18051413-0052-0000-0000-000002EE3FB7 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009024; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000260; SDB=6.01032180; UDB=6.00527662; IPR=6.00811312; MB=3.00021105; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-14 13:24:12 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051413-0053-0000-0000-00005CADF361 Message-Id: <20180514132541.GS26088@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-14_03:,, 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-1805140137 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 14, 2018 at 08:57:55AM +0200, Peter Zijlstra wrote: > On Fri, May 11, 2018 at 09:20:53AM -0700, Paul E. McKenney wrote: > > 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? > > Then it bloody well should have a comment. But at least one side of the > fifo needs a read barrier I think. We can rely on a ctrl-dep on the > write side, where we read the head/tail values, compute space and then > conditionally allow writes to happen. > > But on the read side it's all reads and ctrl-dep doesn't help anything. Agreed, for a control depdendency to help, there does need to be a control dependency. ;-) Thanx, Paul