PG_reserved and compound pages

From: Frank Mehnert
Date: Wed Apr 06 2016 - 07:29:01 EST


Hi,

Linux 4.5 introduced additional checks to ensure that compound pages are
never marked as reserved. In our code we use PG_reserved to ensure that
the kernel does never swap out such pages, e.g.

int i;
struct page *pages = alloc_pages(GFP_HIGHUSER | __GFP_COMP, 4);
for (i = 0; i < 16; i++)
SetPageReserved(&pages[i]);

The purpose of setting PG_reserved is to prevent the kernel from swapping
this memory out. This worked with older kernel but not with Linux 4.5 as
setting PG_reserved to compound pages is not allowed any more.

Can somebody explain how we can achieve the same result in accordance to
the new Linux 4.5 rules?

Thanks,

Frank
--
Dr.-Ing. Frank Mehnert | Software Development Director, VirtualBox
ORACLE Deutschland B.V. & Co. KG | Werkstr. 24 | 71384 Weinstadt, Germany

ORACLE Deutschland B.V. & Co. KG
Hauptverwaltung: RiesstraÃe 25, D-80992 MÃnchen
Registergericht: Amtsgericht MÃnchen, HRA 95603

KomplementÃrin: ORACLE Deutschland Verwaltung B.V.
Hertogswetering 163/167, 3543 AS Utrecht, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
GeschÃftsfÃhrer: Alexander van der Ven, Jan Schultheiss, Val Maher