x86, cpu: trivial printk formatting fixes
PATCH 1/1 x86, cpu: trivial printk formatting fixes
A 2 line printk makes dmesg output messy, because the second line does not get a timestamp. For example:
[ 0.012863] CPU0: Thermal monitoring enabled (TM1) [ 0.012869] Last level iTLB entries: 4KB 1024, 2MB 1024, 4MB 1024 Last level dTLB entries: 4KB 1024, 2MB 1024, 4MB 1024, 1GB 4 [ 0.012958] Freeing SMP alternatives memory: 28K (ffffffff81d86000 - ffffffff81d8d000) [ 0.014961] dmar: Host address width 39
--- arch/x86/kernel/cpu/common.c | 11 ++++++----- arch/x86/kernel/cpu/intel.c | 6 ++---- 2 files changed, 8 insertions(+), 9 deletions(-)
arch/x86/kernel/cpu/common.c +6 -5
@@ -494,12 +494,13 @@ void cpu_detect_tlb(struct cpuinfo_x86 *c)if (this_cpu->c_detect_tlb) this_cpu->c_detect_tlb (c); -printk (KERN_INFO "Last level iTLB entries: 4KB %d, 2MB %d, 4MB %d\n" -"Last level dTLB entries: 4KB %d, 2MB %d, 4MB %d, 1GB %d\n" , +pr_info ("Last level iTLB entries: 4KB %d, 2MB %d, 4MB %d\n" , tlb_lli_4k[ENTRIES ], tlb_lli_2m[ENTRIES ], - tlb_lli_4m[ENTRIES ], tlb_lld_4k[ENTRIES ], - tlb_lld_2m[ENTRIES ], tlb_lld_4m[ENTRIES ], - tlb_lld_1g[ENTRIES ]); + tlb_lli_4m[ENTRIES ]); + +pr_info ("Last level dTLB entries: 4KB %d, 2MB %d, 4MB %d, 1GB %d\n" , + tlb_lld_4k[ENTRIES ], tlb_lld_2m[ENTRIES ], + tlb_lld_4m[ENTRIES ], tlb_lld_1g[ENTRIES ]); }void detect_ht (struct cpuinfo_x86 *c)
arch/x86/kernel/cpu/intel.c +2 -4
@@ -487,10 +487,8 @@ static void init_intel(struct cpuinfo_x86 *c)rdmsrl (MSR_IA32_ENERGY_PERF_BIAS , epb);if ((epb &0xF ) ==ENERGY_PERF_BIAS_PERFORMANCE ) { -printk_once (KERN_WARNING "ENERGY_PERF_BIAS:" -" Set to 'normal', was 'performance'\n" -"ENERGY_PERF_BIAS: View and update with" -" x86_energy_perf_policy(8)\n" ); +pr_info_once ("ENERGY_PERF_BIAS: Set to 'normal', was 'performance'\n" ); +pr_info_once ("ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8)\n" ); epb = (epb & ~0xF ) |ENERGY_PERF_BIAS_NORMAL ;wrmsrl (MSR_IA32_ENERGY_PERF_BIAS , epb); }
Signature · 1 line
2.1.3
Quoted 2 lines · Steven Honeyman
A 2 line printk makes dmesg output messy, because the second line does not get a timestamp. For example:
[]
arch/x86/kernel/cpu/intel.c
Quoted 1 line
arch/x86/kernel/cpu/intel.c +0
-0
[]
arch/x86/kernel/cpu/intel.c static void init_intel(struct cpuinfo_x86 *c) · line 491
Quoted 10 lines
arch/x86/kernel/cpu/intel.c +2
-4@@ -487,10 +487,8 @@ static void init_intel(struct cpuinfo_x86 *c)rdmsrl (MSR_IA32_ENERGY_PERF_BIAS , epb);if ((epb &0xF ) ==ENERGY_PERF_BIAS_PERFORMANCE ) { -printk_once (KERN_WARNING "ENERGY_PERF_BIAS:" -" Set to 'normal', was 'performance'\n" -"ENERGY_PERF_BIAS: View and update with" -" x86_energy_perf_policy(8)\n" ); +pr_info_once ("ENERGY_PERF_BIAS: Set to 'normal', was 'performance'\n" ); +pr_info_once ("ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8)\n" );
This changes the logging level.
You should either mention why in the changelog
or use pr_warn_once
Borislav Petkov
maintainerQuoted 8 lines · Steven Honeyman
A 2 line printk makes dmesg output messy, because the second line does not get a timestamp. For example:
[ 0.012863] CPU0: Thermal monitoring enabled (TM1) [ 0.012869] Last level iTLB entries: 4KB 1024, 2MB 1024, 4MB 1024 Last level dTLB entries: 4KB 1024, 2MB 1024, 4MB 1024, 1GB 4 [ 0.012958] Freeing SMP alternatives memory: 28K (ffffffff81d86000 - ffffffff81d8d000) [ 0.014961] dmar: Host address width 39
It looks just fine here, albeit with repeated timestamp:
$ dmesg | grep -E "[id]TLB" [ 0.269607] Last level iTLB entries: 4KB 512, 2MB 1024, 4MB 512 [ 0.269607] Last level dTLB entries: 4KB 1024, 2MB 1024, 4MB 512, 1GB 0
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Quoted 10 lines · Borislav Petkov
Quoted 8 lines · Steven Honeyman
A 2 line printk makes dmesg output messy, because the second line does not get a timestamp. For example:
[ 0.012863] CPU0: Thermal monitoring enabled (TM1) [ 0.012869] Last level iTLB entries: 4KB 1024, 2MB 1024, 4MB 1024 Last level dTLB entries: 4KB 1024, 2MB 1024, 4MB 1024, 1GB 4 [ 0.012958] Freeing SMP alternatives memory: 28K (ffffffff81d86000 - ffffffff81d8d000) [ 0.014961] dmar: Host address width 39
Quoted 5 lines
It looks just fine here, albeit with repeated timestamp:
$ dmesg | grep -E "[id]TLB" [ 0.269607] Last level iTLB entries: 4KB 512, 2MB 1024, 4MB 512 [ 0.269607] Last level dTLB entries: 4KB 1024, 2MB 1024, 4MB 512, 1GB 0
That's strange! Is it the same for the other one? I just double checked on the slight chance I had an alias causing problems etc, but that wasn't the case:
$ 'dmesg'|'grep' ENERGY [ 0.010557] ENERGY_PERF_BIAS: Set to 'normal', was 'performance' ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8) $ dmesg --version && grep --version dmesg from util-linux 2.25.2 grep (GNU grep) 2.20
Quoted 4 lines · Joe Perches
This changes the logging level.
You should either mention why in the changelog
or usepr_warn_once
OK, I will resubmit with a new description if needed. Would you agree that info is a more suitable log level than warn for this message? Even notice seemed too much, as it isn't a 'significant condition'
Thanks,
Steven
Borislav Petkov
maintainerQuoted 11 lines · Steven Honeyman
Quoted 10 lines · Borislav Petkov
Quoted 8 lines · Steven Honeyman
A 2 line printk makes dmesg output messy, because the second line does not get a timestamp. For example:
[ 0.012863] CPU0: Thermal monitoring enabled (TM1) [ 0.012869] Last level iTLB entries: 4KB 1024, 2MB 1024, 4MB 1024 Last level dTLB entries: 4KB 1024, 2MB 1024, 4MB 1024, 1GB 4 [ 0.012958] Freeing SMP alternatives memory: 28K (ffffffff81d86000 - ffffffff81d8d000) [ 0.014961] dmar: Host address width 39
Quoted 7 lines
Quoted 5 lines
It looks just fine here, albeit with repeated timestamp:
$ dmesg | grep -E "[id]TLB" [ 0.269607] Last level iTLB entries: 4KB 512, 2MB 1024, 4MB 512 [ 0.269607] Last level dTLB entries: 4KB 1024, 2MB 1024, 4MB 512, 1GB 0That's strange! Is it the same for the other one? I just double
dmesg | grep ENERGY
[ 0.061976] ENERGY_PERF_BIAS: Set to 'normal', was 'performance' [ 0.061976] ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8)
Quoted 9 lines
checked on the slight chance I had an alias causing problems etc, but that wasn't the case:
$ 'dmesg'|'grep' ENERGY [ 0.010557] ENERGY_PERF_BIAS: Set to 'normal', was 'performance' ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8) $ dmesg --version && grep --version dmesg from util-linux 2.25.2 grep (GNU grep) 2.20
$ dmesg --version && grep --version dmesg from util-linux 2.20.1 grep (GNU grep) 2.20
I've upgraged util-linux (for dmesg) on the other box:
$ dmesg --version && grep --version dmesg from util-linux 2.25.1 grep (GNU grep) 2.18
and now I get:
dmesg | grep -E "[id]TLB"
[ 0.269607] Last level iTLB entries: 4KB 512, 2MB 1024, 4MB 512
Last level dTLB entries: 4KB 1024, 2MB 1024, 4MB 512, 1GB 0
So I'd say it looks like a regression in dmesg itself.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Quoted 44 lines · Borislav Petkov
Quoted 11 lines · Steven Honeyman
Quoted 10 lines · Borislav Petkov
Quoted 8 lines · Steven Honeyman
A 2 line printk makes dmesg output messy, because the second line does not get a timestamp. For example:
[ 0.012863] CPU0: Thermal monitoring enabled (TM1) [ 0.012869] Last level iTLB entries: 4KB 1024, 2MB 1024, 4MB 1024 Last level dTLB entries: 4KB 1024, 2MB 1024, 4MB 1024, 1GB 4 [ 0.012958] Freeing SMP alternatives memory: 28K (ffffffff81d86000 - ffffffff81d8d000) [ 0.014961] dmar: Host address width 39Quoted 7 lines
Quoted 5 lines
It looks just fine here, albeit with repeated timestamp:
$ dmesg | grep -E "[id]TLB" [ 0.269607] Last level iTLB entries: 4KB 512, 2MB 1024, 4MB 512 [ 0.269607] Last level dTLB entries: 4KB 1024, 2MB 1024, 4MB 512, 1GB 0That's strange! Is it the same for the other one? I just double
dmesg | grep ENERGY
[ 0.061976] ENERGY_PERF_BIAS: Set to 'normal', was 'performance' [ 0.061976] ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8)Quoted 9 lines
checked on the slight chance I had an alias causing problems etc, but that wasn't the case:
$ 'dmesg'|'grep' ENERGY [ 0.010557] ENERGY_PERF_BIAS: Set to 'normal', was 'performance' ENERGY_PERF_BIAS: View and update with x86_energy_perf_policy(8) $ dmesg --version && grep --version dmesg from util-linux 2.25.2 grep (GNU grep) 2.20$ dmesg --version && grep --version dmesg from util-linux 2.20.1 grep (GNU grep) 2.20I've upgraged util-linux (for dmesg) on the other box:
$ dmesg --version && grep --version dmesg from util-linux 2.25.1 grep (GNU grep) 2.18
Quoted 7 lines
and now I get:
dmesg | grep -E "[id]TLB"
[ 0.269607] Last level iTLB entries: 4KB 512, 2MB 1024, 4MB 512Last level dTLB entries: 4KB 1024, 2MB 1024, 4MB 512, 1GB 0
So I'd say it looks like a regression in dmesg itself.
Hmm - the difference is to do with the source of the kernel ring buffer. The old output format be obtained using the latest dmesg by adding "-S", which uses syslog(2) rather than /dev/kmsg. (added in commit 7af230601ab)
The klogctl version interprets the \n and adds the timestamp afterwards, but /dev/kmsg changes the '\n' to "\x0a" resulting in:
4,355,10557,-;ENERGY_PERF_BIAS: Set to 'normal', was 'performance'\x0aENERGY_P...
It looks as though it's just a matter of opinion/preference whether control characters are printed (rfc5424)
Borislav Petkov
maintainerQuoted 5 lines · Steven Honeyman
Hmm - the difference is to do with the source of the kernel ring buffer. The old output format be obtained using the latest dmesg by adding "-S", which uses syslog(2) rather than
/dev/kmsg. (added in commit7af230601ab)
Quoted 7 lines
The klogctl version interprets the \n and adds the timestamp afterwards, but
/dev/kmsgchanges the '\n' to "\x0a" resulting in:
4,355,10557,-;ENERGY_PERF_BIAS: Set to 'normal', was 'performance'\x0aENERGY_P...It looks as though it's just a matter of opinion/preference whether control characters are printed (rfc5424)
Right, I see what you mean. There's this in the /dev/kmsg code
---
* /dev/kmsg exports the structured data in the following line format:
* "level,sequnum,timestamp;<message text>\n"
*
* The optional key/value pairs are attached as continuation lines starting
* with a space character and terminated by a newline. All possible
* non-prinatable characters are escaped in the "\xff" notation. *
* Users of the export format should ignore possible additional values
* separated by ',', and find the message after the ';' character. */
--
and also
---
/* escape non-printable characters */
for (i = 0; i < msg->text_len; i++) {
unsigned char c = log_text(msg)[i];
if (c < ' ' || c >= 127 || c == '\\')
len += sprintf(user->buf + len, "\\x%02x", c);
else
user->buf[len++] = c;
}--
in devkmsg_read().
Hmm, so this all looks like an agreed upon thing or whatever. Oh, and btw, if you don't enable printk timestamping, you won't see the issue.
I'd say the simplest solution - and this is only me and I like practical
- is to accept your patch after all and stop wasting time with this :-)
Only after you fix it, though, to *not* change log levels for the other printk message. FWIW, your change even improves the readability a bit of those printks.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--(Adding Len Brown, original post: https://lkml.org/lkml/2014/11/1/67)
Quoted 10 lines · Steven Honeyman
Quoted 4 lines · Joe Perches
This changes the logging level.
You should either mention why in the changelog
or usepr_warn_onceOK, I will resubmit with a new description if needed. Would you agree that info is a more suitable log level than warn for this message? Even notice seemed too much, as it isn't a 'significant
condition'
This is only emitted when the bios didn't do the "right thing". See commit abe48b108247e9b90
So it seems more like the origial message isn't descriptive enough than KERN_WARN is not the correct level.