linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 4/5 VM changes: zoneinfo.patch
@ 2003-07-09  8:47 Nikita Danilov
  0 siblings, 0 replies; only message in thread
From: Nikita Danilov @ 2003-07-09  8:47 UTC (permalink / raw)
  To: Linux Kernel Mailing List


Add /proc/zoneinfo file to display information about memory zones.



diff -puN fs/proc/proc_misc.c~zoneinfo fs/proc/proc_misc.c
--- i386/fs/proc/proc_misc.c~zoneinfo	Wed Jul  9 12:24:52 2003
+++ i386-god/fs/proc/proc_misc.c	Wed Jul  9 12:24:52 2003
@@ -251,6 +251,20 @@ static struct file_operations fragmentat
 	.release	= seq_release,
 };
 
+extern struct seq_operations zoneinfo_op;
+static int zoneinfo_open(struct inode *inode, struct file *file)
+{
+	(void)inode;
+	return seq_open(file, &zoneinfo_op);
+}
+
+static struct file_operations proc_zoneinfo_file_operations = {
+	.open		= zoneinfo_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= seq_release,
+};
+
 static int version_read_proc(char *page, char **start, off_t off,
 				 int count, int *eof, void *data)
 {
@@ -694,6 +708,7 @@ void __init proc_misc_init(void)
 	create_seq_entry("slabinfo",S_IWUSR|S_IRUGO,&proc_slabinfo_operations);
 	create_seq_entry("buddyinfo",S_IRUGO, &fragmentation_file_operations);
 	create_seq_entry("vmstat",S_IRUGO, &proc_vmstat_file_operations);
+	create_seq_entry("zoneinfo",S_IRUGO, &proc_zoneinfo_file_operations);
 	create_seq_entry("diskstats", 0, &proc_diskstats_operations);
 #ifdef CONFIG_MODULES
 	create_seq_entry("modules", 0, &proc_modules_operations);
diff -puN mm/page_alloc.c~zoneinfo mm/page_alloc.c
--- i386/mm/page_alloc.c~zoneinfo	Wed Jul  9 12:24:52 2003
+++ i386-god/mm/page_alloc.c	Wed Jul  9 12:24:52 2003
@@ -1464,6 +1464,61 @@ struct seq_operations fragmentation_op =
 	.show	= frag_show,
 };
 
+/* 
+ * Output information about zones in @pgdat.
+ */
+static int zoneinfo_show(struct seq_file *m, void *arg)
+{
+	pg_data_t *pgdat = (pg_data_t *)arg;
+	struct zone *zone;
+	struct zone *node_zones = pgdat->node_zones;
+	unsigned long flags;
+
+	for (zone = node_zones; zone - node_zones < MAX_NR_ZONES; ++zone) {
+		if (!zone->present_pages)
+			continue;
+
+		spin_lock_irqsave(&zone->lock, flags);
+		seq_printf(m, "Node %d, zone %8s", pgdat->node_id, zone->name);
+		seq_printf(m, 
+			   "\n\tpages free %lu"
+			   "\n\tpages min %lu"
+			   "\n\tpages low %lu"
+			   "\n\tpages high %lu"
+			   "\n\tpages active %lu"
+			   "\n\tpages inactive %lu"
+			   "\n\tpages scanned %lu"
+			   "\n\tpages spanned %lu"
+			   "\n\tpages present %lu",
+			   zone->free_pages, 
+			   zone->pages_min, 
+			   zone->pages_low, 
+			   zone->pages_high, 
+			   zone->nr_active, 
+			   zone->nr_inactive,
+			   zone->pages_scanned,
+			   zone->spanned_pages,
+			   zone->present_pages);
+		seq_printf(m, 
+			   "\n\trefill %i"
+			   "\n\tall_unreclaimable: %u"
+			   "\n\tpressure: %i",
+			   atomic_read(&zone->refill_counter), 
+			   zone->all_unreclaimable, zone->pressure);
+		spin_unlock_irqrestore(&zone->lock, flags);
+		seq_putc(m, '\n');
+	}
+	return 0;
+}
+
+struct seq_operations zoneinfo_op = {
+	.start	= frag_start, /* iterate over all zones. The same as in
+			       * fragmentation. */
+	.next	= frag_next,
+	.stop	= frag_stop,
+	.show	= zoneinfo_show,
+};
+
 static char *vmstat_text[] = {
 	"nr_dirty",
 	"nr_writeback",

_

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-07-09  8:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-09  8:47 [PATCH] 4/5 VM changes: zoneinfo.patch Nikita Danilov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).