Re: [PATCH] printk: Add caller information to printk() output.

From: Tetsuo Handa
Date: Mon Dec 17 2018 - 16:05:13 EST

On 2018/12/17 23:54, Petr Mladek wrote:
> On Thu 2018-12-13 21:42:55, Sergey Senozhatsky wrote:
>> On (12/13/18 13:18), Petr Mladek wrote:
>>>> Sometimes we want to print a series of printk() messages to consoles
>>>> without being disturbed by concurrent printk() from interrupts and/or
>>>> other threads. But we can't enforce printk() callers to use their local
>>>> buffers because we need to ask them to make too much changes. Also, even
>>>> buffering up to one line inside printk() might cause failing to emit
>>>> an important clue under critical situation.
>>>> Therefore, instead of trying to help buffering, let's try to help
>>>> reconstructing messages by saving caller information as of calling
>>>> log_store() and adding it as "[T$thread_id]" or "[C$processor_id]"
>>>> upon printing to consoles.
>>> Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>
>> Acked-by: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx>
>>> From my point of view, the patch is ready to go into
>>> linux-next. Well, I would prefer to keep it there one more
>>> release cycle.
> I have pushed the patch into printk.git, for-4.22 branch.

Thank you.

> Now, I always felt that the "from" name was a bit strange but
> nothing better came to my mind until today.
> I would like to rename "from" to "caller", see the patch below.
> If you agree, I could push it on top or I could even squash it
> into the original patch.
> What do you think about it, please?

No problem. Squashed version attached.

> - char from[18];
> - u32 id = msg->from_id;
> + char caller[18];
> + u32 id = msg->caller_id;
> - snprintf(from, sizeof(from), ",from=%c%u",
> + snprintf(caller, sizeof(caller), ",caller=%c%u",
> id & 0x80000000 ? 'C' : 'T', id & ~0x80000000);

Updated to [20] in case memory corruption like

CPU: 0 PID: -2035180937 Comm: L ïïïïï Not tainted 4.20.0-rc6+ #344