From mboxrd@z Thu Jan 1 00:00:00 1970 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 DA03AC433EF for ; Wed, 18 May 2022 00:40:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40ECD6B0072; Tue, 17 May 2022 20:40:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BE746B0073; Tue, 17 May 2022 20:40:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 285006B0074; Tue, 17 May 2022 20:40:02 -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 162566B0072 for ; Tue, 17 May 2022 20:40:02 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CFF65204B6 for ; Wed, 18 May 2022 00:40:01 +0000 (UTC) X-FDA: 79477006602.16.6792104 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf18.hostedemail.com (Postfix) with ESMTP id ABF651C00BE for ; Wed, 18 May 2022 00:39:47 +0000 (UTC) MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1652834399; h=from:from: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=gYxdg6Ywm1j2Wqe+IHnSaRNfCJl3qR7KAJAGDMcZWC8=; b=kv2pu9RWnlddP39MuGJgbSDQozgsbuVWohuHyEjNca9yyLjc1tpqETXSJo6HXceNkGIRnI GLd4aimZPDlkXTDOSmGUZi43e7IahJ9viNNhERbtWxDXiK6kHbZzKnav57kxFqergdtf50 93o/ncyxbVF6niCwUpS7+y0neWXmn+o= Date: Wed, 18 May 2022 00:39:53 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: "Jackie Liu" Message-ID: <3f53409c2de1dd22e42dffcad57f3603@linux.dev> Subject: Re: [PATCH] mm/kfence: print disabling or re-enabling message To: "Marco Elver" Cc: glider@google.com, dvyukov@google.com, kasan-dev@googlegroups.com, linux-mm@kvack.org In-Reply-To: References: <20220517111551.4077061-1-liu.yun@linux.dev> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Rspamd-Queue-Id: ABF651C00BE X-Stat-Signature: hgybun43qd8ugi8dj95knyzw59t79hur X-Rspam-User: Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=kv2pu9RW; spf=pass (imf18.hostedemail.com: domain of liu.yun@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=liu.yun@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspamd-Server: rspam09 X-HE-Tag: 1652834387-461238 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: Hi Marco, Thanks for your reply.=0A=0A=0A=0AMay 17, 2022 11:42 AM, "Marco= Elver" =E5=86=99=E5=88=B0:=0A=0A> On Tue, May 17, 202= 2 at 07:15PM +0800, Jackie Liu wrote:=0A> =0A>> From: Jackie Liu =0A>> =0A>> By printing information, we can friendly prompt = the status change=0A>> information of kfence by dmesg.=0A>> =0A>> Signed-= off-by: Jackie Liu =0A> =0A> Personally, I've never = found this useful. If I want to get the current=0A> accurate state of KFE= NCE enablement, I just look at=0A> /sys/kernel/debug/kfence/stats.=0A=0AY= es, I can get the status through this file, but there is no other place= =0Ato indicate that the status has changed. By logging in kmsg, it can no= t=0Aonly reflect the status change through dmesg, but also be recorded by= =0Aprograms such as syslog.=0A=0AThis is very useful for me.=0A=0A> =0A> = Nevertheless, some comments below.=0A> =0A>> ---=0A>> mm/kfence/core.c | = 6 +++++-=0A>> 1 file changed, 5 insertions(+), 1 deletion(-)=0A>> =0A>> d= iff --git a/mm/kfence/core.c b/mm/kfence/core.c=0A>> index 11a954763be9..= beb552089b67 100644=0A>> --- a/mm/kfence/core.c=0A>> +++ b/mm/kfence/core= .c=0A>> @@ -67,8 +67,11 @@ static int param_set_sample_interval(const cha= r *val, const struct kernel_param=0A>> if (ret < 0)=0A>> return ret;=0A>>= =0A>> - if (!num) /* Using 0 to indicate KFENCE is disabled. */=0A>> + i= f (!num) {=0A>> + /* Using 0 to indicate KFENCE is disabled. */=0A>> WRIT= E_ONCE(kfence_enabled, false);=0A>> + pr_info("KFENCE is disabled.\n");= =0A> =0A> This will also print on boot if kfence.sample_interval=3D0 is p= assed. This=0A> is ugly.=0A> =0A> We also have a pr_fmt, and writing "KFE= NCE" again is ugly, too. And=0A> adding '.' at the end of these short log= lines is not something done=0A> much in the kernel, and also ugly.=0A> = =0A> So what you want is this fixup:=0A> =0A> diff --git a/mm/kfence/core= .c b/mm/kfence/core.c=0A> index beb552089b67..de5bcf2609fe 100644=0A> ---= a/mm/kfence/core.c=0A> +++ b/mm/kfence/core.c=0A> @@ -67,10 +67,11 @@ st= atic int param_set_sample_interval(const char *val, const struct kernel_p= aram=0A> if (ret < 0)=0A> return ret;=0A> =0A> + /* Using 0 to indicate K= FENCE is disabled. */=0A> if (!num) {=0A> - /* Using 0 to indicate KFENCE= is disabled. */=0A> + if (READ_ONCE(kfence_enabled))=0A> + pr_info("disa= bled\n");=0A> WRITE_ONCE(kfence_enabled, false);=0A> - pr_info("KFENCE is= disabled.\n");=0A> }=0A> =0A> *((unsigned long *)kp->arg) =3D num;=0A> @= @ -877,7 +878,7 @@ static int kfence_enable_late(void)=0A> =0A> WRITE_ONC= E(kfence_enabled, true);=0A> queue_delayed_work(system_unbound_wq, &kfenc= e_timer, 0);=0A> - pr_info("KFENCE is re-enabled.\n");=0A> + pr_info("re-= enabled\n");=0A> return 0;=0A> }=0A=0AThanks for you fixup.=0A=0A--=0AJac= kie Liu