From: "Paul E. McKenney" <paulmck@kernel.org>
To: Marco Elver <elver@google.com>
Cc: andreyknvl@google.com, glider@google.com, dvyukov@google.com,
kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org,
Qian Cai <cai@lca.pw>,
mingo@kernel.org, will@kernel.org, torvalds@linux-foundation.org
Subject: Re: [PATCH] kcsan: Expose core configuration parameters as module params
Date: Fri, 7 Feb 2020 11:40:21 -0800 [thread overview]
Message-ID: <20200207194021.GO2935@paulmck-ThinkPad-P72> (raw)
In-Reply-To: <20200207185910.162512-1-elver@google.com>
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 <elver@google.com>
> Cc: Qian Cai <cai@lca.pw>
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 <linux/export.h>
> #include <linux/init.h>
> #include <linux/kernel.h>
> +#include <linux/moduleparam.h>
> #include <linux/percpu.h>
> #include <linux/preempt.h>
> #include <linux/random.h>
> @@ -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
>
prev parent reply other threads:[~2020-02-07 19:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-07 18:59 Marco Elver
2020-02-07 19:40 ` Paul E. McKenney [this message]
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=20200207194021.GO2935@paulmck-ThinkPad-P72 \
--to=paulmck@kernel.org \
--cc=andreyknvl@google.com \
--cc=cai@lca.pw \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=will@kernel.org \
/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
all inboxes | Powered by JetHome®