Skip to contentSkip to conversation

PROBLEM: KB->KiB, MB -> MiB, ... (IEC 60027-2)

DISCUSSION Michał Kudła 11 participants 16 messages Jan 20, 2007 – Jan 27, 2007

lore
Share & tools
lore
#0 lore raw

Hello,
according to http://www.kernel.org/pub/linux/docs/lkml/reporting-bugs.html
[1.] One line summary of the problem:
KB->KiB, MB -> MiB, ... (IEC 60027-2 Letter symbols to be used in electrical technology – Part 2)
[2.] Full description of the problem/report:
kernel: 2.6.19
linux: gentoo

after
#dmesg
I find somethings like it

Memory: 515992k/524224k available (1909k kernel code, 7684k reserved, 768k data, 172k init, 0k highmem)
virtual kernel memory layout:

    fixmap  : 0xfffb7000 - 0xfffff000   ( 288 kB)
    vmalloc : 0xe0800000 - 0xfffb5000   ( 503 MB)
    lowmem  : 0xc0000000 - 0xdfff0000   ( 511 MB)
      .init : 0xc03a0000 - 0xc03cb000   ( 172 kB)
      .data : 0xc02dd6d6 - 0xc039d8f4   ( 768 kB)
      .text : 0xc0100000 - 0xc02dd6d6   (1909 kB)

...
hdb: max request size: 512KiB
hdb: 488397168 sectors (250059 MB) w/8192KiB Cache, CHS=30401/255/63, UDMA(100)
hdb: cache flushes supported
hdb: hdb1 hdb2 hdb3
hdc: ATAPI 40X DVD-ROM DVD-R CD-R/RW drive, 2000kB Cache, UDMA(66)

Should be everywere KiB, MiB, GiB, ... according to IEC 60027-2

http://www.iec.ch/zone/si/si_bytes.htm
http://en.wikipedia.org/wiki/Kibibyte

[3.] Keywords (i.e., modules, networking, kernel):
modules, networking, kernel,... everywere
[4.] Kernel version (from /proc/version):
Linux version 2.6.19-gentoo-r4 (root@athlonik) (gcc version 4.1.1 (Gentoo 4.1.1-r3)) #1 Fri Jan 19 22:22:39 CET 2007
[5.] Output of Oops.. message (if applicable) with symbolic information
resolved (see Documentation/oops-tracing.txt)
none
[6.] A small shell script or example program which triggers the
problem (if possible)
dmesg | grep -E '(KB)|(KiB)|(MB)'
[7.] Environment
linux
[7.1.] Software (add the output of the ver_linux script here) [7.2.] Processor information (from /proc/cpuinfo):
cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 6
model : 8
model name : AMD Athlon(tm) XP
stepping : 1
cpu MHz : 1666.742
cache size : 256 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat
pse36 mmx fxsr sse syscall mmxext 3dnowext 3dnow ts
bogomips : 3335.02

[7.3.] Module information (from /proc/modules):
not important
[7.4.] Loaded driver and hardware information (/proc/ioports, /proc/iomem) not important
[7.5.] PCI information ('lspci -vvv' as root)
not important
[7.6.] SCSI information (from /proc/scsi/scsi)
not important
[7.7.] Other information that might be relevant to the problem
(please look in /proc and include all information that you think to be relevant):
not important
[X.] Other notes, patches, fixes, workarounds:
“That’s one small step for a man, one giant leap for mankind.” - Neil Armstrong

#1 lore raw
Quoted 6 lines

[1.] One line summary of the problem:
KB->KiB, MB -> MiB, ... (IEC 60027-2 Letter symbols to be used in electrical
technology – Part 2)
Should be everywere KiB, MiB, GiB, ... according to IEC 60027-2

Bytes are not an SI unit. A "megabyte" doesn't have to be a million bytes any more than a "megaphone" has to be a million phones. A "megabyte" is 1,048,576 bytes. The "mega" in there is not an SI prefix. "Mega" is only an SI prefix when it appears before an SI unit.

DS

#2 lore raw

Hello,

Quoted 9 lines · David Schwartz
Quoted 6 lines

[1.] One line summary of the problem:
KB->KiB, MB -> MiB, ... (IEC 60027-2 Letter symbols to be used in electrical
technology – Part 2)
Should be everywere KiB, MiB, GiB, ... according to IEC 60027-2

