Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp440582imm; Thu, 31 May 2018 03:24:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIk1/Me0VVzhZcyh5RfS2tpygLs0qno+WFylRpVH78cDWrmVUemkx3hl6RCEL0rP6OlceRp X-Received: by 2002:a17:902:3081:: with SMTP id v1-v6mr6582042plb.266.1527762277867; Thu, 31 May 2018 03:24:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527762277; cv=none; d=google.com; s=arc-20160816; b=YL0/pd06jSVEd5o8zyMiIudIy01bxoO7VcGFVTQc4lbahlvyLBbYGo+IKgp3A84z+2 ctH68UKDyNZqyOR4EUX5yGMYWVksiYdA9ZorSJoT09Y95kMFCFcOTHf3XNzSLEsrI+bO 2k3lyraMYYX4sxsEt5QgxGJDQHnjIJBJ2E26DtPi1Zsq/V8wk4sHyQO+OtDDrCTgLWoT 04DBBZPsCDMj7fe0tZfTBMg1kEtjeeKaunJac5a2dFJKQUsmh0dBVqiRdh2gFJs7qxR3 eEKqqZsfCIbOfZNOM2/0y/Z2x9c4FX0JMPU7oRr8cPpMItpOdvQr23yaCvEEHkkN9zd1 8m0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=2T1AhK3uEft/cuGpeKoPYWjFo+UBXzIS6ncGfhgBanw=; b=IFFPGkoOYEuTBmaQ1pQoltzlnI8PniinMTaDz1/2wpaCiqXEiOiz9TM/YKP312wXbU t0nSRIdTH/EcL8hjz58hl6sNXGLzCiA8iiJ8MYSqBE/wzMQ+p5Si4uouFREoY8/2mdSv KxUivVlfA7894v2zF4EOuE/FJL33vzjgSNZc/7d5j3NGetr+CQAv+44nEiwFepg8TXUn ydnN/1OuGtWpoqQotQ5IBk+b3bma3W056ahVjIKqMcrJZE+ra4F1YHMFN4sEMxPjjKFm 4VLQqqYMnkfjMCc8OEfARJi7PJTKxf/maZP+QacqjqmaoBVD/kz54OfyEQCyC8tkOcx+ tREA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=QvQe/VSM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e66-v6si28748966pgc.466.2018.05.31.03.24.23; Thu, 31 May 2018 03:24:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=QvQe/VSM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754403AbeEaKWu (ORCPT + 99 others); Thu, 31 May 2018 06:22:50 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:33963 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754268AbeEaKWs (ORCPT ); Thu, 31 May 2018 06:22:48 -0400 Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20180531102247epoutp037addc1d956fa04fa775bed1f43bfab31~zs5jI5jgH2308723087epoutp03i for ; Thu, 31 May 2018 10:22:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20180531102247epoutp037addc1d956fa04fa775bed1f43bfab31~zs5jI5jgH2308723087epoutp03i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1527762167; bh=2T1AhK3uEft/cuGpeKoPYWjFo+UBXzIS6ncGfhgBanw=; h=From:To:Cc:Subject:Date:References:From; b=QvQe/VSMAlxqWsIlOBAsZKNNsPcDogipKA4QFXohlCRZzz1BMZm8fOYRypFVw1ywv MjvOC0HBl2ctzkvSH8+noMtusw3dbggUoDDcC/hFayvEamV78f4MhSjpicKbL1wH4z ZbwyJxL2/rqct9RkYs/hn3npzSsasb/pmdgsi1sc= Received: from epsmges5p3new.samsung.com (unknown [182.195.40.198]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20180531102246epcas5p2941e6e11f300e84d6a8235400335cef0~zs5idHBaE2025320253epcas5p2V; Thu, 31 May 2018 10:22:46 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 9B.E7.04408.6FCCF0B5; Thu, 31 May 2018 19:22:46 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20180531102246epcas5p2f1cbc6ff217172e12e2f78bb88eb4a7e~zs5h59tMh2250222502epcas5p2S; Thu, 31 May 2018 10:22:46 +0000 (GMT) Received: from epsmgms1p2new.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180531102246epsmtrp1eeb37aeb69aa843aabda42ff69aacacd~zs5h4XTIP1786617866epsmtrp1r; Thu, 31 May 2018 10:22:46 +0000 (GMT) X-AuditID: b6c32a4b-989ff70000001138-06-5b0fccf6b737 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 66.E8.03631.5FCCF0B5; Thu, 31 May 2018 19:22:45 +0900 (KST) Received: from localhost.localdomain (unknown [107.108.92.210]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180531102237epsmtip112f5c5b657ef237b51f346e5836d28a6~zs5ZtfIS-3213432134epsmtip1H; Thu, 31 May 2018 10:22:36 +0000 (GMT) From: Maninder Singh To: pmladek@suse.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org Cc: linux-kernel@vger.kernel.org, a.sahrawat@samsung.com, pankaj.m@samsung.com, v.narang@samsung.com, Maninder Singh Subject: [PATCH 2/2] printk: make sure to print log on console. Date: Thu, 31 May 2018 15:49:11 +0530 X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA0VSbUhTYRTm3e62qzS7Ta1Xkxg3DJU2t9XsFppKViOlBv4IHGIX96Livtrd lkY/FspYI81KCUXJwJaJZYlpqSlNUwwpzSSLPiQVKq3ltxlU267Rr/Oc8zzPOYfDwbmiV7xI vMBgQWYDrSP5wVh7X2ysZGV4s0b2eXwXNdqFqLHOWj7Vd92BUR/mHnCoP1PLPKrHOcmh7ixO CSjPUB1IwVWPat4LVKU9bwWq8rYmoGppG8dUi6071LwslJiPaC0yi5Eh16gtMOQlkemZOYdy lAkyuUS+n9pHig20HiWRaRlqyZECnW8VUmyjdVZfSU0zDBl/MNFstFqQON/IWJJIjVyukMpl +6QKhS8qsw8olD7JKZR/s6mSY7qxs2i65D5mB41RLhCEQ2Iv/Ohu5LpAMC4iugDsL1/B2GQB wNrJnwI2WQHwyeOL2D/LbMc0jyUeA9gxcI/DJksALrRV8fwqPiGFTZ3dAUcYcRQurP7g+0Vc 4gqAqx+bA0QokQznyuwCP8aIaPj9xRSfHbEDDg1cDYyAhJMPa53uACEkbPDDXS+HFaXBBc/g hiEUfh1sE7A4En655NjADHR5zwO2USmA35Y+cVkiGU5OPPWJcN9KsbClM95f5hIhsOzXNMdf hoQQOh0iVh0NS9/c47F4O1ycn984hQpOnB8NrCAismHd3XpQAaJq/jetB6AJRCATo89DjNK0 x4DOSBlaz1gNedJco74VBD4qLv0haH2e4QEEDshNQrw5RCPi0T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a7e~zs5h59tMh2250222502epcas5p2S@epcas5p2.samsung.com> X-CMS-MailID: 20180531102246epcas5p2f1cbc6ff217172e12e2f78bb88eb4a7e X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180531102246epcas5p2f1cbc6ff217172e12e2f78bb88eb4a7e References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch make sure printing of log if loglevel at time of storing log is greater than current console loglevel. @why In case of async printk, printk thread can miss logs because it checks current log level at time of console_unlock. func() { .... .... console_verbose(); // user wants to have all the logs on console. pr_alert(); pr_info(); dump_backtrace(); // prints with default loglevel. pr_info(); pr_emerg(); pr_info(); ... ... ... pr_info(); console_silent(); // stop all logs from printing on console. } Now if printk thread is scheduled after setting console loglevel to silent, then user's requirement will be in waste, because it will not print logs on console at time of printk thread scheduling. @how use one bit of flags field to store whether its console print or not(console_print) by checking current console loglevel with message's level at time of log. At time of print check this flag for printing message on console. Signed-off-by: Vaneet Narang Signed-off-by: Maninder Singh --- kernel/printk/printk.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index ab15903..4e0be66e 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -360,8 +360,16 @@ struct printk_log { u16 text_len; /* length of text buffer */ u16 dict_len; /* length of dictionary buffer */ u8 facility; /* syslog facility */ - u8 flags:5; /* internal record flags */ + u8 flags:4; /* internal record flags */ u8 level:3; /* syslog level */ + /* + * whether to print this msg on console or not? + * due to async printk, printk thread can miss + * prints at the time of console_flush because of + * change in print level afterwards. + */ + u8 console_print:1; + } #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS __packed __aligned(4) @@ -623,7 +631,12 @@ static int log_store(int facility, int level, msg->dict_len = dict_len; msg->facility = facility; msg->level = level & 7; - msg->flags = flags & 0x1f; + if (msg->level >= console_loglevel) + msg->console_print = 0; + else + msg->console_print = 1; + + msg->flags = flags & 0xf; if (ts_nsec > 0) msg->ts_nsec = ts_nsec; else @@ -1144,9 +1157,9 @@ static int __init ignore_loglevel_setup(char *str) MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting (prints all kernel messages to the console)"); -static bool suppress_message_printing(int level) +static bool suppress_message_printing(int console_print) { - return (level >= console_loglevel && !ignore_loglevel); + return (!console_print && !ignore_loglevel); } #ifdef CONFIG_BOOT_PRINTK_DELAY @@ -1172,13 +1185,13 @@ static int __init boot_delay_setup(char *str) } early_param("boot_delay", boot_delay_setup); -static void boot_delay_msec(int level) +static void boot_delay_msec(int console_print) { unsigned long long k; unsigned long timeout; if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING) - || suppress_message_printing(level)) { + || suppress_message_printing(console_print)) { return; } @@ -1199,7 +1212,7 @@ static void boot_delay_msec(int level) } } #else -static inline void boot_delay_msec(int level) +static inline void boot_delay_msec(int console_print) { } #endif @@ -1840,7 +1853,7 @@ asmlinkage int vprintk_emit(int facility, int level, in_sched = true; } - boot_delay_msec(level); + boot_delay_msec(level < console_loglevel); printk_delay(); /* This stops the holder of console_sem just where we want him */ @@ -2011,7 +2024,7 @@ static void call_console_drivers(const char *ext_text, size_t ext_len, const char *text, size_t len) {} 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; } +static bool suppress_message_printing(int console_print) { return false; } #endif /* CONFIG_PRINTK */ @@ -2354,7 +2367,7 @@ void console_unlock(void) break; msg = log_from_idx(console_idx); - if (suppress_message_printing(msg->level)) { + if (suppress_message_printing(msg->console_print)) { /* * Skip record we have buffered and already printed * directly to the console when we received it, and -- 1.9.1