linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: <akpm@linux-foundation.org>, <naoya.horiguchi@nec.com>
Cc: <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>,
	<linmiaohe@huawei.com>
Subject: [PATCH 3/6] mm, hwpoison: use num_poisoned_pages_sub() to decrease num_poisoned_pages
Date: Tue, 30 Aug 2022 20:36:01 +0800	[thread overview]
Message-ID: <20220830123604.25763-4-linmiaohe@huawei.com> (raw)
In-Reply-To: <20220830123604.25763-1-linmiaohe@huawei.com>

Use num_poisoned_pages_sub() to combine multiple atomic ops into one. Also
num_poisoned_pages_dec() can be killed as there's no caller now.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 include/linux/swapops.h | 5 -----
 mm/memory-failure.c     | 6 ++++--
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/include/linux/swapops.h b/include/linux/swapops.h
index dbf9df854124..86b95ccb81bb 100644
--- a/include/linux/swapops.h
+++ b/include/linux/swapops.h
@@ -602,11 +602,6 @@ static inline void num_poisoned_pages_inc(void)
 	atomic_long_inc(&num_poisoned_pages);
 }
 
-static inline void num_poisoned_pages_dec(void)
-{
-	atomic_long_dec(&num_poisoned_pages);
-}
-
 static inline void num_poisoned_pages_sub(long i)
 {
 	atomic_long_sub(i, &num_poisoned_pages);
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 3966fa6abe03..69c4d1b48ad6 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2596,7 +2596,7 @@ int soft_offline_page(unsigned long pfn, int flags)
 
 void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
 {
-	int i;
+	int i, total = 0;
 
 	/*
 	 * A further optimization is to have per section refcounted
@@ -2609,8 +2609,10 @@ void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
 
 	for (i = 0; i < nr_pages; i++) {
 		if (PageHWPoison(&memmap[i])) {
-			num_poisoned_pages_dec();
+			total++;
 			ClearPageHWPoison(&memmap[i]);
 		}
 	}
+	if (total)
+		num_poisoned_pages_sub(total);
 }
-- 
2.23.0



  parent reply	other threads:[~2022-08-30 12:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-30 12:35 [PATCH 0/6] A few cleanup patches for memory-failure Miaohe Lin
2022-08-30 12:35 ` [PATCH 1/6] mm, hwpoison: use ClearPageHWPoison() in memory_failure() Miaohe Lin
2022-09-05  5:23   ` HORIGUCHI NAOYA(堀口 直也)
2022-08-30 12:36 ` [PATCH 2/6] mm, hwpoison: use __PageMovable() to detect non-lru movable pages Miaohe Lin
2022-09-05  5:22   ` HORIGUCHI NAOYA(堀口 直也)
2022-09-05  6:53     ` Miaohe Lin
2022-09-05  7:15       ` HORIGUCHI NAOYA(堀口 直也)
2022-09-05  7:29         ` Miaohe Lin
2022-09-05 21:53           ` Andrew Morton
2022-09-06  1:07             ` Miaohe Lin
2022-08-30 12:36 ` Miaohe Lin [this message]
2022-09-05  5:24   ` [PATCH 3/6] mm, hwpoison: use num_poisoned_pages_sub() to decrease num_poisoned_pages HORIGUCHI NAOYA(堀口 直也)
2022-08-30 12:36 ` [PATCH 4/6] mm, hwpoison: avoid unneeded page_mapped_in_vma() overhead in collect_procs_anon() Miaohe Lin
2022-09-05  5:24   ` HORIGUCHI NAOYA(堀口 直也)
2022-08-30 12:36 ` [PATCH 5/6] mm, hwpoison: check PageTable() explicitly in hwpoison_user_mappings() Miaohe Lin
2022-09-05  5:25   ` HORIGUCHI NAOYA(堀口 直也)
2022-08-30 12:36 ` [PATCH 6/6] mm, hwpoison: cleanup some obsolete comments Miaohe Lin
2022-09-05  5:25   ` HORIGUCHI NAOYA(堀口 直也)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220830123604.25763-4-linmiaohe@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=naoya.horiguchi@nec.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox