On Thu, Apr 11, 2024 at 10:57:28AM +1000, Alistair Popple wrote: > Zone device pages are used to represent various type of device memory > managed by device drivers. Currently compound zone device pages are > not supported. This is because MEMORY_DEVICE_FS_DAX pages are the only > user of higher order zone device pages and have their own page > reference counting. > > A future change will unify FS DAX reference counting with normal page > reference counting rules and remove the special FS DAX reference > counting. Supporting that requires compound zone device pages. > > Supporting compound zone device pages requires compound_head() to > distinguish between head and tail pages whilst still preserving the > special struct page fields that are specific to zone device pages. > > A tail page is distinguished by having bit zero being set in > page->compound_head, with the remaining bits pointing to the head > page. For zone device pages page->compound_head is shared with > page->pgmap. > > The page->pgmap field is common to all pages within a memory section. > Therefore pgmap is the same for both head and tail pages and we can > use the same scheme to distinguish tail pages. To obtain the pgmap for > a tail page a new accessor is introduced to fetch it from > compound_head. > > Signed-off-by: Alistair Popple <apopple@xxxxxxxxxx> > --- > drivers/gpu/drm/nouveau/nouveau_dmem.c | 2 +- > drivers/pci/p2pdma.c | 2 +- > include/linux/memremap.h | 12 +++++++++--- > include/linux/migrate.h | 2 +- > lib/test_hmm.c | 2 +- > mm/hmm.c | 2 +- > mm/memory.c | 2 +- > mm/memremap.c | 6 +++--- > mm/migrate_device.c | 4 ++-- > 9 files changed, 20 insertions(+), 14 deletions(-) Makes sense to me Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx> Jason