* [RFC] mm:change /proc/smaps caculation behavior
@ 2015-01-30 6:14 Wang, Yalin
2015-01-30 7:47 ` [RFC V2] mm:change smaps/pagemap_read calculation behavior Wang, Yalin
0 siblings, 1 reply; 4+ messages in thread
From: Wang, Yalin @ 2015-01-30 6:14 UTC (permalink / raw)
To: 'akpm@linux-foundation.org',
'kirill.shutemov@linux.intel.com',
'oleg@redhat.com', 'gorcunov@openvz.org',
'n-horiguchi@ah.jp.nec.com', 'pfeiner@google.com',
'aquini@redhat.com',
'linux-kernel@vger.kernel.org'
This patch change smaps pagetable walk behavior, to make
sure not skip VM_PFNMAP pagetables,
so that we can calculate COW pages of VM_PFNMAP as normal pages.
Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
---
fs/proc/task_mmu.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index c7267e9..00a5b73 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -503,6 +503,15 @@ static void smaps_pte_entry(pte_t *pte, unsigned long addr,
smaps_account(mss, page, PAGE_SIZE, pte_young(*pte), pte_dirty(*pte));
}
+static int smaps_test_walk(unsigned long addr, unsigned long next,
+ struct mm_walk *walk)
+{
+ /*
+ * don't skip VM_PFNMAP, so that we can caculate some COW pages.
+ */
+ return 0;
+}
+
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
static void smaps_pmd_entry(pmd_t *pmd, unsigned long addr,
struct mm_walk *walk)
@@ -616,6 +625,7 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
struct mem_size_stats mss;
struct mm_walk smaps_walk = {
.pmd_entry = smaps_pte_range,
+ .test_walk = smaps_test_walk,
.mm = vma->vm_mm,
.private = &mss,
};
--
2.2.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [RFC V2] mm:change smaps/pagemap_read calculation behavior
2015-01-30 6:14 [RFC] mm:change /proc/smaps caculation behavior Wang, Yalin
@ 2015-01-30 7:47 ` Wang, Yalin
2015-01-30 8:23 ` Naoya Horiguchi
0 siblings, 1 reply; 4+ messages in thread
From: Wang, Yalin @ 2015-01-30 7:47 UTC (permalink / raw)
To: 'akpm@linux-foundation.org',
'kirill.shutemov@linux.intel.com',
'oleg@redhat.com', 'gorcunov@openvz.org',
'n-horiguchi@ah.jp.nec.com', 'pfeiner@google.com',
'aquini@redhat.com',
'linux-kernel@vger.kernel.org'
This patch change smaps/pagemap_read pagetable walk behavior, to make
sure not skip VM_PFNMAP pagetables,
so that we can calculate COW pages of VM_PFNMAP as normal pages.
Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
---
fs/proc/task_mmu.c | 2 ++
include/linux/mm.h | 2 ++
mm/pagewalk.c | 5 +++++
3 files changed, 9 insertions(+)
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index c7267e9..e7d7c43 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -616,6 +616,7 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
struct mem_size_stats mss;
struct mm_walk smaps_walk = {
.pmd_entry = smaps_pte_range,
+ .test_walk = generic_walk_page_test_no_skip,
.mm = vma->vm_mm,
.private = &mss,
};
@@ -1264,6 +1265,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
pagemap_walk.pmd_entry = pagemap_pte_range;
pagemap_walk.pte_hole = pagemap_pte_hole;
+ pagemap_walk.test_walk = generic_walk_page_test_no_skip;
#ifdef CONFIG_HUGETLB_PAGE
pagemap_walk.hugetlb_entry = pagemap_hugetlb_range;
#endif
diff --git a/include/linux/mm.h b/include/linux/mm.h
index b976d9f..07f71c5 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1191,6 +1191,8 @@ struct mm_walk {
void *private;
};
+int generic_walk_page_test_no_skip(unsigned long start, unsigned long end,
+ struct mm_walk *walk);
int walk_page_range(unsigned long addr, unsigned long end,
struct mm_walk *walk);
int walk_page_vma(struct vm_area_struct *vma, struct mm_walk *walk);
diff --git a/mm/pagewalk.c b/mm/pagewalk.c
index 75c1f28..14f38d5 100644
--- a/mm/pagewalk.c
+++ b/mm/pagewalk.c
@@ -206,6 +206,11 @@ static int __walk_page_range(unsigned long start, unsigned long end,
return err;
}
+int generic_walk_page_test_no_skip(unsigned long start, unsigned long end,
+ struct mm_walk *walk)
+{
+ return 0;
+}
/**
* walk_page_range - walk page table with caller specific callbacks
*
--
2.2.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC V2] mm:change smaps/pagemap_read calculation behavior
2015-01-30 7:47 ` [RFC V2] mm:change smaps/pagemap_read calculation behavior Wang, Yalin
@ 2015-01-30 8:23 ` Naoya Horiguchi
2015-01-30 9:15 ` Wang, Yalin
0 siblings, 1 reply; 4+ messages in thread
From: Naoya Horiguchi @ 2015-01-30 8:23 UTC (permalink / raw)
To: Wang, Yalin
Cc: 'akpm@linux-foundation.org',
'kirill.shutemov@linux.intel.com',
'oleg@redhat.com', 'gorcunov@openvz.org',
'pfeiner@google.com', 'aquini@redhat.com',
'linux-kernel@vger.kernel.org'
On Fri, Jan 30, 2015 at 03:47:54PM +0800, Wang, Yalin wrote:
> This patch change smaps/pagemap_read pagetable walk behavior, to make
> sure not skip VM_PFNMAP pagetables,
> so that we can calculate COW pages of VM_PFNMAP as normal pages.
>
> Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
Hi Yalin,
The original motivation of the VM_PFNMAP code in pagewalk.c comes from the
following patch:
commit a9ff785e4437c83d2179161e012f5bdfbd6381f0
Author: Cliff Wickman <cpw@sgi.com>
Date: Fri May 24 15:55:36 2013 -0700
mm/pagewalk.c: walk_page_range should avoid VM_PFNMAP areas
, where Cliff stated that some kind of vma(VM_PFNMAP) caused kernel panic
when walk_page_range() was called over it. So I don't think that re-enabling
to walk over every vma(VM_PFNMAP) unexceptionally is a good idea.
If you really want to get some information from a vma(VM_PFNMAP) via these
interfaces, I recommend you to implement proper judging code which returns
0 for your vma(VM_PFNMAP) and returns 1 for Cliff's vma(VM_PFNMAP).
Thanks,
Naoya Horiguchi
> ---
> fs/proc/task_mmu.c | 2 ++
> include/linux/mm.h | 2 ++
> mm/pagewalk.c | 5 +++++
> 3 files changed, 9 insertions(+)
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index c7267e9..e7d7c43 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -616,6 +616,7 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
> struct mem_size_stats mss;
> struct mm_walk smaps_walk = {
> .pmd_entry = smaps_pte_range,
> + .test_walk = generic_walk_page_test_no_skip,
> .mm = vma->vm_mm,
> .private = &mss,
> };
> @@ -1264,6 +1265,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
>
> pagemap_walk.pmd_entry = pagemap_pte_range;
> pagemap_walk.pte_hole = pagemap_pte_hole;
> + pagemap_walk.test_walk = generic_walk_page_test_no_skip;
> #ifdef CONFIG_HUGETLB_PAGE
> pagemap_walk.hugetlb_entry = pagemap_hugetlb_range;
> #endif
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index b976d9f..07f71c5 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1191,6 +1191,8 @@ struct mm_walk {
> void *private;
> };
>
> +int generic_walk_page_test_no_skip(unsigned long start, unsigned long end,
> + struct mm_walk *walk);
> int walk_page_range(unsigned long addr, unsigned long end,
> struct mm_walk *walk);
> int walk_page_vma(struct vm_area_struct *vma, struct mm_walk *walk);
> diff --git a/mm/pagewalk.c b/mm/pagewalk.c
> index 75c1f28..14f38d5 100644
> --- a/mm/pagewalk.c
> +++ b/mm/pagewalk.c
> @@ -206,6 +206,11 @@ static int __walk_page_range(unsigned long start, unsigned long end,
> return err;
> }
>
> +int generic_walk_page_test_no_skip(unsigned long start, unsigned long end,
> + struct mm_walk *walk)
> +{
> + return 0;
> +}
> /**
> * walk_page_range - walk page table with caller specific callbacks
> *
> --
> 2.2.2
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [RFC V2] mm:change smaps/pagemap_read calculation behavior
2015-01-30 8:23 ` Naoya Horiguchi
@ 2015-01-30 9:15 ` Wang, Yalin
0 siblings, 0 replies; 4+ messages in thread
From: Wang, Yalin @ 2015-01-30 9:15 UTC (permalink / raw)
To: 'Naoya Horiguchi'
Cc: 'akpm@linux-foundation.org',
'kirill.shutemov@linux.intel.com',
'oleg@redhat.com', 'gorcunov@openvz.org',
'pfeiner@google.com', 'aquini@redhat.com',
'linux-kernel@vger.kernel.org'
> -----Original Message-----
> From: Naoya Horiguchi [mailto:n-horiguchi@ah.jp.nec.com]
> Sent: Friday, January 30, 2015 4:24 PM
> To: Wang, Yalin
> Cc: 'akpm@linux-foundation.org'; 'kirill.shutemov@linux.intel.com';
> 'oleg@redhat.com'; 'gorcunov@openvz.org'; 'pfeiner@google.com';
> 'aquini@redhat.com'; 'linux-kernel@vger.kernel.org'
> Subject: Re: [RFC V2] mm:change smaps/pagemap_read calculation behavior
>
> On Fri, Jan 30, 2015 at 03:47:54PM +0800, Wang, Yalin wrote:
> > This patch change smaps/pagemap_read pagetable walk behavior, to make
> > sure not skip VM_PFNMAP pagetables,
> > so that we can calculate COW pages of VM_PFNMAP as normal pages.
> >
> > Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
>
> Hi Yalin,
>
> The original motivation of the VM_PFNMAP code in pagewalk.c comes from the
> following patch:
>
> commit a9ff785e4437c83d2179161e012f5bdfbd6381f0
> Author: Cliff Wickman <cpw@sgi.com>
> Date: Fri May 24 15:55:36 2013 -0700
>
> mm/pagewalk.c: walk_page_range should avoid VM_PFNMAP areas
>
> , where Cliff stated that some kind of vma(VM_PFNMAP) caused kernel panic
> when walk_page_range() was called over it. So I don't think that re-
> enabling
> to walk over every vma(VM_PFNMAP) unexceptionally is a good idea.
>
> If you really want to get some information from a vma(VM_PFNMAP) via these
> interfaces, I recommend you to implement proper judging code which returns
> 0 for your vma(VM_PFNMAP) and returns 1 for Cliff's vma(VM_PFNMAP).
>
I see, but I am curious that why kernel panic when I just
access process pagetables in page_table_walk()?
Is it caused by hardware problem?
The reason that I want to enable it is to see some drivers map some COW pages
With VM_PFNMAP, so that user space can get correct page allocation info for
These COW special pages with VM_PFNMAP flag.
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-30 9:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-30 6:14 [RFC] mm:change /proc/smaps caculation behavior Wang, Yalin
2015-01-30 7:47 ` [RFC V2] mm:change smaps/pagemap_read calculation behavior Wang, Yalin
2015-01-30 8:23 ` Naoya Horiguchi
2015-01-30 9:15 ` Wang, Yalin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.