Re: [PATCH] mm: soft-offline: fix num_poisoned_pages counting on concurrent events

2015-04-23 Thread Dean Nelson
On 04/20/2015 11:18 PM, Naoya Horiguchi wrote:
> If multiple soft offline events hit one free page/hugepage concurrently,
> soft_offline_page() can handle the free page/hugepage multiple times,
> which makes num_poisoned_pages counter increased more than once.
> This patch fixes this wrong counting by checking TestSetPageHWPoison for
> normal papes and by checking the return value of 
> dequeue_hwpoisoned_huge_page()
> for hugepages.
> 
> Signed-off-by: Naoya Horiguchi 

Acked-by: Dean Nelson 


> Cc: sta...@vger.kernel.org  # v3.14+
> ---
> # This problem might happen before 3.14, but it's rare and non-critical,
> # so I want this patch to be backported to stable trees only if the patch
> # cleanly applies (i.e. v3.14+).
> ---
>   mm/memory-failure.c | 8 
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git v4.0.orig/mm/memory-failure.c v4.0/mm/memory-failure.c
> index 2cc1d578144b..72a5224c8084 100644
> --- v4.0.orig/mm/memory-failure.c
> +++ v4.0/mm/memory-failure.c
> @@ -1721,12 +1721,12 @@ int soft_offline_page(struct page *page, int flags)
>   } else if (ret == 0) { /* for free pages */
>   if (PageHuge(page)) {
>   set_page_hwpoison_huge_page(hpage);
> - dequeue_hwpoisoned_huge_page(hpage);
> - atomic_long_add(1 << compound_order(hpage),
> + if (!dequeue_hwpoisoned_huge_page(hpage))
> + atomic_long_add(1 << compound_order(hpage),
>   _poisoned_pages);
>   } else {
> - SetPageHWPoison(page);
> - atomic_long_inc(_poisoned_pages);
> + if (!TestSetPageHWPoison(page))
> + atomic_long_inc(_poisoned_pages);
>   }
>   }
>   unset_migratetype_isolate(page, MIGRATE_MOVABLE);
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mm: soft-offline: fix num_poisoned_pages counting on concurrent events

2015-04-23 Thread Dean Nelson
On 04/20/2015 11:18 PM, Naoya Horiguchi wrote:
 If multiple soft offline events hit one free page/hugepage concurrently,
 soft_offline_page() can handle the free page/hugepage multiple times,
 which makes num_poisoned_pages counter increased more than once.
 This patch fixes this wrong counting by checking TestSetPageHWPoison for
 normal papes and by checking the return value of 
 dequeue_hwpoisoned_huge_page()
 for hugepages.
 
 Signed-off-by: Naoya Horiguchi n-horigu...@ah.jp.nec.com

Acked-by: Dean Nelson dnel...@redhat.com


 Cc: sta...@vger.kernel.org  # v3.14+
 ---
 # This problem might happen before 3.14, but it's rare and non-critical,
 # so I want this patch to be backported to stable trees only if the patch
 # cleanly applies (i.e. v3.14+).
 ---
   mm/memory-failure.c | 8 
   1 file changed, 4 insertions(+), 4 deletions(-)
 
 diff --git v4.0.orig/mm/memory-failure.c v4.0/mm/memory-failure.c
 index 2cc1d578144b..72a5224c8084 100644
 --- v4.0.orig/mm/memory-failure.c
 +++ v4.0/mm/memory-failure.c
 @@ -1721,12 +1721,12 @@ int soft_offline_page(struct page *page, int flags)
   } else if (ret == 0) { /* for free pages */
   if (PageHuge(page)) {
   set_page_hwpoison_huge_page(hpage);
 - dequeue_hwpoisoned_huge_page(hpage);
 - atomic_long_add(1  compound_order(hpage),
 + if (!dequeue_hwpoisoned_huge_page(hpage))
 + atomic_long_add(1  compound_order(hpage),
   num_poisoned_pages);
   } else {
 - SetPageHWPoison(page);
 - atomic_long_inc(num_poisoned_pages);
 + if (!TestSetPageHWPoison(page))
 + atomic_long_inc(num_poisoned_pages);
   }
   }
   unset_migratetype_isolate(page, MIGRATE_MOVABLE);
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mm: soft-offline: fix num_poisoned_pages counting on concurrent events

2015-04-20 Thread Naoya Horiguchi
If multiple soft offline events hit one free page/hugepage concurrently,
soft_offline_page() can handle the free page/hugepage multiple times,
which makes num_poisoned_pages counter increased more than once.
This patch fixes this wrong counting by checking TestSetPageHWPoison for
normal papes and by checking the return value of dequeue_hwpoisoned_huge_page()
for hugepages.

Signed-off-by: Naoya Horiguchi 
Cc: sta...@vger.kernel.org  # v3.14+
---
# This problem might happen before 3.14, but it's rare and non-critical,
# so I want this patch to be backported to stable trees only if the patch
# cleanly applies (i.e. v3.14+).
---
 mm/memory-failure.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git v4.0.orig/mm/memory-failure.c v4.0/mm/memory-failure.c
index 2cc1d578144b..72a5224c8084 100644
--- v4.0.orig/mm/memory-failure.c
+++ v4.0/mm/memory-failure.c
@@ -1721,12 +1721,12 @@ int soft_offline_page(struct page *page, int flags)
} else if (ret == 0) { /* for free pages */
if (PageHuge(page)) {
set_page_hwpoison_huge_page(hpage);
-   dequeue_hwpoisoned_huge_page(hpage);
-   atomic_long_add(1 << compound_order(hpage),
+   if (!dequeue_hwpoisoned_huge_page(hpage))
+   atomic_long_add(1 << compound_order(hpage),
_poisoned_pages);
} else {
-   SetPageHWPoison(page);
-   atomic_long_inc(_poisoned_pages);
+   if (!TestSetPageHWPoison(page))
+   atomic_long_inc(_poisoned_pages);
}
}
unset_migratetype_isolate(page, MIGRATE_MOVABLE);
-- 
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] mm: soft-offline: fix num_poisoned_pages counting on concurrent events

2015-04-20 Thread Naoya Horiguchi
If multiple soft offline events hit one free page/hugepage concurrently,
soft_offline_page() can handle the free page/hugepage multiple times,
which makes num_poisoned_pages counter increased more than once.
This patch fixes this wrong counting by checking TestSetPageHWPoison for
normal papes and by checking the return value of dequeue_hwpoisoned_huge_page()
for hugepages.

Signed-off-by: Naoya Horiguchi n-horigu...@ah.jp.nec.com
Cc: sta...@vger.kernel.org  # v3.14+
---
# This problem might happen before 3.14, but it's rare and non-critical,
# so I want this patch to be backported to stable trees only if the patch
# cleanly applies (i.e. v3.14+).
---
 mm/memory-failure.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git v4.0.orig/mm/memory-failure.c v4.0/mm/memory-failure.c
index 2cc1d578144b..72a5224c8084 100644
--- v4.0.orig/mm/memory-failure.c
+++ v4.0/mm/memory-failure.c
@@ -1721,12 +1721,12 @@ int soft_offline_page(struct page *page, int flags)
} else if (ret == 0) { /* for free pages */
if (PageHuge(page)) {
set_page_hwpoison_huge_page(hpage);
-   dequeue_hwpoisoned_huge_page(hpage);
-   atomic_long_add(1  compound_order(hpage),
+   if (!dequeue_hwpoisoned_huge_page(hpage))
+   atomic_long_add(1  compound_order(hpage),
num_poisoned_pages);
} else {
-   SetPageHWPoison(page);
-   atomic_long_inc(num_poisoned_pages);
+   if (!TestSetPageHWPoison(page))
+   atomic_long_inc(num_poisoned_pages);
}
}
unset_migratetype_isolate(page, MIGRATE_MOVABLE);
-- 
2.1.0
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/