Boot-delayed printk messages already have this checked up front, and
it's odd that we don't do the same check for global printk delays, since
there's no reason to delay if we are not going to emit anything.
Signed-off-by: Chris Down <chris@chrisdown.name>
---
kernel/printk/printk.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index fd0c9f913940..06f16a5f1516 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1289,15 +1289,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(void)
{
unsigned long long k;
unsigned long timeout;
if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING)
- || suppress_message_printing(level)) {
return;
- }
k = (unsigned long long)loops_per_msec * boot_delay;
@@ -1316,7 +1314,7 @@ static void boot_delay_msec(int level)
}
}
#else
-static inline void boot_delay_msec(int level)
+static inline void boot_delay_msec(void)
{
}
#endif
@@ -2064,7 +2062,10 @@ int printk_delay_msec __read_mostly;
static inline void printk_delay(int level)
{
- boot_delay_msec(level);
+ if (suppress_message_printing(level))
+ return;
+
+ boot_delay_msec();
if (unlikely(printk_delay_msec)) {
int m = printk_delay_msec;
--
2.40.0
Hi Chris,
kernel test robot noticed the following build errors:
[auto build test ERROR on cb0856346a60fe3eb837ba5e73588a41f81ac05f]
url: https://github.com/intel-lab-lkp/linux/commits/Chris-Down/printk-Do-not-delay-messages-which-aren-t-solicited-by-any-console/20230420-204202
base: cb0856346a60fe3eb837ba5e73588a41f81ac05f
patch link: https://lore.kernel.org/r/43d7f8d6e4b45a1a76fceef2d117bbc3954bc0bf.1681994221.git.chris%40chrisdown.name
patch subject: [PATCH v4 1/2] printk: Do not delay messages which aren't solicited by any console
config: i386-randconfig-a011 (https://download.01.org/0day-ci/archive/20230421/202304211628.wQn1SxkT-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/db9fb81bc5f175ef48cb317c24da85d0f6d4391d
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Chris-Down/printk-Do-not-delay-messages-which-aren-t-solicited-by-any-console/20230420-204202
git checkout db9fb81bc5f175ef48cb317c24da85d0f6d4391d
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash kernel/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304211628.wQn1SxkT-lkp@intel.com/
All errors (new ones prefixed by >>):
>> kernel/printk/printk.c:1297:2: error: unterminated function-like macro invocation
if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING)
^
include/linux/compiler.h:56:9: note: macro 'if' defined here
#define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
^
>> kernel/printk/printk.c:4272:24: error: expected '}'
#endif /* CONFIG_SMP */
^
kernel/printk/printk.c:1293:1: note: to match this '{'
{
^
2 errors generated.
vim +1297 kernel/printk/printk.c
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1291
db9fb81bc5f175 kernel/printk/printk.c Chris Down 2023-04-20 1292 static void boot_delay_msec(void)
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1293 {
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1294 unsigned long long k;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1295 unsigned long timeout;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1296
ff48cd26fc4889 kernel/printk/printk.c Thomas Gleixner 2017-05-16 @1297 if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING)
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1298 return;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1299
3a3b6ed2235f2f kernel/printk.c Dave Young 2009-09-22 1300 k = (unsigned long long)loops_per_msec * boot_delay;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1301
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1302 timeout = jiffies + msecs_to_jiffies(boot_delay);
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1303 while (k) {
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1304 k--;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1305 cpu_relax();
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1306 /*
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1307 * use (volatile) jiffies to prevent
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1308 * compiler reduction; loop termination via jiffies
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1309 * is secondary and may or may not happen.
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1310 */
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1311 if (time_after(jiffies, timeout))
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1312 break;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1313 touch_nmi_watchdog();
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1314 }
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1315 }
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1316 #else
db9fb81bc5f175 kernel/printk/printk.c Chris Down 2023-04-20 1317 static inline void boot_delay_msec(void)
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1318 {
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1319 }
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1320 #endif
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1321
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
Hi Chris,
kernel test robot noticed the following build errors:
[auto build test ERROR on cb0856346a60fe3eb837ba5e73588a41f81ac05f]
url: https://github.com/intel-lab-lkp/linux/commits/Chris-Down/printk-Do-not-delay-messages-which-aren-t-solicited-by-any-console/20230420-204202
base: cb0856346a60fe3eb837ba5e73588a41f81ac05f
patch link: https://lore.kernel.org/r/43d7f8d6e4b45a1a76fceef2d117bbc3954bc0bf.1681994221.git.chris%40chrisdown.name
patch subject: [PATCH v4 1/2] printk: Do not delay messages which aren't solicited by any console
config: x86_64-randconfig-a013-20230417 (https://download.01.org/0day-ci/archive/20230421/202304210846.3xN0Ge3m-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/db9fb81bc5f175ef48cb317c24da85d0f6d4391d
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Chris-Down/printk-Do-not-delay-messages-which-aren-t-solicited-by-any-console/20230420-204202
git checkout db9fb81bc5f175ef48cb317c24da85d0f6d4391d
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash fs// kernel/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304210846.3xN0Ge3m-lkp@intel.com/
All errors (new ones prefixed by >>):
>> kernel/printk/printk.c:1298:3: error: expected ')'
return;
^
kernel/printk/printk.c:1297:5: note: to match this '('
if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING)
^
1 error generated.
vim +1298 kernel/printk/printk.c
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1291
db9fb81bc5f175 kernel/printk/printk.c Chris Down 2023-04-20 1292 static void boot_delay_msec(void)
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1293 {
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1294 unsigned long long k;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1295 unsigned long timeout;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1296
ff48cd26fc4889 kernel/printk/printk.c Thomas Gleixner 2017-05-16 1297 if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING)
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 @1298 return;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1299
3a3b6ed2235f2f kernel/printk.c Dave Young 2009-09-22 1300 k = (unsigned long long)loops_per_msec * boot_delay;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1301
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1302 timeout = jiffies + msecs_to_jiffies(boot_delay);
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1303 while (k) {
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1304 k--;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1305 cpu_relax();
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1306 /*
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1307 * use (volatile) jiffies to prevent
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1308 * compiler reduction; loop termination via jiffies
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1309 * is secondary and may or may not happen.
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1310 */
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1311 if (time_after(jiffies, timeout))
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1312 break;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1313 touch_nmi_watchdog();
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1314 }
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1315 }
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1316 #else
db9fb81bc5f175 kernel/printk/printk.c Chris Down 2023-04-20 1317 static inline void boot_delay_msec(void)
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1318 {
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1319 }
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1320 #endif
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1321
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
Hi Chris,
kernel test robot noticed the following build errors:
[auto build test ERROR on cb0856346a60fe3eb837ba5e73588a41f81ac05f]
url: https://github.com/intel-lab-lkp/linux/commits/Chris-Down/printk-Do-not-delay-messages-which-aren-t-solicited-by-any-console/20230420-204202
base: cb0856346a60fe3eb837ba5e73588a41f81ac05f
patch link: https://lore.kernel.org/r/43d7f8d6e4b45a1a76fceef2d117bbc3954bc0bf.1681994221.git.chris%40chrisdown.name
patch subject: [PATCH v4 1/2] printk: Do not delay messages which aren't solicited by any console
config: arc-randconfig-r043-20230416 (https://download.01.org/0day-ci/archive/20230421/202304210550.jdh8v273-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/db9fb81bc5f175ef48cb317c24da85d0f6d4391d
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Chris-Down/printk-Do-not-delay-messages-which-aren-t-solicited-by-any-console/20230420-204202
git checkout db9fb81bc5f175ef48cb317c24da85d0f6d4391d
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arc SHELL=/bin/bash fs// kernel/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304210550.jdh8v273-lkp@intel.com/
All errors (new ones prefixed by >>):
kernel/printk/printk.c: In function 'boot_delay_msec':
>> kernel/printk/printk.c:1297:64: error: expected ')' before 'return'
1297 | if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING)
| ~ ^
| )
1298 | return;
| ~~~~~~
>> kernel/printk/printk.c:1315:1: error: expected expression before '}' token
1315 | }
| ^
kernel/printk/printk.c:1295:23: warning: unused variable 'timeout' [-Wunused-variable]
1295 | unsigned long timeout;
| ^~~~~~~
kernel/printk/printk.c:1294:28: warning: unused variable 'k' [-Wunused-variable]
1294 | unsigned long long k;
| ^
vim +1297 kernel/printk/printk.c
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1291
db9fb81bc5f175 kernel/printk/printk.c Chris Down 2023-04-20 1292 static void boot_delay_msec(void)
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1293 {
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1294 unsigned long long k;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1295 unsigned long timeout;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1296
ff48cd26fc4889 kernel/printk/printk.c Thomas Gleixner 2017-05-16 @1297 if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING)
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1298 return;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1299
3a3b6ed2235f2f kernel/printk.c Dave Young 2009-09-22 1300 k = (unsigned long long)loops_per_msec * boot_delay;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1301
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1302 timeout = jiffies + msecs_to_jiffies(boot_delay);
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1303 while (k) {
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1304 k--;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1305 cpu_relax();
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1306 /*
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1307 * use (volatile) jiffies to prevent
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1308 * compiler reduction; loop termination via jiffies
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1309 * is secondary and may or may not happen.
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1310 */
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1311 if (time_after(jiffies, timeout))
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1312 break;
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1313 touch_nmi_watchdog();
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1314 }
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 @1315 }
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1316 #else
db9fb81bc5f175 kernel/printk/printk.c Chris Down 2023-04-20 1317 static inline void boot_delay_msec(void)
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1318 {
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1319 }
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1320 #endif
bfe8df3d314bdd kernel/printk.c Randy Dunlap 2007-10-16 1321
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
On 2023-04-20, Chris Down <chris@chrisdown.name> wrote:
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index fd0c9f913940..06f16a5f1516 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1289,15 +1289,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(void)
> {
> unsigned long long k;
> unsigned long timeout;
>
> if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING)
^----- you will need to remove this paren as well
> - || suppress_message_printing(level)) {
> return;
> - }
John Ogness
John Ogness writes:
>On 2023-04-20, Chris Down <chris@chrisdown.name> wrote:
>> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
>> index fd0c9f913940..06f16a5f1516 100644
>> --- a/kernel/printk/printk.c
>> +++ b/kernel/printk/printk.c
>> @@ -1289,15 +1289,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(void)
>> {
>> unsigned long long k;
>> unsigned long timeout;
>>
>> if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING)
>
> ^----- you will need to remove this paren as well
That'll teach me to compile test without remembering it also needs
CONFIG_BOOT_PRINTK_DELAY=y :-) Thanks.
>
>> - || suppress_message_printing(level)) {
>> return;
>> - }
>
>John Ogness
© 2016 - 2025 Red Hat, Inc.