Skip to contentSkip to conversation

proc: export mlocked pages info through "/proc/meminfo: Wired"

PATCH In review Stone Wang 5 participants 14 messages Mar 20, 2006 – Mar 24, 2006

Subsystems (6)
lore
Share & tools
lore

Stone Wang

author
#0 lore raw

PATCH 5/8 proc: export mlocked pages info through "/proc/meminfo: Wired"

Export mlock(wired) info through file /proc/meminfo.

--

 fs/proc/proc_misc.c    |    5 ++++-
 include/linux/mm.h     |    4 ++++
 include/linux/mmzone.h |    4 ++--
 mm/page_alloc.c        |   26 +++++++++++++++++++-------
 mm/readahead.c         |    3 ++-
 5 files changed, 31 insertions(+), 11 deletions(-)
fs/proc/proc_misc.c +4 -1
diff -urN linux-2.6.15.orig/fs/proc/proc_misc.c linux-2.6.15/fs/proc/proc_misc.c
@@ -123,6 +123,7 @@
 	struct page_state ps;
 	unsigned long inactive;
 	unsigned long active;
+	unsigned long wired;
 	unsigned long free;
 	unsigned long committed;
 	unsigned long allowed;
@@ -130,7 +131,7 @@
 	long cached;
 
 	get_page_state(&ps);
-	get_zone_counts(&active, &inactive, &free);
+	get_zone_counts(&active, &inactive, &wired, &free);
 
 /*
  * display in kilobytes.
@@ -159,6 +160,7 @@
 		"SwapCached:   %8lu kB\n"
 		"Active:       %8lu kB\n"
 		"Inactive:     %8lu kB\n"
+		"Wired:        %8lu kB\n"
 		"HighTotal:    %8lu kB\n"
 		"HighFree:     %8lu kB\n"
 		"LowTotal:     %8lu kB\n"
@@ -182,6 +184,7 @@
 		K(total_swapcache_pages),
 		K(active),
 		K(inactive),
+		K(wired),
 		K(i.totalhigh),
 		K(i.freehigh),
 		K(i.totalram-i.totalhigh),

diff -urN linux-2.6.15.orig/include/linux/mmzone.h linux-2.6.15/include/linux/mmzone.h

include/linux/mmzone.h +2 -2
@@ -315,9 +317,9 @@
 extern struct pglist_data *pgdat_list;
 
 void __get_zone_counts(unsigned long *active, unsigned long *inactive,
-			unsigned long *free, struct pglist_data *pgdat);
+		unsigned long *wired, unsigned long *free, struct pglist_data *pgdat);
 void get_zone_counts(unsigned long *active, unsigned long *inactive,
-			unsigned long *free);
+		unsigned long *wired, unsigned long *free);
 void build_all_zonelists(void);
 void wakeup_kswapd(struct zone *zone, int order);
 int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
mm/page_alloc.c +19 -7
diff -urN linux-2.6.15.orig/mm/page_alloc.c linux-2.6.15/mm/page_alloc.c
@@ -1252,35 +1254,39 @@
 EXPORT_SYMBOL(__mod_page_state);
 
 void __get_zone_counts(unsigned long *active, unsigned long *inactive,
-			unsigned long *free, struct pglist_data *pgdat)
+			unsigned long *wired,unsigned long *free, struct pglist_data *pgdat)
 {
 	struct zone *zones = pgdat->node_zones;
 	int i;
 
 	*active = 0;
 	*inactive = 0;
+	*wired = 0;
 	*free = 0;
 	for (i = 0; i < MAX_NR_ZONES; i++) {
 		*active += zones[i].nr_active;
 		*inactive += zones[i].nr_inactive;
+		*wired += zones[i].nr_wired;
 		*free += zones[i].free_pages;
 	}
 }
 
 void get_zone_counts(unsigned long *active,
-		unsigned long *inactive, unsigned long *free)
+		unsigned long *inactive, unsigned long *wired, unsigned long *free)
 {
 	struct pglist_data *pgdat;
 
 	*active = 0;
 	*inactive = 0;
+	*wired = 0;
 	*free = 0;
 	for_each_pgdat(pgdat) {
-		unsigned long l, m, n;
-		__get_zone_counts(&l, &m, &n, pgdat);
+		unsigned long l, m, n, o;
+		__get_zone_counts(&l, &m, &n, &o, pgdat);
 		*active += l;
 		*inactive += m;
-		*free += n;
+		*wired += n;
+		*free += o;
 	}
 }
 
@@ -1328,6 +1334,7 @@
 	int cpu, temperature;
 	unsigned long active;
 	unsigned long inactive;
+	unsigned long wired;
 	unsigned long free;
 	struct zone *zone;
 
@@ -1358,16 +1365,17 @@
 	}
 
 	get_page_state(&ps);
-	get_zone_counts(&active, &inactive, &free);
+	get_zone_counts(&active, &inactive, &wired, &free);
 
 	printk("Free pages: %11ukB (%ukB HighMem)\n",
 		K(nr_free_pages()),
 		K(nr_free_highpages()));
 
-	printk("Active:%lu inactive:%lu dirty:%lu writeback:%lu "
+	printk("Active:%lu inactive:%lu wired:%lu dirty:%lu writeback:%lu "
 		"unstable:%lu free:%u slab:%lu mapped:%lu pagetables:%lu\n",
 		active,
 		inactive,
+		wired,
 		ps.nr_dirty,
 		ps.nr_writeback,
 		ps.nr_unstable,
@@ -1387,6 +1395,7 @@
 			" high:%lukB"
 			" active:%lukB"
 			" inactive:%lukB"
+			" wired:%lukB"
 			" present:%lukB"
 			" pages_scanned:%lu"
 			" all_unreclaimable? %s"
@@ -1398,6 +1407,7 @@
 			K(zone->pages_high),
 			K(zone->nr_active),
 			K(zone->nr_inactive),
+			K(zone->nr_wired),
 			K(zone->present_pages),
 			zone->pages_scanned,
 			(zone->all_unreclaimable ? "yes" : "no")
@@ -2009,10 +2019,12 @@
 		zone_pcp_init(zone);
 		INIT_LIST_HEAD(&zone->active_list);
 		INIT_LIST_HEAD(&zone->inactive_list);
+		INIT_LIST_HEAD(&zone->wired_list);
 		zone->nr_scan_active = 0;
 		zone->nr_scan_inactive = 0;
 		zone->nr_active = 0;
 		zone->nr_inactive = 0;
+		zone->nr_wired = 0;
 		atomic_set(&zone->reclaim_in_progress, 0);
 		if (!size)
 			continue;
@@ -2161,6 +2173,7 @@
 			   "\n        high     %lu"
 			   "\n        active   %lu"
 			   "\n        inactive %lu"
+			   "\n        wired    %lu"
 			   "\n        scanned  %lu (a: %lu i: %lu)"
 			   "\n        spanned  %lu"
 			   "\n        present  %lu",
@@ -2170,6 +2183,7 @@
 			   zone->pages_high,
 			   zone->nr_active,
 			   zone->nr_inactive,
+			   zone->nr_wired,
 			   zone->pages_scanned,
 			   zone->nr_scan_active, zone->nr_scan_inactive,
 			   zone->spanned_pages,
include/linux/mm.h +4 -0
diff -urN linux-2.6.15.orig/include/linux/mm.h linux-2.6.15/include/linux/mm.h
@@ -218,6 +221,10 @@
 	unsigned long flags;		/* Atomic flags, some possibly
 					 * updated asynchronously */
 	atomic_t _count;		/* Usage count, see below. */
+	unsigned short wired_count; /* Count of wirings of the page.
+					 * If not zero,the page would be SetPageWired,
+					 * and put on Wired list of the zone.
+					 */
 	atomic_t _mapcount;		/* Count of ptes mapped in mms,
 					 * to show when page is mapped
 					 * & limit reverse map searches.
mm/readahead.c +2 -1
diff -urN linux-2.6.15.orig/mm/readahead.c linux-2.6.15/mm/readahead.c
@@ -564,8 +564,9 @@
 {
 	unsigned long active;
 	unsigned long inactive;
+	unsigned long wired;
 	unsigned long free;
 
-	__get_zone_counts(&active, &inactive, &free, NODE_DATA(numa_node_id()));
+	__get_zone_counts(&active, &inactive, &wired, &free,

NODE_DATA(numa_node_id()));
return min(nr, (inactive + free) / 2);
}

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 2 lines · Stone Wang

Export mlock(wired) info through file /proc/meminfo.

If wired is solely for mlock pages... why not just call it mlock/mlocked?

Signature · 9 lines
SUSE Labs, Novell Inc.

Send instant messages to your online friends http://au.messenger.yahoo.com 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#2 lore raw

The list potentially could have more wider use.

For example, kernel-space locked/pinned pages could be placed on the list too (while mlocked pages are locked/pinned by system calls from user-space).

2006/3/21, Nick Piggin <[email protected]>:

Quoted 4 lines
Quoted 2 lines · Stone Wang

Export mlock(wired) info through file /proc/meminfo.

Quoted 9 lines

If wired is solely for mlock pages... why not just call it mlock/mlocked?

--
SUSE Labs, Novell Inc.

Send instant messages to your online friends http://au.messenger.yahoo.com

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#3 lore raw
Quoted 4 lines · Stone Wang

The list potentially could have more wider use.

For example, kernel-space locked/pinned pages could be placed on the list too (while mlocked pages are locked/pinned by system calls from user-space).

then please call it pinned_list or locked_down_list or so ;)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
In reply to Stone Wang
Quoted 5 lines · Stone Wang

The list potentially could have more wider use.

For example, kernel-space locked/pinned pages could be placed on the list too (while mlocked pages are locked/pinned by system calls from user-space).

kernel-space pages are always pinned. And no, you can't put them on the list because you never know if their ->lru field is going to be used for something else.

Why would you want to ever do something like that though? I don't think you should use this name "just in case", unless you have some really good potential usage in mind.

---
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#5 lore raw

The name "Wired" could be changed to which one most kids think better fits the job.

I choosed "Wired" for:
"Locked" will conflict with PG_locked bit of a pags. "Pinned" indicates a short-term lock,so not fits the job too.

Shaoping Wang

2006/3/21, Nick Piggin <[email protected]>:

Quoted 11 lines
Quoted 5 lines · Stone Wang

The list potentially could have more wider use.

For example, kernel-space locked/pinned pages could be placed on the list too (while mlocked pages are locked/pinned by system calls from user-space).

kernel-space pages are always pinned. And no, you can't put them on the list because you never know if their ->lru field is going to be used for something else.

Quoted 9 lines

Why would you want to ever do something like that though? I don't think you should use this name "just in case", unless you have some really good potential usage in mind.

---
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#6 lore raw
Quoted 7 lines · Stone Wang

The name "Wired" could be changed to which one most kids think better fits the job.

I choosed "Wired" for:
"Locked" will conflict with PG_locked bit of a pags. "Pinned" indicates a short-term lock,so not fits the job too.

Err we're going around in circles here. This tangent started because I suggested that you could call them "mlock" or "mlocked".

But don't get too hung up on the naming. I pointed out quite a lot of much more fundamental problems.

Signature · 8 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#7 lore raw
In reply to Stone Wang
Quoted 6 lines · Stone Wang

The name "Wired" could be changed to which one most kids think better fits the job.

I choosed "Wired" for:
"Locked" will conflict with PG_locked bit of a pags. "Pinned" indicates a short-term lock,so not fits the job too.

pinned does not imply short term

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw
In reply to Nick Piggin
Quoted 3 lines · Nick Piggin

Why would you want to ever do something like that though? I don't think you should use this name "just in case", unless you have some really good potential usage in mind.

ramfs

Signature · 7 lines
All Rights Reversed

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#9 lore raw
Quoted 8 lines · Rik van Riel
Quoted 1 line · Nick Piggin

Why would you want to ever do something like that though? I don't think you should use this name "just in case", unless you have some really good potential usage in mind.

ramfs

Why would ramfs want its pages in this wired list? (I'm not so familiar with it but I can't think of a reason).

Signature · 8 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#10 lore raw
Quoted 11 lines · Nick Piggin
Quoted 7 lines · Rik van Riel
Quoted 3 lines · Nick Piggin

Why would you want to ever do something like that though? I don't think you should use this name "just in case", unless you have some really good potential usage in mind.

ramfs

Why would ramfs want its pages in this wired list? (I'm not so familiar with it but I can't think of a reason).

Because ramfs pages cannot be paged out, which makes them locked into memory the same way mlocked pages are.

Signature · 7 lines
All Rights Reversed

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#11 lore raw
Quoted 11 lines · Rik van Riel
Quoted 9 lines · Nick Piggin
Quoted 7 lines · Rik van Riel
Quoted 3 lines · Nick Piggin

Why would you want to ever do something like that though? I don't think you should use this name "just in case", unless you have some really good potential usage in mind.

Quoted 9 lines
Quoted 4 lines
Quoted 1 line

ramfs

Why would ramfs want its pages in this wired list? (I'm not so familiar with it but I can't think of a reason).

Because ramfs pages cannot be paged out, which makes them locked into memory the same way mlocked pages are.

I don't understand why they need to be on any list though, that isn't an internal ramfs specific structure (ie. not the just-in-case wired list).

Signature · 8 lines
SUSE Labs, Novell Inc.
Send instant messages to your online friends http://au.messenger.yahoo.com 

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#12 lore raw
In reply to Stone Wang

include/linux/mm.h 2006-03-07 01:49:12.000000000 -0500 line 230

Quoted 13 lines · Stone Wang
include/linux/mm.h 2006-03-07 01:49:12.000000000 -0500 renamed from include/linux/mm.h 2006-01-02 22:21:10.000000000 -0500 +4 -0
@@ -218,6 +221,10 @@
        unsigned long flags;            /* Atomic flags, some possibly
                                         * updated asynchronously */
        atomic_t _count;                /* Usage count, see below. */
+       unsigned short wired_count; /* Count of wirings of the page.
+                                        * If not zero,the page would be SetPageWired,
+                                        * and put on Wired list of the zone.
+                                        */
        atomic_t _mapcount;             /* Count of ptes mapped in mms,
                                         * to show when page is mapped
                                         * & limit reverse map searches. 

We're usually pretty picky about adding stuff to 'struct page'. It _just_ fits inside a cacheline on most 32-bit architectures.

Can this wired_count not be derived at runtime? It seems like it would be possible to run through all VMAs mapping the page, and determining how many of them are VM_LOCKED. Would that be too slow?

Also, does it matter how many times it is locked, or just that _somebody_ has it locked?

-- Dave

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#13 lore raw

2006/3/21, Dave Hansen <[email protected]>:

Quoted 18 lines · Stone Wang

include/linux/mm.h 2006-03-07 01:49:12.000000000 -0500 line 230

Quoted 13 lines
include/linux/mm.h 2006-03-07 01:49:12.000000000 -0500 renamed from include/linux/mm.h 2006-01-02 22:21:10.000000000 -0500 +4 -0
@@ -218,6 +221,10 @@
        unsigned long flags;            /* Atomic flags, some possibly
                                         * updated asynchronously */
        atomic_t _count;                /* Usage count, see below. */
+       unsigned short wired_count; /* Count of wirings of the page.
+                                        * If not zero,the page would be SetPageWired,
+                                        * and put on Wired list of the zone.
+                                        */
        atomic_t _mapcount;             /* Count of ptes mapped in mms,
                                         * to show when page is mapped
                                         * & limit reverse map searches.

We're usually pretty picky about adding stuff to 'struct page'. It _just_ fits inside a cacheline on most 32-bit architectures.

Quoted 3 lines

Can this wired_count not be derived at runtime? It seems like it would be possible to run through all VMAs mapping the page, and determining how many of them are VM_LOCKED. Would that be too slow?

It can be derived, but perhaps would made code not that clear.

I will try accroding to your comments, and i think there could be fast scanning of the vma list for this purpose.

Quoted 2 lines

Also, does it matter how many times it is locked, or just that _somebody_ has it locked?

For now, it just matters somebody has it locked. When munlock a page, it matters somebody else has it locked.

Quoted 4 lines

-- Dave

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>