Re: [PATCH] Support resetting WARN*_ONCE

Michael Ellerman
2017-11-03T09:39:59Z

Andi Kleen <andi@firstfloor.org> writes:

> diff --git a/kernel/panic.c b/kernel/panic.c
> index bdd18afa19a4..b2d872fa16de 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -587,6 +588,32 @@ void warn_slowpath_null(const char *file, int line)
> EXPORT_SYMBOL(warn_slowpath_null);
> #endif
>
> +#ifdef CONFIG_BUG
> +
> +/* Support resetting WARN*_ONCE state */
> +
> +static int clear_warn_once_set(void *data, u64 val)
> +{
> + memset(__start_once, 0, __end_once - __start_once);
> + return 0;
> +}
> +
> +DEFINE_SIMPLE_ATTRIBUTE(clear_warn_once_fops,
> + NULL,
> + clear_warn_once_set,
> + "%lld\n");
> +
> +static __init int register_warn_debugfs(void)
> +{
> + /* Don't care about failure */
> + debugfs_create_file("clear_warn_once", 0644, NULL,
^

Wouldn't 0200 be more appropriate if it's only writable?

Otherwise it appears readable, but cat'ing it gives you an error.

cheers