Guest page hinting: discarded page list.
Subsystems (5)
PATCH 8/9 Guest page hinting: discarded page list.
[patch 8/9] Guest page hinting: discarded page list.
The discarded page list is used to postpone the freeing of discarded pages. The PG_discarded is set by either __remove_from_page_cache, __delete_from_swap_cache or the discard fault handler for pages that have been removed by the host. free_hot_cold_page test for the bit and puts the page to a per-cpu discarded page list if it is set. try_to_free_pages does an smp_call_function to collect all the partial discarded page lists and frees them.
There are two reasons why this is desirable. First, discarded page are really cold. Before the guest can reaccess the page frame the host needs to provide a fresh page. It is faster to use only non-discarded pages which do not require a host action as long as the working set of the guest allows it.
The second reason has to do with the peculiars of the s390 architecture. The discard fault exception delivers the absolute address of the page that caused the fault to the guest instead of the virtual address. With the virtual address we could have used the page table entry of the current process to safely get a reference to the discarded page. We can get to the struct page from the absolute page address but it is rather hard to get to a proper page reference. The page that caused the fault could already have been freed and reused for a different purpose. None of the fields in the struct page would be reliable to use. The discard list and the call of smp_call_function before freeing discarded pages makes sure that the discard fault handler is reached only for pages that have not been freed yet. A call to get_page_unless_zero can then be used to get a proper page reference.
---
include/linux/page-states.h | 4 +++ mm/page_alloc.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 3 ++ 3 files changed, 63 insertions(+)
include/linux/page-states.h +4 -0
@@ -69,9 +69,13 @@* - page_reset_writable: * Resets the page state after the last writable page table entry * refering to the page has been removed. +* - page_shrink_discards: +* Frees all pages that free_hot_cold_page has put on the list of +* discarded pages. */ extern void page_unmap_all (struct page *page);extern void page_discard (struct page *page); +extern unsigned long page_shrink_discards (void );static inline int page_make_stable (struct page *page) {
mm/page_alloc.c +56 -0
80 lines not on this page · raw message
mm/vmscan.c +3 -0
@@ -1034,6 +1034,9 @@ unsigned long try_to_free_pages(struct z sc.nr_scanned =0 ;if (!priority)disable_swap_token (); +#ifdef CONFIG_PAGE_DISCARD_LIST + nr_reclaimed +=page_shrink_discards (); +#endif nr_reclaimed +=shrink_zones (priority, zones, &sc);shrink_slab (sc.nr_scanned, gfp_mask, lru_pages);if (reclaim_state) {
--
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>