Re: [PATCH] printk: Add loglevel for "do not print to consoles".
From: Tetsuo Handa
Date: Thu May 14 2020 - 19:25:37 EST
On 2020/05/15 1:26, Petr Mladek wrote:
> This does not make much sense to me. KERN_NO_CONSOLES would be another
> global flag. If you enable/disable its functionality, it would affect
> all strings with this flag (not only the ones used by OOM killer).
Are you assuming that the switch is applied on KERN_$LEVEL setting (e.g.
/proc/sys/kernel/print_emerg_messages_on_consoles
/proc/sys/kernel/print_alert_messages_on_consoles
/proc/sys/kernel/print_crit_messages_on_consoles
/proc/sys/kernel/print_err_messages_on_consoles
/proc/sys/kernel/print_warning_messages_on_consoles
/proc/sys/kernel/print_notice_messages_on_consoles
/proc/sys/kernel/print_info_messages_on_consoles
/proc/sys/kernel/print_debug_messages_on_consoles
) ? Then, that is not what I'm proposing.
The switch I will propose is applied on individual printk() call (e.g.
printk("%s[%7d] %5d %5d %8lu %8lu %8ld %8lu %5hd %s\n",
sysctl_oom_dump_tasks == 2 ? KERN_INFO KERN_NO_CONSOLES : KERN_INFO,
task->pid, from_kuid(&init_user_ns, task_uid(task)),
task->tgid, task->mm->total_vm, get_mm_rss(task->mm),
mm_pgtables_bytes(task->mm),
get_mm_counter(task->mm, MM_SWAPENTS),
task->signal->oom_score_adj, task->comm);
) which is NOT another global flag.
Since Dmitry Safonov is working on adding loglevel argument to show_stack(),
we will also be able to implement dump_stack_loglvl(const char *loglvl). Thus,
we will be able to apply KERN_NO_CONSOLES flags to e.g. only dump_stack() /
show_mem() / dump_tasks() etc. WITHOUT MAKING THE SWITCHES GLOBAL.
The direction is heading for "+ loglevel assigned to each message".