From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932197AbcICOtn (ORCPT ); Sat, 3 Sep 2016 10:49:43 -0400 Received: from netrider.rowland.org ([192.131.102.5]:60275 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S932162AbcICOtl (ORCPT ); Sat, 3 Sep 2016 10:49:41 -0400 Date: Sat, 3 Sep 2016 10:49:39 -0400 (EDT) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: Peter Zijlstra cc: "Paul E. McKenney" , Ingo Molnar , Felipe Balbi , USB list , Kernel development list Subject: Re: Memory barrier needed with wake_up_process()? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 3 Sep 2016, Alan Stern wrote: > In other words, we have: > > CPU 0 CPU 1 > ----- ----- > Start DMA Handle DMA-complete irq > Sleep until bh->state Set bh->state > smp_wmb() > Wake up CPU 0 > smp_rmb() > Compute rc based on contents > of the DMA buffer > > This was written many years ago, at a time when I did not fully > understand all the details of memory ordering. Do you agree that both > of those barriers should really be smp_mb()? That's what Felipe has > been testing. Actually, seeing it written out like this, one realizes that it really ought to be: CPU 0 CPU 1 ----- ----- Start DMA Handle DMA-complete irq Sleep until bh->state smp_mb() set bh->state Wake up CPU 0 smp_mb() Compute rc based on contents of the DMA buffer (Bear in mind also that on some platforms, the I/O operation is carried out by PIO rather than DMA.) Also, the smp_wmb() in bulk_out_complete() looks unnecessary. I can't remember why I put it there originally. Alan Stern