From patchwork Tue Aug 30 12:35:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12959265 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 C7E8EECAAD4 for ; Tue, 30 Aug 2022 12:36:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 634A76B0075; Tue, 30 Aug 2022 08:36:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 56FBA6B0074; 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 261056B0075; 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 09EAA6B0074 for ; Tue, 30 Aug 2022 08:36:39 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D8F9041166 for ; Tue, 30 Aug 2022 12:36:38 +0000 (UTC) X-FDA: 79856207676.04.7A51F02 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf19.hostedemail.com (Postfix) with ESMTP id 212711A001F for ; Tue, 30 Aug 2022 12:36:37 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MH6Fh0mcwzHnV7; Tue, 30 Aug 2022 20:34:48 +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 1/6] mm, hwpoison: use ClearPageHWPoison() in memory_failure() Date: Tue, 30 Aug 2022 20:35:59 +0800 Message-ID: <20220830123604.25763-2-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=BgURznQKGGxHQfSWjK7nEbpIP7ocpTIq1G1gnZRUMoL4yxWqtqFx0boZDzuKxgHFjRwLCO ieJM7zp/kBy9lH/mqsG/9x1gUyqlVgwR0K2WlRJQ7JpPdHFytPcvliPFZr6nQdPc9VYrjp hc84W8Bp7b3cZy732NUXY1o1tyq6yJw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=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=I4E8HX7jVlpzlObdp7l9t4A2vZLO+WBcTPrMgqSR+jg=; b=4/iftO9iwK8pDNZrmXwQ/oKHm2/KjsUJqNWOXqpBuNKdX4LCwvQajMd0SRq/zjm55exxrh FUo5h2g3o0vFMkGcKfnVJpwa3bDPcuBLaA0UrqUKzg4q88DPzTZOexiaPQ2ZDth03snBa+ nTECoe2vRu/E9voQUnFSPvTuCuF/fn8= Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: e1ahcp9wgofp9tomh35p1d11k1bwf3ut X-Rspamd-Queue-Id: 212711A001F X-HE-Tag: 1661862997-989934 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 ClearPageHWPoison() instead of TestClearPageHWPoison() to clear page hwpoison flags to avoid unneeded full memory barrier overhead. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index ebf16d177ee5..a923a6dde871 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2128,7 +2128,7 @@ int memory_failure(unsigned long pfn, int flags) page_flags = p->flags; if (hwpoison_filter(p)) { - TestClearPageHWPoison(p); + ClearPageHWPoison(p); unlock_page(p); put_page(p); res = -EOPNOTSUPP; From patchwork Tue Aug 30 12:36:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12959266 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 6FAD6ECAAA1 for ; Tue, 30 Aug 2022 12:36:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9242C6B0074; Tue, 30 Aug 2022 08:36:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 855C5940008; 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 487CF940007; 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 27BA06B0074 for ; Tue, 30 Aug 2022 08:36:39 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 01455160CFB for ; Tue, 30 Aug 2022 12:36:38 +0000 (UTC) X-FDA: 79856207718.27.6673636 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf05.hostedemail.com (Postfix) with ESMTP id 35D3B10000B for ; Tue, 30 Aug 2022 12:36:38 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MH6Fh3fQkzHnVM; Tue, 30 Aug 2022 20:34:48 +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 2/6] mm, hwpoison: use __PageMovable() to detect non-lru movable pages Date: Tue, 30 Aug 2022 20:36:00 +0800 Message-ID: <20220830123604.25763-3-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-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=Y1McSJydXoxcwnnSt53LN6QCFXnwsUyAG9rVoZ/5U6E=; b=637Qge95pawbrSzf7aSAPwgfMhrWExsgr89BsLL7xgJNwHvYeS237iqDBwX3o4DMSgCv5L cbXgZl0oyYqOcfKW90/FIKqR3uL2AShCKOhXkmM8faoCSZ5z2RjAwqrledzo4usakbVk/n iNClMc7QJW0V0/Wu7UXRExqjYNxlJnc= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661862998; a=rsa-sha256; cv=none; b=BjAi8DjPoMp38Gb4916+Sn/g+lmuwW2y4i9xn+Txtxyq6L+zttMcJTN8oQjdf6pq6M8Apq Jrsg0Mdp9fIbIfiYrRxMhtrkAlANkj2KfUM9yj0UG6g7DyCRL7cYC50sxHvNtOssvqNNNC njUYEOB5PqJBVYcXC22QYezlbNVq8dc= X-Stat-Signature: 7duenpntztzheibshp57fqy47xfrg94i X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 35D3B10000B Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-HE-Tag: 1661862998-75880 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: It's more recommended to use __PageMovable() to detect non-lru movable pages. We can avoid bumping page refcnt via isolate_movable_page() for the isolated lru pages. Also if pages become PageLRU just after they're checked but before trying to isolate them, isolate_lru_page() will be called to do the right work. Signed-off-by: Miaohe Lin Signed-off-by: Andrew Morton --- mm/memory-failure.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index a923a6dde871..3966fa6abe03 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2404,7 +2404,7 @@ EXPORT_SYMBOL(unpoison_memory); static bool isolate_page(struct page *page, struct list_head *pagelist) { bool isolated = false; - bool lru = PageLRU(page); + bool lru = !__PageMovable(page); if (PageHuge(page)) { isolated = !isolate_hugetlb(page, pagelist); 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); } From patchwork Tue Aug 30 12:36:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12959264 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 C1787ECAAA1 for ; Tue, 30 Aug 2022 12:36:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 384566B0073; Tue, 30 Aug 2022 08:36:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3262D6B0078; 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 1C5F6940007; Tue, 30 Aug 2022 08:36:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0620D6B0073 for ; Tue, 30 Aug 2022 08:36:39 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DBADB1A1136 for ; Tue, 30 Aug 2022 12:36:38 +0000 (UTC) X-FDA: 79856207676.03.8FBCEDD Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf09.hostedemail.com (Postfix) with ESMTP id 266F6140050 for ; Tue, 30 Aug 2022 12:36:37 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MH6Fj29qJzHnVZ; Tue, 30 Aug 2022 20:34:49 +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:35 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH 4/6] mm, hwpoison: avoid unneeded page_mapped_in_vma() overhead in collect_procs_anon() Date: Tue, 30 Aug 2022 20:36:02 +0800 Message-ID: <20220830123604.25763-5-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-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661862998; a=rsa-sha256; cv=none; b=UU7lGrLKZnVy7f6+OFXW0+ihnWJWwCwx17mD1mXtABr5UyaW88qYBhJBKXGj6E17vUgTv9 41SadaH3ngl4WpNdm/DsdIBmKVhsnfZCBdsOHe9TrQdyML8UENOVqVmgVtvQlPecLO5VYA obhTvrblmniQ1npw8eQxKSmx4hj0hLU= 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=dK6CV2X06mZNvQjmKnfLI9JARRAkiesBdiNMs7+r5Tk=; b=oX2nxlL9xqLbyrkEDoxAmD9AqP2zipDBVOlrZOIEQWtHXfIK2Q/gzCoII/GOvntoFYpXsj rpl8L/ehBH+vuhWyirNMARW3UdFNxT5n/ZQfqGVw8Wl57XcISEo5rUYFVW68+BtCFjzgGK kX8QLyTIu5bZil3EtEiahEv4CV7wlpI= Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: ddji8x8omjbg31ruzo4q7hyj5jshn9j9 X-Rspamd-Queue-Id: 266F6140050 X-HE-Tag: 1661862997-680521 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: If vma->vm_mm != t->mm, there's no need to call page_mapped_in_vma() as add_to_kill() won't be called in this case. Move up the mm check to avoid possible unneeded calling to page_mapped_in_vma(). Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 69c4d1b48ad6..904c2b6284a4 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -521,11 +521,11 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill, anon_vma_interval_tree_foreach(vmac, &av->rb_root, pgoff, pgoff) { vma = vmac->vma; + if (vma->vm_mm != t->mm) + continue; if (!page_mapped_in_vma(page, vma)) continue; - if (vma->vm_mm == t->mm) - add_to_kill(t, page, FSDAX_INVALID_PGOFF, vma, - to_kill); + add_to_kill(t, page, FSDAX_INVALID_PGOFF, vma, to_kill); } } read_unlock(&tasklist_lock); From patchwork Tue Aug 30 12:36:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12959270 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 1541DC0502C for ; Tue, 30 Aug 2022 12:36:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB3AA94000B; Tue, 30 Aug 2022 08:36:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B723B940009; Tue, 30 Aug 2022 08:36:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9DBAF94000B; Tue, 30 Aug 2022 08:36:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 87555940009 for ; Tue, 30 Aug 2022 08:36:40 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5ED9FC0507 for ; Tue, 30 Aug 2022 12:36:40 +0000 (UTC) X-FDA: 79856207760.03.5B18ECC Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf19.hostedemail.com (Postfix) with ESMTP id 9D0841A001A for ; Tue, 30 Aug 2022 12:36:39 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MH6CY57dmzkWTX; Tue, 30 Aug 2022 20:32:57 +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:35 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH 5/6] mm, hwpoison: check PageTable() explicitly in hwpoison_user_mappings() Date: Tue, 30 Aug 2022 20:36:03 +0800 Message-ID: <20220830123604.25763-6-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-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661862999; a=rsa-sha256; cv=none; b=EinI9KqZOBMdpVnFh22D6AqFqx8C/1QOasJxkgZ4Y7Lv3yhv3PvXmKNrVg9r6Gchc7KMPH NjNflc82b/G7mK7Z2hnAGsQUzMTqnAZuc82+BY1CELAYaDpAK4mzqPg4cxqxJpLE5Z8g/P H8jANxGb60tt2HTa97PHKoqjggt2Ai4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661862999; 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=44BMtSYa6dzUww3mjun54BPNxCqTaX6/MVtuJzTRgOk=; b=8cWHLsa4u9iRwpk+ENTQhzD66Zy4ie5kSML8r0wAnIv3N/j2TpVaU06JPqWRPPqxubGH++ 6OuBCxnosNFRWh4y7ZkTrgURU2zpZyuuXFlYXCns4KvqfyAp8MqI+7/gRKzGKbNxnDTBvE r7lgP+F+fOZFPQxLD5nL85d6pNt5OOw= X-Stat-Signature: cctjac8i3ikhiunufbk5ob51pq44q9tx X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=none; spf=pass (imf19.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9D0841A001A X-HE-Tag: 1661862999-418109 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: PageTable can't be handled by memory_failure(). Filter it out explicitly in hwpoison_user_mappings(). This will also make code more consistent with the relevant check in unpoison_memory(). Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 904c2b6284a4..fb6a10005109 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1406,7 +1406,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, * Here we are interested only in user-mapped pages, so skip any * other types of pages. */ - if (PageReserved(p) || PageSlab(p)) + if (PageReserved(p) || PageSlab(p) || PageTable(p)) return true; if (!(PageLRU(hpage) || PageHuge(p))) return true; From patchwork Tue Aug 30 12:36:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12959269 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 9D9CEECAAD4 for ; Tue, 30 Aug 2022 12:36:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59A13940007; Tue, 30 Aug 2022 08:36:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5095294000B; Tue, 30 Aug 2022 08:36:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28898940007; Tue, 30 Aug 2022 08:36:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id ECCBB940007 for ; Tue, 30 Aug 2022 08:36:39 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D0F9E41318 for ; Tue, 30 Aug 2022 12:36:39 +0000 (UTC) X-FDA: 79856207718.30.91C2F61 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf11.hostedemail.com (Postfix) with ESMTP id 1744340027 for ; Tue, 30 Aug 2022 12:36:38 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MH6CZ3n1Bz1N7J3; Tue, 30 Aug 2022 20:32:58 +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:36 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH 6/6] mm, hwpoison: cleanup some obsolete comments Date: Tue, 30 Aug 2022 20:36:04 +0800 Message-ID: <20220830123604.25763-7-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=1661862999; a=rsa-sha256; cv=none; b=IcGOeKoovaYNuHX0BHdscKBZWphTX9VUxtNus3e4GfrGkCjR79NUMIuizWEhUCWOonILWZ N+QGbhNqGt4AstSCSE60NqAH3dzaCXi9nFUBd+XqzKo4MHSCiYV43Y1tzayardN/YlXhYP nGbFKg1y5udkpSTHAI51bghykEEY31Y= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 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=1661862999; 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=4P395rMGd26gHCwgpyjxNFbEx9ZbyATmNKl13s6uNhM=; b=saMvfaITwS80Nw9Etg8997VVzCeVZKmAOh8yuF5MDI7fp3BX16mwISwmuJ8zbZq1XEcQln WM3bnb6Tcw8k73mLvMqAX22vSV9Hsbc/NGvwqxVeq20l0/6fmyVJ25WI1+PqWuJ8V6U1RK uRjTap1ede9t8VNbnSxAAUdvt5kIBDI= X-Stat-Signature: u8wfk9ghufhfs75twwpumh19tg77hcug X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 1744340027 Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Rspam-User: X-HE-Tag: 1661862998-783493 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: 1.Remove meaningless comment in kill_proc(). That doesn't tell anything. 2.Fix the wrong function name get_hwpoison_unless_zero(). It should be get_page_unless_zero(). 3.The gate keeper for free hwpoison page has moved to check_new_page(). Update the corresponding comment. Signed-off-by: Miaohe Lin Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index fb6a10005109..df3bf266eebf 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -277,7 +277,7 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags) * to SIG_IGN, but hopefully no one will do that? */ ret = send_sig_mceerr(BUS_MCEERR_AO, (void __user *)tk->addr, - addr_lsb, t); /* synchronous? */ + addr_lsb, t); if (ret < 0) pr_info("Error sending signal to %s:%d: %d\n", t->comm, t->pid, ret); @@ -1246,9 +1246,9 @@ static int __get_hwpoison_page(struct page *page, unsigned long flags) return ret; /* - * This check prevents from calling get_hwpoison_unless_zero() - * for any unsupported type of page in order to reduce the risk of - * unexpected races caused by taking a page refcount. + * This check prevents from calling get_page_unless_zero() for any + * unsupported type of page in order to reduce the risk of unexpected + * races caused by taking a page refcount. */ if (!HWPoisonHandlable(head, flags)) return -EBUSY; @@ -2025,7 +2025,7 @@ int memory_failure(unsigned long pfn, int flags) /* * We need/can do nothing about count=0 pages. * 1) it's a free page, and therefore in safe hand: - * prep_new_page() will be the gate keeper. + * check_new_page() will be the gate keeper. * 2) it's part of a non-compound high order page. * Implies some kernel user: cannot stop them from * R/W the page; let's pray that the page has been