proc/smaps: carefully handle migration entries
Subsystems (3)
RFC PATCH 1/3 proc/smaps: carefully handle migration entries
Currently smaps reports migration entries as "swap", as result "swap" can appears in shared mapping.
This patch converts migration entries into pages and handles them as usual.
--- fs/proc/task_mmu.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
fs/proc/task_mmu.c +10 -8
@@ -402,18 +402,20 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr, {struct mem_size_stats *mss = walk->private;struct vm_area_struct *vma = mss->vma; -struct page *page; +struct page *page =NULL ;int mapcount; -if (is_swap_pte (ptent)) { - mss->swap += ptent_size; -return ; - } +if (pte_present (ptent)) { + page =vm_normal_page (vma, addr, ptent); + }else if (is_swap_pte (ptent)) { +swp_entry_t swpent =pte_to_swp_entry (ptent); -if (!pte_present (ptent)) -return ; +if (!non_swap_entry (swpent)) + mss->swap += ptent_size; +else if (is_migration_entry (swpent)) + page =migration_entry_to_page (swpent); + } - page =vm_normal_page (vma, addr, ptent);if (!page)return ;
--
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>
RFC PATCH 2/3 proc/smaps: show amount of nonlinear ptes in vma
Currently, nonlinear mappings can not be distinguished from ordinary mappings. This patch adds into /proc/pid/smaps line "Nonlinear: <size> kB", where size is amount of nonlinear ptes in vma, this line appears only if VM_NONLINEAR is set. This information may be useful not only for checkpoint/restore project.
--- fs/proc/task_mmu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
fs/proc/task_mmu.c +12 -0
@@ -393,6 +393,7 @@ struct mem_size_stats {unsigned long anonymous;unsigned long anonymous_thp;unsigned long swap; +unsigned long nonlinear;u64 pss; };
@@ -402,6 +403,7 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr, {struct mem_size_stats *mss = walk->private;struct vm_area_struct *vma = mss->vma; +pgoff_t pgoff =linear_page_index (vma, addr);struct page *page =NULL ;int mapcount;
@@ -414,6 +416,9 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr, mss->swap += ptent_size; else if (is_migration_entry(swpent)) page =migration_entry_to_page (swpent); + }else if (pte_file (ptent)) { +if (pte_to_pgoff (ptent) != pgoff) + mss->nonlinear += ptent_size; }if (!page)
@@ -422,6 +427,9 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr,if (PageAnon (page)) mss->anonymous += ptent_size; +if (page->index != pgoff) + mss->nonlinear += ptent_size; + mss->resident += ptent_size;/* Accumulate the size in pages that have been accessed. */ if (pte_young (ptent) ||PageReferenced (page))
@@ -523,6 +531,10 @@ static int show_smap(struct seq_file *m, void *v, int is_pid) (vma->vm_flags &VM_LOCKED ) ? (unsigned long)(mss.pss >> (10 + PSS_SHIFT)) : 0); +if (vma->vm_flags &VM_NONLINEAR ) +seq_printf (m,"Nonlinear: %8lu kB\n" , + mss.nonlinear >>10 ); +if (m->count < m->size)/* vma is copied successfully */ m->version = (vma !=get_gate_vma (task->mm)) ? vma->vm_start :0 ;
--
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>
Re: [PATCH RFC 2/3] proc/smaps: show amount of nonlinear ptes in vma
Quoted 32 lines · Konstantin Khlebnikov
Currently, nonlinear mappings can not be distinguished from ordinary mappings. This patch adds into
/proc/pid/smapsline "Nonlinear: <size> kB", where size is amount of nonlinear ptes in vma, this line appears only ifVM_NONLINEARis set. This information may be useful not only for checkpoint/restore project.Signed-off-by Konstantin Khlebnikov <[email protected]>Requested-by Pavel Emelyanov <[email protected]>---
fs/proc/task_mmu.c | 12 ++++++++++++1 file changed, 12 insertions(+)fs/proc/task_mmu.c +2
-0@@ -393,6 +393,7 @@ struct mem_size_stats { unsigned long anonymous; unsigned long anonymous_thp; unsigned long swap; + unsigned long nonlinear; u64 pss; };@@ -402,6 +403,7 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr, { struct mem_size_stats *mss = walk->private; struct vm_area_struct *vma = mss->vma; + pgoff_t pgoff = linear_page_index(vma, addr); struct page *page = NULL; int mapcount;
fs/proc/task_mmu.c static void smaps_pte_entry(pte_t ptent, unsigned long addr, · line 421
Quoted 6 lines
fs/proc/task_mmu.c +3
-0@@ -414,6 +416,9 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr, mss->swap += ptent_size; else if (is_migration_entry(swpent)) page = migration_entry_to_page(swpent); + } else if (pte_file(ptent)) { + if (pte_to_pgoff(ptent) != pgoff) + mss->nonlinear += ptent_size;
I think this is not equal to our non linear mapping definition. Even if pgoff is equal to linear mapping case, it is non linear. I.e. nonlinear is vma attribute. Why do you want to introduce different definition?
--
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>
Re: [PATCH RFC 2/3] proc/smaps: show amount of nonlinear ptes in vma
Quoted 33 lines · KOSAKI Motohiro
Quoted 31 lines · Konstantin Khlebnikov
Currently, nonlinear mappings can not be distinguished from ordinary mappings. This patch adds into
/proc/pid/smapsline "Nonlinear:<size> kB", where size is amount of nonlinear ptes in vma, this line appears only ifVM_NONLINEARis set. This information may be useful not only for checkpoint/restore project.Signed-off-by Konstantin Khlebnikov<[email protected]>Requested-by Pavel Emelyanov<[email protected]>--- fs/proc/task_mmu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)fs/proc/task_mmu.c +2
-0@@ -393,6 +393,7 @@ struct mem_size_stats {unsigned long anonymous;unsigned long anonymous_thp;unsigned long swap; +unsigned long nonlinear;u64 pss; };@@ -402,6 +403,7 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr, {struct mem_size_stats *mss = walk->private;struct vm_area_struct *vma = mss->vma; +pgoff_t pgoff =linear_page_index (vma, addr);struct page *page =NULL ;int mapcount;
Quoted 11 lines
fs/proc/task_mmu.c static void smaps_pte_entry(pte_t ptent, unsigned long addr, · line 421
Quoted 7 lines
fs/proc/task_mmu.c +3
-0@@ -414,6 +416,9 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr, mss->swap += ptent_size; else if (is_migration_entry(swpent)) page =migration_entry_to_page (swpent); + }else if (pte_file (ptent)) { +if (pte_to_pgoff (ptent) != pgoff) + mss->nonlinear += ptent_size;I think this is not equal to our non linear mapping definition. Even if pgoff is equal to linear mapping case, it is non linear. I.e. nonlinear is vma attribute. Why do you want to introduce different definition?
VMA attribute can be determined via presence of this field, without VM_NONLINEAR it does not appears.
--
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>
Re: [PATCH RFC 2/3] proc/smaps: show amount of nonlinear ptes in vma
Quoted 54 lines · Konstantin Khlebnikov
Quoted 39 lines · KOSAKI Motohiro
Quoted 36 lines · Konstantin Khlebnikov
Currently, nonlinear mappings can not be distinguished from ordinary mappings.
This patch adds into/proc/pid/smapsline "Nonlinear:<size> kB", where size is
amount of nonlinear ptes in vma, this line appears only ifVM_NONLINEARis set.
This information may be useful not only for checkpoint/restore project.Signed-off-by Konstantin Khlebnikov<[email protected]>Requested-by Pavel Emelyanov<[email protected]>---
fs/proc/task_mmu.c | 12 ++++++++++++1 file changed, 12 insertions(+)fs/proc/task_mmu.c +2
-0@@ -393,6 +393,7 @@ struct mem_size_stats { unsigned long anonymous; unsigned long anonymous_thp; unsigned long swap; + unsigned long nonlinear; u64 pss; };@@ -402,6 +403,7 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr, { struct mem_size_stats *mss = walk->private; struct vm_area_struct *vma = mss->vma; + pgoff_t pgoff = linear_page_index(vma, addr); struct page *page = NULL; int mapcount;Quoted 13 lines
fs/proc/task_mmu.c static void smaps_pte_entry(pte_t ptent, unsigned · line 422
Quoted 8 lines
fs/proc/task_mmu.c +3
-0@@ -414,6 +416,9 @@ static void smaps_pte_entry(pte_t ptent, unsignedlong addr, mss->swap += ptent_size; else if (is_migration_entry(swpent)) page = migration_entry_to_page(swpent); + } else if (pte_file(ptent)) { + if (pte_to_pgoff(ptent) != pgoff) + mss->nonlinear += ptent_size;I think this is not equal to our non linear mapping definition. Even if pgoff is equal to linear mapping case, it is non linear. I.e. nonlinear is vma attribute. Why do you want to introduce different definition?
Quoted 2 lines
VMA attribute can be determined via presence of this field, without
VM_NONLINEARit does not appears.
I meant, is there any worth?
--
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>
RFC PATCH 3/3 proc/smaps: show amount of hwpoison pages
In reply to Konstantin KhlebnikovThis patch adds line "HWPoinson: <size> kB" into /proc/pid/smaps if CONFIG_MEMORY_FAILURE=y and some HWPoison pages were found. This may be useful for searching applications which use a broken memory.
--- fs/proc/task_mmu.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/proc/task_mmu.c +10 -0
@@ -394,6 +394,7 @@ struct mem_size_stats {unsigned long anonymous_thp;unsigned long swap;unsigned long nonlinear; +unsigned long hwpoison;u64 pss; };
@@ -416,6 +417,8 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr, mss->swap += ptent_size; else if (is_migration_entry(swpent)) page =migration_entry_to_page (swpent); + else if (is_hwpoison_entry(swpent)) + mss->hwpoison += ptent_size; }else if (pte_file (ptent)) {if (pte_to_pgoff (ptent) != pgoff) mss->nonlinear += ptent_size;
@@ -430,6 +433,9 @@ static void smaps_pte_entry(pte_t ptent, unsigned long addr,if (page->index != pgoff) mss->nonlinear += ptent_size; +if (PageHWPoison (page)) + mss->hwpoison += ptent_size; + mss->resident += ptent_size;/* Accumulate the size in pages that have been accessed. */ if (pte_young (ptent) ||PageReferenced (page))
@@ -535,6 +541,10 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)seq_printf (m,"Nonlinear: %8lu kB\n" , mss.nonlinear >>10 ); +if (IS_ENABLED (CONFIG_MEMORY_FAILURE ) && mss.hwpoison) +seq_printf (m,"HWPoison: %8lu kB\n" , + mss.hwpoison >>10 ); +if (m->count < m->size)/* vma is copied successfully */ m->version = (vma !=get_gate_vma (task->mm)) ? vma->vm_start :0 ;
--
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>
Re: [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages
Quoted 3 lines · Konstantin Khlebnikov
This patch adds line "HWPoinson: <size> kB" into
/proc/pid/smapsifCONFIG_MEMORY_FAILURE=yand some HWPoison pages were found. This may be useful for searching applications which use a broken memory.
I dislike "maybe useful" claim. If we don't know exact motivation of a feature, we can't maintain them especially when a bugfix can't avoid ABI change.
Please write down exact use case.
--
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>
Re: [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages
Quoted 10 lines · KOSAKI Motohiro
Quoted 3 lines · Konstantin Khlebnikov
This patch adds line "HWPoinson:<size> kB" into
/proc/pid/smapsifCONFIG_MEMORY_FAILURE=yand some HWPoison pages were found. This may be useful for searching applications which use a broken memory.I dislike "maybe useful" claim. If we don't know exact motivation of a feature, we can't maintain them especially when a bugfix can't avoid ABI change.
Please write down exact use case.
I don't know how to exactly use this hw-poison stuff, but smaps suppose to export state of ptes in vma. It seems to rational to show also hw-poisoned ptes, since kernel has this feature and pte can be in hw-poisoned state.
and now everyone can easily find them:
# sudo grep HWPoison /proc/*/smaps
--
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>
Re: [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages
Quoted 16 lines · Konstantin Khlebnikov
Quoted 9 lines · KOSAKI Motohiro
Quoted 4 lines · Konstantin Khlebnikov
This patch adds line "HWPoinson:<size> kB" into
/proc/pid/smapsifCONFIG_MEMORY_FAILURE=yand some HWPoison pages were found. This may be useful for searching applications which use a broken memory.Quoted 5 lines
I dislike "maybe useful" claim. If we don't know exact motivation of a feature,
we can't maintain them especially when a bugfix can't avoid ABI change.Please write down exact use case.
Quoted 7 lines
I don't know how to exactly use this hw-poison stuff, but smaps suppose to export state of ptes in vma. It seems to rational to show also hw-poisoned ptes,
since kernel has this feature and pte can be in hw-poisoned state.and now everyone can easily find them:
# sudo grep HWPoison /proc/*/smaps
First, I don't think "we can expose it" is good reason. Second, hw-poisoned mean such process is going to be killed at next page touch. But I can't imagine anyone can
use its information because it's racy against process kill. I think admin should use mce log.
So, until we find a good use case, I don't ack this.
--
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>
Re: [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages
Quoted 26 lines · On Tue, 1 May 2012 14:14:57 -0400 KOSAKI Motohiro <[email protected]>…
Quoted 16 lines · Konstantin Khlebnikov
Quoted 9 lines · KOSAKI Motohiro
Quoted 4 lines · On Mon, Apr 30, 2012 at 7:29 AM, Konstantin Khlebnikov <[email protected]>…
This patch adds line "HWPoinson:<size>
__kB" into/proc/pid/smapsifCONFIG_MEMORY_FAILURE=yand some HWPoison pages were found. This may be useful for searching applications which use a broken memory.Quoted 5 lines
I dislike "maybe useful" claim. If we don't know exact motivation of a feature,
we can't maintain them especially when a bugfix can't avoid ABI change.Please write down exact use case.
Quoted 7 lines
I don't know how to exactly use this hw-poison stuff, but smaps suppose to export state of ptes in vma. It seems to rational to show also hw-poisoned ptes,
since kernel has this feature and pte can be in hw-poisoned state.and now everyone can easily find them:
# sudo grep HWPoison /proc/*/smaps
Quoted 7 lines
First, I don't think "we can expose it" is good reason. Second, hw-poisoned mean such process is going to be killed at next page touch. But I can't imagine anyone can
use its information because it's racy against process kill. I think admin should use mce log.So, until we find a good use case, I don't ack this.
Yes, I think I'll drop this patch for now. If we can later produce a good reason for expanding the kernel API in this fashion then please resend.
From: Konstantin Khlebnikov <[email protected]>
Subject: proc/smaps: show amount of hwpoison pages
Add the line "HWPoinson: <size> kB" into /proc/pid/smaps if CONFIG_MEMORY_FAILURE=y and some HWPoison pages were found. This may be useful for searching applications which use a broken memory.
---
fs/proc/task_mmu.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/proc/task_mmu.c renamed from fs/proc/task_mmu.c~proc-smaps-show-amount-of-hwpoison-pages +10 -0
@@ -394,6 +394,7 @@ struct mem_size_stats {unsigned long anonymous_thp;unsigned long swap;unsigned long nonlinear; +unsigned long hwpoison;u64 pss; };
@@ -416,6 +417,8 @@ static void smaps_pte_entry(pte_t ptent, mss->swap += ptent_size; else if (is_migration_entry(swpent)) page =migration_entry_to_page (swpent); + else if (is_hwpoison_entry(swpent)) + mss->hwpoison += ptent_size; }else if (pte_file (ptent)) {if (pte_to_pgoff (ptent) != pgoff) mss->nonlinear += ptent_size;
@@ -430,6 +433,9 @@ static void smaps_pte_entry(pte_t ptent,if (page->index != pgoff) mss->nonlinear += ptent_size; +if (PageHWPoison (page)) + mss->hwpoison += ptent_size; + mss->resident += ptent_size;/* Accumulate the size in pages that have been accessed. */ if (pte_young (ptent) ||PageReferenced (page))
@@ -535,6 +541,10 @@ static int show_smap(struct seq_file *m,seq_printf (m,"Nonlinear: %8lu kB\n" , mss.nonlinear >>10 ); +if (IS_ENABLED (CONFIG_MEMORY_FAILURE ) && mss.hwpoison) +seq_printf (m,"HWPoison: %8lu kB\n" , + mss.hwpoison >>10 ); +if (m->count < m->size)/* vma is copied successfully */ m->version = (vma !=get_gate_vma (task->mm)) ? vma->vm_start :0 ;
_
--
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>
Re: [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages
In reply to Konstantin KhlebnikovQuoted 3 lines · Konstantin Khlebnikov
This patch adds line "HWPoinson: <size> kB" into
/proc/pid/smapsifCONFIG_MEMORY_FAILURE=yand some HWPoison pages were found. This may be useful for searching applications which use a broken memory.
Makes sense. The kernel will log the process names, but it can be useful to look for it after the fact to get a more complete picture of the state of the machine.
-Andi
--
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>