The proper time to split struct page
The proper time to split struct page
Posted Jul 18, 2023 14:49 UTC (Tue) by willy (subscriber, #9762)In reply to: The proper time to split struct page by marcH
Parent article: The proper time to split struct page
I'd give a more useful response, but so much has been written about this already, I'm not inclined to give you a custom response to such a low-effort comment.
Posted Jul 18, 2023 15:37 UTC (Tue)
by Wol (subscriber, #4433)
[Link]
Cheers,
Posted Jul 20, 2023 19:10 UTC (Thu)
by knotapun (guest, #166136)
[Link] (2 responses)
Posted Jul 21, 2023 2:50 UTC (Fri)
by willy (subscriber, #9762)
[Link] (1 responses)
unsigned long flags;
#define FOO (1<<0)
instead of
unsigned long foo_flag:1;
? Assuming that's your question ...
There's no way to atomically set a bitfield to a value. That is, if one process sets foo_flag at the same time another process sets bar_flag, both CPUs will do a read-modify-write and one write can get lost. Of course, this is true for "unsigned long flags" too, which is why we have set_bit() and friends.
We do use bitfields in some places, but probably could make more use of them; not every flags word needs to be accessed atomically.
Posted Jul 21, 2023 3:33 UTC (Fri)
by knotapun (guest, #166136)
[Link]
Thanks, C is still new to me!
Posted Jul 21, 2023 9:12 UTC (Fri)
by marcH (subscriber, #57642)
[Link]
On the other hand, it wasn't a question, just a perfectly neutral statement. As such it wasn't expecting any answer and certainly not an agressive and somewhat cryptic one (I honestly don't know what you've imagined from my comment; please do *not* elaborate on that)
I enjoy LWN comments most of the time because they can be both relaxed/low bar while being incredibly knowledgeable and valuable from time to time. Basically what social media should have been.
The proper time to split struct page
Wol
The proper time to split struct page
The proper time to split struct page
#define BAR (1<<1)
unsigned long bar_flag:1;
The proper time to split struct page
The proper time to split struct page