On Tue, 30 Aug 2022 16:23:44 +0200 Alexander Potapenko <glider@xxxxxxxxxx> wrote: > > from init/do_mounts.c:2: > > ./include/linux/page-flags.h: In function ‘page_fixed_fake_head’: > > ./include/linux/page-flags.h:226:36: error: invalid use of undefined type ‘const struct page’ > > 226 | test_bit(PG_head, &page->flags)) { > > | ^~ > > ./include/linux/bitops.h:50:44: note: in definition of macro ‘bitop’ > > 50 | __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \ > > | ^~~~ > > ./include/linux/page-flags.h:226:13: note: in expansion of macro ‘test_bit’ > > 226 | test_bit(PG_head, &page->flags)) { > > | ^~~~~~~~ > > ... > > Gotcha, this is a circular dependency: mm_types.h -> sched.h -> > kmsan.h -> gfp.h -> mmzone.h -> page-flags.h -> mm_types.h, where the > inclusion of sched.h into mm_types.h was only introduced in "mm: > multi-gen LRU: support page table walks" - that's why the problem was > missing in other trees. Ah, thanks for digging that out. Yu, that inclusion is regrettable. I don't think mm_types.h is an appropriate site for implementing lru_gen_use_mm() anyway. Adding a new header is always the right fix for these things. I'd suggest adding a new mglru.h (or whatever) and putting most/all of the mglru material in there. Also, the addition to kernel/sched/core.c wasn't clearly changelogged, is uncommented and I doubt if the sched developers know about it, let alone reviewed it. Please give them a heads-up. The addition looks fairly benign, but core context_switch() is the sort of thing which people get rather defensive about and putting mm-specific stuff in there might be challenged. Some quantitative justification of this optimization would be appropriate. > In fact sched.h only needs the definitions of `struct > kmsan_context_state` and `struct kmsan_ctx` from kmsan.h, so I am > splitting them off into kmsan_types.h to break this circle. > Doing so also helped catch a couple of missing/incorrect inclusions of > KMSAN headers in subsystems.