proc/pagemap: correctly report non-present ptes and holes between vmas
Subsystems (3)
PATCH 1/1 proc/pagemap: correctly report non-present ptes and holes between vmas
This patch resets current pagemap-entry if current pte isn't present, or if current vma is over. Otherwise pagemap reports last entry again and again.
non-present pte reporting was broken in commit v3.3-3738-g092b50b ("pagemap: introduce data structure for pagemap entry")
reporting for holes was broken in commit v3.3-3734-g5aaabe8 ("pagemap: avoid splitting thp when reading /proc/pid/pagemap")
--- fs/proc/task_mmu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
fs/proc/task_mmu.c +10 -2
@@ -747,6 +747,8 @@ static void pte_to_pagemap_entry(pagemap_entry_t *pme, pte_t pte)else if (pte_present (pte)) *pme =make_pme (PM_PFRAME (pte_pfn (pte)) |PM_PSHIFT (PAGE_SHIFT ) |PM_PRESENT ); +else + *pme =make_pme (PM_NOT_PRESENT ); }#ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -761,6 +763,8 @@ static void thp_pmd_to_pagemap_entry(pagemap_entry_t *pme,if (pmd_present (pmd)) *pme =make_pme (PM_PFRAME (pmd_pfn (pmd) + offset) |PM_PSHIFT (PAGE_SHIFT ) |PM_PRESENT ); +else + *pme =make_pme (PM_NOT_PRESENT ); }#else static inline void thp_pmd_to_pagemap_entry(pagemap_entry_t *pme,
@@ -801,8 +805,10 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,/* check to see if we've left 'vma' behind * and need a new, higher one */ -if (vma && (addr >= vma->vm_end)) +if (vma && (addr >= vma->vm_end)) { vma =find_vma (walk->mm, addr); + pme =make_pme (PM_NOT_PRESENT ); + }/* check that 'vma' actually covers this address, * and that it isn't a huge page vma */
@@ -830,6 +836,8 @@ static void huge_pte_to_pagemap_entry(pagemap_entry_t *pme,if (pte_present (pte)) *pme =make_pme (PM_PFRAME (pte_pfn (pte) + offset) |PM_PSHIFT (PAGE_SHIFT ) |PM_PRESENT ); +else + *pme =make_pme (PM_NOT_PRESENT ); }/* This function walks within one hugetlb entry in the single call */
@@ -839,7 +847,7 @@ static int pagemap_hugetlb_range(pte_t *pte, unsigned long hmask, {struct pagemapread *pm = walk->private;int err =0 ; -pagemap_entry_t pme =make_pme (PM_NOT_PRESENT ); +pagemap_entry_t pme;for (; addr != end; addr +=PAGE_SIZE ) {int offset = (addr & ~hmask) >>PAGE_SHIFT ;
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 6 lines · Konstantin Khlebnikov
This patch resets current pagemap-entry if current pte isn't present, or if current vma is over. Otherwise pagemap reports last entry again and again.
non-present pte reporting was broken in commit v3.3-3738-g092b50b ("pagemap: introduce data structure for pagemap entry")
Quoted 8 lines
reporting for holes was broken in commit v3.3-3734-g5aaabe8 ("pagemap: avoid splitting thp when reading
/proc/pid/pagemap")Signed-off-by Konstantin Khlebnikov <[email protected]>Reported-by Pavel Emelyanov <[email protected]>Cc Naoya Horiguchi <[email protected]>Cc KAMEZAWA Hiroyuki <[email protected]>Cc Andi Kleen <[email protected]>
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Hi,
Quoted 6 lines · Konstantin Khlebnikov
This patch resets current pagemap-entry if current pte isn't present, or if current vma is over. Otherwise pagemap reports last entry again and again.
non-present pte reporting was broken in commit v3.3-3738-g092b50b ("pagemap: introduce data structure for pagemap entry")
Quoted 8 lines
reporting for holes was broken in commit v3.3-3734-g5aaabe8 ("pagemap: avoid splitting thp when reading
/proc/pid/pagemap")Signed-off-by Konstantin Khlebnikov <[email protected]>Reported-by Pavel Emelyanov <[email protected]>Cc Naoya Horiguchi <[email protected]>Cc KAMEZAWA Hiroyuki <[email protected]>Cc Andi Kleen <[email protected]>
Thanks for your efforts.
I confirmed that this patch fixes the problem on v3.4-rc4. But originally (before the commits you pointed to above) initializing pagemap entries (originally labelled with confusing 'pfn') were done in for-loop in pagemap_pte_range(), so I think it's better to get it back to things like that.
How about the following?
---
fs/proc/task_mmu.c +4 -2
@@ -779,13 +779,14 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,struct pagemapread *pm = walk->private;pte_t *pte;int err =0 ; -pagemap_entry_t pme =make_pme (PM_NOT_PRESENT ); +pagemap_entry_t pme;/* find the first VMA at or above 'addr' */ vma =find_vma (walk->mm, addr);if (pmd_trans_huge_lock (pmd, vma) ==1 ) {for (; addr != end; addr +=PAGE_SIZE ) {unsigned long offset; + pme =make_pme (PM_NOT_PRESENT ); offset = (addr & ~PAGEMAP_WALK_MASK ) >>PAGE_SHIFT ;
@@ -801,6 +802,7 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,if (pmd_trans_unstable (pmd))return 0 ;for (; addr != end; addr +=PAGE_SIZE ) { + pme =make_pme (PM_NOT_PRESENT );/* check to see if we've left 'vma' behind * and need a new, higher one */
@@ -842,10 +844,10 @@ static int pagemap_hugetlb_range(pte_t *pte, unsigned long hmask, {struct pagemapread *pm = walk->private;int err =0 ; -pagemap_entry_t pme =make_pme (PM_NOT_PRESENT );for (; addr != end; addr +=PAGE_SIZE ) {int offset = (addr & ~hmask) >>PAGE_SHIFT ; +pagemap_entry_t pme =make_pme (PM_NOT_PRESENT );huge_pte_to_pagemap_entry (&pme, *pte, offset); err =add_to_pagemap (addr, &pme, pm);if (err)
---
Thanks,
Naoya
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 18 lines · Naoya Horiguchi
Hi,
Quoted 6 lines · Konstantin Khlebnikov
This patch resets current pagemap-entry if current pte isn't present, or if current vma is over. Otherwise pagemap reports last entry again and again.
non-present pte reporting was broken in commit v3.3-3738-g092b50b ("pagemap: introduce data structure for pagemap entry")
Quoted 8 lines
reporting for holes was broken in commit v3.3-3734-g5aaabe8 ("pagemap: avoid splitting thp when reading
/proc/pid/pagemap")Signed-off-by Konstantin Khlebnikov<[email protected]>Reported-by Pavel Emelyanov<[email protected]>Cc Naoya Horiguchi<[email protected]>Cc KAMEZAWA Hiroyuki<[email protected]>Cc Andi Kleen<[email protected]>
Quoted 8 lines
Thanks for your efforts.
I confirmed that this patch fixes the problem on v3.4-rc4. But originally (before the commits you pointed to above) initializing pagemap entries (originally labelled with confusing 'pfn') were done in for-loop inpagemap_pte_range(), so I think it's better to get it back to things like that.How about the following?
I don't like this. Functions which returns void should always initialize its "output" argument, it much more clear than relying on preinitialized value.
Quoted 43 lines
---
fs/proc/task_mmu.c +4
-3@@ -779,13 +779,14 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,struct pagemapread *pm = walk->private;pte_t *pte;int err =0 ; -pagemap_entry_t pme =make_pme (PM_NOT_PRESENT ); +pagemap_entry_t pme;/* find the first VMA at or above 'addr' */ vma =find_vma (walk->mm, addr);if (pmd_trans_huge_lock (pmd, vma) ==1 ) {for (; addr != end; addr +=PAGE_SIZE ) {unsigned long offset; + pme =make_pme (PM_NOT_PRESENT ); offset = (addr& ~PAGEMAP_WALK_MASK )>>PAGE_SHIFT ;@@ -801,6 +802,7 @@ static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,if (pmd_trans_unstable (pmd))return 0 ;for (; addr != end; addr +=PAGE_SIZE ) { + pme =make_pme (PM_NOT_PRESENT );/* check to see if we've left 'vma' behind * and need a new, higher one */ @@ -842,10 +844,10 @@ static int pagemap_hugetlb_range(pte_t *pte, unsigned long hmask, {struct pagemapread *pm = walk->private;int err =0 ; -pagemap_entry_t pme =make_pme (PM_NOT_PRESENT );for (; addr != end; addr +=PAGE_SIZE ) {int offset = (addr& ~hmask)>>PAGE_SHIFT ; +pagemap_entry_t pme =make_pme (PM_NOT_PRESENT );huge_pte_to_pagemap_entry (&pme, *pte, offset); err =add_to_pagemap (addr,&pme, pm);if (err) ---
Quoted 2 lines
Thanks,
Naoya
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 26 lines · Konstantin Khlebnikov
Quoted 25 lines · Naoya Horiguchi
Hi,
Quoted 6 lines · Konstantin Khlebnikov
This patch resets current pagemap-entry if current pte isn't present, or if current vma is over. Otherwise pagemap reports last entry again and again.
non-present pte reporting was broken in commit v3.3-3738-g092b50b ("pagemap: introduce data structure for pagemap entry")
Quoted 8 lines
reporting for holes was broken in commit v3.3-3734-g5aaabe8 ("pagemap: avoid splitting thp when reading
/proc/pid/pagemap")Signed-off-by Konstantin Khlebnikov<[email protected]>Reported-by Pavel Emelyanov<[email protected]>Cc Naoya Horiguchi<[email protected]>Cc KAMEZAWA Hiroyuki<[email protected]>Cc Andi Kleen<[email protected]>Thanks for your efforts.
I confirmed that this patch fixes the problem on v3.4-rc4. But originally (before the commits you pointed to above) initializing pagemap entries (originally labelled with confusing 'pfn') were done in for-loop inpagemap_pte_range(), so I think it's better to get it back to things like that.
Quoted 4 lines
Quoted 1 line
How about the following?
I don't like this. Functions which returns void should always initialize its "output" argument, it much more clear than relying on preinitialized value.
OK, it makes sense.
Thanks,
Naoya
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>