freenode
Kernel & Low-Level

Kernel RFC aims to drop PG_private for a new folio flag bit

Zi Yan’s series would free a scarce page-flag bit by treating a non-NULL private pointer as the sole signal that a page carries filesystem or driver state.

Zi Yan has posted an RFC series to the Linux kernel mailing list that removes the long-standing PG_private page flag, reclaiming the bit for a planned PG_folio flag used to tell ordinary pages apart from folio heads and tails.

Page flags are a tightly rationed resource. PG_private has historically meant “this page or folio has private data attached.” In practice almost every caller already stores that data in the page or folio private pointer and bumps the reference count through the standard attach and detach helpers. Yan’s patches therefore replace PG_private tests with a simple check that the private pointer is non-NULL, then delete the flag and reserve its slot as __PG_folio.

Most filesystems and drivers need no logic change beyond that substitution. A handful of outliers required real work: zsmalloc’s first-component marker, the perf ring-buffer’s order field, Xen grant-table foreign-page tracking on 32-bit, fscrypt bounce pages, and two distinct erofs uses of the private pointer (one turned into a new reverse-readahead helper, the other switched to the refcount-aware attach path). Swap-cache and hugetlb folios, which overload the same storage for unrelated data, are explicitly excluded from the new helper.

Early review has been cautiously positive. Usama Arif acked the fscrypt and hugetlb cleanups after minor commit-message fixes. Xen maintainer Jürgen Groß asked whether union overlap could ever leave the private pointer non-NULL while PG_private was clear, a hazard the series must still prove cannot occur. The patches remain RFC and are not yet staged for a merge window.