Skip to content

RFC Remove mapcount from struct page

Magnus Damm linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest7 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7Remove page_mapcountfs/proc/task_mmu.c include/linux/mm.h mm/fremap.c +3 more+15 -520 replies
2/7Add PG_mappedinclude/linux/page-flags.h+5 -00 replies
3/7Add anon_vma use countinclude/linux/rmap.h mm/page_alloc.c mm/rmap.c+18 -100 replies
4/7Replace mapcount with PG_mappedinclude/linux/mm.h include/linux/rmap.h mm/fremap.c +3 more+140 -430 replies
5/7Remove reset_page_mapcountinclude/linux/mm.h mm/page_alloc.c+2 -130 replies
6/7Remove page_remove_rmapinclude/linux/rmap.h mm/fremap.c mm/memory.c +1 more+0 -60 replies
7/7Remove page_dup_rmapinclude/linux/rmap.h mm/memory.c+0 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/07][RFC] Remove mapcount from struct page

This patchset tries to remove page->_mapcount. On x86 systems this saves 4 bytes lowmem per page which means a 0.1% memory reduction. For small embedded systems this saves one 4 K page per 4 M of memory. For systems with large amounts of highmem this helps saving valuable lowmem.

The patches introduce a new bit in page->flags called PG_mapped. This bit is used to determine if the page is mapped or not. The value zero means that the page is guaranteed to be unmapped. A one tells us that the page is either mapped or unmapped, probably the former. So, page_mapped() might be lying.

This PG_mapped bit can go from 0 to 1 at any time, see page_add_anon_rmap() and page_add_file_rmap(). The transition from 1 to 0 for an active page is more complicated and is implemented in the new function update_page_mapped(). The PG_mapped bit is also checked when pages are freed. PG_locked protects us.

In order to determine if a page is unmapped or not, the rmap data structures must be traversed. For this to work correctly an usage counter has been added to struct anon_vma.

Apart from performace, there are some issues such as:

- The number of maps limit (INT_MAX/2) is removed.
- can_share_swap_page() always returns 0 for now, ie sharing is disabled.
- Nonlinear file backed vmas are not handled yet.
- Is the anon_vma use count really correct?
- Is the PG_locked bit enough protection?
- There might be other places where update_page_mapped() should be used.

Some testing, but no benchmarking has been done. Have fun. Wear a helmet.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>