Bytes are not an SI unit. A "megabyte" doesn't have to be a million bytes any more than a "megaphone" has to be a million phones. A "megabyte" is 1,048,576 bytes. The "mega" in there is not an SI prefix. "Mega" is only an SI prefix when it appears before an SI unit.

Nice observation, however, it still leaves quite an amount of internal inconsistencies in the kernel output.

One way of getting rid of those inconsistencies would be to follow IEC 60027-2 for those cases where SI is inappropriate.

Leon.

#3 lore raw
Quoted 3 lines

Nice observation, however, it still leaves quite an amount of internal inconsistencies in the kernel output.

I agree with the majority view that using the term 'MB' or 'GB' to mean a
million or a billion bytes is inaccurate. The way RAM and flash are measured is correct. The way disk manufacturers advertise disk capacity is simply *wrong*. There is no word for a million bytes. There is no word for a billion bytes.

Quoted 2 lines

One way of getting rid of those inconsistencies would be to follow IEC 60027-2 for those cases where SI is inappropriate.

Talk about a cure worse than the disease! So you're saying that 256MB flash
cards could be advertised as having 268.4MB? A 512MB RAM stick is mislabelled and could correctly say 536.8MB? That's just plain craziness.

Adopting IEC 60027-2 just replaces a set of well-understood problems with
all new problems.

DS

#4 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"David" == David Schwartz <[email protected]> writes:

David> The way RAM and flash are measured is correct.

In my experience, RAM and flash *drives* are measured differently.

I understand that individual flash chips come in powers of 2, but by the time they're packaged as a "flash drive", some of that has been used up -- yet they're still sold as the full capacity, and the manufacturers use the confusion between MiB and MB to defend the practice.

This "16Mb" drive doesn't really have 16 megabytes of capacity - it's really got 15.5. But that's just standard operating procedure for storage manufacturers. Non-volatile storage manufacturers, including hard drive companies, like to define a megabyte as 1,000,000 bytes and a gigabyte as 1,000,000,000 bytes. They're actually two-to-the-power-of-20 and two-to-the-power-of-30 bytes, which is 1,048,576 and 1,073,741,824 bytes respectively. This is the main reason why a "20Gb" hard drive won't actually give you 20Gb of capacity.

In flash RAM devices, things can get a bit more complex again, thanks to the small amount of memory which may be used by the device itself for housekeeping. That can vary between device families; a CompactFlash card with a given nominal capacity may actually have a bit less space than a SmartMedia card with the same number on the label. And manufacturers may throw in some more memory to push the real capacity up closer to the stated one, which is what they've done with the USBDrive. It's still about three per cent shy of its claimed capacity, though.

-- http://www.dansdata.com/flashcomp.htm

(E.g., my "512MB" CF card shows up as "487MB" in the camera -- a difference of exactly 5%, as would be expected by the MB-vs-MiB scam. I'd be happier if the camera said "487MiB", but we're looking at OSes we do have control over, not others.)

And this cheat is getting better (for the seller) with every expansion:

1 MiB is 5% bigger than 1 MB
1 GiB is 7% bigger than 1 GB
1 TiB is 10% bigger than 1 TB

So when you go out to buy your 1TB drive this year, you're really only buying 0.9TiB or so.

Since all the manufacturers do the same thing, it's possible to consider it "fair", at least for comparisons -- but when the customer gets home and formats their drive, I think they'd be happier if the number was the same as on the carton.

Just last night I formatted some new "500GB" drives, and they eventually came back with 465GB as the displayed capacity. Wouldn't it make more sense to display that as "465GiB"?

David> Talk about a cure worse than the disease! So you're saying that David> 256MB flash cards could be advertised as having 268.4MB? A David> 512MB RAM stick is mislabelled and could correctly say 536.8MB? David> That's just plain craziness.

No, it sounds like he wants them advertised as 256MB and 512MiB, respectively -- packaged flash cards tend to use the 1000 multiples, while DRAM uses the 1024. One extra letter doesn't sound all that crazy.

How fast is your Ethernet port? 100Mbps or 95.37Mbps?

Somewhat archaic now, but how big was your common 3.5" floppy disk (PC "HD" format)? It actually used a basis of 1,024,000:

And if two definitions of the megabyte are not enough, a third megabyte of 1 024 000 bytes is the megabyte used to format the familiar 90 mm (3 1/2 inch), "1.44 MB" diskette.

