Skip to contentSkip to conversation

makedumpfile: optimize is_zero_page

PATCH Marc Milgram 2 participants 2 messages Mar 5, 2014 – Mar 10, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

There are local complaints that filtering out only zero pages is slow. I found that is_zero_page was inefficient. It checks if the page contains any non-zero bytes - one byte at a time.

Improve performance by checking for non-zero data 64 bits at a time.

Did testing in x86_64 mode on an Intel Xeon x5560 system with 18GB RAM. Executed:
time makedumpfile -d 1 /proc/vmcore <destination>

The amount of time taken in User space was reduced by 64%. The total time to dump memory was reduced by 27%.

Change Log:

v1 => v2)

o Eliminate loop unrolling as it is of minimal benefit based on CPU.

is_zero_page
Signed-off-by: Marc Milgram <mmilgram at redhat.com>
---

makedumpfile.h +4 -2
index 3d270c6..1751e3a 100644
@@ -1634,9 +1634,11 @@ static inline int
 is_zero_page(unsigned char *buf, long page_size)
 {
 	size_t i;
+	unsigned long long *vect = (unsigned long long *) buf;
+	long page_len = page_size / sizeof(unsigned long long);
 
-	for (i = 0; i < page_size; i++)
-		if (buf[i])
+	for (i = 0; i < page_len; i++)
+		if (vect[i])
 			return FALSE;
 	return TRUE;
 }

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#1 lore raw
Quoted 10 lines

There are local complaints that filtering out only zero pages is slow. I found that is_zero_page was inefficient. It checks if the page contains any non-zero bytes - one byte at a time.

Improve performance by checking for non-zero data 64 bits at a time.

Did testing in x86_64 mode on an Intel Xeon x5560 system with 18GB RAM. Executed:
time makedumpfile -d 1 /proc/vmcore <destination>

Quoted 8 lines

The amount of time taken in User space was reduced by 64%. The total time to dump memory was reduced by 27%.

Change Log:

v1 => v2)

o Eliminate loop unrolling as it is of minimal benefit based on CPU.

Thank you for fixing, I'll merge this into v1.5.6.

Atsushi Kumagai

Quoted 22 lines

is_zero_page
Signed-off-by: Marc Milgram <mmilgram at redhat.com>
---

makedumpfile.h +4 -2
index 3d270c6..1751e3a 100644
@@ -1634,9 +1634,11 @@ static inline int
 is_zero_page(unsigned char *buf, long page_size)
 {
 	size_t i;
+	unsigned long long *vect = (unsigned long long *) buf;
+	long page_len = page_size / sizeof(unsigned long long);
 
-	for (i = 0; i < page_size; i++)
-		if (buf[i])
+	for (i = 0; i < page_len; i++)
+		if (vect[i])
 			return FALSE;
 	return TRUE;
 }
Quoted 4 lines

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec