Re: [PATCH 1/4] Properly account for the number of page cache pages zone_reclaim() can reclaim

From: KOSAKI Motohiro
Date: Wed Jun 10 2009 - 23:26:23 EST



> We are not talking about NR_TMPFS_PAGES, but NR_TMPFS_MAPPED :)
>
> We only need to account it in page_add_file_rmap() and page_remove_rmap(),
> I don't think they are too hot paths. And the relative cost is low enough.
>
> It will look like this.
>
> ---
> include/linux/mmzone.h | 1 +
> mm/rmap.c | 4 ++++
> 2 files changed, 5 insertions(+)
>
> --- linux.orig/include/linux/mmzone.h
> +++ linux/include/linux/mmzone.h
> @@ -99,6 +99,7 @@ enum zone_stat_item {
> NR_VMSCAN_WRITE,
> /* Second 128 byte cacheline */
> NR_WRITEBACK_TEMP, /* Writeback using temporary buffers */
> + NR_TMPFS_MAPPED,
> #ifdef CONFIG_NUMA
> NUMA_HIT, /* allocated in intended node */
> NUMA_MISS, /* allocated in non intended node */
> --- linux.orig/mm/rmap.c
> +++ linux/mm/rmap.c
> @@ -844,6 +844,8 @@ void page_add_file_rmap(struct page *pag
> {
> if (atomic_inc_and_test(&page->_mapcount)) {
> __inc_zone_page_state(page, NR_FILE_MAPPED);
> + if (PageSwapBacked(page))
> + __inc_zone_page_state(page, NR_TMPFS_MAPPED);
> mem_cgroup_update_mapped_file_stat(page, 1);
> }
> }
> @@ -894,6 +896,8 @@ void page_remove_rmap(struct page *page)
> mem_cgroup_uncharge_page(page);
> __dec_zone_page_state(page,
> PageAnon(page) ? NR_ANON_PAGES : NR_FILE_MAPPED);
> + if (!PageAnon(page) && PageSwapBacked(page))
> + __dec_zone_page_state(page, NR_TMPFS_MAPPED);
> mem_cgroup_update_mapped_file_stat(page, -1);
> /*
> * It would be tidy to reset the PageAnon mapping here,

I think this patch looks good. thanks :)

but I have one request.
Could you please rename NR_FILE_MAPPED to NR_SWAP_BACKED_FILE_MAPPED?

I mean, mm/shmem isn't only used for tmpfs, but also be used ipc/shm and
/dev/zero.
NR_TMPFS_MAPPED seems a bit misleading.



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/