lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <46892356.9010209@garzik.org>
Date:	Mon, 02 Jul 2007 12:09:58 -0400
From:	Jeff Garzik <jeff@...zik.org>
To:	Andrew Morton <akpm@...ux-foundation.org>
CC:	"Kok, Auke" <auke-jan.h.kok@...el.com>,
	Arjan van de Ven <arjan@...ux.intel.com>,
	Ayyappan Veeraiyan <ayyappan.veeraiyan@...el.com>,
	netdev@...r.kernel.org
Subject: Re: [PATCH] ixgbe: Introduce new 10GbE driver for Intel 82598 based
 PCI Express adapters...

Andrew Morton wrote:
> On Mon, 02 Jul 2007 11:32:41 -0400 Jeff Garzik <jeff@...zik.org> wrote:
> 
>> Bitfields are to be avoided for many reasons:
>> * more difficult, in general, for a compiler to generate optimal code
>> * in particular, known to generate worse code on various architectures
>> * often causes endian problems
>> * often enhances programmer confusion, when trying to review structs and 
>> determine optimal layout and alignment
>> * programmers have proven they will screw up bitfields in e.g. cases 
>> with 1-bit and signedness.
>>
>> I can probably think up more reasons to avoid bitfields if given another 
>> 5 minutes :)
> 
> A significant problem is that modifications to "nearby" bitfields need
> locking: concurrent modifications to two bitfields can result in concurrent
> modifications to the same word.
> 
> And that's OK, but it's pretty unobvious that these stores are nonatomic
> from the source code and people could easily forget to do it.

Indeed.

Overall, it isn't any one specific thing that makes me reject bitfields 
in new code, it's the sum of all these reasons.

Kernel and compiler history proves that humans and compilers screw up 
bitfields early and often :)

Another reason that I just thought of:  bitfields cannot be 
conglomerated into easy-to-assign-and-test masks, making

	foo = (1 << 0),
	bar = (1 << 4),
	baz = (1 << 9),
	default_feature_flags = foo | bar | baz,

	foo->flags = default_feature_flags;

impossible with bitfields.

You also cannot test multiple bits at one time, with bitfields.


> That being said, they _are_ attractive from the nice-to-read POV...

My personal style disagrees, but that's a personal taste.  I can see how 
other people might think that, though, agreed.

	Jeff



-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