2022-07-22 14:31:41

by Takashi Iwai

[permalink] [raw]
Subject: [PATCH 3/4] exfat: Expand exfat_err() and co directly to pr_*() macro

Currently the error and info messages handled by exfat_err() and co
are tossed to exfat_msg() function that does nothing but passes the
strings with printk() invocation. Not only that this is more overhead
by the indirect calls, but also this makes harder to extend for the
debug print usage; because of the direct printk() call, you cannot
make it for dynamic debug or without debug like the standard helpers
such as pr_debug() or dev_dbg().

For addressing the problem, this patch replaces exfat_msg() function
with a macro to expand to pr_*() directly. This allows us to create
exfat_debug() macro that is expanded to pr_debug() (which output can
gracefully suppressed via dyndbg).

Signed-off-by: Takashi Iwai <[email protected]>
---
fs/exfat/exfat_fs.h | 15 ++++++++++-----
fs/exfat/misc.c | 17 -----------------
2 files changed, 10 insertions(+), 22 deletions(-)

diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
index f431327af459..a5bc0fc11f79 100644
--- a/fs/exfat/exfat_fs.h
+++ b/fs/exfat/exfat_fs.h
@@ -508,14 +508,19 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
#define exfat_fs_error_ratelimit(sb, fmt, args...) \
__exfat_fs_error(sb, __ratelimit(&EXFAT_SB(sb)->ratelimit), \
fmt, ## args)
-void exfat_msg(struct super_block *sb, const char *lv, const char *fmt, ...)
- __printf(3, 4) __cold;
+
+/* expand to pr_xxx() with prefix */
+#define exfat_msg(sb, lv, fmt, ...) \
+ pr_##lv("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
+
#define exfat_err(sb, fmt, ...) \
- exfat_msg(sb, KERN_ERR, fmt, ##__VA_ARGS__)
+ exfat_msg(sb, err, fmt, ##__VA_ARGS__)
#define exfat_warn(sb, fmt, ...) \
- exfat_msg(sb, KERN_WARNING, fmt, ##__VA_ARGS__)
+ exfat_msg(sb, warn, fmt, ##__VA_ARGS__)
#define exfat_info(sb, fmt, ...) \
- exfat_msg(sb, KERN_INFO, fmt, ##__VA_ARGS__)
+ exfat_msg(sb, info, fmt, ##__VA_ARGS__)
+#define exfat_debug(sb, fmt, ...) \
+ exfat_msg(sb, debug, fmt, ##__VA_ARGS__)

void exfat_get_entry_time(struct exfat_sb_info *sbi, struct timespec64 *ts,
u8 tz, __le16 time, __le16 date, u8 time_cs);
diff --git a/fs/exfat/misc.c b/fs/exfat/misc.c
index 9380e0188b55..2e1a1a6b1021 100644
--- a/fs/exfat/misc.c
+++ b/fs/exfat/misc.c
@@ -46,23 +46,6 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
}
}

-/*
- * exfat_msg() - print preformated EXFAT specific messages.
- * All logs except what uses exfat_fs_error() should be written by exfat_msg()
- */
-void exfat_msg(struct super_block *sb, const char *level, const char *fmt, ...)
-{
- struct va_format vaf;
- va_list args;
-
- va_start(args, fmt);
- vaf.fmt = fmt;
- vaf.va = &args;
- /* level means KERN_ pacility level */
- printk("%sexFAT-fs (%s): %pV\n", level, sb->s_id, &vaf);
- va_end(args);
-}
-
#define SECS_PER_MIN (60)
#define TIMEZONE_SEC(x) ((x) * 15 * SECS_PER_MIN)

--
2.35.3


2022-07-23 07:44:00

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 3/4] exfat: Expand exfat_err() and co directly to pr_*() macro

On Fri, 2022-07-22 at 16:29 +0200, Takashi Iwai wrote:
> Currently the error and info messages handled by exfat_err() and co
> are tossed to exfat_msg() function that does nothing but passes the
> strings with printk() invocation. Not only that this is more overhead
> by the indirect calls, but also this makes harder to extend for the
> debug print usage; because of the direct printk() call, you cannot
> make it for dynamic debug or without debug like the standard helpers
> such as pr_debug() or dev_dbg().
>
> For addressing the problem, this patch replaces exfat_msg() function
> with a macro to expand to pr_*() directly. This allows us to create
> exfat_debug() macro that is expanded to pr_debug() (which output can
> gracefully suppressed via dyndbg).
[]
> diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
[]
> @@ -508,14 +508,19 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
> #define exfat_fs_error_ratelimit(sb, fmt, args...) \
> __exfat_fs_error(sb, __ratelimit(&EXFAT_SB(sb)->ratelimit), \
> fmt, ## args)
> -void exfat_msg(struct super_block *sb, const char *lv, const char *fmt, ...)
> - __printf(3, 4) __cold;
> +
> +/* expand to pr_xxx() with prefix */
> +#define exfat_msg(sb, lv, fmt, ...) \
> + pr_##lv("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
> +
> #define exfat_err(sb, fmt, ...) \
> - exfat_msg(sb, KERN_ERR, fmt, ##__VA_ARGS__)
> + exfat_msg(sb, err, fmt, ##__VA_ARGS__)
> #define exfat_warn(sb, fmt, ...) \
> - exfat_msg(sb, KERN_WARNING, fmt, ##__VA_ARGS__)
> + exfat_msg(sb, warn, fmt, ##__VA_ARGS__)
> #define exfat_info(sb, fmt, ...) \
> - exfat_msg(sb, KERN_INFO, fmt, ##__VA_ARGS__)
> + exfat_msg(sb, info, fmt, ##__VA_ARGS__)
> +#define exfat_debug(sb, fmt, ...) \
> + exfat_msg(sb, debug, fmt, ##__VA_ARGS__)

I think this would be clearer using pr_<level> directly instead
of an indirecting macro that uses concatenation of <level> that
obscures the actual use of pr_<level>

Either: (and this first option would be my preference)

#define exfat_err(sb, fmt, ...) \
pr_err("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
#define exfat_warn(sb, fmt, ...) \
pr_warn("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
etc...

or using an indirecting macro:

#define exfat_printk(pr_level, sb, fmt, ...) \
pr_level("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)

#define exfat_err(sb, fmt, ...)
exfat_printk(pr_err, sb, fmt, ##__VA_ARGS)
#define exfat_warn(sb, fmt, ...)
exfat_printk(pr_warn, sb, fmt, ##__VA_ARGS)
etc...

and btw, there are multiple uses of exfat_<level> output with a
unnecessary and duplicated '\n' that the macro already adds that
should be removed:

$ git grep -P -n '\bexfat_(err|warn|info).*\\n' fs/exfat/
fs/exfat/fatent.c:334: exfat_err(sb, "sbi->clu_srch_ptr is invalid (%u)\n",
fs/exfat/nls.c:674: exfat_err(sb, "failed to read sector(0x%llx)\n",
fs/exfat/super.c:467: exfat_err(sb, "bogus sector size bits : %u\n",
fs/exfat/super.c:476: exfat_err(sb, "bogus sectors bits per cluster : %u\n",

2022-07-23 08:26:35

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH 3/4] exfat: Expand exfat_err() and co directly to pr_*() macro

On Sat, 23 Jul 2022 09:42:12 +0200,
Joe Perches wrote:
>
> On Fri, 2022-07-22 at 16:29 +0200, Takashi Iwai wrote:
> > Currently the error and info messages handled by exfat_err() and co
> > are tossed to exfat_msg() function that does nothing but passes the
> > strings with printk() invocation. Not only that this is more overhead
> > by the indirect calls, but also this makes harder to extend for the
> > debug print usage; because of the direct printk() call, you cannot
> > make it for dynamic debug or without debug like the standard helpers
> > such as pr_debug() or dev_dbg().
> >
> > For addressing the problem, this patch replaces exfat_msg() function
> > with a macro to expand to pr_*() directly. This allows us to create
> > exfat_debug() macro that is expanded to pr_debug() (which output can
> > gracefully suppressed via dyndbg).
> []
> > diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
> []
> > @@ -508,14 +508,19 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
> > #define exfat_fs_error_ratelimit(sb, fmt, args...) \
> > __exfat_fs_error(sb, __ratelimit(&EXFAT_SB(sb)->ratelimit), \
> > fmt, ## args)
> > -void exfat_msg(struct super_block *sb, const char *lv, const char *fmt, ...)
> > - __printf(3, 4) __cold;
> > +
> > +/* expand to pr_xxx() with prefix */
> > +#define exfat_msg(sb, lv, fmt, ...) \
> > + pr_##lv("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
> > +
> > #define exfat_err(sb, fmt, ...) \
> > - exfat_msg(sb, KERN_ERR, fmt, ##__VA_ARGS__)
> > + exfat_msg(sb, err, fmt, ##__VA_ARGS__)
> > #define exfat_warn(sb, fmt, ...) \
> > - exfat_msg(sb, KERN_WARNING, fmt, ##__VA_ARGS__)
> > + exfat_msg(sb, warn, fmt, ##__VA_ARGS__)
> > #define exfat_info(sb, fmt, ...) \
> > - exfat_msg(sb, KERN_INFO, fmt, ##__VA_ARGS__)
> > + exfat_msg(sb, info, fmt, ##__VA_ARGS__)
> > +#define exfat_debug(sb, fmt, ...) \
> > + exfat_msg(sb, debug, fmt, ##__VA_ARGS__)
>
> I think this would be clearer using pr_<level> directly instead
> of an indirecting macro that uses concatenation of <level> that
> obscures the actual use of pr_<level>
>
> Either: (and this first option would be my preference)
>
> #define exfat_err(sb, fmt, ...) \
> pr_err("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
> #define exfat_warn(sb, fmt, ...) \
> pr_warn("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
> etc...

IMO, it's a matter of taste, and I don't mind either way.
Just let me know.

> or using an indirecting macro:
>
> #define exfat_printk(pr_level, sb, fmt, ...) \
> pr_level("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)

Is pr_level() defined anywhere...?

>
> and btw, there are multiple uses of exfat_<level> output with a
> unnecessary and duplicated '\n' that the macro already adds that
> should be removed:
>
> $ git grep -P -n '\bexfat_(err|warn|info).*\\n' fs/exfat/
> fs/exfat/fatent.c:334: exfat_err(sb, "sbi->clu_srch_ptr is invalid (%u)\n",
> fs/exfat/nls.c:674: exfat_err(sb, "failed to read sector(0x%llx)\n",
> fs/exfat/super.c:467: exfat_err(sb, "bogus sector size bits : %u\n",
> fs/exfat/super.c:476: exfat_err(sb, "bogus sectors bits per cluster : %u\n",

Right, that should be addressed in another patch.


thanks,

Takashi

2022-07-23 08:39:43

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 3/4] exfat: Expand exfat_err() and co directly to pr_*() macro

On Sat, 2022-07-23 at 10:04 +0200, Takashi Iwai wrote:
> On Sat, 23 Jul 2022 09:42:12 +0200, Joe Perches wrote:
> > On Fri, 2022-07-22 at 16:29 +0200, Takashi Iwai wrote:
> > > Currently the error and info messages handled by exfat_err() and co
> > > are tossed to exfat_msg() function that does nothing but passes the
> > > strings with printk() invocation. Not only that this is more overhead
> > > by the indirect calls, but also this makes harder to extend for the
> > > debug print usage; because of the direct printk() call, you cannot
> > > make it for dynamic debug or without debug like the standard helpers
> > > such as pr_debug() or dev_dbg().
> > >
> > > For addressing the problem, this patch replaces exfat_msg() function
> > > with a macro to expand to pr_*() directly. This allows us to create
> > > exfat_debug() macro that is expanded to pr_debug() (which output can
> > > gracefully suppressed via dyndbg).
> > []
> > > diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
> > []
> > > @@ -508,14 +508,19 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
> > > #define exfat_fs_error_ratelimit(sb, fmt, args...) \
> > > __exfat_fs_error(sb, __ratelimit(&EXFAT_SB(sb)->ratelimit), \
> > > fmt, ## args)
> > > -void exfat_msg(struct super_block *sb, const char *lv, const char *fmt, ...)
> > > - __printf(3, 4) __cold;
> > > +
> > > +/* expand to pr_xxx() with prefix */
> > > +#define exfat_msg(sb, lv, fmt, ...) \
> > > + pr_##lv("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
> > > +
> > > #define exfat_err(sb, fmt, ...) \
> > > - exfat_msg(sb, KERN_ERR, fmt, ##__VA_ARGS__)
> > > + exfat_msg(sb, err, fmt, ##__VA_ARGS__)
> > > #define exfat_warn(sb, fmt, ...) \
> > > - exfat_msg(sb, KERN_WARNING, fmt, ##__VA_ARGS__)
> > > + exfat_msg(sb, warn, fmt, ##__VA_ARGS__)
> > > #define exfat_info(sb, fmt, ...) \
> > > - exfat_msg(sb, KERN_INFO, fmt, ##__VA_ARGS__)
> > > + exfat_msg(sb, info, fmt, ##__VA_ARGS__)
> > > +#define exfat_debug(sb, fmt, ...) \
> > > + exfat_msg(sb, debug, fmt, ##__VA_ARGS__)
> >
> > I think this would be clearer using pr_<level> directly instead
> > of an indirecting macro that uses concatenation of <level> that
> > obscures the actual use of pr_<level>
> >
> > Either: (and this first option would be my preference)
> >
> > #define exfat_err(sb, fmt, ...) \
> > pr_err("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
> > #define exfat_warn(sb, fmt, ...) \
> > pr_warn("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
> > etc...
>
> IMO, it's a matter of taste, and I don't mind either way.
> Just let me know.
>
> > or using an indirecting macro:
> >
> > #define exfat_printk(pr_level, sb, fmt, ...) \
> > pr_level("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
>
> Is pr_level() defined anywhere...?

no

$ git grep -w pr_level
$

2022-07-23 09:17:30

by Petr Vorel

[permalink] [raw]
Subject: Re: [PATCH 3/4] exfat: Expand exfat_err() and co directly to pr_*() macro

Hi all,

Reviewed-by: Petr Vorel <[email protected]>

Kind regards,
Petr

2022-07-26 07:20:32

by Namjae Jeon

[permalink] [raw]
Subject: Re: [PATCH 3/4] exfat: Expand exfat_err() and co directly to pr_*() macro

2022-07-23 17:04 GMT+09:00, Takashi Iwai <[email protected]>:
> On Sat, 23 Jul 2022 09:42:12 +0200,
> Joe Perches wrote:
>>
>> On Fri, 2022-07-22 at 16:29 +0200, Takashi Iwai wrote:
>> > Currently the error and info messages handled by exfat_err() and co
>> > are tossed to exfat_msg() function that does nothing but passes the
>> > strings with printk() invocation. Not only that this is more overhead
>> > by the indirect calls, but also this makes harder to extend for the
>> > debug print usage; because of the direct printk() call, you cannot
>> > make it for dynamic debug or without debug like the standard helpers
>> > such as pr_debug() or dev_dbg().
>> >
>> > For addressing the problem, this patch replaces exfat_msg() function
>> > with a macro to expand to pr_*() directly. This allows us to create
>> > exfat_debug() macro that is expanded to pr_debug() (which output can
>> > gracefully suppressed via dyndbg).
>> []
>> > diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
>> []
>> > @@ -508,14 +508,19 @@ void __exfat_fs_error(struct super_block *sb, int
>> > report, const char *fmt, ...)
>> > #define exfat_fs_error_ratelimit(sb, fmt, args...) \
>> > __exfat_fs_error(sb, __ratelimit(&EXFAT_SB(sb)->ratelimit), \
>> > fmt, ## args)
>> > -void exfat_msg(struct super_block *sb, const char *lv, const char *fmt,
>> > ...)
>> > - __printf(3, 4) __cold;
>> > +
>> > +/* expand to pr_xxx() with prefix */
>> > +#define exfat_msg(sb, lv, fmt, ...) \
>> > + pr_##lv("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
>> > +
>> > #define exfat_err(sb, fmt, ...) \
>> > - exfat_msg(sb, KERN_ERR, fmt, ##__VA_ARGS__)
>> > + exfat_msg(sb, err, fmt, ##__VA_ARGS__)
>> > #define exfat_warn(sb, fmt, ...) \
>> > - exfat_msg(sb, KERN_WARNING, fmt, ##__VA_ARGS__)
>> > + exfat_msg(sb, warn, fmt, ##__VA_ARGS__)
>> > #define exfat_info(sb, fmt, ...) \
>> > - exfat_msg(sb, KERN_INFO, fmt, ##__VA_ARGS__)
>> > + exfat_msg(sb, info, fmt, ##__VA_ARGS__)
>> > +#define exfat_debug(sb, fmt, ...) \
>> > + exfat_msg(sb, debug, fmt, ##__VA_ARGS__)
>>
>> I think this would be clearer using pr_<level> directly instead
>> of an indirecting macro that uses concatenation of <level> that
>> obscures the actual use of pr_<level>
>>
>> Either: (and this first option would be my preference)
>>
>> #define exfat_err(sb, fmt, ...) \
>> pr_err("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
>> #define exfat_warn(sb, fmt, ...) \
>> pr_warn("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
>> etc...
>
> IMO, it's a matter of taste, and I don't mind either way.
> Just let me know.
Joe has already said that he prefers the first.
Will you send v2 patch-set ?

Thanks!
>
>> or using an indirecting macro:
>>
>> #define exfat_printk(pr_level, sb, fmt, ...) \
>> pr_level("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
>
> Is pr_level() defined anywhere...?
>
>>
>> and btw, there are multiple uses of exfat_<level> output with a
>> unnecessary and duplicated '\n' that the macro already adds that
>> should be removed:
>>
>> $ git grep -P -n '\bexfat_(err|warn|info).*\\n' fs/exfat/
>> fs/exfat/fatent.c:334: exfat_err(sb, "sbi->clu_srch_ptr
>> is invalid (%u)\n",
>> fs/exfat/nls.c:674: exfat_err(sb, "failed to read
>> sector(0x%llx)\n",
>> fs/exfat/super.c:467: exfat_err(sb, "bogus sector size bits :
>> %u\n",
>> fs/exfat/super.c:476: exfat_err(sb, "bogus sectors bits per
>> cluster : %u\n",
>
> Right, that should be addressed in another patch.
>
>
> thanks,
>
> Takashi
>

2022-07-26 07:48:33

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH 3/4] exfat: Expand exfat_err() and co directly to pr_*() macro

On Tue, 26 Jul 2022 09:02:40 +0200,
Namjae Jeon wrote:
>
> 2022-07-23 17:04 GMT+09:00, Takashi Iwai <[email protected]>:
> > On Sat, 23 Jul 2022 09:42:12 +0200,
> > Joe Perches wrote:
> >>
> >> On Fri, 2022-07-22 at 16:29 +0200, Takashi Iwai wrote:
> >> > Currently the error and info messages handled by exfat_err() and co
> >> > are tossed to exfat_msg() function that does nothing but passes the
> >> > strings with printk() invocation. Not only that this is more overhead
> >> > by the indirect calls, but also this makes harder to extend for the
> >> > debug print usage; because of the direct printk() call, you cannot
> >> > make it for dynamic debug or without debug like the standard helpers
> >> > such as pr_debug() or dev_dbg().
> >> >
> >> > For addressing the problem, this patch replaces exfat_msg() function
> >> > with a macro to expand to pr_*() directly. This allows us to create
> >> > exfat_debug() macro that is expanded to pr_debug() (which output can
> >> > gracefully suppressed via dyndbg).
> >> []
> >> > diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
> >> []
> >> > @@ -508,14 +508,19 @@ void __exfat_fs_error(struct super_block *sb, int
> >> > report, const char *fmt, ...)
> >> > #define exfat_fs_error_ratelimit(sb, fmt, args...) \
> >> > __exfat_fs_error(sb, __ratelimit(&EXFAT_SB(sb)->ratelimit), \
> >> > fmt, ## args)
> >> > -void exfat_msg(struct super_block *sb, const char *lv, const char *fmt,
> >> > ...)
> >> > - __printf(3, 4) __cold;
> >> > +
> >> > +/* expand to pr_xxx() with prefix */
> >> > +#define exfat_msg(sb, lv, fmt, ...) \
> >> > + pr_##lv("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
> >> > +
> >> > #define exfat_err(sb, fmt, ...) \
> >> > - exfat_msg(sb, KERN_ERR, fmt, ##__VA_ARGS__)
> >> > + exfat_msg(sb, err, fmt, ##__VA_ARGS__)
> >> > #define exfat_warn(sb, fmt, ...) \
> >> > - exfat_msg(sb, KERN_WARNING, fmt, ##__VA_ARGS__)
> >> > + exfat_msg(sb, warn, fmt, ##__VA_ARGS__)
> >> > #define exfat_info(sb, fmt, ...) \
> >> > - exfat_msg(sb, KERN_INFO, fmt, ##__VA_ARGS__)
> >> > + exfat_msg(sb, info, fmt, ##__VA_ARGS__)
> >> > +#define exfat_debug(sb, fmt, ...) \
> >> > + exfat_msg(sb, debug, fmt, ##__VA_ARGS__)
> >>
> >> I think this would be clearer using pr_<level> directly instead
> >> of an indirecting macro that uses concatenation of <level> that
> >> obscures the actual use of pr_<level>
> >>
> >> Either: (and this first option would be my preference)
> >>
> >> #define exfat_err(sb, fmt, ...) \
> >> pr_err("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
> >> #define exfat_warn(sb, fmt, ...) \
> >> pr_warn("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
> >> etc...
> >
> > IMO, it's a matter of taste, and I don't mind either way.
> > Just let me know.
> Joe has already said that he prefers the first.

My question was about the preference of the exfat maintainers :)

> Will you send v2 patch-set ?

Sure.


Takashi

2022-07-26 08:56:14

by Namjae Jeon

[permalink] [raw]
Subject: Re: [PATCH 3/4] exfat: Expand exfat_err() and co directly to pr_*() macro

2022-07-26 16:46 GMT+09:00, Takashi Iwai <[email protected]>:
> On Tue, 26 Jul 2022 09:02:40 +0200,
> Namjae Jeon wrote:
>>
>> 2022-07-23 17:04 GMT+09:00, Takashi Iwai <[email protected]>:
>> > On Sat, 23 Jul 2022 09:42:12 +0200,
>> > Joe Perches wrote:
>> >>
>> >> On Fri, 2022-07-22 at 16:29 +0200, Takashi Iwai wrote:
>> >> > Currently the error and info messages handled by exfat_err() and co
>> >> > are tossed to exfat_msg() function that does nothing but passes the
>> >> > strings with printk() invocation. Not only that this is more
>> >> > overhead
>> >> > by the indirect calls, but also this makes harder to extend for the
>> >> > debug print usage; because of the direct printk() call, you cannot
>> >> > make it for dynamic debug or without debug like the standard helpers
>> >> > such as pr_debug() or dev_dbg().
>> >> >
>> >> > For addressing the problem, this patch replaces exfat_msg() function
>> >> > with a macro to expand to pr_*() directly. This allows us to create
>> >> > exfat_debug() macro that is expanded to pr_debug() (which output can
>> >> > gracefully suppressed via dyndbg).
>> >> []
>> >> > diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
>> >> []
>> >> > @@ -508,14 +508,19 @@ void __exfat_fs_error(struct super_block *sb,
>> >> > int
>> >> > report, const char *fmt, ...)
>> >> > #define exfat_fs_error_ratelimit(sb, fmt, args...) \
>> >> > __exfat_fs_error(sb, __ratelimit(&EXFAT_SB(sb)->ratelimit), \
>> >> > fmt, ## args)
>> >> > -void exfat_msg(struct super_block *sb, const char *lv, const char
>> >> > *fmt,
>> >> > ...)
>> >> > - __printf(3, 4) __cold;
>> >> > +
>> >> > +/* expand to pr_xxx() with prefix */
>> >> > +#define exfat_msg(sb, lv, fmt, ...) \
>> >> > + pr_##lv("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
>> >> > +
>> >> > #define exfat_err(sb, fmt, ...) \
>> >> > - exfat_msg(sb, KERN_ERR, fmt, ##__VA_ARGS__)
>> >> > + exfat_msg(sb, err, fmt, ##__VA_ARGS__)
>> >> > #define exfat_warn(sb, fmt, ...) \
>> >> > - exfat_msg(sb, KERN_WARNING, fmt, ##__VA_ARGS__)
>> >> > + exfat_msg(sb, warn, fmt, ##__VA_ARGS__)
>> >> > #define exfat_info(sb, fmt, ...) \
>> >> > - exfat_msg(sb, KERN_INFO, fmt, ##__VA_ARGS__)
>> >> > + exfat_msg(sb, info, fmt, ##__VA_ARGS__)
>> >> > +#define exfat_debug(sb, fmt, ...) \
>> >> > + exfat_msg(sb, debug, fmt, ##__VA_ARGS__)
>> >>
>> >> I think this would be clearer using pr_<level> directly instead
>> >> of an indirecting macro that uses concatenation of <level> that
>> >> obscures the actual use of pr_<level>
>> >>
>> >> Either: (and this first option would be my preference)
>> >>
>> >> #define exfat_err(sb, fmt, ...) \
>> >> pr_err("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
>> >> #define exfat_warn(sb, fmt, ...) \
>> >> pr_warn("exFAT-fs (%s): " fmt "\n", (sb)->s_id, ##__VA_ARGS__)
>> >> etc...
>> >
>> > IMO, it's a matter of taste, and I don't mind either way.
>> > Just let me know.
>> Joe has already said that he prefers the first.
>
> My question was about the preference of the exfat maintainers :)
I also agree with his opinion.
>
>> Will you send v2 patch-set ?
>
> Sure.
Thanks a lot!
>
>
> Takashi
>