Commit 21c9e90a authored by Miaohe Lin's avatar Miaohe Lin Committed by Andrew Morton

mm, hwpoison: use num_poisoned_pages_sub() to decrease num_poisoned_pages

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.

Link: https://lkml.kernel.org/r/20220830123604.25763-4-linmiaohe@huawei.comSigned-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Acked-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent da294991
......@@ -485,11 +485,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);
......
......@@ -2602,7 +2602,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
......@@ -2615,8 +2615,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);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment