Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755279AbdDECIP (ORCPT ); Tue, 4 Apr 2017 22:08:15 -0400 Received: from mail-pf0-f180.google.com ([209.85.192.180]:34218 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751888AbdDECIK (ORCPT ); Tue, 4 Apr 2017 22:08:10 -0400 Date: Wed, 5 Apr 2017 11:08:00 +0900 From: Sergey Senozhatsky To: Calvin Owens Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Greg Kroah-Hartman , Jiri Slaby , Andrew Morton , Manuel =?iso-8859-1?Q?Sch=F6lling?= , Hans de Goede , Paul Burton , linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [RFC][PATCH 1/2] printk: Introduce per-console filtering of messages by loglevel Message-ID: <20170405020800.GB11669@jagdpanzerIV.localdomain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.8.0 (2017-02-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2099 Lines: 66 On (04/04/17 16:02), Calvin Owens wrote: [..] > static void call_console_drivers(const char *ext_text, size_t ext_len, > - const char *text, size_t len) > + const char *text, size_t len, int level) > { > struct console *con; > > @@ -1581,6 +1581,8 @@ static void call_console_drivers(const char *ext_text, size_t ext_len, > if (!cpu_online(smp_processor_id()) && > !(con->flags & CON_ANYTIME)) > continue; > + if (level > con->maxlevel) > + continue; > if (con->flags & CON_EXTENDED) > con->write(con, ext_text, ext_len); > else > @@ -1869,7 +1871,7 @@ static ssize_t msg_print_ext_body(char *buf, size_t size, > char *dict, size_t dict_len, > char *text, size_t text_len) { return 0; } > static void call_console_drivers(const char *ext_text, size_t ext_len, > - const char *text, size_t len) {} > + const char *text, size_t len, int level) {} > static size_t msg_print_text(const struct printk_log *msg, > bool syslog, char *buf, size_t size) { return 0; } > static bool suppress_message_printing(int level) { return false; } > @@ -2238,7 +2240,7 @@ void console_unlock(void) > raw_spin_unlock(&logbuf_lock); > > stop_critical_timings(); /* don't trace print latency */ > - call_console_drivers(ext_text, ext_len, text, len); > + call_console_drivers(ext_text, ext_len, text, len, msg->level); > start_critical_timings(); > printk_safe_exit_irqrestore(flags); ok, so the idea is quite clear and reasonable. some thoughts, we have a system-wide suppress_message_printing() loglevel filtering in console_unlock() loop, which sets a limit on loglevel for all of the messages - we don't even msg_print_text() if the message has suppressible loglevel. and this implicitly restricts per-console maxlevels. console_unlock() { for (;;) { ... skip: if (suppress_message_printing(msg->level)) // console_loglevel goto skip; call_console_drivers(msg->level) { if (level > con->maxlevel) // con loglevel continue; ... } } } this can be slightly confusing. what do you think? -ss