Chunsheng Luo <luochunsheng@xxxxxxxx> writes: > + available = sum_zone_node_page_state(nid, NR_FREE_PAGES) - pgdat->totalreserve_pages; > + > + /* > + * Not all the page cache can be freed, otherwise the system will > + * start swapping or thrashing. Assume at least half of the page > + * cache, or the low watermark worth of cache, needs to stay. > + */ > + pagecache = node_page_state(pgdat, NR_ACTIVE_FILE) + > + node_page_state(pgdat, NR_INACTIVE_FILE); > + pagecache -= min(pagecache / 2, wmark_low); The magic number 2 should be a define (or maybe even a tunable). Similar below. It seems quite arbitrary, but I don't have a better solution either. Maybe could handle dirty differently, but nothing stands out here > + node_page_state(pgdat, NR_KERNEL_MISC_RECLAIMABLE); > + reclaimable -= min(reclaimable / 2, wmark_low); > + available += reclaimable; > + > + if (available < 0) > + available = 0; That would be a bug? Perhaps add a WARN_ON With those changes: Reviewed-by: Andi Kleen <ak@xxxxxxxxxxxxxxx> -Andi