On 8/28/25 12:10, Jason Gunthorpe wrote:
The biggest single chunk of code is defining ptdesc_*_kernel(). The rest of it is painfully simple.
Seems not great to be casting ptdesc to folio just to use folio_set_referenced(), I'm pretty sure that is no the direction things are going in..
Ideally, the ptdesc->__page_flags fields would have their own set of macros just like folios do, right? Alas, I was too lazy to go to the trouble of conjuring those up for this single bit.
I'd set the flag yourself or perhaps use the memory of __page_mapping to store a flag (but zero it before freeing).
That was my first inclination as well (actually I was going to use __page_type since the lower 24 bits are evidently open, but same idea).
Willy pointed me in the direction of PG_referenced on IRC, so I took that path. But I'm open to doing whatever. It's just three lines of code that probably end up boiling down to
bts 0x1, 0x8(%rax) versus bts 0x2, 0x16(%rax)
;)