x86, efi: print debug values in Kib not MB
PATCH 1/1 x86, efi: print debug values in Kib not MB
The current debug print in EFI does
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (0MB)
and rounds off the size to 0MB and isn't very useful. We should print this in Kib. After applying this patch we get better info with
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (280kiB)
--- arch/x86/platform/efi/efi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/platform/efi/efi.c +2 -2
@@ -384,10 +384,10 @@ static void __init print_efi_memmap(void) p < memmap.map_end; p += memmap.desc_size, i++) { md = p; -pr_info ("mem%02u: type=%u, attr=0x%llx, range=[0x%016llx-0x%016llx) (%lluMB)\n" , +pr_info ("mem%02u: type=%u, attr=0x%llx, range=[0x%016llx-0x%016llx) (%lluKiB)\n" , i, md->type, md->attribute, md->phys_addr, md->phys_addr + (md->num_pages <<EFI_PAGE_SHIFT ), - (md->num_pages >> (20 -EFI_PAGE_SHIFT ))); + (md->num_pages <<2 )); }#endif /* EFI_DEBUG */ }
Signature · 1 line
1.7.9.3
Quoted 7 lines · Prarit Bhargava
arch/x86/platform/efi/efi.c +0
-0@@ -384,10 +384,10 @@ static void __init print_efi_memmap(void) p < memmap.map_end; p += memmap.desc_size, i++) {
arch/x86/platform/efi/efi.c static void __init print_efi_memmap(void) · line 393
Quoted 10 lines
arch/x86/platform/efi/efi.c +2
-2md = p; -pr_info ("mem%02u: type=%u, attr=0x%llx, range=[0x%016llx-0x%016llx) (%lluMB)\n" , +pr_info ("mem%02u: type=%u, attr=0x%llx, range=[0x%016llx-0x%016llx) (%lluKiB)\n" , i, md->type, md->attribute, md->phys_addr, md->phys_addr + (md->num_pages <<EFI_PAGE_SHIFT ), - (md->num_pages >> (20 - EFI_PAGE_SHIFT))); + (md->num_pages << 2)); }#endif /* EFI_DEBUG */ }
If EFI_PAGE_SHIFT were to ever change from its hard-coded 12, then this would be wrong. Any reason to not simply print EFI_PAGE_SIZE and md->num_pages?
Quoted 2 lines · David Rientjes
arch/x86/platform/efi/efi.c
Quoted 1 line · Prarit Bhargava
arch/x86/platform/efi/efi.c +0
-0
[]
Quoted 9 lines
Quoted 9 lines
arch/x86/platform/efi/efi.c +1
-2@@ -384,10 +384,10 @@ static void __init print_efi_memmap(void) p < memmap.map_end; p += memmap.desc_size, i++) { md = p; -pr_info ("mem%02u: type=%u, attr=0x%llx, range=[0x%016llx-0x%016llx) (%lluMB)\n" , + pr_info("mem%02u: type=%u, attr=0x%llx, range=[0x%016llx-0x%016llx) (%lluKiB)\n", i, md->type, md->attribute, md->phys_addr, md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT), - (md->num_pages >> (20 -EFI_PAGE_SHIFT )));
Quoted 8 lines
arch/x86/platform/efi/efi.c static void __init print_efi_memmap(void) · line 393
Quoted 4 lines
arch/x86/platform/efi/efi.c +1
-0+ (md->num_pages << 2)); }#endif /* EFI_DEBUG */ }If
EFI_PAGE_SHIFTwere to ever change from its hard-coded 12, then( this would be wrong. Any reason to not simply printEFI_PAGE_SIZEandmd->num_pages?
Or maybe ((u64)EFI_PAGE_SIZE * md->num_pages) >> 10
Quoted 15 lines · David Rientjes
Quoted 13 lines · Prarit Bhargava
arch/x86/platform/efi/efi.c +1
-2@@ -384,10 +384,10 @@ static void __init print_efi_memmap(void) p < memmap.map_end; p += memmap.desc_size, i++) { md = p; -pr_info ("mem%02u: type=%u, attr=0x%llx, range=[0x%016llx-0x%016llx) (%lluMB)\n" , + pr_info("mem%02u: type=%u, attr=0x%llx, range=[0x%016llx-0x%016llx) (%lluKiB)\n", i, md->type, md->attribute, md->phys_addr, md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT), - (md->num_pages >> (20 -EFI_PAGE_SHIFT )));
Quoted 8 lines
arch/x86/platform/efi/efi.c static void __init print_efi_memmap(void) · line 393
Quoted 4 lines
arch/x86/platform/efi/efi.c +1
-0+ (md->num_pages << 2)); }#endif /* EFI_DEBUG */ }If
EFI_PAGE_SHIFTwere to ever change from its hard-coded 12, then this would be wrong. Any reason to not simply printEFI_PAGE_SIZEandmd->num_pages?
Hmm ... maybe it might be better to print out (md->num_pages * EFI_PAGE_SIZE) >> 10 ? I'll just double check that in a kernel and repost.
Thanks for the suggestion David :)
P.
Quoted 1 line
Quoted 22 lines · Joe Perches
Quoted 2 lines · David Rientjes
arch/x86/platform/efi/efi.c
Quoted 1 line · Prarit Bhargava
arch/x86/platform/efi/efi.c +0
-0[]
Quoted 9 lines
Quoted 9 lines
arch/x86/platform/efi/efi.c +1
-2@@ -384,10 +384,10 @@ static void __init print_efi_memmap(void) p < memmap.map_end; p += memmap.desc_size, i++) { md = p; -pr_info ("mem%02u: type=%u, attr=0x%llx, range=[0x%016llx-0x%016llx) (%lluMB)\n" , + pr_info("mem%02u: type=%u, attr=0x%llx, range=[0x%016llx-0x%016llx) (%lluKiB)\n", i, md->type, md->attribute, md->phys_addr, md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT), - (md->num_pages >> (20 -EFI_PAGE_SHIFT )));Quoted 8 lines
arch/x86/platform/efi/efi.c static void __init print_efi_memmap(void) · line 393
Quoted 4 lines
arch/x86/platform/efi/efi.c +1
-0+ (md->num_pages << 2)); }#endif /* EFI_DEBUG */ }If
EFI_PAGE_SHIFTwere to ever change from its hard-coded 12, then( this would be wrong. Any reason to not simply printEFI_PAGE_SIZEandmd->num_pages?
Quoted 1 line
Or maybe ((u64)EFI_PAGE_SIZE *
md->num_pages) >> 10
Heh :) See my just sent email. I'll give this a shot :)
P.
Quoted 2 lines
Borislav Petkov
maintainerQuoted 8 lines · Prarit Bhargava
The current debug print in EFI does
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (0MB)and rounds off the size to 0MB and isn't very useful. We should print this in Kib. After applying this patch we get better info with
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (280kiB)
Turning this into kiB unconditionally won't always work ok:
First of all, there might be something which parses that output so I'd make sure I'm not breaking that. Maybe fwts... Matt will know.
Then, I have an UEFI region which is > 13G:
[ 0.000000] efi: mem42: type=7, attr=0xf, range=[0x0000000100000000-0x0000000450000000) (13568MB)
With your patch it is even worse:
[ 0.000000] efi: mem42: type=7, attr=0xf, range=[0x0000000100000000-0x0000000450000000) (13893632kiB)
I'd guess you'll have to go all out and do this properly. :-)
Something like showing the highest unit which is still > 1. In the above case, this should be (13GB) or maybe even introduce fractions.
Depends on how involved this output should be.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Quoted 25 lines · Borislav Petkov
Quoted 8 lines · Prarit Bhargava
The current debug print in EFI does
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (0MB)and rounds off the size to 0MB and isn't very useful. We should print this in Kib. After applying this patch we get better info with
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (280kiB)Turning this into kiB unconditionally won't always work ok:
First of all, there might be something which parses that output so I'd make sure I'm not breaking that. Maybe fwts... Matt will know.
Then, I have an UEFI region which is > 13G:
[ 0.000000] efi: mem42: type=7, attr=0xf, range=[0x0000000100000000-0x0000000450000000) (13568MB)With your patch it is even worse:
[ 0.000000] efi: mem42: type=7, attr=0xf, range=[0x0000000100000000-0x0000000450000000) (13893632kiB)
Quoted 6 lines
I'd guess you'll have to go all out and do this properly. :-)
Something like showing the highest unit which is still > 1. In the above case, this should be (13GB) or maybe even introduce fractions.
Depends on how involved this output should be.
Yeah, I thought about doing something like that but figured if I'm at this level I can do some math ;), and it was best to keep the code simple with a KiB.
Matt -- will anything be broken here if we change the output?
P.
Quoted 1 line
Borislav Petkov
maintainerQuoted 1 line · Prarit Bhargava
and it was best to keep the code simple with a KiB.
You're missing the point - the output doesn't get simple with KiB. Read the example I just gave you!
(13893632kiB) is actively *not* helping when one looks at it!
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Quoted 8 lines · Borislav Petkov
Quoted 1 line · Prarit Bhargava
and it was best to keep the code simple with a KiB.
You're missing the point - the output doesn't get simple with KiB. Read the example I just gave you!
(13893632kiB) is actively *not* helping when one looks at it!
/proc/meminfo must be frustrating then, too.
If Prarit is going to implement this suggested reverse memparse() then it would be nice to also have it as a generic function that others can use.
Quoted 7 lines · Borislav Petkov
Quoted 1 line · Prarit Bhargava
and it was best to keep the code simple with a KiB.
You're missing the point - the output doesn't get simple with KiB. Read the example I just gave you!
(13893632kiB) is actively *not* helping when one looks at it!
I did get your point and I'm (politely) disagreeing with it. Your case ONLY works if the number is _exactly_ 13GB. What if it is 13.5? Then we're still rounding off and reporting 14GB. Which, if this code is meant for debug, makes no sense to me. Why round it off?
P.
Quoted 1 line
Borislav Petkov
maintainerQuoted 1 line · David Rientjes
If Prarit is going to implement this suggested reverse
memparse()...
The only meaningful argument about the formatting here IMO is what people staring at this output are going to understand from it.
And since those people most often tend to be the poor souls dealing with UEFI, we should ask them whether this needs fixing and if so, how.
That's it.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Quoted 9 lines · Borislav Petkov
Quoted 1 line · David Rientjes
If Prarit is going to implement this suggested reverse
memparse()...The only meaningful argument about the formatting here IMO is what people staring at this output are going to understand from it.
And since those people most often tend to be the poor souls dealing with UEFI, we should ask them whether this needs fixing and if so, how.
... I did do a get_maintainers.pl on this before sending it. Did I miss someone or some list? :(
P.
Quoted 2 lines
That's it.
Quoted 8 lines · David Rientjes
Quoted 6 lines · Borislav Petkov
Quoted 1 line · Prarit Bhargava
and it was best to keep the code simple with a KiB.
You're missing the point - the output doesn't get simple with KiB. Read the example I just gave you!
Quoted 7 lines
Quoted 2 lines
(13893632kiB) is actively *not* helping when one looks at it!
/proc/meminfomust be frustrating then, too.If Prarit is going to implement this suggested reverse
memparse()then it would be nice to also have it as a generic function that others can use.
Maybe yet another vsprintf extension?
Maybe %pH<vartype> where vartype is one of [hh, h, u, ul, ull] with something like
u64 t1 = (u64)*(appropriate cast)vartype;
u64 t2 = t1;
int index = 0;
while ((t1 >>= 10)) {
index++;
t2 >>= 10;
}to output the equivalent of
%llu%s, t2, "bkmgtpezy"[index]
ala dump_pagetables
Quoted 12 lines · Joe Perches
Maybe yet another vsprintf extension?
Maybe %pH<vartype> where vartype is one of [hh, h, u, ul, ull] with something like
u64 t1 = (u64)*(appropriate cast)vartype; u64 t2 = t1; int index = 0; while ((t1 >>= 10)) { index++; t2 >>= 10; }
Quoted 4 lines
to output the equivalent of
%llu%s, t2, "bkmgtpezy"[index]ala
dump_pagetables
Prarit has a good point about unnecessarily rounding the value, which is exactly what the patch is addressing, and it wouldn't be good to be changing the units depending on the value if anybody is using it for anything other than reading it with their own two eyes. Since EFI_PAGE_SIZE will always be in KB, it makes sense to export it in KB.
Quoted 9 lines · Prarit Bhargava
Quoted 6 lines · Borislav Petkov
Quoted 1 line · Prarit Bhargava
and it was best to keep the code simple with a KiB.
You're missing the point - the output doesn't get simple with KiB. Read the example I just gave you!
Quoted 7 lines
Quoted 1 line
(13893632kiB) is actively *not* helping when one looks at it!
I did get your point and I'm (politely) disagreeing with it. Your case ONLY works if the number is _exactly_ 13GB. What if it is 13.5? Then we're still rounding off and reporting 14GB. Which, if this code is meant for debug, makes no sense to me. Why round it off?
I think if it was being represented in procfs or sysfs, we'd need to be extremely specific to make it machine-readable, but for a human-readable printk, it makes sense to me to print it in the smaller unit size until the value is in tens of the next higher unit size (e.g. print in KiB until 10+MiB, print in MiB until 10+GiB).
Quoted 8 lines · Borislav Petkov
Quoted 7 lines · Prarit Bhargava
The current debug print in EFI does
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (0MB)and rounds off the size to 0MB and isn't very useful. We should print this in Kib. After applying this patch we get better info with
Quoted 6 lines
Quoted 1 line
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (280kiB)Turning this into kiB unconditionally won't always work ok:
First of all, there might be something which parses that output so I'd make sure I'm not breaking that. Maybe fwts... Matt will know.
I'm not aware of anything that parses the dmesg output, but I'm including Colin in case he has any insight.
Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
Quoted 11 lines · Matt Fleming
Quoted 10 lines · Borislav Petkov
Quoted 8 lines · Prarit Bhargava
The current debug print in EFI does
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (0MB)and rounds off the size to 0MB and isn't very useful. We should print this in Kib. After applying this patch we get better info with
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (280kiB)
Quoted 8 lines
Quoted 4 lines
Turning this into kiB unconditionally won't always work ok:
First of all, there might be something which parses that output so I'd make sure I'm not breaking that. Maybe fwts... Matt will know.
I'm not aware of anything that parses the dmesg output, but I'm including Colin in case he has any insight.
That won't break fwts.
Colin
Quoted 14 lines · Colin Ian King
Quoted 13 lines · Matt Fleming
Quoted 12 lines · Borislav Petkov
Quoted 8 lines · Prarit Bhargava
The current debug print in EFI does
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (0MB)and rounds off the size to 0MB and isn't very useful. We should print this in Kib. After applying this patch we get better info with
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (280kiB)Turning this into kiB unconditionally won't always work ok:
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
First of all, there might be something which parses that output so I'd make sure I'm not breaking that. Maybe fwts... Matt will know.
I'm not aware of anything that parses the dmesg output, but I'm including Colin in case he has any insight.
That won't break fwts.
Matt -- could you make a decision on whether or not this should be strictly in KiB or if it should be a rolling KiB, Mib, and GiB?
My issue is simply that I'd like to know *exactly* how big each range is and not have it rounded off. Others think that it is easier to read Mib & Gib ...
P.
Quoted 3 lines
Colin
Quoted 23 lines · Prarit Bhargava
Quoted 20 lines · Colin Ian King
Quoted 19 lines · Matt Fleming
Quoted 8 lines · Borislav Petkov
Quoted 7 lines · Prarit Bhargava
The current debug print in EFI does
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (0MB)and rounds off the size to 0MB and isn't very useful. We should print this in Kib. After applying this patch we get better info with
Quoted 6 lines
Quoted 1 line
[ 0.000000] efi: mem84: type=3, attr=0xf, range=[0x00000000645b5000-0x00000000645fb000) (280kiB)Turning this into kiB unconditionally won't always work ok:
First of all, there might be something which parses that output so I'd make sure I'm not breaking that. Maybe fwts... Matt will know.
I'm not aware of anything that parses the dmesg output, but I'm including Colin in case he has any insight.
Quoted 7 lines
Quoted 1 line
That won't break fwts.
Matt -- could you make a decision on whether or not this should be strictly in KiB or if it should be a rolling KiB, Mib, and GiB?
My issue is simply that I'd like to know *exactly* how big each range is and not have it rounded off. Others think that it is easier to read Mib & Gib ...
It is easier to read in MiB or GiB IMHO, but since it is debug info, exact is good. It would be even better [more readable] to use commas (or periods/dots) to separate it into groups of 3 digits.
Signature · 1 line
~Randy
H. Peter Anvin
reviewerQuoted 8 lines · Randy Dunlap
Quoted 3 lines
My issue is simply that I'd like to know *exactly* how big each range is and not have it rounded off. Others think that it is easier to read Mib & Gib ...
It is easier to read in MiB or GiB IMHO, but since it is debug info, exact is good. It would be even better [more readable] to use commas (or periods/dots) to separate it into groups of 3 digits.
Arguably the exactness is available in the range...
-hpa
Borislav Petkov
maintainerQuoted 1 line · H. Peter Anvin
Arguably the exactness is available in the range...
... and the size too. FWIW, other region dumps don't even print size:
[ 0.000000] e820: BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009e7ff] usable [ 0.000000] BIOS-e820: [mem 0x000000000009e800-0x000000000009ffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved
...
If we do that too for UEFI, we can certainly put an end to the bikeshedding... provided everyone is tired of it by now. :-P
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--Quoted 5 lines · Borislav Petkov
Quoted 1 line · H. Peter Anvin
Arguably the exactness is available in the range...
... and the size too. FWIW, other region dumps don't even print size:
Quoted 8 lines
[ 0.000000] e820: BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009e7ff] usable [ 0.000000] BIOS-e820: [mem 0x000000000009e800-0x000000000009ffff] reserved [ 0.000000] BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved...
If we do that too for UEFI, we can certainly put an end to the bikeshedding... provided everyone is tired of it by now. :-P
Yes, please. (I'm tired and I barely got started ;)
Signature · 1 line
~Randy