From: Baoquan He <bhe@redhat.com>
To: kexec@lists.infradead.org
Cc: d.hatayama@jp.fujitsu.com, kumagai-atsushi@mxc.nes.nec.co.jp,
Baoquan He <bhe@redhat.com>
Subject: [v3 1/3] makedumpfile: introduce struct cycle to store the cyclic region
Date: Sat, 8 Feb 2014 17:19:26 +0800 [thread overview]
Message-ID: <1391851168-6431-2-git-send-email-bhe@redhat.com> (raw)
In-Reply-To: <1391851168-6431-1-git-send-email-bhe@redhat.com>
The cyclic mode uses two member variables in struct DumpInfo to store
the cyclic region each time. Since there's a global instance of struct
DumpInfo, then those two member variables, cyclic_start_pfn and
cyclic_end_pfn would be the same as global variable on behavior. So
with this attribute, the implementation of updating cyclic region
have to be coupled with several other functions. Mainly in function
update_cyclic_region() this happened.
struct DumpInfo {
...
unsigned long long cyclic_start_pfn;
unsigned long long cyclic_end_pfn;
...
}
Now introduce struct cycle and several helper functions and MACRO
as Hatayama suggested. With these, the pfn region which is contained
in struct cycle can be passed down to inner functions. Then several
actions embedded in update_cyclic_region() can be decoupled.
struct cycle {
unsigned long long start_pfn;
unsigned long long end_pfn;
};
Signed-off-by: Baoquan He <bhe@redhat.com>
---
makedumpfile.c | 27 +++++++++++++++++++++++++++
makedumpfile.h | 5 +++++
2 files changed, 32 insertions(+)
diff --git a/makedumpfile.c b/makedumpfile.c
index 7536274..01c6443 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -37,6 +37,33 @@ struct DumpInfo *info = NULL;
char filename_stdout[] = FILENAME_STDOUT;
+static void first_cycle(unsigned long long start, unsigned long long max, struct cycle *cycle)
+{
+ cycle->start_pfn = round(start, info->pfn_cyclic);
+ cycle->end_pfn = cycle->start_pfn + info->pfn_cyclic;
+
+ if (cycle->end_pfn > max)
+ cycle->end_pfn = max;
+}
+
+static void update_cycle(unsigned long long max, struct cycle *cycle)
+{
+ cycle->start_pfn= cycle->end_pfn;
+ cycle->end_pfn= cycle->start_pfn + info->pfn_cyclic;
+
+ if (cycle->end_pfn > max)
+ cycle->end_pfn = max;
+}
+
+static int end_cycle(unsigned long long max, struct cycle *cycle)
+{
+ return (cycle->start_pfn >= max)?TRUE:FALSE;
+}
+
+#define for_each_cycle(start, max, C) \
+ for (first_cycle(start, max, C); !end_cycle(max, C); \
+ update_cycle(max, C))
+
/*
* The numbers of the excluded pages
*/
diff --git a/makedumpfile.h b/makedumpfile.h
index 3d270c6..4cf8102 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -1590,6 +1590,11 @@ int get_xen_info_ia64(void);
#define get_xen_info_arch(X) FALSE
#endif /* s390x */
+struct cycle {
+ unsigned long long start_pfn;
+ unsigned long long end_pfn;
+};
+
static inline int
is_on(char *bitmap, int i)
{
--
1.8.3.1
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2014-02-08 9:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-08 9:19 [v3 0/3] Introduce struct cycle to store cyclic region and clean up Baoquan He
2014-02-08 9:19 ` Baoquan He [this message]
2014-02-08 9:19 ` [v3 2/3] makedumpfile: use struct cycle to update " Baoquan He
2014-02-08 9:19 ` [v3 3/3] makedumpfile: remove member variables representing cyclic pfn region in struct DumpInfo Baoquan He
2014-02-10 7:58 ` [v3 0/3] Introduce struct cycle to store cyclic region and clean up Atsushi Kumagai
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=1391851168-6431-2-git-send-email-bhe@redhat.com \
--to=bhe@redhat.com \
--cc=d.hatayama@jp.fujitsu.com \
--cc=kexec@lists.infradead.org \
--cc=kumagai-atsushi@mxc.nes.nec.co.jp \
/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