Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp498420imm; Fri, 11 May 2018 01:34:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpJ2NuGjUYttzoISzwKRaackx5R8JMZ1PSz3LpawVEcDDg1w1LIVHZt9URWDc3QEQU9s6PB X-Received: by 2002:a65:4c06:: with SMTP id u6-v6mr3631192pgq.388.1526027682627; Fri, 11 May 2018 01:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526027682; cv=none; d=google.com; s=arc-20160816; b=F+B9AAIM5mxAtSAH8xq80nkE2dJEqsgGYWjeo1sc96ugPZlAPFwVA2DN7VjZbxfEp4 XEQt5yxM7/5iUiVJpUConHMFP+IIRtuF/Za3ERRrj8v34MnNoHWDlFSYsFuEajdQzTx+ T7fjTTCKR0UiKvx8m4nWZSIWU9Y71oEthyLCX9GeuCULF8JL8TNTWUpi9tznXGJM1JWF yLM792jeP2k7BAPsaf5okR2INpWC3yUR5kZ7Vdq8C+SV13xhYOweZ3UZG8qZFq+FIBQc Ppd1kZ0+1tSxONSghvfBbUDK/AS7T9ZGSuC5P6Nx0fyvRAg39F8Dp5oPjEK1oULGtkcy vh5A== 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:dkim-signature:arc-authentication-results; bh=tlZpi+hGzawoPVKAU+UqIVNdsuOfr5wt3S8Pa/2ayrY=; b=CC8hwH6YTu25i2jUWmNlfhFryqM1kN6lnSHEA5Qy1H1y/22yjF+ZcfVxHeilOnJt1o 7G6EcnyzkUJRUBVJZ0hj/nc7uvxd1TOPSsqP0H7y+BaWMot7LBLcXZaEcE3oG/DFKxCQ 8gMHH59JBF5rPly5gQjEzhsFwjSjeqSy9oJ/rgU3mQVtiDFKMfInkjKDAtJnt8Vgh6Pu wnb8xuMyk4QuBl8UM4U7Onrq8B7T8UId6qvnIqXK8aXdoxA9ClO3sWRgDJ6G97oNi3GN CkBwh77i1wuVuzWn4voYTlHOY28u+Vg5ZaqiWmfxfJqzO6/jw5Ipdk1bNnXe3esIFhCP eKsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=QidwoE9v; 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 n3-v6si2358275pgr.342.2018.05.11.01.34.27; Fri, 11 May 2018 01:34: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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=QidwoE9v; 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 S1752827AbeEKIcx (ORCPT + 99 others); Fri, 11 May 2018 04:32:53 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41064 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752389AbeEKIcw (ORCPT ); Fri, 11 May 2018 04:32:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=tlZpi+hGzawoPVKAU+UqIVNdsuOfr5wt3S8Pa/2ayrY=; b=QidwoE9vkeYOCONU9qdL7yOLs RJRnH73KIS0h0AXO7MCZZaVFs926AtvK2JPvbt+Vkop+0pU9OKe5hPsG/3At4eL5aP+W/EvdnqqPe XXziDKen+DBZ3V2xUjFoSnRq4/FPMAbckxOBIo8YGwqwHLVpPBZDXxbXipILv1ZlvHpJpAcuShlBX ZKXuQFK2al2xEYVzw+0T32XxO0X35W3TjJJJuhd5415tzdBxf9tgfNckExi3Etj6CYJOgUq/cVRf6 ps7jyZ1P34f1UChM3v3+czj0wr6PsgKps2MPIAegMjfCOaeKGF13uCJDf7kGDJq6TtJck4T3pE67R kKurkJauQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fH3To-0005JN-CY; Fri, 11 May 2018 08:32:44 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 9DF402029FA13; Fri, 11 May 2018 10:32:42 +0200 (CEST) Date: Fri, 11 May 2018 10:32:42 +0200 From: Peter Zijlstra To: Xiao Guangrong Cc: paulmck@linux.vnet.ibm.com, rostedt@goodmis.org, Lai Jiangshan , stefani@seibold.net, "linux-kernel@vger.kernel.org" Subject: Re: Is read barrier missed in kfifo? Message-ID: <20180511083242.GJ12217@hirez.programming.kicks-ass.net> References: <5382d3a8-08e0-5429-0cd3-36f9c69197e1@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5382d3a8-08e0-5429-0cd3-36f9c69197e1@gmail.com> User-Agent: Mutt/1.9.5 (2018-04-13) 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 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.