|
|
Subscribe / Log in / New account

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

Tell me you don't understand the problem without telling me you don't understand the problem.

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.


to post comments

The proper time to split struct page

Posted Jul 18, 2023 15:37 UTC (Tue) by Wol (subscriber, #4433) [Link]

I think marc is being facetious. He left out "except for the problem of too many layers of indirection".

Cheers,
Wol

The proper time to split struct page

Posted Jul 20, 2023 19:10 UTC (Thu) by knotapun (guest, #166136) [Link] (2 responses)

Hi, thanks for all your work with Folio! I'm quite new to reading kernel source code, and especially memory management code. My reading has led me to a nagging question, why are so many of the structures described in terms of bit-offsets as opposed to C-std bit-fields? I haven't seen an example where the first would lead to more, or better functionality than the second, and I think this means I'm missing something.

The proper time to split struct page

Posted Jul 21, 2023 2:50 UTC (Fri) by willy (subscriber, #9762) [Link] (1 responses)

You're asking why we use things like:

unsigned long flags;

#define FOO (1<<0)
#define BAR (1<<1)

instead of

unsigned long foo_flag:1;
unsigned long bar_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.

The proper time to split struct page

Posted Jul 21, 2023 3:33 UTC (Fri) by knotapun (guest, #166136) [Link]

Ah! I had not ventured into "bitops.h", but that explains a lot. I guess it's probably a whole lot easier to be cross platform if you can force the assembly.

Thanks, C is still new to me!

The proper time to split struct page

Posted Jul 21, 2023 9:12 UTC (Fri) by marcH (subscriber, #57642) [Link]

My comment was certainly not competing for the "LWN comment of the year", no doubt about that.

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.



Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds