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

From: Linus Torvalds
Date: Mon Mar 03 2014 - 17:55:36 EST


On Mon, Mar 3, 2014 at 1:52 PM, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>>
>> Most of the cases have it kept separately in registers, actually - there's
>> a reason why fdget() and friends are inlined.
>
> Yes. And bit test and set ops on registers are actually cheaper than
> playing around with bytes.

Ugh. gcc gets this *horribly* wrong when it's a bitfield in a union.

The

f.need_pos_unlock = 1;

thing *should* be just a simple "orl $2,reg", but bitfields seem to
generate really crappy code, and it actually does some insane shifting
and masking crud with the constant "1".

gcc has had problems with bitfields before.

I think I'll respin this with the compat readv/writev case fixed and
with the bitfield replaced with an "unsigned int" that we just do
bitops by hand on. Because that code generation makes me feel slightly
ill.

Linus
--
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/