Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] makedumpfile: introduce struct cycle to store the cyclic region
@ 2014-01-22 13:57 Baoquan He
  2014-01-22 13:57 ` [PATCH 2/3] makedumpfile: use struct cycle to update cyclic region and clean up Baoquan He
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Baoquan He @ 2014-01-22 13:57 UTC (permalink / raw)
  To: kexec; +Cc: d.hatayama, kumagai-atsushi, Baoquan He

The cyclic mode use 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 couple with several other actions. Especially in function
update_cyclic_region().

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 73467ab..325cd66 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 = start;
+	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

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

end of thread, other threads:[~2014-01-23  0:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-22 13:57 [PATCH 1/3] makedumpfile: introduce struct cycle to store the cyclic region Baoquan He
2014-01-22 13:57 ` [PATCH 2/3] makedumpfile: use struct cycle to update cyclic region and clean up Baoquan He
2014-01-23  0:47   ` Baoquan He
2014-01-22 13:57 ` [PATCH 3/3] makedumpfile: remove member variables representing cyclic pfn region in struct DumpInfo Baoquan He
2014-01-23  0:39 ` [PATCH 1/3] makedumpfile: introduce struct cycle to store the cyclic region Baoquan He

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox