printk: add loglevel for messages from /dev/kmsg
Eric Miao [Thu, 11 Jun 2015 17:37:42 +0000 (10:37 -0700)]
Bug 1644887

Allow messages to /dev/kmsg to have a different loglevel other than
the default_message_loglevel, which is the one kernel printk() uses
when no loglevel is specified.

Change-Id: I340d20693d87cfea9aaea51845caf32b4cbd62fa
Signed-off-by: Eric Miao <emiao@nvidia.com>
Reviewed-on: http://git-master/r/756603
Reviewed-by: Li Li (SW-TEGRA) <lli5@nvidia.com>
Tested-by: Li Li (SW-TEGRA) <lli5@nvidia.com>
Reviewed-by: Nitin Kumbhar <nkumbhar@nvidia.com>
Reviewed-on: http://git-master/r/805255
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vinayak Pane <vpane@nvidia.com>

include/linux/printk.h
kernel/printk.c
kernel/sysctl.c

index 708b8a8..09ddba9 100644 (file)
@@ -39,6 +39,7 @@ extern int console_printk[];
 #define default_message_loglevel (console_printk[1])
 #define minimum_console_loglevel (console_printk[2])
 #define default_console_loglevel (console_printk[3])
+#define default_devkmsg_loglevel (console_printk[4])
 
 static inline void console_silent(void)
 {
index 67f72f5..5f74f5a 100644 (file)
@@ -62,11 +62,12 @@ extern void printascii(char *);
 #define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
 #define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */
 
-int console_printk[4] = {
+int console_printk[5] = {
        DEFAULT_CONSOLE_LOGLEVEL,       /* console_loglevel */
        DEFAULT_MESSAGE_LOGLEVEL,       /* default_message_loglevel */
        MINIMUM_CONSOLE_LOGLEVEL,       /* minimum_console_loglevel */
        DEFAULT_CONSOLE_LOGLEVEL,       /* default_console_loglevel */
+       DEFAULT_MESSAGE_LOGLEVEL,       /* default_devkmsg_loglevel */
 };
 
 /*
@@ -428,7 +429,7 @@ static ssize_t devkmsg_writev(struct kiocb *iocb, const struct iovec *iv,
 {
        char *buf, *line;
        int i;
-       int level = default_message_loglevel;
+       int level = default_devkmsg_loglevel;
        int facility = 1;       /* LOG_USER */
        size_t len = iov_length(iv, count);
        ssize_t ret = len;
index 2c58ffa..0d4a56b 100644 (file)
@@ -761,7 +761,7 @@ static struct ctl_table kern_table[] = {
        {
                .procname       = "printk",
                .data           = &console_loglevel,
-               .maxlen         = 4*sizeof(int),
+               .maxlen         = 5*sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_dointvec,
        },