X-Spam-Checker-Version: SpamAssassin 3.4.0-r929098 (2010-03-30) on oss.sgi.com X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.4.0-r929098 Received: from cuda.sgi.com (cuda3.sgi.com [192.48.176.15]) by oss.sgi.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id q5KMaCF2179193 for ; Wed, 20 Jun 2012 17:36:12 -0500 X-ASG-Debug-ID: 1340231770-04cb6c3b918fc7b0001-NocioJ Received: from ipmail04.adl6.internode.on.net (ipmail04.adl6.internode.on.net [150.101.137.141]) by cuda.sgi.com with ESMTP id EkiGPTC6l8YkfxIg for ; Wed, 20 Jun 2012 15:36:10 -0700 (PDT) X-Barracuda-Envelope-From: david@fromorbit.com X-Barracuda-Apparent-Source-IP: 150.101.137.141 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgwKAO9P4k95LOQs/2dsb2JhbABFtCIDgS+BCIIYAQEFJxMcIxAIAw4KLhQlAyETiAq6JxSLGoERhQoDlSmQAoJx Received: from ppp121-44-228-44.lns20.syd7.internode.on.net (HELO dastard) ([121.44.228.44]) by ipmail04.adl6.internode.on.net with ESMTP; 21 Jun 2012 08:05:50 +0930 Received: from dave by dastard with local (Exim 4.76) (envelope-from ) id 1ShTV6-00022X-FE; Thu, 21 Jun 2012 08:35:48 +1000 Date: Thu, 21 Jun 2012 08:35:48 +1000 From: Dave Chinner To: Brian Foster Cc: Christoph Hellwig , xfs@oss.sgi.com Subject: Re: [PATCH v2] xfs: re-enable xfsaild idle mode and fix associated races Message-ID: <20120620223548.GK30705@dastard> X-ASG-Orig-Subj: Re: [PATCH v2] xfs: re-enable xfsaild idle mode and fix associated races References: <1339087793-45731-1-git-send-email-bfoster@redhat.com> <20120620080523.GA26167@infradead.org> <4FE1F37E.6090706@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4FE1F37E.6090706@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Barracuda-Connect: ipmail04.adl6.internode.on.net[150.101.137.141] X-Barracuda-Start-Time: 1340231770 X-Barracuda-URL: http://192.48.176.15:80/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1.3 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.100438 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- On Wed, Jun 20, 2012 at 11:59:58AM -0400, Brian Foster wrote: > On 06/20/2012 04:05 AM, Christoph Hellwig wrote: > > On Thu, Jun 07, 2012 at 12:49:53PM -0400, Brian Foster wrote: > [snip] > >> spin_lock(&ailp->xa_lock); > >> + > >> + /* barrier matches the xa_target update in xfs_ail_push() */ > >> + smp_rmb(); > >> + target = ailp->xa_target; > >> + ailp->xa_target_prev = target; > >> + > >> lip = xfs_trans_ail_cursor_first(ailp, &cur, ailp->xa_last_pushed_lsn); > >> if (!lip) { > >> /* > >> + > >> + spin_lock(&ailp->xa_lock); > >> + > >> + /* > >> + * Idle if the AIL is empty and we are not racing with a target > >> + * update. The barrier matches the xa_target update in > >> + * xfs_ail_push(). > >> + */ > >> + smp_rmb(); > > > > Given that both sides are under xa_lock I can't see any need for > > barriers here. > > > > Actually now that I look at it, it appears xfs_trans_ail_copy_lsn() does > not necessarily acquire the xa_lock... Right, it does not acquire the lock on 64 bit systems as reads and writes are single instructions on 64 bit systems. The lock is required for 32 bit systems because the write requires separate 32 bit writes to the LSN which can result in unlocked accesses seeing partially updated (and hence incorrect) LSN values. So the memory barriers are definitely needed for 64 bit machines because there is no locking on the update and spinlocks only provide memory barriers via unlock->lock transitions, not via a single spin_lock() call. Cheers, Dave. -- Dave Chinner david@fromorbit.com