-- http://physics.nist.gov/cuu/Units/binary.html

What's likely is that the flash and drive manufacturers will either mark their products honestly, or they'll increase the capacity of their product to meet the given label.

(Think about the CRT "diagonal" measurements -- it took a few lawsuits, but they eventually switched from measuring bezel-to-bezel, or total tube diagonal, to "viewable". Sure, everyone in technology "knew" that you had to chop off an inch or two from the advertised value to get the viewable; but that's not enough to meet the standard of truth in advertising.)

David> Adopting IEC 60027-2 just replaces a set of well-understood David> problems with all new problems.

Which are clearly solved in the standards document, and remove any ambiguity. Is one extra character really that painful to you?

t.

#9 lore raw
In reply to David Schwartz
Quoted 8 lines · David Schwartz

Talk about a cure worse than the disease! So you're saying that 256MB flash
cards could be advertised as having 268.4MB? A 512MB RAM stick is mislabelled and could correctly say 536.8MB? That's just plain craziness.

Adopting IEC 60027-2 just replaces a set of well-understood problems with
all new problems.

Except that you're wrong above. Most 512 MB flash cards are less than 512 MiB; most of them are, in fact, around 512 MB! RAM, of course, is consistently 512 MiB.

This little tidbit discovered in the process of working on an application which required powers-of-two flash cards, and finding that one does have to use one size larger...

-hpa

#12 lore raw
In reply to David Schwartz

David,

Quoted 8 lines · David Schwartz

[Leon said:]

Quoted 2 lines

One way of getting rid of those inconsistencies would be to follow IEC 60027-2 for those cases where SI is inappropriate.

Talk about a cure worse than the disease! So you're saying that 256MB flash
cards could be advertised as having 268.4MB? A 512MB RAM stick is mislabelled and could correctly say 536.8MB? That's just plain craziness.

No, I meant to advertise it as a 256 MiB flash device and a 512 MiB flash device, as the Mi prefix has a single interpretation, that is 2 to the power of 20, as per IEC 60027-2, whereas M has not if used outside SI units.

Leon.

#10 lore raw
In reply to H. Peter Anvin
Quoted 10 lines · H. Peter Anvin
Quoted 8 lines · David Schwartz

Talk about a cure worse than the disease! So you're saying that 256MB
flash
cards could be advertised as having 268.4MB? A 512MB RAM stick is mislabelled and could correctly say 536.8MB? That's just plain craziness.

Adopting IEC 60027-2 just replaces a set of well-understood problems
with
all new problems.

Quoted 7 lines

Except that you're wrong above. Most 512 MB flash cards are less than 512 MiB; most of them are, in fact, around 512 MB! RAM, of course, is consistently 512 MiB.

This little tidbit discovered in the process of working on an application which required powers-of-two flash cards, and finding that one does have to use one size larger...

Yeah, and Ethernet speed is measured in Mbps, not Mibps.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#11 lore raw
Quoted 3 lines · Geert Uytterhoeven

Yeah, and Ethernet speed is measured in Mbps, not Mibps.

Indeed.

-hpa

#5 lore raw
In reply to Tony Foiani
Quoted 3 lines

How fast is your Ethernet port? 100Mbps or 95.37Mbps?

Same lie like with harddrives. It's around 80, not 100. But it depends on how you look at it. 80 for Layer3, possibly a little more for Layer2/1.

	-`J'
#13 lore raw
In reply to Leon Woestenberg
Quoted 11 lines
Quoted 6 lines

Talk about a cure worse than the disease! So you're saying that 256MB flash
cards could be advertised as having 268.4MB? A 512MB RAM stick is mislabelled and could correctly say 536.8MB? That's just plain craziness.

No, I meant to advertise it as a 256 MiB flash device and a 512 MiB flash device, as the Mi prefix has a single interpretation, that is 2 to the power of 20, as per IEC 60027-2, whereas M has not if used outside SI units.

If it actually has 256*2^20 bytes, why advertise it as "256 MiB" when "268.4 MB" is equally valid and looks better? It really comes down to this: is it your position that "256 MB" can only correctly mean 256 million bytes?

If you are right, a "512MB" RAM stick is mislabelled and is more correctly labelled as "536.8MB". (With 512MiB being equally correct.)

Isn't that obviously not just wrong but borderline crazy? Yes, your position has some nice consequences, but that doesn't allow you to ignore the bad ones.

Unfortunately, we're not writing on a clean slate here.

DS

#6 lore raw
In reply to Jan Engelhardt
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

"Tony" == Tony Foiani <[email protected]> writes:

Tony> How fast is your Ethernet port? 100Mbps or 95.37Mbps?

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Jan" == Jan Engelhardt <[email protected]> writes:

Jan> Same lie like with harddrives. It's around 80, not 100. But it Jan> depends on how you look at it. 80 for Layer3, possibly a little Jan> more for Layer2/1.

No, it's not the same lie. The physical media -- as presented to the next higher layer -- really has 100Mbps capability. Likewise, the "physical media" of a hard drive (as seen outside the controller on the disk) really is 500GB/465GiB (or whatever). [1]

The overhead caused by Ethernet frames (level 2) and then IP packets (level 3) and then TCP or UDP (level 4) are more closely related to the losses you get on filesystem overhead (superblock, inodes, directories) and "slack" in block-allocated systems (having to round sizes up to the next 512 or whatever). [2]

The problem is that a drive labelled "500GB" on its packaging is displayed as "465GB" on the computer. The fix is to have the computer display either "500GB" or "465GiB".

t.

[1] SFAIK, what's really on hard drive platters anymore is something much closer to "symbols", not just 1s and 0s. In the same way that "baud" is "symbols per second", the actual thingies on the platters are symbols, and it's up to the drive electronics to make sense of them.

[2] Level numbers from: http://en.wikipedia.org/wiki/TCP/IP_model

#14 lore raw
In reply to David Schwartz
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"DS" == David Schwartz <[email protected]> writes:

DS> If you are right, a "512MB" RAM stick is mislabelled and is more DS> correctly labelled as "536.8MB". (With 512MiB being equally DS> correct.)

DS> Isn't that obviously not just wrong but borderline crazy?

No. It is not obvious to me what is wrong with that. RAM is the only thing using binary units, everything else is decimal. It is about time that RAM switched too.

/Benny

#7 lore raw
In reply to Jan Engelhardt

Hi Jan!

Quoted 6 lines · Jan Engelhardt
Quoted 1 line

How fast is your Ethernet port? 100Mbps or 95.37Mbps?

Same lie like with harddrives. It's around 80, not 100. But it depends on how you look at it. 80 for Layer3, possibly a little more for Layer2/1.

Nope, I get consistently 12e6 bytes/sec, which is 96e6 bits/sec across 100Mbps ethernet, fitting nicely with the frame overhead (some 50 bytes out of 1500, without TCP options). So no lie here. With gigabit I'm not completely sure yet, still have to see the advertised 125e6 symbols/sec (got only as far as 115e6 up to now).

Ciao,
Roland

--
TU Muenchen, Physik-Department E18, James-Franck-Str., 85748 Garching Telefon 089/289-12575; Telefax 089/289-12570
--
CERN office: 892-1-D23 phone: +41 22 7676540 mobile: +41 76 487 4482 --
Any society that would give up a little liberty to gain a little security will deserve neither and lose both. - Benjamin Franklin -----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GS/CS/M/MU d-(++) s:+ a-> C+++ UL++++ P+++ L+++ E(+) W+ !N K- w--- M+ !V Y+ PGP++ t+(++) 5 R+ tv-- b+ DI++ e+++>++++ h---- y+++
------END GEEK CODE BLOCK------

#8 lore raw
In reply to Jan Engelhardt
Quoted 3 lines · Jan Engelhardt

Same lie like with harddrives. It's around 80, not 100. But it depends on how you look at it. 80 for Layer3, possibly a little more for Layer2/1.

Strange, I tend to get about 95 for layer 3.

--
Len Sorensen

#15 lore raw
In reply to Michał Kudła
Quoted 8 lines · Michał Kudła

Hello,

after
...
hdb: max request size: 512KiB
hdb: 488397168 sectors (250059 MB) w/8192KiB Cache, CHS=30401/255/63,

Should be everywere KiB, MiB, GiB, ... according to IEC 60027-2

You are mistaken. The MB here are actual megabytes (million bytes), not MiB. Read the code, or do the computation: 488397168*512 = 250059350016.

(Precisely what one wants - the kernel gives the correct size, just like the disk manufacturers, and there is no discrepancy. Binary abuse for decimal prefixes is a sloppiness that might be acceptable for stuff that naturally comes in powers of two. It is long ago that that was true for disks.)

Andries