[RFC PATCH 0/1] mm: page_frag: account page_frag pages in vmstat and meminfo

From: Yifan Li

Date: Fri Oct 09 2026 - 23:03:15 EST


This is an RFC.

Pages held by the page_frag cache are not accounted by any memory
statistics counter, so on systems that derive "LostRAM" as MemTotal
minus the sum of accounted memory they inflate LostRAM and lead to
misleading "leak" conclusions, even though the memory is legitimately
used by the network path.

The page_frag allocator (page_frag_alloc / napi_alloc_frag /
netdev_alloc_frag) backs sk_buff->head and the frags portion of
skb_shared_info. Unlike slab (NR_SLAB_*) or page_pool, page_frag
pages have no counter. A preliminary measurement on a 4K-page
arm64 Android device shows 14432 kB (3608 pages) of page_frag
pages already in use at boot, and the memory footprint grows
larger under heavy load (e.g. sustained traffic through the
virtio_net / tun receive paths).

Patch 1/1 adds an NR_PAGE_FRAG node counter and exposes it as
nr_page_frag in /proc/vmstat and PageFrag in /proc/meminfo. Pages
enter the cache through a single entry point
__page_frag_cache_refill(), so the increment side is complete; the
decrements sit on the paths that free the cache page.

The remaining gap is on the release side, which is open: a cache page
handed to an skb frags array (skb_add_rx_frag() /
skb_fill_page_desc(), without an extra get_page) is freed via
put_page() (kfree_skb -> __skb_frag_unref -> put_netmem -> put_page),
bypassing page_frag_free(), so the counter can over-count under
network load.

Closing that needs the page to carry a marker checked at the common
free path, e.g. either

1. a page flag: PAGEFLAG(PageFrag, page_frag, PF_HEAD), accounted
and cleared in __free_pages_prepare(); or

2. a page type: PGTY_page_frag reusing _mapcount, accounted in
free_frozen_pages() (requires that page_frag pages are never
mapped into userspace; true for the current RX paths).

With either variant, the per-path decrements of patch 1/1 would go
away and only the increment would remain. Which variant fits
mainline better?

Yifan Li (1):
mm: page_frag: account page_frag pages in vmstat and meminfo

fs/proc/meminfo.c | 1 +
include/linux/mmzone.h | 1 +
mm/page_frag_cache.c | 14 ++++++++++++--
mm/vmstat.c | 1 +
4 files changed, 15 insertions(+), 2 deletions(-)

--
2.46.0.windows.1

#/******±¾Óʼþ¼°Æä¸½¼þº¬ÓÐСÃ×¹«Ë¾µÄ±£ÃÜÐÅÏ¢£¬½öÏÞÓÚ·¢Ë͸øÉÏÃæµØÖ·ÖÐÁгöµÄ¸öÈË»òȺ×é¡£½ûÖ¹ÈÎºÎÆäËûÈËÒÔÈκÎÐÎʽʹÓ㨰üÀ¨µ«²»ÏÞÓÚÈ«²¿»ò²¿·ÖµØÐ¹Â¶¡¢¸´ÖÆ¡¢»òÉ¢·¢£©±¾ÓʼþÖеÄÐÅÏ¢¡£Èç¹ûÄú´íÊÕÁ˱¾Óʼþ£¬ÇëÄúÁ¢¼´µç»°»òÓʼþ֪ͨ·¢¼þÈ˲¢É¾³ý±¾Óʼþ£¡ This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#