On Thu, 17 Aug 2023 at 10:42, David Laight <David.Laight@xxxxxxxxxx> wrote: > > Although I'm not sure the bit-fields really help. > There are 8 bytes at the start of the structure, might as well > use them :-) Actuallyç I wrote the patch that way because it seems to improve code generation. The bitfields are generally all set together as just plain one-time constants at initialization time, and gcc sees that it's a full byte write. And the reason 'data_source' is not a bitfield is that it's not a constant at iov_iter init time (it's an argument to all the init functions), so having that one as a separate byte at init time is good for code generation when you don't need to mask bits or anything like that. And once initialized, having things be dense and doing all the compares with a bitwise 'and' instead of doing them as some value compare again tends to generate good code. Then being able to test multiple bits at the same time is just gravy on top of that (ie that whole "remove user_backed, because it's easier to just test the bit combination"). > OTOH the 'nofault' and 'copy_mc' flags could be put into much > higher bits of a 32bit value. Once you start doing that, you often get bigger constants in the code stream. I didn't do any *extensive* testing of the code generation, but the stuff I looked at looked good. Linus