From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mathieu Desnoyers Subject: Re: [RFC patch 08/18] cnt32_to_63 should use smp_rmb() Date: Fri, 7 Nov 2008 14:18:34 -0500 Message-ID: <20081107191833.GA31809@Krystal> References: <20081107053349.861709786@polymtl.ca> <20081107052336.652868737@polymtl.ca> <25257.1226055312@redhat.com> <20081107170902.GD22134@Krystal> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from tomts40.bellnexxia.net ([209.226.175.97]:42309 "EHLO tomts40-srv.bellnexxia.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750974AbYKGTSg (ORCPT ); Fri, 7 Nov 2008 14:18:36 -0500 Content-Disposition: inline In-Reply-To: Sender: linux-arch-owner@vger.kernel.org List-ID: To: Steven Rostedt Cc: David Howells , "Paul E. McKenney" , Linus Torvalds , akpm@linux-foundation.org, Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, Nicolas Pitre , Ralf Baechle , benh@kernel.crashing.org, paulus@samba.org, David Miller , Ingo Molnar , Thomas Gleixner , linux-arch@vger.kernel.org * Steven Rostedt (rostedt@goodmis.org) wrote: > > On Fri, 7 Nov 2008, Mathieu Desnoyers wrote: > > > > __m_cnt_hi > > is read before > > mmio cnt_lo read > > > > for the detailed reasons explained in my previous discussion with > > Nicolas here : > > http://lkml.org/lkml/2008/10/21/1 > > > > I use smp_rmb() to do this on SMP systems (hrm, actually, a rmb() could > > be required so it works also on UP systems safely wrt interrupts). > > smp_rmb turns into a compiler barrier on UP and should prevent the below > description. > Ah, right, preserving program order on UP should be enough. smp_rmb() then. Thanks, Mathieu > -- Steve > > > > > The write side is between the hardware counter, which is assumed to > > increment monotonically between each read, and the value __m_cnt_hi > > updated by the CPU. I don't see where we could put a wmb() there. > > > > Without barrier, the smp race looks as follow : > > > > > > CPU A B > > read hw cnt low (0xFFFFFFFA) > > read __m_cnt_hi (0x80000000) > > read hw cnt low (0x00000001) > > (wrap detected : > > (s32)(0x80000000 ^ 0x1) < 0) > > write __m_cnt_hi = 0x00000001 > > read __m_cnt_hi (0x00000001) > > return 0x0000000100000001 > > (wrap detected : > > (s32)(0x00000001 ^ 0xFFFFFFFA) < 0) > > write __m_cnt_hi = 0x80000001 > > return 0x80000001FFFFFFFA > > (time jumps) > > > > And UP interrupt race : > > > > Thread context Interrupts > > read hw cnt low (0xFFFFFFFA) > > read __m_cnt_hi (0x80000000) > > read hw cnt low (0x00000001) > > (wrap detected : > > (s32)(0x80000000 ^ 0x1) < 0) > > write __m_cnt_hi = 0x00000001 > > read __m_cnt_hi (0x00000001) > > return 0x0000000100000001 > > (wrap detected : > > (s32)(0x00000001 ^ 0xFFFFFFFA) < 0) > > write __m_cnt_hi = 0x80000001 > > return 0x80000001FFFFFFFA > > (time jumps) > > -- Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68