linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: memtest: make it a bit faster
@ 2012-11-09 13:12 Alexander Holler
  2012-11-09 14:21 ` richard -rw- weinberger
  0 siblings, 1 reply; 6+ messages in thread
From: Alexander Holler @ 2012-11-09 13:12 UTC (permalink / raw)
  To: linux-kernel; +Cc: Alexander Holler

While implementing the same functionality for arm, I've noticed that
memtest does an unnecessary round to zero the memory. Just reversing the
order so that the last round writes 0s spares that round.

While there, I've also changed the message if bad memory is found from
informational to emergency.

And last I've removed some warnings from checkpatch.

Signed-off-by: Alexander Holler <holler@ahsoftware.de>
---
 arch/x86/mm/memtest.c | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/arch/x86/mm/memtest.c b/arch/x86/mm/memtest.c
index c80b9fb..da80083 100644
--- a/arch/x86/mm/memtest.c
+++ b/arch/x86/mm/memtest.c
@@ -9,7 +9,7 @@
 #include <linux/memblock.h>
 
 static u64 patterns[] __initdata = {
-	0,
+	0, /* Has has to be 0 to leave memtest with zeroed memory */
 	0xffffffffffffffffULL,
 	0x5555555555555555ULL,
 	0xaaaaaaaaaaaaaaaaULL,
@@ -30,7 +30,7 @@ static u64 patterns[] __initdata = {
 
 static void __init reserve_bad_mem(u64 pattern, u64 start_bad, u64 end_bad)
 {
-	printk(KERN_INFO "  %016llx bad mem addr %010llx - %010llx reserved\n",
+	pr_emerg("  %016llx bad mem addr %010llx - %010llx reserved\n",
 	       (unsigned long long) pattern,
 	       (unsigned long long) start_bad,
 	       (unsigned long long) end_bad);
@@ -77,7 +77,7 @@ static void __init do_one_pass(u64 pattern, u64 start, u64 end)
 		this_start = clamp_t(phys_addr_t, this_start, start, end);
 		this_end = clamp_t(phys_addr_t, this_end, start, end);
 		if (this_start < this_end) {
-			printk(KERN_INFO "  %010llx - %010llx pattern %016llx\n",
+			pr_info("  %010llx - %010llx pattern %016llx\n",
 			       (unsigned long long)this_start,
 			       (unsigned long long)this_end,
 			       (unsigned long long)cpu_to_be64(pattern));
@@ -91,8 +91,10 @@ static int memtest_pattern __initdata;
 
 static int __init parse_memtest(char *arg)
 {
+	ssize_t ret __always_unused;
+
 	if (arg)
-		memtest_pattern = simple_strtoul(arg, NULL, 0);
+		ret = kstrtoint(arg, 0, &memtest_pattern);
 	else
 		memtest_pattern = ARRAY_SIZE(patterns);
 
@@ -109,16 +111,9 @@ void __init early_memtest(unsigned long start, unsigned long end)
 	if (!memtest_pattern)
 		return;
 
-	printk(KERN_INFO "early_memtest: # of tests: %d\n", memtest_pattern);
-	for (i = 0; i < memtest_pattern; i++) {
+	pr_info("early_memtest: # of tests: %d\n", memtest_pattern);
+	for (i = memtest_pattern-1; i < UINT_MAX; --i) {
 		idx = i % ARRAY_SIZE(patterns);
 		do_one_pass(patterns[idx], start, end);
 	}
-
-	if (idx > 0) {
-		printk(KERN_INFO "early_memtest: wipe out "
-		       "test pattern from memory\n");
-		/* additional test with pattern 0 will do this */
-		do_one_pass(0, start, end);
-	}
 }
-- 
1.7.11.7


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: memtest: make it a bit faster
  2012-11-09 13:12 [PATCH] x86: memtest: make it a bit faster Alexander Holler
@ 2012-11-09 14:21 ` richard -rw- weinberger
  2012-11-09 14:27   ` Alexander Holler
  0 siblings, 1 reply; 6+ messages in thread
From: richard -rw- weinberger @ 2012-11-09 14:21 UTC (permalink / raw)
  To: Alexander Holler; +Cc: linux-kernel

On Fri, Nov 9, 2012 at 2:12 PM, Alexander Holler <holler@ahsoftware.de> wrote:
> While implementing the same functionality for arm, I've noticed that
> memtest does an unnecessary round to zero the memory. Just reversing the
> order so that the last round writes 0s spares that round.
>
> While there, I've also changed the message if bad memory is found from
> informational to emergency.
>
> And last I've removed some warnings from checkpatch.

Please send these as additional patch.

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: memtest: make it a bit faster
  2012-11-09 14:21 ` richard -rw- weinberger
@ 2012-11-09 14:27   ` Alexander Holler
  2012-11-21 16:18     ` Alexander Holler
  0 siblings, 1 reply; 6+ messages in thread
From: Alexander Holler @ 2012-11-09 14:27 UTC (permalink / raw)
  To: richard -rw- weinberger; +Cc: linux-kernel

Am 09.11.2012 15:21, schrieb richard -rw- weinberger:
> On Fri, Nov 9, 2012 at 2:12 PM, Alexander Holler <holler@ahsoftware.de> wrote:
>> While implementing the same functionality for arm, I've noticed that
>> memtest does an unnecessary round to zero the memory. Just reversing the
>> order so that the last round writes 0s spares that round.
>>
>> While there, I've also changed the message if bad memory is found from
>> informational to emergency.
>>
>> And last I've removed some warnings from checkpatch.
> 
> Please send these as additional patch.

Than it might be better to wait for an answer from some ARM-people.

Maybe it will make sense to move the whole file to mm/ or similar where
I could be used and modified for usage by ARM too.

Regards,

Alexander

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86: memtest: make it a bit faster
  2012-11-09 14:27   ` Alexander Holler
@ 2012-11-21 16:18     ` Alexander Holler
  2012-11-21 16:24       ` [PATCH 1/2] x86: memtest: checkpatch and emergency warning if memtest fails Alexander Holler
  0 siblings, 1 reply; 6+ messages in thread
From: Alexander Holler @ 2012-11-21 16:18 UTC (permalink / raw)
  To: richard -rw- weinberger; +Cc: linux-kernel

Hello,

Am 09.11.2012 15:27, schrieb Alexander Holler:
> Am 09.11.2012 15:21, schrieb richard -rw- weinberger:
>> On Fri, Nov 9, 2012 at 2:12 PM, Alexander Holler <holler@ahsoftware.de> wrote:
>>> While implementing the same functionality for arm, I've noticed that
>>> memtest does an unnecessary round to zero the memory. Just reversing the
>>> order so that the last round writes 0s spares that round.
>>>
>>> While there, I've also changed the message if bad memory is found from
>>> informational to emergency.
>>>
>>> And last I've removed some warnings from checkpatch.
>>
>> Please send these as additional patch.
> 
> Than it might be better to wait for an answer from some ARM-people.
> 
> Maybe it will make sense to move the whole file to mm/ or similar where
> I could be used and modified for usage by ARM too.

As I don't know if version for ARM (or the move) will ever happen, I've
now made 2 patches as requested. They will follow.

Regards,

Alexander

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] x86: memtest: checkpatch and emergency warning if memtest fails
  2012-11-21 16:18     ` Alexander Holler
@ 2012-11-21 16:24       ` Alexander Holler
  2012-11-21 16:24         ` [PATCH 2/2] x86: memtest: remove unnecessary round to leave memtest with zeroed mem Alexander Holler
  0 siblings, 1 reply; 6+ messages in thread
From: Alexander Holler @ 2012-11-21 16:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: richard -rw- weinberger, Alexander Holler

I've used the source of memtest.c for a 32bit version (to use with ARM)
and checkpatch had some warnings. This patch removes them.

It also changes the message if bad memory was found from warning
to emergency.

Signed-off-by: Alexander Holler <holler@ahsoftware.de>
---
 arch/x86/mm/memtest.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/x86/mm/memtest.c b/arch/x86/mm/memtest.c
