From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Piggin Subject: Re: [RESEND] [PATCH] VFS: make file->f_pos access atomic on 32bit arch Date: Wed, 8 Oct 2008 03:27:44 +1100 Message-ID: <200810080327.44530.nickpiggin@yahoo.com.au> References: <6.0.0.20.2.20081007140438.0580f110@172.19.0.2> <6.0.0.20.2.20081007183452.0f052210@172.19.0.2> <20081007102942.GE20740@one.firstfloor.org> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Cc: Hisashi Hifumi , akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Andi Kleen Return-path: Received: from smtp114.mail.mud.yahoo.com ([209.191.84.67]:23615 "HELO smtp114.mail.mud.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752882AbYJGQ14 (ORCPT ); Tue, 7 Oct 2008 12:27:56 -0400 In-Reply-To: <20081007102942.GE20740@one.firstfloor.org> Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Tuesday 07 October 2008 21:29, Andi Kleen wrote: > > Maybe cmpxchg8b is good for i486 or later x86, but i386 or other > > architectures that do not have similar instruction needs some locking > > primitive. I think lazy > > We have a cmpxchg emulation on 386. That works because only UP 386s are > supported, so it can be done in software. > > > seqlock is one option for making file->f_pos access atomic. > > The question is if it's the right option. At least all the common > operations on fds (read/write) are all writers, not readers. Common operations are read, do something, write. So seqlocks then cost one atomic operation, a couple of memory barriers (all noops on x86), and some predictable branches etc. cmpxchg based would require 2 lock ; cmpxchg8b on 32-bit. Fairly heavy. Also I don't think we have generic accessors to do this, so I think that is for another project. Anyway, I think importantly this creates some usable accessors for the f_pos problem. I think we actually need to touch a _lot_ of code to cover all f_pos accesses in the kernel, but I guess this gets the ball rolling. So.. is everyone agreed that corrupting f_pos is a bad thing? (serious question) If so, then we should get something like this merged sooner rather than later.