linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 1/3] proc/smaps: carefully handle migration entries
@ 2012-04-30 11:29 Konstantin Khlebnikov
  2012-04-30 11:29 ` [PATCH RFC 2/3] proc/smaps: show amount of nonlinear ptes in vma Konstantin Khlebnikov
  2012-04-30 11:29 ` [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages Konstantin Khlebnikov
  0 siblings, 2 replies; 11+ messages in thread
From: Konstantin Khlebnikov @ 2012-04-30 11:29 UTC (permalink / raw)
  To: linux-mm, linux-kernel; +Cc: Andrew Morton

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.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
---
 fs/proc/task_mmu.c |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index b073971..acee5fd 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -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;
 


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH RFC 2/3] proc/smaps: show amount of nonlinear ptes in vma
  2012-04-30 11:29 [PATCH RFC 1/3] proc/smaps: carefully handle migration entries Konstantin Khlebnikov
@ 2012-04-30 11:29 ` Konstantin Khlebnikov
  2012-05-01 17:39   ` KOSAKI Motohiro
  2012-04-30 11:29 ` [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages Konstantin Khlebnikov
  1 sibling, 1 reply; 11+ messages in thread
From: Konstantin Khlebnikov @ 2012-04-30 11:29 UTC (permalink / raw)
  To: linux-mm, linux-kernel; +Cc: Andrew Morton

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.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Requested-by: Pavel Emelyanov <xemul@parallels.com>
---
 fs/proc/task_mmu.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index acee5fd..b1d9729 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -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;


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages
  2012-04-30 11:29 [PATCH RFC 1/3] proc/smaps: carefully handle migration entries Konstantin Khlebnikov
  2012-04-30 11:29 ` [PATCH RFC 2/3] proc/smaps: show amount of nonlinear ptes in vma Konstantin Khlebnikov
@ 2012-04-30 11:29 ` Konstantin Khlebnikov
  2012-05-01 17:35   ` KOSAKI Motohiro
  2012-05-01 18:29   ` Andi Kleen
  1 sibling, 2 replies; 11+ messages in thread
From: Konstantin Khlebnikov @ 2012-04-30 11:29 UTC (permalink / raw)
  To: linux-mm, linux-kernel; +Cc: Andrew Morton, Andi Kleen

This 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.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Cc: Andi Kleen <andi@firstfloor.org>
---
 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 b1d9729..3e564f0 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -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;


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages
  2012-04-30 11:29 ` [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages Konstantin Khlebnikov
@ 2012-05-01 17:35   ` KOSAKI Motohiro
  2012-05-01 18:05     ` Konstantin Khlebnikov
  2012-05-01 18:29   ` Andi Kleen
  1 sibling, 1 reply; 11+ messages in thread
From: KOSAKI Motohiro @ 2012-05-01 17:35 UTC (permalink / raw)
  To: Konstantin Khlebnikov; +Cc: linux-mm, linux-kernel, Andrew Morton, Andi Kleen

On Mon, Apr 30, 2012 at 7:29 AM, Konstantin Khlebnikov
<khlebnikov@openvz.org> wrote:
> This 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.

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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RFC 2/3] proc/smaps: show amount of nonlinear ptes in vma
  2012-04-30 11:29 ` [PATCH RFC 2/3] proc/smaps: show amount of nonlinear ptes in vma Konstantin Khlebnikov
@ 2012-05-01 17:39   ` KOSAKI Motohiro
  2012-05-01 17:56     ` Konstantin Khlebnikov
  0 siblings, 1 reply; 11+ messages in thread
From: KOSAKI Motohiro @ 2012-05-01 17:39 UTC (permalink / raw)
  To: Konstantin Khlebnikov; +Cc: linux-mm, linux-kernel, Andrew Morton

On Mon, Apr 30, 2012 at 7:29 AM, Konstantin Khlebnikov
<khlebnikov@openvz.org> wrote:
> 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.
>
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
> Requested-by: Pavel Emelyanov <xemul@parallels.com>
> ---
>  fs/proc/task_mmu.c |   12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index acee5fd..b1d9729 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -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;

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?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RFC 2/3] proc/smaps: show amount of nonlinear ptes in vma
  2012-05-01 17:39   ` KOSAKI Motohiro
@ 2012-05-01 17:56     ` Konstantin Khlebnikov
  2012-05-01 18:08       ` KOSAKI Motohiro
  0 siblings, 1 reply; 11+ messages in thread
From: Konstantin Khlebnikov @ 2012-05-01 17:56 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: linux-mm, linux-kernel, Andrew Morton

KOSAKI Motohiro wrote:
> On Mon, Apr 30, 2012 at 7:29 AM, Konstantin Khlebnikov
> <khlebnikov@openvz.org>  wrote:
>> 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.
>>
>> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
>> Requested-by: Pavel Emelyanov<xemul@parallels.com>
>> ---
>>   fs/proc/task_mmu.c |   12 ++++++++++++
>>   1 file changed, 12 insertions(+)
>>
>> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
>> index acee5fd..b1d9729 100644
>> --- a/fs/proc/task_mmu.c
>> +++ b/fs/proc/task_mmu.c
>> @@ -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;
>
> 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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages
  2012-05-01 17:35   ` KOSAKI Motohiro
@ 2012-05-01 18:05     ` Konstantin Khlebnikov
  2012-05-01 18:14       ` KOSAKI Motohiro
  0 siblings, 1 reply; 11+ messages in thread
