Blame SOURCES/0003-dmidecode-Use-the-most-appropriate-unit-for-cache-si.patch

abf46d
From c43afb47fcbadabe2655fe7863a1e2ea9af1446c Mon Sep 17 00:00:00 2001
abf46d
From: Jean Delvare <jdelvare@suse.de>
abf46d
Date: Tue, 15 Jan 2019 12:59:00 +0100
abf46d
Subject: [PATCH 3/5] dmidecode: Use the most appropriate unit for cache size
abf46d
abf46d
As newer CPUs have larger and larger cache, using kB to represent the
abf46d
cache size is getting less convenient. Reuse the same function we have
abf46d
for system memory size so that large units will be used as
abf46d
appropriate. For example, a cache size reported as "20 MB" looks nicer
abf46d
than as "20480 kB".
abf46d
abf46d
Signed-off-by: Jean Delvare <jdelvare@suse.de>
abf46d
Acked-by: Neil Horman <nhorman@tuxdriver.com>
abf46d
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
abf46d
---
abf46d
 dmidecode.c | 17 +++++++++++------
abf46d
 1 file changed, 11 insertions(+), 6 deletions(-)
abf46d
abf46d
diff --git a/dmidecode.c b/dmidecode.c
abf46d
index 7ac6438a23db..162e0c50ba26 100644
abf46d
--- a/dmidecode.c
abf46d
+++ b/dmidecode.c
abf46d
@@ -1560,17 +1560,22 @@ static void dmi_cache_size(u16 code)
abf46d
 
abf46d
 static void dmi_cache_size_2(u32 code)
abf46d
 {
abf46d
+	u64 size;
abf46d
+
abf46d
 	if (code & 0x80000000)
abf46d
 	{
abf46d
 		code &= 0x7FFFFFFFLU;
abf46d
-		/* Use a more convenient unit for large cache size */
abf46d
-		if (code >= 0x8000)
abf46d
-			printf(" %u MB", code >> 4);
abf46d
-		else
abf46d
-			printf(" %u kB", code << 6);
abf46d
+		size.l = code << 6;
abf46d
+		size.h = code >> 26;
abf46d
 	}
abf46d
 	else
abf46d
-		printf(" %u kB", code);
abf46d
+	{
abf46d
+		size.l = code;
abf46d
+		size.h = 0;
abf46d
+	}
abf46d
+
abf46d
+	/* Use a more convenient unit for large cache size */
abf46d
+	dmi_print_memory_size(size, 1);
abf46d
 }
abf46d
 
abf46d
 static void dmi_cache_types(u16 code, const char *sep)
abf46d
-- 
abf46d
2.17.1
abf46d