diff mbox series

mm/hwpoison: reset hwpoison filter parameters in pfn_inject_exit()

Message ID 20240715102806.2638849-1-linmiaohe@huawei.com (mailing list archive)
State New
Headers show
Series mm/hwpoison: reset hwpoison filter parameters in pfn_inject_exit() | expand

Commit Message

Miaohe Lin July 15, 2024, 10:28 a.m. UTC
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>
---
 mm/hwpoison-inject.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Andrew Morton July 15, 2024, 8:33 p.m. UTC | #1
On Mon, 15 Jul 2024 18:28:06 +0800 Miaohe Lin <linmiaohe@huawei.com> wrote:

> When hwpoison_inject module is removed, hwpoison_filter_* parameters
> should be reset. Otherwise these parameters will have non-default values
> at next insmod time.
> 
> ...
>
> --- a/mm/hwpoison-inject.c
> +++ b/mm/hwpoison-inject.c
> @@ -64,9 +64,20 @@ 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);
>  }

The new reset_hwpoison_filter() has no callers?
Miaohe Lin July 16, 2024, 2:37 a.m. UTC | #2
On 2024/7/16 4:33, Andrew Morton wrote:
> On Mon, 15 Jul 2024 18:28:06 +0800 Miaohe Lin <linmiaohe@huawei.com> wrote:
> 
>> When hwpoison_inject module is removed, hwpoison_filter_* parameters
>> should be reset. Otherwise these parameters will have non-default values
>> at next insmod time.
>>
>> ...
>>
>> --- a/mm/hwpoison-inject.c
>> +++ b/mm/hwpoison-inject.c
>> @@ -64,9 +64,20 @@ 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);
>>  }
> 
> The new reset_hwpoison_filter() has no callers?

I'm sorry but I can't figure out why that's missed. I remember I tested this patch
and queued it... Will send a new version and re-test it.
Thanks.
.
diff mbox series

Patch

diff --git a/mm/hwpoison-inject.c b/mm/hwpoison-inject.c
index 7ecaa1900137..b0bd11133a1d 100644
--- a/mm/hwpoison-inject.c
+++ b/mm/hwpoison-inject.c
@@ -64,9 +64,20 @@  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);
 }