diff mbox series

[v2,1/3] libkmod: add a library notice log level print

Message ID 20210810051602.3067384-2-mcgrof@kernel.org (mailing list archive)
State New
Headers show
Series kmod: add patient module removal support | expand

Commit Message

Luis Chamberlain Aug. 10, 2021, 5:16 a.m. UTC
When you use pass the -v argument to modprobe we bump
the log level from the default modprobe log level of
LOG_WARNING (4) to LOG_NOTICE (5), however the library
only has avaiable to print:

 #define DBG(ctx, arg...) kmod_log_cond(ctx, LOG_DEBUG, ## arg)
 #define INFO(ctx, arg...) kmod_log_cond(ctx, LOG_INFO, ## arg)
 #define ERR(ctx, arg...) kmod_log_cond(ctx, LOG_ERR, ## arg)

LOG_INFO (6) however is too high of a level for it to be
effective at printing anything when modprobe -v is passed.
And so the only way in which modprobe -v can trigger the
library to print a verbose message is to use ERR() but that
always prints something and we don't want that in some
situations.

We need to add a new log level macro which uses LOG_NOTICE (5)
for a "normal but significant condition" which users and developers
can use to look underneath the hood to confirm if a situation is
happening.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 libkmod/libkmod-internal.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Lucas De Marchi Sept. 21, 2021, 5:53 a.m. UTC | #1
On Mon, Aug 9, 2021 at 11:56 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
>
> When you use pass the -v argument to modprobe we bump
> the log level from the default modprobe log level of
> LOG_WARNING (4) to LOG_NOTICE (5), however the library
> only has avaiable to print:
>
>  #define DBG(ctx, arg...) kmod_log_cond(ctx, LOG_DEBUG, ## arg)
>  #define INFO(ctx, arg...) kmod_log_cond(ctx, LOG_INFO, ## arg)
>  #define ERR(ctx, arg...) kmod_log_cond(ctx, LOG_ERR, ## arg)
>
> LOG_INFO (6) however is too high of a level for it to be
> effective at printing anything when modprobe -v is passed.
> And so the only way in which modprobe -v can trigger the
> library to print a verbose message is to use ERR() but that
> always prints something and we don't want that in some
> situations.
>
> We need to add a new log level macro which uses LOG_NOTICE (5)
> for a "normal but significant condition" which users and developers
> can use to look underneath the hood to confirm if a situation is
> happening.
>
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> ---
>  libkmod/libkmod-internal.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libkmod/libkmod-internal.h b/libkmod/libkmod-internal.h
> index 398af9c..2e5e1bc 100644
> --- a/libkmod/libkmod-internal.h
> +++ b/libkmod/libkmod-internal.h
> @@ -25,10 +25,12 @@ static _always_inline_ _printf_format_(2, 3) void
>  #  else
>  #    define DBG(ctx, arg...) kmod_log_null(ctx, ## arg)
>  #  endif
> +#  define NOTICE(ctx, arg...) kmod_log_cond(ctx, LOG_NOTICE, ## arg)
>  #  define INFO(ctx, arg...) kmod_log_cond(ctx, LOG_INFO, ## arg)
>  #  define ERR(ctx, arg...) kmod_log_cond(ctx, LOG_ERR, ## arg)
>  #else
>  #  define DBG(ctx, arg...) kmod_log_null(ctx, ## arg)
> +#  define NOTICE(ctx, arg...) kmod_log_cond(ctx, LOG_NOTICE, ## arg)

did you mean kmod_log_null()?

Lucas De Marchi

>  #  define INFO(ctx, arg...) kmod_log_null(ctx, ## arg)
>  #  define ERR(ctx, arg...) kmod_log_null(ctx, ## arg)
>  #endif
> --
> 2.30.2
>
Luis Chamberlain Sept. 21, 2021, 6:40 p.m. UTC | #2
On Mon, Sep 20, 2021 at 10:53:53PM -0700, Lucas De Marchi wrote:
> On Mon, Aug 9, 2021 at 11:56 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
> >
> > When you use pass the -v argument to modprobe we bump
> > the log level from the default modprobe log level of
> > LOG_WARNING (4) to LOG_NOTICE (5), however the library
> > only has avaiable to print:
> >
> >  #define DBG(ctx, arg...) kmod_log_cond(ctx, LOG_DEBUG, ## arg)
> >  #define INFO(ctx, arg...) kmod_log_cond(ctx, LOG_INFO, ## arg)
> >  #define ERR(ctx, arg...) kmod_log_cond(ctx, LOG_ERR, ## arg)
> >
> > LOG_INFO (6) however is too high of a level for it to be
> > effective at printing anything when modprobe -v is passed.
> > And so the only way in which modprobe -v can trigger the
> > library to print a verbose message is to use ERR() but that
> > always prints something and we don't want that in some
> > situations.
> >
> > We need to add a new log level macro which uses LOG_NOTICE (5)
> > for a "normal but significant condition" which users and developers
> > can use to look underneath the hood to confirm if a situation is
> > happening.
> >
> > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> > ---
> >  libkmod/libkmod-internal.h | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/libkmod/libkmod-internal.h b/libkmod/libkmod-internal.h
> > index 398af9c..2e5e1bc 100644
> > --- a/libkmod/libkmod-internal.h
> > +++ b/libkmod/libkmod-internal.h
> > @@ -25,10 +25,12 @@ static _always_inline_ _printf_format_(2, 3) void
> >  #  else
> >  #    define DBG(ctx, arg...) kmod_log_null(ctx, ## arg)
> >  #  endif
> > +#  define NOTICE(ctx, arg...) kmod_log_cond(ctx, LOG_NOTICE, ## arg)
> >  #  define INFO(ctx, arg...) kmod_log_cond(ctx, LOG_INFO, ## arg)
> >  #  define ERR(ctx, arg...) kmod_log_cond(ctx, LOG_ERR, ## arg)
> >  #else
> >  #  define DBG(ctx, arg...) kmod_log_null(ctx, ## arg)
> > +#  define NOTICE(ctx, arg...) kmod_log_cond(ctx, LOG_NOTICE, ## arg)
> 
> did you mean kmod_log_null()?

Sure, feel free to change on your end or let me know if you would
prefer if I respin.

  Luis
Lucas De Marchi Sept. 23, 2021, 8:02 a.m. UTC | #3
On Tue, Sep 21, 2021 at 11:40:52AM -0700, Luis Chamberlain wrote:
>On Mon, Sep 20, 2021 at 10:53:53PM -0700, Lucas De Marchi wrote:
>> On Mon, Aug 9, 2021 at 11:56 PM Luis Chamberlain <mcgrof@kernel.org> wrote:
>> >
>> > When you use pass the -v argument to modprobe we bump
>> > the log level from the default modprobe log level of
>> > LOG_WARNING (4) to LOG_NOTICE (5), however the library
>> > only has avaiable to print:
>> >
>> >  #define DBG(ctx, arg...) kmod_log_cond(ctx, LOG_DEBUG, ## arg)
>> >  #define INFO(ctx, arg...) kmod_log_cond(ctx, LOG_INFO, ## arg)
>> >  #define ERR(ctx, arg...) kmod_log_cond(ctx, LOG_ERR, ## arg)
>> >
>> > LOG_INFO (6) however is too high of a level for it to be
>> > effective at printing anything when modprobe -v is passed.
>> > And so the only way in which modprobe -v can trigger the
>> > library to print a verbose message is to use ERR() but that
>> > always prints something and we don't want that in some
>> > situations.
>> >
>> > We need to add a new log level macro which uses LOG_NOTICE (5)
>> > for a "normal but significant condition" which users and developers
>> > can use to look underneath the hood to confirm if a situation is
>> > happening.
>> >
>> > Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
>> > ---
>> >  libkmod/libkmod-internal.h | 2 ++
>> >  1 file changed, 2 insertions(+)
>> >
>> > diff --git a/libkmod/libkmod-internal.h b/libkmod/libkmod-internal.h
>> > index 398af9c..2e5e1bc 100644
>> > --- a/libkmod/libkmod-internal.h
>> > +++ b/libkmod/libkmod-internal.h
>> > @@ -25,10 +25,12 @@ static _always_inline_ _printf_format_(2, 3) void
>> >  #  else
>> >  #    define DBG(ctx, arg...) kmod_log_null(ctx, ## arg)
>> >  #  endif
>> > +#  define NOTICE(ctx, arg...) kmod_log_cond(ctx, LOG_NOTICE, ## arg)
>> >  #  define INFO(ctx, arg...) kmod_log_cond(ctx, LOG_INFO, ## arg)
>> >  #  define ERR(ctx, arg...) kmod_log_cond(ctx, LOG_ERR, ## arg)
>> >  #else
>> >  #  define DBG(ctx, arg...) kmod_log_null(ctx, ## arg)
>> > +#  define NOTICE(ctx, arg...) kmod_log_cond(ctx, LOG_NOTICE, ## arg)
>>
>> did you mean kmod_log_null()?
>
>Sure, feel free to change on your end or let me know if you would
>prefer if I respin.

fixed that and pushed this patch.

thanks
Lucas De Marchi

>
>  Luis
diff mbox series

Patch

diff --git a/libkmod/libkmod-internal.h b/libkmod/libkmod-internal.h
index 398af9c..2e5e1bc 100644
--- a/libkmod/libkmod-internal.h
+++ b/libkmod/libkmod-internal.h
@@ -25,10 +25,12 @@  static _always_inline_ _printf_format_(2, 3) void
 #  else
 #    define DBG(ctx, arg...) kmod_log_null(ctx, ## arg)
 #  endif
+#  define NOTICE(ctx, arg...) kmod_log_cond(ctx, LOG_NOTICE, ## arg)
 #  define INFO(ctx, arg...) kmod_log_cond(ctx, LOG_INFO, ## arg)
 #  define ERR(ctx, arg...) kmod_log_cond(ctx, LOG_ERR, ## arg)
 #else
 #  define DBG(ctx, arg...) kmod_log_null(ctx, ## arg)
+#  define NOTICE(ctx, arg...) kmod_log_cond(ctx, LOG_NOTICE, ## arg)
 #  define INFO(ctx, arg...) kmod_log_null(ctx, ## arg)
 #  define ERR(ctx, arg...) kmod_log_null(ctx, ## arg)
 #endif