Re: Update of file offset on write() etc. is non-atomic with I/O

From: Al Viro
Date: Mon Mar 03 2014 - 18:29:11 EST


On Mon, Mar 03, 2014 at 02:17:55PM -0800, Linus Torvalds wrote:

> Something like the attached untested patch. This gets rid of
> "fget_light()", and instead makes "fdget()" the native interface (same
> for the "raw" version).

Umm... I would be very surprised if that worked well. You have just
forced fdget() to comply to the ABI. And unless that has such structs
returned in register pairs, there's no way for compiler to do about
that.

The current variant lets the optimizer see what's going on and decide
that since it doesn't need struct fd local variable kept as a single
object, so it can turn it into a pair of locals, independently assigned
(in the inlined fdget() body) and independently used. If those can
be put into registers, it happens separately for both, etc.

Try your variant on e.g. ppc or alpha. Both will pass that struct on
stack. So will mips. So will s390. So will 32bit sparc, not that there
had been much use of sparc32 kernels...

It will work on amd64, sparc64. On i386 we explicitly pass it
-freg-struct-return, so it passes in a pair of registers there as well.

We could start usinmg -freg-struct-return on other architectures, but
I'm not sure if it would actually work - e.g. on ppc it still returns
such a struct on stack.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/