Re: [PATCH 1/2] Make cramfs little endian only

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linus Torvalds <torvalds@...>
Cc: Andi Drebes <lists-receive@...>, J?rn Engel <joern@...>, <linux-fsdevel@...>, Karel Zak <kzak@...>, Andrew Morton <akpm@...>, Christoph Hellwig <hch@...>, Phillip Lougher <phillip@...>
Date: Tuesday, December 4, 2007 - 6:58 pm

Linus Torvalds wrote:

Bitfields also generate lower-quality assembly than masks&shifts 
(typically more instructions using additional temporaries to accomplish 
the same thing), based on my own informal gcc testing.

You would think gcc would be advanced enough to turn bitfield use into 
masks and shifts under the hood, but for whatever reason that often is 
not the case in kernel code.

Due to the way they're used, bitfields make more difficult the common 
code pattern of setting several flags at once:

	(assuming 'foo', 'bar' and 'baz' are bitfields in a struct)
	pdev->foo = 1;
	pdev->bar = 0;
	pdev->baz = 1;

     versus

	flag_foo = (1 << 0);
	flag_bar = (1 << 1);
	flag_baz = (1 << 2);
	...
	pdev->flags = flag_foo | flag_bar;

</pet peeve>

And getting back on topic, I think "pdev->flags = 
cpu_to_le32(flag1|flag2)" is nicer than dealing with bitfields, when 
your data structures are fixed-endian.

	Jeff


-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/2] Make cramfs little endian only, Andi Drebes, (Tue Dec 4, 7:59 am)
[PATCH 2/2] Update documentation, Andi Drebes, (Tue Dec 4, 8:02 am)
[PATCH 1/2] Make cramfs little endian only, Andi Drebes, (Tue Dec 4, 8:01 am)
Re: [PATCH 1/2] Make cramfs little endian only, Andrew Morton, (Tue Dec 4, 4:11 pm)
Re: [PATCH 1/2] Make cramfs little endian only, Andi Drebes, (Tue Dec 4, 4:58 pm)
Re: [PATCH 1/2] Make cramfs little endian only, Andi Drebes, (Tue Dec 4, 4:37 pm)
Re: [PATCH 1/2] Make cramfs little endian only, Linus Torvalds, (Tue Dec 4, 4:58 pm)
Re: [PATCH 1/2] Make cramfs little endian only, Andi Drebes, (Tue Dec 4, 5:31 pm)
Re: [PATCH 1/2] Make cramfs little endian only, Linus Torvalds, (Tue Dec 4, 6:35 pm)
Re: [PATCH 1/2] Make cramfs little endian only, Jeff Garzik, (Tue Dec 4, 6:58 pm)
Re: [PATCH 1/2] Make cramfs little endian only, Andi Drebes, (Wed Dec 5, 5:57 pm)
Re: [PATCH 1/2] Make cramfs little endian only, Linus Torvalds, (Wed Dec 5, 6:21 pm)
Re: [PATCH 1/2] Make cramfs little endian only, Andi Drebes, (Thu Dec 6, 12:27 pm)
Re: [PATCH 1/2] Make cramfs little endian only, Linus Torvalds, (Thu Dec 6, 1:31 pm)
Re: [PATCH 1/2] Make cramfs little endian only, Andi Drebes, (Thu Dec 6, 6:37 pm)
Re: [PATCH 1/2] Make cramfs little endian only, Linus Torvalds, (Thu Dec 6, 1:35 pm)
Re: [PATCH 1/2] Make cramfs little endian only, Andi Drebes, (Thu Dec 6, 12:38 pm)