From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756641AbeARPHV (ORCPT ); Thu, 18 Jan 2018 10:07:21 -0500 Received: from merlin.infradead.org ([205.233.59.134]:47050 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756573AbeARPHM (ORCPT ); Thu, 18 Jan 2018 10:07:12 -0500 Date: Thu, 18 Jan 2018 16:06:58 +0100 From: Peter Zijlstra To: Jia-Ju Bai Cc: nic_swsd@realtek.com, romieu@fr.zoreil.com, alexander.h.duyck@redhat.com, David Miller , dhowells@redhat.com, paulmck@linux.vnet.ibm.com, will.deacon@arm.com, netdev@vger.kernel.org, Linux Kernel Mailing List Subject: Re: net: r8169: a question of memory barrier in the r8169 driver Message-ID: <20180118150658.GE2249@hirez.programming.kicks-ass.net> References: <9a373156-41e5-a78b-cd31-c4b9bdba2696@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9a373156-41e5-a78b-cd31-c4b9bdba2696@gmail.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 18, 2018 at 10:06:17PM +0800, Jia-Ju Bai wrote: > In the rt8169 driver, the function "rtl_tx" uses "smp_mb" to sync the > writing operation with rtl8169_start_xmit: > if (tp->dirty_tx != dirty_tx) { > tp->dirty_tx = dirty_tx; > smp_mb(); > ... > } > The function rtl8169_start_xmit reads tp->dirty_tx in TX_FRAGS_READY_FOR: > if (unlikely(!TX_FRAGS_READY_FOR(tp, skb_shinfo(skb)->nr_frags))) { > netif_err(tp, drv, dev, "BUG! Tx Ring full when queue awake!\n"); > goto err_stop_0; > } > But there is no memory barrier around this code. > > Is there a possible data race here? > If not, how this data race is avoided? There is only 1 variable afaict. Memory barriers need at least 2 in order to be able to do _anything_.