linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] mm/kfence: print disabling or re-enabling message
@ 2022-05-18  1:03 Jackie Liu
  2022-05-18  7:24 ` Marco Elver
  0 siblings, 1 reply; 3+ messages in thread
From: Jackie Liu @ 2022-05-18  1:03 UTC (permalink / raw)
  To: elver; +Cc: glider, liu.yun, dvyukov, kasan-dev, linux-mm

From: Jackie Liu <liuyun01@kylinos.cn>

By printing information, we can friendly prompt the status change
information of kfence by dmesg and record by syslog.

Co-developed-by: Marco Elver <elver@google.com>
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
 v1->v2:
   fixup by Marco Elver <elver@google.com>
 v2->v3:
   write kfence_enabled=false only true before

 mm/kfence/core.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/mm/kfence/core.c b/mm/kfence/core.c
index 11a954763be9..41840b8d9cb3 100644
--- a/mm/kfence/core.c
+++ b/mm/kfence/core.c
@@ -67,8 +67,13 @@ static int param_set_sample_interval(const char *val, const struct kernel_param
 	if (ret < 0)
 		return ret;
 
-	if (!num) /* Using 0 to indicate KFENCE is disabled. */
-		WRITE_ONCE(kfence_enabled, false);
+	/* Using 0 to indicate KFENCE is disabled. */
+	if (!num) {
+		if (READ_ONCE(kfence_enabled)) {
+			pr_info("disabled\n");
+			WRITE_ONCE(kfence_enabled, false);
+		}
+	}
 
 	*((unsigned long *)kp->arg) = num;
 
@@ -874,6 +879,7 @@ static int kfence_enable_late(void)
 
 	WRITE_ONCE(kfence_enabled, true);
 	queue_delayed_work(system_unbound_wq, &kfence_timer, 0);
+	pr_info("re-enabled\n");
 	return 0;
 }
 
-- 
2.25.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] mm/kfence: print disabling or re-enabling message
  2022-05-18  1:03 [PATCH v3] mm/kfence: print disabling or re-enabling message Jackie Liu
@ 2022-05-18  7:24 ` Marco Elver
  2022-05-18  7:26   ` Jackie Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Marco Elver @ 2022-05-18  7:24 UTC (permalink / raw)
  To: Jackie Liu; +Cc: glider, dvyukov, kasan-dev, linux-mm

On Wed, 18 May 2022 at 03:03, Jackie Liu <liu.yun@linux.dev> wrote:
>
> From: Jackie Liu <liuyun01@kylinos.cn>
>
> By printing information, we can friendly prompt the status change
> information of kfence by dmesg and record by syslog.
>
> Co-developed-by: Marco Elver <elver@google.com>
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> ---
>  v1->v2:
>    fixup by Marco Elver <elver@google.com>
>  v2->v3:
>    write kfence_enabled=false only true before
>
>  mm/kfence/core.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/mm/kfence/core.c b/mm/kfence/core.c
> index 11a954763be9..41840b8d9cb3 100644
> --- a/mm/kfence/core.c
> +++ b/mm/kfence/core.c
> @@ -67,8 +67,13 @@ static int param_set_sample_interval(const char *val, const struct kernel_param
>         if (ret < 0)
>                 return ret;
>
> -       if (!num) /* Using 0 to indicate KFENCE is disabled. */
> -               WRITE_ONCE(kfence_enabled, false);
> +       /* Using 0 to indicate KFENCE is disabled. */
> +       if (!num) {
> +               if (READ_ONCE(kfence_enabled)) {

Now you could just write

  if (!num && READ_ONCE(kfence_enabled)) {
    ....

> +                       pr_info("disabled\n");
> +                       WRITE_ONCE(kfence_enabled, false);
> +               }
> +       }
>
>         *((unsigned long *)kp->arg) = num;
>
> @@ -874,6 +879,7 @@ static int kfence_enable_late(void)
>
>         WRITE_ONCE(kfence_enabled, true);
>         queue_delayed_work(system_unbound_wq, &kfence_timer, 0);
> +       pr_info("re-enabled\n");
>         return 0;
>  }
>
> --
> 2.25.1
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3] mm/kfence: print disabling or re-enabling message
  2022-05-18  7:24 ` Marco Elver
@ 2022-05-18  7:26   ` Jackie Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Jackie Liu @ 2022-05-18  7:26 UTC (permalink / raw)
  To: Marco Elver; +Cc: glider, dvyukov, kasan-dev, linux-mm



在 2022/5/18 下午3:24, Marco Elver 写道:
> On Wed, 18 May 2022 at 03:03, Jackie Liu <liu.yun@linux.dev> wrote:
>>
>> From: Jackie Liu <liuyun01@kylinos.cn>
>>
>> By printing information, we can friendly prompt the status change
>> information of kfence by dmesg and record by syslog.
>>
>> Co-developed-by: Marco Elver <elver@google.com>
>> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
>> ---
>>   v1->v2:
>>     fixup by Marco Elver <elver@google.com>
>>   v2->v3:
>>     write kfence_enabled=false only true before
>>
>>   mm/kfence/core.c | 10 ++++++++--
>>   1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/kfence/core.c b/mm/kfence/core.c
>> index 11a954763be9..41840b8d9cb3 100644
>> --- a/mm/kfence/core.c
>> +++ b/mm/kfence/core.c
>> @@ -67,8 +67,13 @@ static int param_set_sample_interval(const char *val, const struct kernel_param
>>          if (ret < 0)
>>                  return ret;
>>
>> -       if (!num) /* Using 0 to indicate KFENCE is disabled. */
>> -               WRITE_ONCE(kfence_enabled, false);
>> +       /* Using 0 to indicate KFENCE is disabled. */
>> +       if (!num) {
>> +               if (READ_ONCE(kfence_enabled)) {
> 
> Now you could just write
> 
>    if (!num && READ_ONCE(kfence_enabled)) {

Sure.

>      ....
> 
>> +                       pr_info("disabled\n");
>> +                       WRITE_ONCE(kfence_enabled, false);
>> +               }
>> +       }
>>
>>          *((unsigned long *)kp->arg) = num;
>>
>> @@ -874,6 +879,7 @@ static int kfence_enable_late(void)
>>
>>          WRITE_ONCE(kfence_enabled, true);
>>          queue_delayed_work(system_unbound_wq, &kfence_timer, 0);
>> +       pr_info("re-enabled\n");
>>          return 0;
>>   }
>>
>> --
>> 2.25.1
>>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-18  7:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-18  1:03 [PATCH v3] mm/kfence: print disabling or re-enabling message Jackie Liu
2022-05-18  7:24 ` Marco Elver
2022-05-18  7:26   ` Jackie Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox