From: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
To: kumagai-atsushi@mxc.nes.nec.co.jp
Cc: kexec@lists.infradead.org, vgoyal@redhat.com
Subject: [PATCH 1/2] Use memset() to improve the 1st bitmap initialization performance
Date: Thu, 24 Oct 2013 15:52:00 +0900 [thread overview]
Message-ID: <20131024065200.5291.71203.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20131024065015.5291.51864.stgit@localhost6.localdomain6>
Currently, 1st bitmap is initialized per bits. This is very slow, in
particular, on large memory system more than tera bytes. Instead, use
memset() to initialize bitmap quickly.
This helps next patch that changes the 1st bitmap creation to be done
at each cycle.
Here area a simple benchmark program that measures initialization time
for 384 MiB bitmap corresponding to 12 TiB memory.
On Xeon E7-4820 2.00GHz, output example is as follows:
$ ./bench
17.420970
0.340347
Also, the average result of 10 times excluding max and min are:
old: 17.453785 sec
new: 0.340808 sec
==
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
enum {
PAGE_SIZE = 4096,
BITSPERBYTE = 8,
};
static inline double getdtime(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (double)tv.tv_sec + (double)tv.tv_usec * 1.0e-6;
}
int main(int argc, char **argv)
{
const unsigned long long mem_size = 12ULL << 40;
const unsigned long long max_pfn = mem_size / PAGE_SIZE;
const size_t bitmap_size = max_pfn / BITSPERBYTE;
char *bitmap1 = calloc(bitmap_size, sizeof(char));
char *bitmap2 = calloc(bitmap_size, sizeof(char));
unsigned long long pfn;
double t1, t2;
t1 = getdtime();
for (pfn = 0; pfn < max_pfn; ++pfn) {
bitmap1[pfn >> 3] |= 1 << (pfn & 7);
}
t2 = getdtime();
printf("%lf\n", t2 - t1);
t1 = getdtime();
memset(bitmap2, 0xff, bitmap_size);
t2 = getdtime();
printf("%lf\n", t2 - t1);
return 0;
}
==
Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
---
makedumpfile.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/makedumpfile.c b/makedumpfile.c
index 428c53e..4b6c0ed 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -4317,6 +4317,8 @@ create_1st_bitmap_cyclic()
unsigned long long pfn, pfn_bitmap1;
unsigned long long phys_start, phys_end;
unsigned long long pfn_start, pfn_end;
+ unsigned long long pfn_start_roundup, pfn_end_round;
+ unsigned long pfn_start_byte, pfn_end_byte;
/*
* At first, clear all the bits on the 1st-bitmap.
@@ -4329,10 +4331,30 @@ create_1st_bitmap_cyclic()
*/
pfn_bitmap1 = 0;
for (i = 0; get_pt_load(i, &phys_start, &phys_end, NULL, NULL); i++) {
- pfn_start = paddr_to_pfn(phys_start);
- pfn_end = paddr_to_pfn(phys_end);
+ pfn_start = MAX(paddr_to_pfn(phys_start), info->cyclic_start_pfn);
+ pfn_end = MIN(paddr_to_pfn(phys_end), info->cyclic_end_pfn);
- for (pfn = pfn_start; pfn < pfn_end; pfn++) {
+ if (pfn_start >= pfn_end)
+ continue;
+
+ pfn_start_roundup = roundup(pfn_start, BITPERBYTE);
+ pfn_end_round = round(pfn_end, BITPERBYTE);
+
+ for (pfn = pfn_start; pfn < pfn_start_roundup; pfn++) {
+ if (set_bit_on_1st_bitmap(pfn))
+ pfn_bitmap1++;
+ }
+
+ pfn_start_byte = (pfn_start_roundup - info->cyclic_start_pfn) >> 3;
+ pfn_end_byte = (pfn_end_round - info->cyclic_start_pfn) >> 3;
+
+ memset(info->partial_bitmap1 + pfn_start_byte,
+ 0xff,
+ pfn_end_byte - pfn_start_byte);
+
+ pfn_bitmap1 += (pfn_end_byte - pfn_start_byte) * BITPERBYTE;
+
+ for (pfn = pfn_end_round; pfn < pfn_end; pfn++) {
if (set_bit_on_1st_bitmap(pfn))
pfn_bitmap1++;
}
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2013-10-24 6:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-24 6:51 [PATCH 0/2] makedumpfile: write out a whole part of the 1st bitmap before entering cyclic process HATAYAMA Daisuke
2013-10-24 6:52 ` HATAYAMA Daisuke [this message]
2013-10-24 6:52 ` [PATCH 2/2] Write " HATAYAMA Daisuke
2013-10-30 10:52 ` Atsushi Kumagai
2013-10-31 4:28 ` HATAYAMA Daisuke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131024065200.5291.71203.stgit@localhost6.localdomain6 \
--to=d.hatayama@jp.fujitsu.com \
--cc=kexec@lists.infradead.org \
--cc=kumagai-atsushi@mxc.nes.nec.co.jp \
--cc=vgoyal@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox