linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: <akpm@linux-foundation.org>
Cc: <nao.horiguchi@gmail.com>, <linmiaohe@huawei.com>,
	<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v2] mm/hwpoison: reset hwpoison filter parameters in pfn_inject_exit()
Date: Tue, 16 Jul 2024 11:35:16 +0800	[thread overview]
Message-ID: <20240716033516.606582-1-linmiaohe@huawei.com> (raw)

When hwpoison_inject module is removed, hwpoison_filter_* parameters
should be reset. Otherwise these parameters will have non-default values
at next insmod time.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
v2:
 Add missing call to reset_hwpoison_filter() per Andrew. Thanks.
---
 mm/hwpoison-inject.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/mm/hwpoison-inject.c b/mm/hwpoison-inject.c
index 7ecaa1900137..0b855cd3433a 100644
--- a/mm/hwpoison-inject.c
+++ b/mm/hwpoison-inject.c
@@ -64,10 +64,22 @@ static int hwpoison_unpoison(void *data, u64 val)
 DEFINE_DEBUGFS_ATTRIBUTE(hwpoison_fops, NULL, hwpoison_inject, "%lli\n");
 DEFINE_DEBUGFS_ATTRIBUTE(unpoison_fops, NULL, hwpoison_unpoison, "%lli\n");
 
-static void __exit pfn_inject_exit(void)
+static inline void reset_hwpoison_filter(void)
 {
 	hwpoison_filter_enable = 0;
+	hwpoison_filter_dev_major = ~0U;
+	hwpoison_filter_dev_minor = ~0U;
+	hwpoison_filter_flags_mask = 0;
+	hwpoison_filter_flags_value = 0;
+#ifdef CONFIG_MEMCG
+	hwpoison_filter_memcg = 0;
+#endif
+}
+
+static void __exit pfn_inject_exit(void)
+{
 	debugfs_remove_recursive(hwpoison_dir);
+	reset_hwpoison_filter();
 }
 
 static int __init pfn_inject_init(void)
-- 
2.33.0



             reply	other threads:[~2024-07-16  3:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-16  3:35 Miaohe Lin [this message]
2024-07-16  8:38 ` Michal Hocko
2024-07-17  2:23   ` Miaohe Lin
2024-07-17  6:18     ` Michal Hocko
2024-07-17  6:59       ` Miaohe Lin
2024-07-17  7:25         ` Michal Hocko
2024-07-17  7:48           ` Miaohe Lin

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=20240716033516.606582-1-linmiaohe@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nao.horiguchi@gmail.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