From patchwork Tue Aug 30 12:36:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12959267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E884BECAAD4 for ; Tue, 30 Aug 2022 12:36:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CEFD7940008; Tue, 30 Aug 2022 08:36:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C0EAA940009; Tue, 30 Aug 2022 08:36:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CAB56B007B; Tue, 30 Aug 2022 08:36:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 671976B0078 for ; Tue, 30 Aug 2022 08:36:39 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4284A1C5CF2 for ; Tue, 30 Aug 2022 12:36:39 +0000 (UTC) X-FDA: 79856207718.19.AE447DD Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf21.hostedemail.com (Postfix) with ESMTP id 563211C0040 for ; Tue, 30 Aug 2022 12:36:38 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MH6Dx4Y3VznTjS; Tue, 30 Aug 2022 20:34:09 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 30 Aug 2022 20:36:34 +0800 From: Miaohe Lin To: , CC: , , 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 Message-ID: <20220830123604.25763-4-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220830123604.25763-1-linmiaohe@huawei.com> References: <20220830123604.25763-1-linmiaohe@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661862998; a=rsa-sha256; cv=none; b=n4bAhm5RBqBafmphURf5uhO1eC3+6gIBPXmBayey+JMv1DaZHAvqKQxiGs8cQ/7pyZwzT2 Snr0MUEu/ognbkepXi+8vsRy3il/4clN9f8ZXfiyqoa1UryEyyNS6VrwaRrkPZ5rX1F3BD 8Tlc2cNkGDAVqDkkkkcQjwI55QAXIq0= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661862998; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XhVydFNg7RC7PkO7/4fbPcXGn5p2pKzeftNQoVpGfcQ=; b=tdPxVTZC5aRpe7Gl/BbeLjxbFBG0aatgpO9WW3DRhl416cYyxp5Y3eDkyBD2nvIc06LIkr XnOHLGRRjDJvyRmXdvnAE1yLJwAesVhSOufnSSZF+3VN0HLQsKojFFabb8f1FxOic/I7D3 nw6A7tJAAWzpiAY4e7Ad7YlzXfiz2+I= X-Rspam-User: X-Rspamd-Queue-Id: 563211C0040 X-Rspamd-Server: rspam12 X-Stat-Signature: aimdpbxnnx4rp6mrw8f4y5x7g5nygsy3 Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-HE-Tag: 1661862998-409344 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Acked-by: Naoya Horiguchi --- 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); }