* [PATCH 0/8] page-types tool updates
@ 2009-09-16 10:01 Wu Fengguang
2009-09-16 10:01 ` [PATCH 1/8] pagemap: export KPF_HWPOISON Wu Fengguang
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Wu Fengguang @ 2009-09-16 10:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wu Fengguang, LKML
Hi Andrew,
Here are some updates for page-types. The first 2 patches
are trivial additions of the KSM and HWPOISON bits, which
should be OK for .32.
The latter patches are mainly code refactors (no behavior change)
plus one final patch for adding the hwpoison/unpoison feature.
They are tested OK, but could delay merging them if necessary.
Thanks,
Fengguang
--
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/8] pagemap: export KPF_HWPOISON
2009-09-16 10:01 [PATCH 0/8] page-types tool updates Wu Fengguang
@ 2009-09-16 10:01 ` Wu Fengguang
2009-09-16 10:01 ` [PATCH 2/8] pagemap: document KPF_KSM and show it in page-types Wu Fengguang
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Wu Fengguang @ 2009-09-16 10:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wu Fengguang, LKML, Andi Kleen
[-- Attachment #1: kpageflags-hwpoison.patch --]
[-- Type: text/plain, Size: 2341 bytes --]
This flag indicates a hardware detected memory corruption on the page.
Any future access of the page data may bring down the machine.
CC: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
Documentation/vm/page-types.c | 2 ++
Documentation/vm/pagemap.txt | 4 ++++
fs/proc/page.c | 5 +++++
3 files changed, 11 insertions(+)
--- linux-mm.orig/fs/proc/page.c 2009-09-15 17:37:38.000000000 +0800
+++ linux-mm/fs/proc/page.c 2009-09-16 17:12:50.000000000 +0800
@@ -94,6 +94,7 @@ static const struct file_operations proc
#define KPF_COMPOUND_TAIL 16
#define KPF_HUGE 17
#define KPF_UNEVICTABLE 18
+#define KPF_HWPOISON 19
#define KPF_NOPAGE 20
#define KPF_KSM 21
@@ -180,6 +181,10 @@ u64 page_uflags(struct page *page)
u |= kpf_copy_bit(k, KPF_UNEVICTABLE, PG_unevictable);
u |= kpf_copy_bit(k, KPF_MLOCKED, PG_mlocked);
+#ifdef CONFIG_MEMORY_FAILURE
+ u |= kpf_copy_bit(k, KPF_HWPOISON, PG_hwpoison);
+#endif
+
#ifdef CONFIG_IA64_UNCACHED_ALLOCATOR
u |= kpf_copy_bit(k, KPF_UNCACHED, PG_uncached);
#endif
--- linux-mm.orig/Documentation/vm/page-types.c 2009-09-16 17:12:01.000000000 +0800
+++ linux-mm/Documentation/vm/page-types.c 2009-09-16 17:12:50.000000000 +0800
@@ -69,6 +69,7 @@
#define KPF_COMPOUND_TAIL 16
#define KPF_HUGE 17
#define KPF_UNEVICTABLE 18
+#define KPF_HWPOISON 19
#define KPF_NOPAGE 20
/* [32-] kernel hacking assistances */
@@ -116,6 +117,7 @@ static char *page_flag_names[] = {
[KPF_COMPOUND_TAIL] = "T:compound_tail",
[KPF_HUGE] = "G:huge",
[KPF_UNEVICTABLE] = "u:unevictable",
+ [KPF_HWPOISON] = "X:hwpoison",
[KPF_NOPAGE] = "n:nopage",
[KPF_RESERVED] = "r:reserved",
--- linux-mm.orig/Documentation/vm/pagemap.txt 2009-09-11 18:43:25.000000000 +0800
+++ linux-mm/Documentation/vm/pagemap.txt 2009-09-16 17:12:50.000000000 +0800
@@ -57,6 +57,7 @@ There are three components to pagemap:
16. COMPOUND_TAIL
16. HUGE
18. UNEVICTABLE
+ 19. HWPOISON
20. NOPAGE
Short descriptions to the page flags:
@@ -86,6 +87,9 @@ Short descriptions to the page flags:
17. HUGE
this is an integral part of a HugeTLB page
+19. HWPOISON
+ hardware detected memory corruption on this page: don't touch the data!
+
20. NOPAGE
no page frame exists at the requested address
--
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/8] pagemap: document KPF_KSM and show it in page-types
2009-09-16 10:01 [PATCH 0/8] page-types tool updates Wu Fengguang
2009-09-16 10:01 ` [PATCH 1/8] pagemap: export KPF_HWPOISON Wu Fengguang
@ 2009-09-16 10:01 ` Wu Fengguang
2009-09-16 10:01 ` [PATCH 3/8] page-types: add GPL note Wu Fengguang
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Wu Fengguang @ 2009-09-16 10:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wu Fengguang, LKML, Hugh Dickins, Izik Eidus, Chris Wright
[-- Attachment #1: kpageflags-ksm.patch --]
[-- Type: text/plain, Size: 1692 bytes --]
It indicates to the system admin that processes mapping such pages may be
eating less physical memory than the reported numbers by legacy tools.
CC: Hugh Dickins <hugh.dickins@tiscali.co.uk>
CC: Izik Eidus <ieidus@redhat.com>
Acked-by: Chris Wright <chrisw@redhat.com>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
Documentation/vm/page-types.c | 2 ++
Documentation/vm/pagemap.txt | 4 ++++
2 files changed, 6 insertions(+)
--- linux-mm.orig/Documentation/vm/pagemap.txt 2009-09-16 17:12:50.000000000 +0800
+++ linux-mm/Documentation/vm/pagemap.txt 2009-09-16 17:13:24.000000000 +0800
@@ -59,6 +59,7 @@ There are three components to pagemap:
18. UNEVICTABLE
19. HWPOISON
20. NOPAGE
+ 21. KSM
Short descriptions to the page flags:
@@ -93,6 +94,9 @@ Short descriptions to the page flags:
20. NOPAGE
no page frame exists at the requested address
+21. KSM
+ identical memory pages dynamically shared between one or more processes
+
[IO related page flags]
1. ERROR IO error occurred
3. UPTODATE page has up-to-date data
--- linux-mm.orig/Documentation/vm/page-types.c 2009-09-16 17:12:50.000000000 +0800
+++ linux-mm/Documentation/vm/page-types.c 2009-09-16 17:13:24.000000000 +0800
@@ -71,6 +71,7 @@
#define KPF_UNEVICTABLE 18
#define KPF_HWPOISON 19
#define KPF_NOPAGE 20
+#define KPF_KSM 21
/* [32-] kernel hacking assistances */
#define KPF_RESERVED 32
@@ -119,6 +120,7 @@ static char *page_flag_names[] = {
[KPF_UNEVICTABLE] = "u:unevictable",
[KPF_HWPOISON] = "X:hwpoison",
[KPF_NOPAGE] = "n:nopage",
+ [KPF_KSM] = "x:ksm",
[KPF_RESERVED] = "r:reserved",
[KPF_MLOCKED] = "m:mlocked",
--
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/8] page-types: add GPL note
2009-09-16 10:01 [PATCH 0/8] page-types tool updates Wu Fengguang
2009-09-16 10:01 ` [PATCH 1/8] pagemap: export KPF_HWPOISON Wu Fengguang
2009-09-16 10:01 ` [PATCH 2/8] pagemap: document KPF_KSM and show it in page-types Wu Fengguang
@ 2009-09-16 10:01 ` Wu Fengguang
2009-09-16 10:01 ` [PATCH 4/8] page-types: introduce checked_open() Wu Fengguang
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Wu Fengguang @ 2009-09-16 10:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wu Fengguang, LKML, Andi Kleen
[-- Attachment #1: page-types-gpl.patch --]
[-- Type: text/plain, Size: 672 bytes --]
CC: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
Documentation/vm/page-types.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- linux-mm.orig/Documentation/vm/page-types.c 2009-09-16 17:16:26.000000000 +0800
+++ linux-mm/Documentation/vm/page-types.c 2009-09-16 17:24:22.000000000 +0800
@@ -2,7 +2,10 @@
* page-types: Tool for querying page flags
*
* Copyright (C) 2009 Intel corporation
- * Copyright (C) 2009 Wu Fengguang <fengguang.wu@intel.com>
+ *
+ * Authors: Wu Fengguang <fengguang.wu@intel.com>
+ *
+ * Released under the General Public License (GPL).
*/
#define _LARGEFILE64_SOURCE
--
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/8] page-types: introduce checked_open()
2009-09-16 10:01 [PATCH 0/8] page-types tool updates Wu Fengguang
` (2 preceding siblings ...)
2009-09-16 10:01 ` [PATCH 3/8] page-types: add GPL note Wu Fengguang
@ 2009-09-16 10:01 ` Wu Fengguang
2009-09-16 10:01 ` [PATCH 5/8] page-types: make standalone pagemap/kpageflags read routines Wu Fengguang
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Wu Fengguang @ 2009-09-16 10:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wu Fengguang, LKML, Andi Kleen
[-- Attachment #1: page-types-checked-open.patch --]
[-- Type: text/plain, Size: 1419 bytes --]
This helps merge duplicate code (now and future)
and outstand the main logic.
CC: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
Documentation/vm/page-types.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
--- linux-mm.orig/Documentation/vm/page-types.c 2009-09-16 17:13:24.000000000 +0800
+++ linux-mm/Documentation/vm/page-types.c 2009-09-16 17:14:07.000000000 +0800
@@ -211,6 +211,18 @@ static void fatal(const char *x, ...)
exit(EXIT_FAILURE);
}
+int checked_open(const char *pathname, int flags)
+{
+ int fd = open(pathname, flags);
+
+ if (fd < 0) {
+ perror(pathname);
+ exit(EXIT_FAILURE);
+ }
+
+ return fd;
+}
+
/*
* page flag names
@@ -531,11 +543,7 @@ static void walk_addr_ranges(void)
{
int i;
- kpageflags_fd = open(PROC_KPAGEFLAGS, O_RDONLY);
- if (kpageflags_fd < 0) {
- perror(PROC_KPAGEFLAGS);
- exit(EXIT_FAILURE);
- }
+ kpageflags_fd = checked_open(PROC_KPAGEFLAGS, O_RDONLY);
if (!nr_addr_ranges)
add_addr_range(0, ULONG_MAX);
@@ -628,11 +636,7 @@ static void parse_pid(const char *str)
opt_pid = parse_number(str);
sprintf(buf, "/proc/%d/pagemap", opt_pid);
- pagemap_fd = open(buf, O_RDONLY);
- if (pagemap_fd < 0) {
- perror(buf);
- exit(EXIT_FAILURE);
- }
+ pagemap_fd = checked_open(buf, O_RDONLY);
sprintf(buf, "/proc/%d/maps", opt_pid);
file = fopen(buf, "r");
--
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/8] page-types: make standalone pagemap/kpageflags read routines
2009-09-16 10:01 [PATCH 0/8] page-types tool updates Wu Fengguang
` (3 preceding siblings ...)
2009-09-16 10:01 ` [PATCH 4/8] page-types: introduce checked_open() Wu Fengguang
@ 2009-09-16 10:01 ` Wu Fengguang
2009-09-16 10:01 ` [PATCH 6/8] page-types: make voffset local variables Wu Fengguang
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Wu Fengguang @ 2009-09-16 10:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wu Fengguang, LKML, Andi Kleen
[-- Attachment #1: page-types-standalone-read-funcs.patch --]
[-- Type: text/plain, Size: 5059 bytes --]
Refactor the code to be more modular and easier to reuse.
CC: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
Documentation/vm/page-types.c | 156 ++++++++++++++++++--------------
1 file changed, 90 insertions(+), 66 deletions(-)
--- linux-mm.orig/Documentation/vm/page-types.c 2009-09-16 14:59:48.000000000 +0800
+++ linux-mm/Documentation/vm/page-types.c 2009-09-16 15:15:37.000000000 +0800
@@ -154,8 +154,6 @@ static unsigned long pg_start[MAX_VMAS];
static unsigned long pg_end[MAX_VMAS];
static unsigned long voffset;
-static int pagemap_fd;
-
#define MAX_BIT_FILTERS 64
static int nr_bit_filters;
static uint64_t opt_mask[MAX_BIT_FILTERS];
@@ -163,7 +161,7 @@ static uint64_t opt_bits[MAX_BIT_FILTER
static int page_size;
-#define PAGES_BATCH (64 << 10) /* 64k pages */
+static int pagemap_fd;
static int kpageflags_fd;
#define HASH_SHIFT 13
@@ -219,6 +217,62 @@ int checked_open(const char *pathname, i
return fd;
}
+/*
+ * pagemap/kpageflags routines
+ */
+
+static unsigned long do_u64_read(int fd, char *name,
+ uint64_t *buf,
+ unsigned long index,
+ unsigned long count)
+{
+ long bytes;
+
+ if (index > ULONG_MAX / 8)
+ fatal("index overflow: %lu\n", index);
+
+ if (lseek(fd, index * 8, SEEK_SET) < 0) {
+ perror(name);
+ exit(EXIT_FAILURE);
+ }
+
+ bytes = read(fd, buf, count * 8);
+ if (bytes < 0) {
+ perror(name);
+ exit(EXIT_FAILURE);
+ }
+ if (bytes % 8)
+ fatal("partial read: %lu bytes\n", bytes);
+
+ return bytes / 8;
+}
+
+static unsigned long kpageflags_read(uint64_t *buf,
+ unsigned long index,
+ unsigned long pages)
+{
+ return do_u64_read(kpageflags_fd, PROC_KPAGEFLAGS, buf, index, pages);
+}
+
+static unsigned long pagemap_read(uint64_t *buf,
+ unsigned long index,
+ unsigned long pages)
+{
+ return do_u64_read(pagemap_fd, "/proc/pid/pagemap", buf, index, pages);
+}
+
+static unsigned long pagemap_pfn(uint64_t val)
+{
+ unsigned long pfn;
+
+ if (val & PM_PRESENT)
+ pfn = PM_PFRAME(val);
+ else
+ pfn = 0;
+
+ return pfn;
+}
+
/*
* page flag names
@@ -425,79 +479,53 @@ static void add_page(unsigned long offse
total_pages++;
}
+#define KPAGEFLAGS_BATCH (64 << 10) /* 64k pages */
static void walk_pfn(unsigned long index, unsigned long count)
{
+ uint64_t buf[KPAGEFLAGS_BATCH];
unsigned long batch;
- unsigned long n;
+ unsigned long pages;
unsigned long i;
- if (index > ULONG_MAX / KPF_BYTES)
- fatal("index overflow: %lu\n", index);
-
- lseek(kpageflags_fd, index * KPF_BYTES, SEEK_SET);
-
while (count) {
- uint64_t kpageflags_buf[KPF_BYTES * PAGES_BATCH];
-
- batch = min_t(unsigned long, count, PAGES_BATCH);
- n = read(kpageflags_fd, kpageflags_buf, batch * KPF_BYTES);
- if (n == 0)
- break;
- if (n < 0) {
- perror(PROC_KPAGEFLAGS);
- exit(EXIT_FAILURE);
- }
-
- if (n % KPF_BYTES != 0)
- fatal("partial read: %lu bytes\n", n);
- n = n / KPF_BYTES;
+ batch = min_t(unsigned long, count, KPAGEFLAGS_BATCH);
+ pages = kpageflags_read(buf, index, batch);
+ if (pages == 0)
+ break;
- for (i = 0; i < n; i++)
- add_page(index + i, kpageflags_buf[i]);
+ for (i = 0; i < pages; i++)
+ add_page(index + i, buf[i]);
- index += batch;
- count -= batch;
+ index += pages;
+ count -= pages;
}
}
-
-#define PAGEMAP_BATCH 4096
-static unsigned long task_pfn(unsigned long pgoff)
+#define PAGEMAP_BATCH (64 << 10)
+static void walk_vma(unsigned long index, unsigned long count)
{
- static uint64_t buf[PAGEMAP_BATCH];
- static unsigned long start;
- static long count;
- uint64_t pfn;
+ uint64_t buf[PAGEMAP_BATCH];
+ unsigned long batch;
+ unsigned long pages;
+ unsigned long pfn;
+ unsigned long i;
- if (pgoff < start || pgoff >= start + count) {
- if (lseek64(pagemap_fd,
- (uint64_t)pgoff * PM_ENTRY_BYTES,
- SEEK_SET) < 0) {
- perror("pagemap seek");
- exit(EXIT_FAILURE);
- }
- count = read(pagemap_fd, buf, sizeof(buf));
- if (count == 0)
- return 0;
- if (count < 0) {
- perror("pagemap read");
- exit(EXIT_FAILURE);
- }
- if (count % PM_ENTRY_BYTES) {
- fatal("pagemap read not aligned.\n");
- exit(EXIT_FAILURE);
- }
- count /= PM_ENTRY_BYTES;
- start = pgoff;
- }
+ while (count) {
+ batch = min_t(unsigned long, count, PAGEMAP_BATCH);
+ pages = pagemap_read(buf, index, batch);
+ if (pages == 0)
+ break;
- pfn = buf[pgoff - start];
- if (pfn & PM_PRESENT)
- pfn = PM_PFRAME(pfn);
- else
- pfn = 0;
+ for (i = 0; i < pages; i++) {
+ pfn = pagemap_pfn(buf[i]);
+ voffset = index + i;
+ if (pfn)
+ walk_pfn(pfn, 1);
+ }
- return pfn;
+ index += pages;
+ count -= pages;
+ }
}
static void walk_task(unsigned long index, unsigned long count)
@@ -517,11 +545,7 @@ static void walk_task(unsigned long inde
index = min_t(unsigned long, pg_end[i], end);
assert(voffset < index);
- for (; voffset < index; voffset++) {
- unsigned long pfn = task_pfn(voffset);
- if (pfn)
- walk_pfn(pfn, 1);
- }
+ walk_vma(voffset, index - voffset);
}
}
--
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 6/8] page-types: make voffset local variables
2009-09-16 10:01 [PATCH 0/8] page-types tool updates Wu Fengguang
` (4 preceding siblings ...)
2009-09-16 10:01 ` [PATCH 5/8] page-types: make standalone pagemap/kpageflags read routines Wu Fengguang
@ 2009-09-16 10:01 ` Wu Fengguang
2009-09-16 10:01 ` [PATCH 7/8] page-types: introduce kpageflags_flags() Wu Fengguang
2009-09-16 10:01 ` [PATCH 8/8] page-types: add hwpoison/unpoison feature Wu Fengguang
7 siblings, 0 replies; 9+ messages in thread
From: Wu Fengguang @ 2009-09-16 10:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wu Fengguang, LKML, Andi Kleen
[-- Attachment #1: page-types-voffset.patch --]
[-- Type: text/plain, Size: 3911 bytes --]
CC: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
Documentation/vm/page-types.c | 39 +++++++++++++++++---------------
1 file changed, 21 insertions(+), 18 deletions(-)
--- linux-mm.orig/Documentation/vm/page-types.c 2009-09-16 17:25:07.000000000 +0800
+++ linux-mm/Documentation/vm/page-types.c 2009-09-16 17:53:36.000000000 +0800
@@ -159,7 +159,6 @@ static unsigned long opt_size[MAX_ADDR_R
static int nr_vmas;
static unsigned long pg_start[MAX_VMAS];
static unsigned long pg_end[MAX_VMAS];
-static unsigned long voffset;
#define MAX_BIT_FILTERS 64
static int nr_bit_filters;
@@ -328,7 +327,8 @@ static char *page_flag_longname(uint64_t
* page list and summary
*/
-static void show_page_range(unsigned long offset, uint64_t flags)
+static void show_page_range(unsigned long voffset,
+ unsigned long offset, uint64_t flags)
{
static uint64_t flags0;
static unsigned long voff;
@@ -354,7 +354,8 @@ static void show_page_range(unsigned lon
count = 1;
}
-static void show_page(unsigned long offset, uint64_t flags)
+static void show_page(unsigned long voffset,
+ unsigned long offset, uint64_t flags)
{
if (opt_pid)
printf("%lx\t", voffset);
@@ -435,7 +436,6 @@ static uint64_t well_known_flags(uint64_
return flags;
}
-
/*
* page frame walker
*/
@@ -467,7 +467,8 @@ static int hash_slot(uint64_t flags)
exit(EXIT_FAILURE);
}
-static void add_page(unsigned long offset, uint64_t flags)
+static void add_page(unsigned long voffset,
+ unsigned long offset, uint64_t flags)
{
flags = expand_overloaded_flags(flags);
@@ -478,16 +479,18 @@ static void add_page(unsigned long offse
return;
if (opt_list == 1)
- show_page_range(offset, flags);
+ show_page_range(voffset, offset, flags);
else if (opt_list == 2)
- show_page(offset, flags);
+ show_page(voffset, offset, flags);
nr_pages[hash_slot(flags)]++;
total_pages++;
}
#define KPAGEFLAGS_BATCH (64 << 10) /* 64k pages */
-static void walk_pfn(unsigned long index, unsigned long count)
+static void walk_pfn(unsigned long voffset,
+ unsigned long index,
+ unsigned long count)
{
uint64_t buf[KPAGEFLAGS_BATCH];
unsigned long batch;
@@ -501,7 +504,7 @@ static void walk_pfn(unsigned long index
break;
for (i = 0; i < pages; i++)
- add_page(index + i, buf[i]);
+ add_page(voffset + i, index + i, buf[i]);
index += pages;
count -= pages;
@@ -525,9 +528,8 @@ static void walk_vma(unsigned long index
for (i = 0; i < pages; i++) {
pfn = pagemap_pfn(buf[i]);
- voffset = index + i;
if (pfn)
- walk_pfn(pfn, 1);
+ walk_pfn(index + i, pfn, 1);
}
index += pages;
@@ -537,8 +539,9 @@ static void walk_vma(unsigned long index
static void walk_task(unsigned long index, unsigned long count)
{
- int i = 0;
const unsigned long end = index + count;
+ unsigned long start;
+ int i = 0;
while (index < end) {
@@ -548,11 +551,11 @@ static void walk_task(unsigned long inde
if (pg_start[i] >= end)
return;
- voffset = max_t(unsigned long, pg_start[i], index);
- index = min_t(unsigned long, pg_end[i], end);
+ start = max_t(unsigned long, pg_start[i], index);
+ index = min_t(unsigned long, pg_end[i], end);
- assert(voffset < index);
- walk_vma(voffset, index - voffset);
+ assert(start < index);
+ walk_vma(start, index - start);
}
}
@@ -577,7 +580,7 @@ static void walk_addr_ranges(void)
for (i = 0; i < nr_addr_ranges; i++)
if (!opt_pid)
- walk_pfn(opt_offset[i], opt_size[i]);
+ walk_pfn(0, opt_offset[i], opt_size[i]);
else
walk_task(opt_offset[i], opt_size[i]);
@@ -879,7 +882,7 @@ int main(int argc, char *argv[])
walk_addr_ranges();
if (opt_list == 1)
- show_page_range(0, 0); /* drain the buffer */
+ show_page_range(0, 0, 0); /* drain the buffer */
if (opt_no_summary)
return 0;
--
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 7/8] page-types: introduce kpageflags_flags()
2009-09-16 10:01 [PATCH 0/8] page-types tool updates Wu Fengguang
` (5 preceding siblings ...)
2009-09-16 10:01 ` [PATCH 6/8] page-types: make voffset local variables Wu Fengguang
@ 2009-09-16 10:01 ` Wu Fengguang
2009-09-16 10:01 ` [PATCH 8/8] page-types: add hwpoison/unpoison feature Wu Fengguang
7 siblings, 0 replies; 9+ messages in thread
From: Wu Fengguang @ 2009-09-16 10:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wu Fengguang, LKML, Andi Kleen
[-- Attachment #1: page-types-flags.patch --]
[-- Type: text/plain, Size: 978 bytes --]
CC: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
Documentation/vm/page-types.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
--- linux-mm.orig/Documentation/vm/page-types.c 2009-09-16 17:54:06.000000000 +0800
+++ linux-mm/Documentation/vm/page-types.c 2009-09-16 17:54:35.000000000 +0800
@@ -436,6 +436,16 @@ static uint64_t well_known_flags(uint64_
return flags;
}
+static uint64_t kpageflags_flags(uint64_t flags)
+{
+ flags = expand_overloaded_flags(flags);
+
+ if (!opt_raw)
+ flags = well_known_flags(flags);
+
+ return flags;
+}
+
/*
* page frame walker
*/
@@ -470,10 +480,7 @@ static int hash_slot(uint64_t flags)
static void add_page(unsigned long voffset,
unsigned long offset, uint64_t flags)
{
- flags = expand_overloaded_flags(flags);
-
- if (!opt_raw)
- flags = well_known_flags(flags);
+ flags = kpageflags_flags(flags);
if (!bit_mask_ok(flags))
return;
--
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 8/8] page-types: add hwpoison/unpoison feature
2009-09-16 10:01 [PATCH 0/8] page-types tool updates Wu Fengguang
` (6 preceding siblings ...)
2009-09-16 10:01 ` [PATCH 7/8] page-types: introduce kpageflags_flags() Wu Fengguang
@ 2009-09-16 10:01 ` Wu Fengguang
7 siblings, 0 replies; 9+ messages in thread
From: Wu Fengguang @ 2009-09-16 10:01 UTC (permalink / raw)
To: Andrew Morton; +Cc: Wu Fengguang, LKML, Andi Kleen
[-- Attachment #1: page-types-hwpoison.patch --]
[-- Type: text/plain, Size: 3495 bytes --]
For hwpoison stress testing.
The debugfs mount point is assumed to be /debug/.
CC: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
Documentation/vm/page-types.c | 73 +++++++++++++++++++++++++++++++-
1 file changed, 72 insertions(+), 1 deletion(-)
--- linux-mm.orig/Documentation/vm/page-types.c 2009-09-16 17:54:35.000000000 +0800
+++ linux-mm/Documentation/vm/page-types.c 2009-09-16 17:54:59.000000000 +0800
@@ -170,6 +170,13 @@ static int page_size;
static int pagemap_fd;
static int kpageflags_fd;
+static int opt_hwpoison;
+static int opt_unpoison;
+
+static char *hwpoison_debug_fs = "/debug/hwpoison";
+static int hwpoison_inject_fd;
+static int hwpoison_forget_fd;
+
#define HASH_SHIFT 13
#define HASH_SIZE (1 << HASH_SHIFT)
#define HASH_MASK (HASH_SIZE - 1)
@@ -447,6 +454,53 @@ static uint64_t kpageflags_flags(uint64_
}
/*
+ * page actions
+ */
+
+static void prepare_hwpoison_fd(void)
+{
+ char buf[100];
+
+ if (opt_hwpoison && !hwpoison_inject_fd) {
+ sprintf(buf, "%s/corrupt-pfn", hwpoison_debug_fs);
+ hwpoison_inject_fd = checked_open(buf, O_WRONLY);
+ }
+
+ if (opt_unpoison && !hwpoison_forget_fd) {
+ sprintf(buf, "%s/renew-pfn", hwpoison_debug_fs);
+ hwpoison_forget_fd = checked_open(buf, O_WRONLY);
+ }
+}
+
+static int hwpoison_page(unsigned long offset)
+{
+ char buf[100];
+ int len;
+
+ len = sprintf(buf, "0x%lx\n", offset);
+ len = write(hwpoison_inject_fd, buf, len);
+ if (len < 0) {
+ perror("hwpoison inject");
+ return len;
+ }
+ return 0;
+}
+
+static int unpoison_page(unsigned long offset)
+{
+ char buf[100];
+ int len;
+
+ len = sprintf(buf, "0x%lx\n", offset);
+ len = write(hwpoison_forget_fd, buf, len);
+ if (len < 0) {
+ perror("hwpoison forget");
+ return len;
+ }
+ return 0;
+}
+
+/*
* page frame walker
*/
@@ -485,6 +539,11 @@ static void add_page(unsigned long voffs
if (!bit_mask_ok(flags))
return;
+ if (opt_hwpoison)
+ hwpoison_page(offset);
+ if (opt_unpoison)
+ unpoison_page(offset);
+
if (opt_list == 1)
show_page_range(voffset, offset, flags);
else if (opt_list == 2)
@@ -624,6 +683,8 @@ static void usage(void)
" -l|--list Show page details in ranges\n"
" -L|--list-each Show page details one by one\n"
" -N|--no-summary Don't show summay info\n"
+" -X|--hwpoison hwpoison pages\n"
+" -x|--unpoison unpoison pages\n"
" -h|--help Show this usage message\n"
"addr-spec:\n"
" N one page at offset N (unit: pages)\n"
@@ -833,6 +894,8 @@ static struct option opts[] = {
{ "list" , 0, NULL, 'l' },
{ "list-each" , 0, NULL, 'L' },
{ "no-summary", 0, NULL, 'N' },
+ { "hwpoison" , 0, NULL, 'X' },
+ { "unpoison" , 0, NULL, 'x' },
{ "help" , 0, NULL, 'h' },
{ NULL , 0, NULL, 0 }
};
@@ -844,7 +907,7 @@ int main(int argc, char *argv[])
page_size = getpagesize();
while ((c = getopt_long(argc, argv,
- "rp:f:a:b:lLNh", opts, NULL)) != -1) {
+ "rp:f:a:b:lLNXxh", opts, NULL)) != -1) {
switch (c) {
case 'r':
opt_raw = 1;
@@ -870,6 +933,14 @@ int main(int argc, char *argv[])
case 'N':
opt_no_summary = 1;
break;
+ case 'X':
+ opt_hwpoison = 1;
+ prepare_hwpoison_fd();
+ break;
+ case 'x':
+ opt_unpoison = 1;
+ prepare_hwpoison_fd();
+ break;
case 'h':
usage();
exit(0);
--
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-09-16 10:30 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-16 10:01 [PATCH 0/8] page-types tool updates Wu Fengguang
2009-09-16 10:01 ` [PATCH 1/8] pagemap: export KPF_HWPOISON Wu Fengguang
2009-09-16 10:01 ` [PATCH 2/8] pagemap: document KPF_KSM and show it in page-types Wu Fengguang
2009-09-16 10:01 ` [PATCH 3/8] page-types: add GPL note Wu Fengguang
2009-09-16 10:01 ` [PATCH 4/8] page-types: introduce checked_open() Wu Fengguang
2009-09-16 10:01 ` [PATCH 5/8] page-types: make standalone pagemap/kpageflags read routines Wu Fengguang
2009-09-16 10:01 ` [PATCH 6/8] page-types: make voffset local variables Wu Fengguang
2009-09-16 10:01 ` [PATCH 7/8] page-types: introduce kpageflags_flags() Wu Fengguang
2009-09-16 10:01 ` [PATCH 8/8] page-types: add hwpoison/unpoison feature Wu Fengguang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox