Re: [PATCH] twist: allow converting pr_devel()/pr_debug() into printk(KERN_DEBUG)

From: Tetsuo Handa
Date: Thu May 28 2020 - 10:14:13 EST


On 2020/05/28 21:14, Petr Mladek wrote:
>> how to handle
>>
>>>> #define no_printk(fmt, ...) \
>>>> ({ \
>>>> if (0) \
>>>> printk(fmt, ##__VA_ARGS__); \
>>>> 0; \
>>>> })
>>
>> part used by e.g. pr_devel() ? Since this macro is not using dynamic debug
>> interface, vprintk_store() will not be called from the beginning. Are you
>> suggesting that we should convert no_printk() to use dynamic debug interface ?
>
> OK, this is one more path that would need special handling. Two paths
> are much better than 15.

OK. That can avoid needlessly increasing dynamic debug locations.
But I believe that your suggestion is much worse than 15. ;-(

Let's go back to "Add twist into vprintk_store().". The condition is not as simple as

#if TWIST
return text_len;
#endif

because we need to check whether the caller wants to print this message or not.
Since we need to print all messages that the caller asked to print, the condition
needs to be

#if TWIST
if (!this_message_should_be_stored_into_logbuf(arg))
return text_len;
#endif

and where does the "arg" come? It is not as simple as loglevel. Like you said

It might get more complicated if you would actually want to see
pr_debug() messages for a selected module in the fuzzer.

, we want to conditionally store KERN_DEBUG messages into logbuf.

We sometimes don't want to store into logbuf due to ratelimit, due to
dynamic debug. But we DO want to evaluate arguments passed to printk().

Oh, if we try to add twist into vprintk_store(), we will have to modify
all printk() callers in order to pass "arg" only for telling whether we
want to store that messages into logbuf. What a nightmare!