index c80b9fb..855a6d5 100644
--- a/arch/x86/mm/memtest.c
+++ b/arch/x86/mm/memtest.c
@@ -30,7 +30,7 @@ static u64 patterns[] __initdata = {
 
 static void __init reserve_bad_mem(u64 pattern, u64 start_bad, u64 end_bad)
 {
-	printk(KERN_INFO "  %016llx bad mem addr %010llx - %010llx reserved\n",
+	pr_emerg("  %016llx bad mem addr %010llx - %010llx reserved\n",
 	       (unsigned long long) pattern,
 	       (unsigned long long) start_bad,
 	       (unsigned long long) end_bad);
@@ -77,7 +77,7 @@ static void __init do_one_pass(u64 pattern, u64 start, u64 end)
 		this_start = clamp_t(phys_addr_t, this_start, start, end);
 		this_end = clamp_t(phys_addr_t, this_end, start, end);
 		if (this_start < this_end) {
-			printk(KERN_INFO "  %010llx - %010llx pattern %016llx\n",
+			pr_info("  %010llx - %010llx pattern %016llx\n",
 			       (unsigned long long)this_start,
 			       (unsigned long long)this_end,
 			       (unsigned long long)cpu_to_be64(pattern));
@@ -91,8 +91,10 @@ static int memtest_pattern __initdata;
 
 static int __init parse_memtest(char *arg)
 {
+	ssize_t ret __always_unused;
+
 	if (arg)
-		memtest_pattern = simple_strtoul(arg, NULL, 0);
+		ret = kstrtoint(arg, 0, &memtest_pattern);
 	else
 		memtest_pattern = ARRAY_SIZE(patterns);
 
@@ -109,7 +111,7 @@ void __init early_memtest(unsigned long start, unsigned long end)
 	if (!memtest_pattern)
 		return;
 
-	printk(KERN_INFO "early_memtest: # of tests: %d\n", memtest_pattern);
+	pr_info("early_memtest: # of tests: %d\n", memtest_pattern);
 	for (i = 0; i < memtest_pattern; i++) {
 		idx = i % ARRAY_SIZE(patterns);
 		do_one_pass(patterns[idx], start, end);
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] x86: memtest: remove unnecessary round to leave memtest with zeroed mem
  2012-11-21 16:24       ` [PATCH 1/2] x86: memtest: checkpatch and emergency warning if memtest fails Alexander Holler
@ 2012-11-21 16:24         ` Alexander Holler
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Holler @ 2012-11-21 16:24 UTC (permalink / raw)
  To: linux-kernel; +Cc: richard -rw- weinberger, Alexander Holler

By just reversing the order memtest is using the test patterns, an
additional round to zero the memory is not necessary.

This makes it a bit faster.

Signed-off-by: Alexander Holler <holler@ahsoftware.de>
---
 arch/x86/mm/memtest.c |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/arch/x86/mm/memtest.c b/arch/x86/mm/memtest.c
index 855a6d5..da80083 100644
--- a/arch/x86/mm/memtest.c
+++ b/arch/x86/mm/memtest.c
@@ -9,7 +9,7 @@
 #include <linux/memblock.h>
 
 static u64 patterns[] __initdata = {
-	0,
+	0, /* Has has to be 0 to leave memtest with zeroed memory */
 	0xffffffffffffffffULL,
 	0x5555555555555555ULL,
 	0xaaaaaaaaaaaaaaaaULL,
@@ -112,15 +112,8 @@ void __init early_memtest(unsigned long start, unsigned long end)
 		return;
 
 	pr_info("early_memtest: # of tests: %d\n", memtest_pattern);
-	for (i = 0; i < memtest_pattern; i++) {
+	for (i = memtest_pattern-1; i < UINT_MAX; --i) {
 		idx = i % ARRAY_SIZE(patterns);
 		do_one_pass(patterns[idx], start, end);
 	}
-
-	if (idx > 0) {
-		printk(KERN_INFO "early_memtest: wipe out "
-		       "test pattern from memory\n");
-		/* additional test with pattern 0 will do this */
-		do_one_pass(0, start, end);
-	}
 }
-- 
1.7.8.6


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-21 16:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-09 13:12 [PATCH] x86: memtest: make it a bit faster Alexander Holler
2012-11-09 14:21 ` richard -rw- weinberger
2012-11-09 14:27   ` Alexander Holler
2012-11-21 16:18     ` Alexander Holler
2012-11-21 16:24       ` [PATCH 1/2] x86: memtest: checkpatch and emergency warning if memtest fails Alexander Holler
2012-11-21 16:24         ` [PATCH 2/2] x86: memtest: remove unnecessary round to leave memtest with zeroed mem Alexander Holler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).