Re: [PATCH 1/3] vmscan: report vm_flags in page_referenced()

From: Minchan Kim
Date: Sat May 16 2009 - 21:37:00 EST


On Sat, May 16, 2009 at 6:00 PM, Wu Fengguang <fengguang.wu@xxxxxxxxx> wrote:
> Collect vma->vm_flags of the VMAs that actually referenced the page.
>
> This is preparing for more informed reclaim heuristics,
> eg. to protect executable file pages more aggressively.
> For now only the VM_EXEC bit will be used by the caller.
>
> CC: Minchan Kim <minchan.kim@xxxxxxxxx>
> CC: Johannes Weiner <hannes@xxxxxxxxxxx>
> CC: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Signed-off-by: Wu Fengguang <fengguang.wu@xxxxxxxxx>
> ---
> Âinclude/linux/rmap.h | Â Â5 +++--
> Âmm/rmap.c      Â|  37 ++++++++++++++++++++++++++-----------
> Âmm/vmscan.c     Â|  Â7 +++++--
> Â3 files changed, 34 insertions(+), 15 deletions(-)
>
> --- linux.orig/include/linux/rmap.h
> +++ linux/include/linux/rmap.h
> @@ -83,7 +83,8 @@ static inline void page_dup_rmap(struct
> Â/*
> Â* Called from mm/vmscan.c to handle paging out
> Â*/
> -int page_referenced(struct page *, int is_locked, struct mem_cgroup *cnt);
> +int page_referenced(struct page *, int is_locked,
> + Â Â Â Â Â Â Â Â Â Â Â struct mem_cgroup *cnt, unsigned long *vm_flags);
> Âint try_to_unmap(struct page *, int ignore_refs);
>
> Â/*
> @@ -128,7 +129,7 @@ int page_wrprotect(struct page *page, in
> Â#define anon_vma_prepare(vma) Â(0)
> Â#define anon_vma_link(vma) Â Â do {} while (0)
>
> -#define page_referenced(page,l,cnt) TestClearPageReferenced(page)
> +#define page_referenced(page, locked, cnt, flags) TestClearPageReferenced(page)
> Â#define try_to_unmap(page, refs) SWAP_FAIL
>
> Âstatic inline int page_mkclean(struct page *page)
> --- linux.orig/mm/rmap.c
> +++ linux/mm/rmap.c
> @@ -333,7 +333,9 @@ static int page_mapped_in_vma(struct pag
> Â* repeatedly from either page_referenced_anon or page_referenced_file.
> Â*/
> Âstatic int page_referenced_one(struct page *page,
> - Â Â Â struct vm_area_struct *vma, unsigned int *mapcount)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âstruct vm_area_struct *vma,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âunsigned int *mapcount,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âunsigned long *vm_flags)
> Â{
> Â Â Â Âstruct mm_struct *mm = vma->vm_mm;
> Â Â Â Âunsigned long address;
> @@ -381,11 +383,14 @@ out_unmap:
> Â Â Â Â(*mapcount)--;
> Â Â Â Âpte_unmap_unlock(pte, ptl);
> Âout:
> + Â Â Â if (referenced)
> + Â Â Â Â Â Â Â *vm_flags |= vma->vm_flags;
> Â Â Â Âreturn referenced;
> Â}
>
> Âstatic int page_referenced_anon(struct page *page,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct mem_cgroup *mem_cont)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct mem_cgroup *mem_cont,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â unsigned long *vm_flags)
> Â{
> Â Â Â Âunsigned int mapcount;
> Â Â Â Âstruct anon_vma *anon_vma;
> @@ -405,7 +410,8 @@ static int page_referenced_anon(struct p
> Â Â Â Â Â Â Â Â */
> Â Â Â Â Â Â Â Âif (mem_cont && !mm_match_cgroup(vma->vm_mm, mem_cont))
> Â Â Â Â Â Â Â Â Â Â Â Âcontinue;
> - Â Â Â Â Â Â Â referenced += page_referenced_one(page, vma, &mapcount);
> + Â Â Â Â Â Â Â referenced += page_referenced_one(page, vma,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &mapcount, vm_flags);
> Â Â Â Â Â Â Â Âif (!mapcount)
> Â Â Â Â Â Â Â Â Â Â Â Âbreak;
> Â Â Â Â}
> @@ -418,6 +424,7 @@ static int page_referenced_anon(struct p
> Â* page_referenced_file - referenced check for object-based rmap
> Â* @page: the page we're checking references on.
> Â* @mem_cont: target memory controller
> + * @vm_flags: collect encountered vma->vm_flags

I missed this.
To clarify, how about ?
collect encountered vma->vm_flags among vma which referenced the page

--
Kinds regards,
Minchan Kim
--
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/