Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp963746ybv; Fri, 7 Feb 2020 11:42:39 -0800 (PST) X-Google-Smtp-Source: APXvYqy3jSEXaVIqoXnUhC9aAG5QcfoDxYtgZIX/zb6/itGTuyRVThVHu7xNcf4EK0HoZPgc3Fj4 X-Received: by 2002:aca:db41:: with SMTP id s62mr3088364oig.87.1581104559231; Fri, 07 Feb 2020 11:42:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581104559; cv=none; d=google.com; s=arc-20160816; b=IPVUfDnNjufc9jzM5Ele5yXwRIl6oCXQAnuRnBF8bTigm5OgApAncWnxz1YwBFLV+a LXXC81z2EBs0znGNF7HhEFHmJviQnkXx2bDH86pe9pRCnXJxNzGS1VyL5WegHxREgSow KP7AtppxbD3xHvQrbkfp0WND3p/dtygc1fx3XlMzz/uwaZwUNUR6roHE7uhtD9YUVrdQ 5dtdXsUHwPevOLaH7EOEKJJ5sNYm6UJsZWP0ql+0fr1KormQo6/zPxLZQzlM9Qrd70/l K/rlbq3TsLcsFqODUQZjv61Hgl8PrVaYOhzOk5lsrpjnUNoQDQUJwI82bcj8lLPRMlNZ Lfrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=V91oaijQ8Rl49IpFIbW1Z7GeCZ2SCsVUSx52WBU4zlQ=; b=rQmK9g/yuct0UCfUHgx8pOsOlui0UPjhMf4J5S+p2xpWFsVBEGhH9fLOyFPcmXx/NQ MrTsHGA6oJtdEgN/ueAB7ejtfl3ql6OXoSW9YcOXXXtFEeB8kELL9BHXYeoRP1BqX1+k c+7YYvDpOUcTTOd4WdHo6y0ge8dHIkllnx7n89+GdYce9/m/6AOMWqFhlSSyfTWX8h3K Rkhap1i1gOQCK7lt/p0r5ZqSwgL1je8VfCF+pFUkerop0jx6+cD5oieamO3n9DF6IxbM 4x20Khppsl8Pmtt939s9LSRTiqQCRVSCy8SlMibtvD9uizOX0yh7lOmxfekq+GNvPRBw byPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vkh70UPw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k11si149465otp.176.2020.02.07.11.42.26; Fri, 07 Feb 2020 11:42:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vkh70UPw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727446AbgBGTkW (ORCPT + 99 others); Fri, 7 Feb 2020 14:40:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:40294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727028AbgBGTkW (ORCPT ); Fri, 7 Feb 2020 14:40:22 -0500 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9B5CD20726; Fri, 7 Feb 2020 19:40:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581104421; bh=ulxptYKoi30zUziVN+g5ACpr4FlhctQvC/XKjr24dPc=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=vkh70UPwTTZoJBPTB/o+/ChdgecXXDbzyTCLwZRwNE9FrgLuMzU9cPxmEEWhB6aPe O9hAjmj2SUI0OvAnHWDrmoJvf+OaMsXGiJ/RAFORf/XDre8pvSXxGSBcU3qBjLypfL Cl654iXLd3kVqSYqb8F75mw8QTdlE5yUiJ12f8NE= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 641F535219BF; Fri, 7 Feb 2020 11:40:21 -0800 (PST) Date: Fri, 7 Feb 2020 11:40:21 -0800 From: "Paul E. McKenney" To: Marco Elver Cc: andreyknvl@google.com, glider@google.com, dvyukov@google.com, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Qian Cai , mingo@kernel.org, will@kernel.org, torvalds@linux-foundation.org Subject: Re: [PATCH] kcsan: Expose core configuration parameters as module params Message-ID: <20200207194021.GO2935@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200207185910.162512-1-elver@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200207185910.162512-1-elver@google.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 07, 2020 at 07:59:10PM +0100, Marco Elver wrote: > This adds early_boot, udelay_{task,interrupt}, and skip_watch as module > params. The latter parameters are useful to modify at runtime to tune > KCSAN's performance on new systems. This will also permit auto-tuning > these parameters to maximize overall system performance and KCSAN's race > detection ability. > > None of the parameters are used in the fast-path and referring to them > via static variables instead of CONFIG constants will not affect > performance. > > Signed-off-by: Marco Elver > Cc: Qian Cai Thank you both! I have pulled this in, and have also rebased the KCSAN commits into a separate branch named kcsan in -rcu. This allows people to use current KCSAN without exposing themselves to random RCU changes. f60f0f543333 ("kcsan: Expose core configuration parameters as module params") git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git I just now kicked off a short sanity test with rcutorture, and will of course do more testing over time. Thanx, Paul > --- > kernel/kcsan/core.c | 24 +++++++++++++++++++----- > 1 file changed, 19 insertions(+), 5 deletions(-) > > diff --git a/kernel/kcsan/core.c b/kernel/kcsan/core.c > index 87ef01e40199d..498b1eb3c1cda 100644 > --- a/kernel/kcsan/core.c > +++ b/kernel/kcsan/core.c > @@ -6,6 +6,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -16,6 +17,20 @@ > #include "encoding.h" > #include "kcsan.h" > > +static bool kcsan_early_enable = IS_ENABLED(CONFIG_KCSAN_EARLY_ENABLE); > +static unsigned int kcsan_udelay_task = CONFIG_KCSAN_UDELAY_TASK; > +static unsigned int kcsan_udelay_interrupt = CONFIG_KCSAN_UDELAY_INTERRUPT; > +static long kcsan_skip_watch = CONFIG_KCSAN_SKIP_WATCH; > + > +#ifdef MODULE_PARAM_PREFIX > +#undef MODULE_PARAM_PREFIX > +#endif > +#define MODULE_PARAM_PREFIX "kcsan." > +module_param_named(early_enable, kcsan_early_enable, bool, 0); > +module_param_named(udelay_task, kcsan_udelay_task, uint, 0644); > +module_param_named(udelay_interrupt, kcsan_udelay_interrupt, uint, 0644); > +module_param_named(skip_watch, kcsan_skip_watch, long, 0644); > + > bool kcsan_enabled; > > /* Per-CPU kcsan_ctx for interrupts */ > @@ -239,9 +254,9 @@ should_watch(const volatile void *ptr, size_t size, int type) > > static inline void reset_kcsan_skip(void) > { > - long skip_count = CONFIG_KCSAN_SKIP_WATCH - > + long skip_count = kcsan_skip_watch - > (IS_ENABLED(CONFIG_KCSAN_SKIP_WATCH_RANDOMIZE) ? > - prandom_u32_max(CONFIG_KCSAN_SKIP_WATCH) : > + prandom_u32_max(kcsan_skip_watch) : > 0); > this_cpu_write(kcsan_skip, skip_count); > } > @@ -253,8 +268,7 @@ static __always_inline bool kcsan_is_enabled(void) > > static inline unsigned int get_delay(void) > { > - unsigned int delay = in_task() ? CONFIG_KCSAN_UDELAY_TASK : > - CONFIG_KCSAN_UDELAY_INTERRUPT; > + unsigned int delay = in_task() ? kcsan_udelay_task : kcsan_udelay_interrupt; > return delay - (IS_ENABLED(CONFIG_KCSAN_DELAY_RANDOMIZE) ? > prandom_u32_max(delay) : > 0); > @@ -527,7 +541,7 @@ void __init kcsan_init(void) > * We are in the init task, and no other tasks should be running; > * WRITE_ONCE without memory barrier is sufficient. > */ > - if (IS_ENABLED(CONFIG_KCSAN_EARLY_ENABLE)) > + if (kcsan_early_enable) > WRITE_ONCE(kcsan_enabled, true); > } > > -- > 2.25.0.341.g760bfbb309-goog >