makedumpfile: get_max_mapnr() from ELF header problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Atsushi,

I debugged my problem a bit further and tried to implement
a function that gets the maximum page frame number from the
Linux kernel memory management structures.

I am no memory management expert, so the following patch probably
is not complete, but at least for my setup it worked.

Michael
---
 makedumpfile.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -2029,6 +2029,48 @@ pgdat4:
 	return SYMBOL(contig_page_data);
 }
 
+int
+get_max_pfn(void)
+{
+	unsigned long pgdat, node_start_pfn, node_spanned_pages, max_pfn = 0;
+	int num_nodes, node;
+
+	if ((node = next_online_node(0)) < 0) {
+		ERRMSG("Can't get next online node.\n");
+		return FALSE;
+	}
+	if (!(pgdat = next_online_pgdat(node))) {
+		ERRMSG("Can't get pgdat list.\n");
+		return FALSE;
+	}
+	for (num_nodes = 1; num_nodes <= vt.numnodes; num_nodes++) {
+		if (!readmem(VADDR, pgdat + OFFSET(pglist_data.node_start_pfn),
+		    &node_start_pfn, sizeof node_start_pfn)) {
+			ERRMSG("Can't get node_start_pfn.\n");
+			return FALSE;
+		}
+		if (!readmem(VADDR,
+			     pgdat + OFFSET(pglist_data.node_spanned_pages),
+			     &node_spanned_pages, sizeof node_spanned_pages)) {
+			ERRMSG("Can't get node_spanned_pages.\n");
+			return FALSE;
+		}
+		max_pfn = MAX(max_pfn, (node_start_pfn + node_spanned_pages));
+		if (num_nodes < vt.numnodes) {
+			if ((node = next_online_node(node + 1)) < 0) {
+				ERRMSG("Can't get next online node.\n");
+				return FALSE;
+			} else if (!(pgdat = next_online_pgdat(node))) {
+				ERRMSG("Can't determine pgdat list (node %d).\n",
+				    node);
+				return FALSE;
+			}
+		}
+	}
+	info->max_mapnr = max_pfn;
+	return TRUE;
+}
+
 void
 dump_mem_map(unsigned long long pfn_start,
     unsigned long long pfn_end, unsigned long mem_map, int num_mm)
@@ -2853,6 +2908,9 @@ out:
 		if (!get_numnodes())
 			return FALSE;
 
+		if (!get_max_pfn())
+			return FALSE;
+
 		if (!get_mem_map())
 			return FALSE;
 




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux