On Tue, Oct 12, 2021 at 04:17:29PM +0200, David Hildenbrand wrote: > On 12.10.21 16:13, Matthew Wilcox wrote: > > One of the things I did in the folio patches that I'm not too fond of > > now is: > > > > struct folio { > > union { > > struct { > > ... > > }; > > struct page page; > > }; > > }; > > > > so that I could do &folio->page instead of casting to struct page. > > But maybe both of these approaches are just bad ideas, and I should do: > > > > static inline void slab_clear_pfmemalloc(struct slab *slab) > > { > > PageClearActive(slab_page(slab)); > > } > > > Yes, that's what I meant. That looks great to me. It abstracts a slab attribute, but is very clear in how it implements that. The dependency between the data structures is more obvious this way than with unions, which I think will be really useful in further refactoring iterations. Btw, I think slab_nid() is an interesting thing when it comes to page polymorphy. We want to know the nid for all sorts of memory types: slab, file, anon, buddy etc. In the goal of distilling page down to the fewest number of bytes, this is probably something that should remain in the page rather than be replicated in all subtypes.