From: Konstantin Khlebnikov @ 2012-05-01 18:05 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: linux-mm, linux-kernel, Andrew Morton, Andi Kleen

KOSAKI Motohiro wrote:
> On Mon, Apr 30, 2012 at 7:29 AM, Konstantin Khlebnikov
> <khlebnikov@openvz.org>  wrote:
>> This 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.
>
> 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RFC 2/3] proc/smaps: show amount of nonlinear ptes in vma
  2012-05-01 17:56     ` Konstantin Khlebnikov
@ 2012-05-01 18:08       ` KOSAKI Motohiro
  0 siblings, 0 replies; 11+ messages in thread
From: KOSAKI Motohiro @ 2012-05-01 18:08 UTC (permalink / raw)
  To: Konstantin Khlebnikov; +Cc: linux-mm, linux-kernel, Andrew Morton

On Tue, May 1, 2012 at 1:56 PM, Konstantin Khlebnikov
<khlebnikov@openvz.org> wrote:
> KOSAKI Motohiro wrote:
>>
>> On Mon, Apr 30, 2012 at 7:29 AM, Konstantin Khlebnikov
>> <khlebnikov@openvz.org>  wrote:
>>>
>>> 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.
>>>
>>> Signed-off-by: Konstantin Khlebnikov<khlebnikov@openvz.org>
>>> Requested-by: Pavel Emelyanov<xemul@parallels.com>
>>> ---
>>>  fs/proc/task_mmu.c |   12 ++++++++++++
>>>  1 file changed, 12 insertions(+)
>>>
>>> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
>>> index acee5fd..b1d9729 100644
>>> --- a/fs/proc/task_mmu.c
>>> +++ b/fs/proc/task_mmu.c
>>> @@ -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;
>>
>>
>> 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.

I meant, is there any worth?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages
  2012-05-01 18:05     ` Konstantin Khlebnikov
@ 2012-05-01 18:14       ` KOSAKI Motohiro
  2012-05-31 20:12         ` Andrew Morton
  0 siblings, 1 reply; 11+ messages in thread
From: KOSAKI Motohiro @ 2012-05-01 18:14 UTC (permalink / raw)
  To: Konstantin Khlebnikov; +Cc: linux-mm, linux-kernel, Andrew Morton, Andi Kleen

On Tue, May 1, 2012 at 2:05 PM, Konstantin Khlebnikov
<khlebnikov@openvz.org> wrote:
> KOSAKI Motohiro wrote:
>>
>> On Mon, Apr 30, 2012 at 7:29 AM, Konstantin Khlebnikov
>> <khlebnikov@openvz.org>  wrote:
>>>
>>> This 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.
>>
>>
>> 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

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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages
  2012-04-30 11:29 ` [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages Konstantin Khlebnikov
  2012-05-01 17:35   ` KOSAKI Motohiro
@ 2012-05-01 18:29   ` Andi Kleen
  1 sibling, 0 replies; 11+ messages in thread
From: Andi Kleen @ 2012-05-01 18:29 UTC (permalink / raw)
  To: Konstantin Khlebnikov; +Cc: linux-mm, linux-kernel, Andrew Morton, Andi Kleen

On Mon, Apr 30, 2012 at 03:29:11PM +0400, Konstantin Khlebnikov wrote:
> This 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.

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.

Acked-by: Andi Kleen <ak@linux.intel.com>

-Andi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages
  2012-05-01 18:14       ` KOSAKI Motohiro
@ 2012-05-31 20:12         ` Andrew Morton
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew Morton @ 2012-05-31 20:12 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: Konstantin Khlebnikov, linux-mm, linux-kernel, Andi Kleen

On Tue, 1 May 2012 14:14:57 -0400
KOSAKI Motohiro <kosaki.motohiro@gmail.com> wrote:

> On Tue, May 1, 2012 at 2:05 PM, Konstantin Khlebnikov
> <khlebnikov@openvz.org> wrote:
> > KOSAKI Motohiro wrote:
> >>
> >> On Mon, Apr 30, 2012 at 7:29 AM, Konstantin Khlebnikov
> >> <khlebnikov@openvz.org> __wrote:
> >>>
> >>> This 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.
> >>
> >>
> >> 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
> 
> 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 <khlebnikov@openvz.org>
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.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Acked-by: Andi Kleen <ak@linux.intel.com>
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/proc/task_mmu.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff -puN fs/proc/task_mmu.c~proc-smaps-show-amount-of-hwpoison-pages fs/proc/task_mmu.c
--- a/fs/proc/task_mmu.c~proc-smaps-show-amount-of-hwpoison-pages
+++ a/fs/proc/task_mmu.c
@@ -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;
_


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-05-31 20:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-30 11:29 [PATCH RFC 1/3] proc/smaps: carefully handle migration entries Konstantin Khlebnikov
2012-04-30 11:29 ` [PATCH RFC 2/3] proc/smaps: show amount of nonlinear ptes in vma Konstantin Khlebnikov
2012-05-01 17:39   ` KOSAKI Motohiro
2012-05-01 17:56     ` Konstantin Khlebnikov
2012-05-01 18:08       ` KOSAKI Motohiro
2012-04-30 11:29 ` [PATCH RFC 3/3] proc/smaps: show amount of hwpoison pages Konstantin Khlebnikov
2012-05-01 17:35   ` KOSAKI Motohiro
2012-05-01 18:05     ` Konstantin Khlebnikov
2012-05-01 18:14       ` KOSAKI Motohiro
2012-05-31 20:12         ` Andrew Morton
2012-05-01 18:29   ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).