[lkml]   [2022]   [Mar]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH v1 05/15] mm/rmap: convert RMAP flags to a proper distinct rmap_t type

> On Mar 8, 2022, at 10:09 AM, Linus Torvalds <> wrote:
> On Tue, Mar 8, 2022 at 9:15 AM Nadav Amit <> wrote:
>> It would be much easier to read. The last time I made such a suggestion,
>> Ingo said "I personally like bitfields in theory … [but] older versions of
>> GCC did a really poor job of optimizing them.”
> Yeah, even not that old versions had serious issues, iirc.
> Bitfields can look nice, but they have some _serious_ syntax issues.
> In particular, they are nice when you want to *test* one single field
> (ie bit in this case), but basically atrociously bad in almost all
> other circumstances.
> For example, passing a bitfield aggregate as an argument is just
> crazy. Oh, you can do it, with syntax like
> (struct type) { .field1 = 1, .field3 = 1 }
> as the argument but when you say "much easier to read" I laugh in your
> face and call your mother a hamster.
> And that's ignoring all the issues when you want to combine two
> bitfields. You can't do it. There is nothing like the binary "or"
> operator. Again, it's easy to modify *one* field, but taking two
> bitfields and merging them? Not going to happen.
> So no. Bitfields have their place, but they are close to useless as
> "flags" type things that get passed around as arguments, unless you
> have very very specific and limited use.

I see your point regarding passing an arg. The or’ing of bitfields
can easily be resolved, unless I am missing something, with a union
that holds the aggregate value and an anonymous struct that holds
the individual flags.

At the time, I thought that bitfields are much better fit for cpuid
fields (which are not just flags).

Anyhow, I will refrain from using bitfields for flags, if only for
the sake of my mother. :)

 \ /
  Last update: 2022-03-08 19:28    [W:0.098 / U:0.404 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site