2 * page-types: Tool for querying page flags
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; version 2.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should find a copy of v2 of the GNU General Public License somewhere on
14 * your Linux system; if not, write to the Free Software Foundation, Inc., 59
15 * Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 * Copyright (C) 2009 Intel corporation
19 * Authors: Wu Fengguang <fengguang.wu@intel.com>
22 #define _LARGEFILE64_SOURCE
32 #include <sys/types.h>
33 #include <sys/errno.h>
34 #include <sys/fcntl.h>
35 #include <sys/mount.h>
36 #include <sys/statfs.h>
37 #include "../../include/linux/magic.h"
46 # define STR(x) _STR(x)
50 * pagemap kernel ABI bits
53 #define PM_ENTRY_BYTES sizeof(uint64_t)
54 #define PM_STATUS_BITS 3
55 #define PM_STATUS_OFFSET (64 - PM_STATUS_BITS)
56 #define PM_STATUS_MASK (((1LL << PM_STATUS_BITS) - 1) << PM_STATUS_OFFSET)
57 #define PM_STATUS(nr) (((nr) << PM_STATUS_OFFSET) & PM_STATUS_MASK)
58 #define PM_PSHIFT_BITS 6
59 #define PM_PSHIFT_OFFSET (PM_STATUS_OFFSET - PM_PSHIFT_BITS)
60 #define PM_PSHIFT_MASK (((1LL << PM_PSHIFT_BITS) - 1) << PM_PSHIFT_OFFSET)
61 #define PM_PSHIFT(x) (((u64) (x) << PM_PSHIFT_OFFSET) & PM_PSHIFT_MASK)
62 #define PM_PFRAME_MASK ((1LL << PM_PSHIFT_OFFSET) - 1)
63 #define PM_PFRAME(x) ((x) & PM_PFRAME_MASK)
65 #define PM_PRESENT PM_STATUS(4LL)
66 #define PM_SWAP PM_STATUS(2LL)
74 #define PROC_KPAGEFLAGS "/proc/kpageflags"
76 /* copied from kpageflags_read() */
79 #define KPF_REFERENCED 2
80 #define KPF_UPTODATE 3
85 #define KPF_WRITEBACK 8
89 /* [11-20] new additions in 2.6.31 */
92 #define KPF_SWAPCACHE 13
93 #define KPF_SWAPBACKED 14
94 #define KPF_COMPOUND_HEAD 15
95 #define KPF_COMPOUND_TAIL 16
97 #define KPF_UNEVICTABLE 18
98 #define KPF_HWPOISON 19
102 /* [32-] kernel hacking assistances */
103 #define KPF_RESERVED 32
104 #define KPF_MLOCKED 33
105 #define KPF_MAPPEDTODISK 34
106 #define KPF_PRIVATE 35
107 #define KPF_PRIVATE_2 36
108 #define KPF_OWNER_PRIVATE 37
110 #define KPF_UNCACHED 39
112 /* [48-] take some arbitrary free slots for expanding overloaded flags
113 * not part of kernel API
115 #define KPF_READAHEAD 48
116 #define KPF_SLOB_FREE 49
117 #define KPF_SLUB_FROZEN 50
118 #define KPF_SLUB_DEBUG 51
120 #define KPF_ALL_BITS ((uint64_t)~0ULL)
121 #define KPF_HACKERS_BITS (0xffffULL << 32)
122 #define KPF_OVERLOADED_BITS (0xffffULL << 48)
123 #define BIT(name) (1ULL << KPF_##name)
124 #define BITS_COMPOUND (BIT(COMPOUND_HEAD) | BIT(COMPOUND_TAIL))
126 static const char *page_flag_names
[] = {
127 [KPF_LOCKED
] = "L:locked",
128 [KPF_ERROR
] = "E:error",
129 [KPF_REFERENCED
] = "R:referenced",
130 [KPF_UPTODATE
] = "U:uptodate",
131 [KPF_DIRTY
] = "D:dirty",
133 [KPF_ACTIVE
] = "A:active",
134 [KPF_SLAB
] = "S:slab",
135 [KPF_WRITEBACK
] = "W:writeback",
136 [KPF_RECLAIM
] = "I:reclaim",
137 [KPF_BUDDY
] = "B:buddy",
139 [KPF_MMAP
] = "M:mmap",
140 [KPF_ANON
] = "a:anonymous",
141 [KPF_SWAPCACHE
] = "s:swapcache",
142 [KPF_SWAPBACKED
] = "b:swapbacked",
143 [KPF_COMPOUND_HEAD
] = "H:compound_head",
144 [KPF_COMPOUND_TAIL
] = "T:compound_tail",
145 [KPF_HUGE
] = "G:huge",
146 [KPF_UNEVICTABLE
] = "u:unevictable",
147 [KPF_HWPOISON
] = "X:hwpoison",
148 [KPF_NOPAGE
] = "n:nopage",
151 [KPF_RESERVED
] = "r:reserved",
152 [KPF_MLOCKED
] = "m:mlocked",
153 [KPF_MAPPEDTODISK
] = "d:mappedtodisk",
154 [KPF_PRIVATE
] = "P:private",
155 [KPF_PRIVATE_2
] = "p:private_2",
156 [KPF_OWNER_PRIVATE
] = "O:owner_private",
157 [KPF_ARCH
] = "h:arch",
158 [KPF_UNCACHED
] = "c:uncached",
160 [KPF_READAHEAD
] = "I:readahead",
161 [KPF_SLOB_FREE
] = "P:slob_free",
162 [KPF_SLUB_FROZEN
] = "A:slub_frozen",
163 [KPF_SLUB_DEBUG
] = "E:slub_debug",
167 static const char *debugfs_known_mountpoints
[] = {
177 static int opt_raw
; /* for kernel developers */
178 static int opt_list
; /* list pages (in ranges) */
179 static int opt_no_summary
; /* don't show summary */
180 static pid_t opt_pid
; /* process to walk */
182 #define MAX_ADDR_RANGES 1024
183 static int nr_addr_ranges
;
184 static unsigned long opt_offset
[MAX_ADDR_RANGES
];
185 static unsigned long opt_size
[MAX_ADDR_RANGES
];
187 #define MAX_VMAS 10240
189 static unsigned long pg_start
[MAX_VMAS
];
190 static unsigned long pg_end
[MAX_VMAS
];
192 #define MAX_BIT_FILTERS 64
193 static int nr_bit_filters
;
194 static uint64_t opt_mask
[MAX_BIT_FILTERS
];
195 static uint64_t opt_bits
[MAX_BIT_FILTERS
];
197 static int page_size
;
199 static int pagemap_fd
;
200 static int kpageflags_fd
;
202 static int opt_hwpoison
;
203 static int opt_unpoison
;
205 static char hwpoison_debug_fs
[MAX_PATH
+1];
206 static int hwpoison_inject_fd
;
207 static int hwpoison_forget_fd
;
209 #define HASH_SHIFT 13
210 #define HASH_SIZE (1 << HASH_SHIFT)
211 #define HASH_MASK (HASH_SIZE - 1)
212 #define HASH_KEY(flags) (flags & HASH_MASK)
214 static unsigned long total_pages
;
215 static unsigned long nr_pages
[HASH_SIZE
];
216 static uint64_t page_flags
[HASH_SIZE
];
223 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
225 #define min_t(type, x, y) ({ \
228 __min1 < __min2 ? __min1 : __min2; })
230 #define max_t(type, x, y) ({ \
233 __max1 > __max2 ? __max1 : __max2; })
235 static unsigned long pages2mb(unsigned long pages
)
237 return (pages
* page_size
) >> 20;
240 static void fatal(const char *x
, ...)
245 vfprintf(stderr
, x
, ap
);
250 static int checked_open(const char *pathname
, int flags
)
252 int fd
= open(pathname
, flags
);
263 * pagemap/kpageflags routines
266 static unsigned long do_u64_read(int fd
, char *name
,
273 if (index
> ULONG_MAX
/ 8)
274 fatal("index overflow: %lu\n", index
);
276 if (lseek(fd
, index
* 8, SEEK_SET
) < 0) {
281 bytes
= read(fd
, buf
, count
* 8);
287 fatal("partial read: %lu bytes\n", bytes
);
292 static unsigned long kpageflags_read(uint64_t *buf
,
296 return do_u64_read(kpageflags_fd
, PROC_KPAGEFLAGS
, buf
, index
, pages
);
299 static unsigned long pagemap_read(uint64_t *buf
,
303 return do_u64_read(pagemap_fd
, "/proc/pid/pagemap", buf
, index
, pages
);
306 static unsigned long pagemap_pfn(uint64_t val
)
310 if (val
& PM_PRESENT
)
311 pfn
= PM_PFRAME(val
);
323 static char *page_flag_name(uint64_t flags
)
329 for (i
= 0, j
= 0; i
< ARRAY_SIZE(page_flag_names
); i
++) {
330 present
= (flags
>> i
) & 1;
331 if (!page_flag_names
[i
]) {
333 fatal("unknown flag bit %d\n", i
);
336 buf
[j
++] = present
? page_flag_names
[i
][0] : '_';
342 static char *page_flag_longname(uint64_t flags
)
344 static char buf
[1024];
347 for (i
= 0, n
= 0; i
< ARRAY_SIZE(page_flag_names
); i
++) {
348 if (!page_flag_names
[i
])
350 if ((flags
>> i
) & 1)
351 n
+= snprintf(buf
+ n
, sizeof(buf
) - n
, "%s,",
352 page_flag_names
[i
] + 2);
363 * page list and summary
366 static void show_page_range(unsigned long voffset
,
367 unsigned long offset
, uint64_t flags
)
369 static uint64_t flags0
;
370 static unsigned long voff
;
371 static unsigned long index
;
372 static unsigned long count
;
374 if (flags
== flags0
&& offset
== index
+ count
&&
375 (!opt_pid
|| voffset
== voff
+ count
)) {
382 printf("%lx\t", voff
);
383 printf("%lx\t%lx\t%s\n",
384 index
, count
, page_flag_name(flags0
));
393 static void show_page(unsigned long voffset
,
394 unsigned long offset
, uint64_t flags
)
397 printf("%lx\t", voffset
);
398 printf("%lx\t%s\n", offset
, page_flag_name(flags
));
401 static void show_summary(void)
405 printf(" flags\tpage-count MB"
406 " symbolic-flags\t\t\tlong-symbolic-flags\n");
408 for (i
= 0; i
< ARRAY_SIZE(nr_pages
); i
++) {
410 printf("0x%016llx\t%10lu %8lu %s\t%s\n",
411 (unsigned long long)page_flags
[i
],
413 pages2mb(nr_pages
[i
]),
414 page_flag_name(page_flags
[i
]),
415 page_flag_longname(page_flags
[i
]));
418 printf(" total\t%10lu %8lu\n",
419 total_pages
, pages2mb(total_pages
));
427 static int bit_mask_ok(uint64_t flags
)
431 for (i
= 0; i
< nr_bit_filters
; i
++) {
432 if (opt_bits
[i
] == KPF_ALL_BITS
) {
433 if ((flags
& opt_mask
[i
]) == 0)
436 if ((flags
& opt_mask
[i
]) != opt_bits
[i
])
444 static uint64_t expand_overloaded_flags(uint64_t flags
)
446 /* SLOB/SLUB overload several page flags */
447 if (flags
& BIT(SLAB
)) {
448 if (flags
& BIT(PRIVATE
))
449 flags
^= BIT(PRIVATE
) | BIT(SLOB_FREE
);
450 if (flags
& BIT(ACTIVE
))
451 flags
^= BIT(ACTIVE
) | BIT(SLUB_FROZEN
);
452 if (flags
& BIT(ERROR
))
453 flags
^= BIT(ERROR
) | BIT(SLUB_DEBUG
);
456 /* PG_reclaim is overloaded as PG_readahead in the read path */
457 if ((flags
& (BIT(RECLAIM
) | BIT(WRITEBACK
))) == BIT(RECLAIM
))
458 flags
^= BIT(RECLAIM
) | BIT(READAHEAD
);
463 static uint64_t well_known_flags(uint64_t flags
)
465 /* hide flags intended only for kernel hacker */
466 flags
&= ~KPF_HACKERS_BITS
;
468 /* hide non-hugeTLB compound pages */
469 if ((flags
& BITS_COMPOUND
) && !(flags
& BIT(HUGE
)))
470 flags
&= ~BITS_COMPOUND
;
475 static uint64_t kpageflags_flags(uint64_t flags
)
477 flags
= expand_overloaded_flags(flags
);
480 flags
= well_known_flags(flags
);
485 /* verify that a mountpoint is actually a debugfs instance */
486 static int debugfs_valid_mountpoint(const char *debugfs
)
490 if (statfs(debugfs
, &st_fs
) < 0)
492 else if (st_fs
.f_type
!= (long) DEBUGFS_MAGIC
)
498 /* find the path to the mounted debugfs */
499 static const char *debugfs_find_mountpoint(void)
505 ptr
= debugfs_known_mountpoints
;
507 if (debugfs_valid_mountpoint(*ptr
) == 0) {
508 strcpy(hwpoison_debug_fs
, *ptr
);
509 return hwpoison_debug_fs
;
514 /* give up and parse /proc/mounts */
515 fp
= fopen("/proc/mounts", "r");
517 perror("Can't open /proc/mounts for read");
519 while (fscanf(fp
, "%*s %"
521 "s %99s %*s %*d %*d\n",
522 hwpoison_debug_fs
, type
) == 2) {
523 if (strcmp(type
, "debugfs") == 0)
528 if (strcmp(type
, "debugfs") != 0)
531 return hwpoison_debug_fs
;
534 /* mount the debugfs somewhere if it's not mounted */
536 static void debugfs_mount(void)
540 /* see if it's already mounted */
541 if (debugfs_find_mountpoint())
544 ptr
= debugfs_known_mountpoints
;
546 if (mount(NULL
, *ptr
, "debugfs", 0, NULL
) == 0) {
547 /* save the mountpoint */
548 strcpy(hwpoison_debug_fs
, *ptr
);
555 perror("mount debugfs");
564 static void prepare_hwpoison_fd(void)
566 char buf
[MAX_PATH
+ 1];
570 if (opt_hwpoison
&& !hwpoison_inject_fd
) {
571 snprintf(buf
, MAX_PATH
, "%s/hwpoison/corrupt-pfn",
573 hwpoison_inject_fd
= checked_open(buf
, O_WRONLY
);
576 if (opt_unpoison
&& !hwpoison_forget_fd
) {
577 snprintf(buf
, MAX_PATH
, "%s/hwpoison/unpoison-pfn",
579 hwpoison_forget_fd
= checked_open(buf
, O_WRONLY
);
583 static int hwpoison_page(unsigned long offset
)
588 len
= sprintf(buf
, "0x%lx\n", offset
);
589 len
= write(hwpoison_inject_fd
, buf
, len
);
591 perror("hwpoison inject");
597 static int unpoison_page(unsigned long offset
)
602 len
= sprintf(buf
, "0x%lx\n", offset
);
603 len
= write(hwpoison_forget_fd
, buf
, len
);
605 perror("hwpoison forget");
615 static int hash_slot(uint64_t flags
)
617 int k
= HASH_KEY(flags
);
620 /* Explicitly reserve slot 0 for flags 0: the following logic
621 * cannot distinguish an unoccupied slot from slot (flags==0).
626 /* search through the remaining (HASH_SIZE-1) slots */
627 for (i
= 1; i
< ARRAY_SIZE(page_flags
); i
++, k
++) {
628 if (!k
|| k
>= ARRAY_SIZE(page_flags
))
630 if (page_flags
[k
] == 0) {
631 page_flags
[k
] = flags
;
634 if (page_flags
[k
] == flags
)
638 fatal("hash table full: bump up HASH_SHIFT?\n");
642 static void add_page(unsigned long voffset
,
643 unsigned long offset
, uint64_t flags
)
645 flags
= kpageflags_flags(flags
);
647 if (!bit_mask_ok(flags
))
651 hwpoison_page(offset
);
653 unpoison_page(offset
);
656 show_page_range(voffset
, offset
, flags
);
657 else if (opt_list
== 2)
658 show_page(voffset
, offset
, flags
);
660 nr_pages
[hash_slot(flags
)]++;
664 #define KPAGEFLAGS_BATCH (64 << 10) /* 64k pages */
665 static void walk_pfn(unsigned long voffset
,
669 uint64_t buf
[KPAGEFLAGS_BATCH
];
675 batch
= min_t(unsigned long, count
, KPAGEFLAGS_BATCH
);
676 pages
= kpageflags_read(buf
, index
, batch
);
680 for (i
= 0; i
< pages
; i
++)
681 add_page(voffset
+ i
, index
+ i
, buf
[i
]);
688 #define PAGEMAP_BATCH (64 << 10)
689 static void walk_vma(unsigned long index
, unsigned long count
)
691 uint64_t buf
[PAGEMAP_BATCH
];
698 batch
= min_t(unsigned long, count
, PAGEMAP_BATCH
);
699 pages
= pagemap_read(buf
, index
, batch
);
703 for (i
= 0; i
< pages
; i
++) {
704 pfn
= pagemap_pfn(buf
[i
]);
706 walk_pfn(index
+ i
, pfn
, 1);
714 static void walk_task(unsigned long index
, unsigned long count
)
716 const unsigned long end
= index
+ count
;
720 while (index
< end
) {
722 while (pg_end
[i
] <= index
)
725 if (pg_start
[i
] >= end
)
728 start
= max_t(unsigned long, pg_start
[i
], index
);
729 index
= min_t(unsigned long, pg_end
[i
], end
);
731 assert(start
< index
);
732 walk_vma(start
, index
- start
);
736 static void add_addr_range(unsigned long offset
, unsigned long size
)
738 if (nr_addr_ranges
>= MAX_ADDR_RANGES
)
739 fatal("too many addr ranges\n");
741 opt_offset
[nr_addr_ranges
] = offset
;
742 opt_size
[nr_addr_ranges
] = min_t(unsigned long, size
, ULONG_MAX
-offset
);
746 static void walk_addr_ranges(void)
750 kpageflags_fd
= checked_open(PROC_KPAGEFLAGS
, O_RDONLY
);
753 add_addr_range(0, ULONG_MAX
);
755 for (i
= 0; i
< nr_addr_ranges
; i
++)
757 walk_pfn(0, opt_offset
[i
], opt_size
[i
]);
759 walk_task(opt_offset
[i
], opt_size
[i
]);
761 close(kpageflags_fd
);
769 static const char *page_flag_type(uint64_t flag
)
771 if (flag
& KPF_HACKERS_BITS
)
773 if (flag
& KPF_OVERLOADED_BITS
)
778 static void usage(void)
783 "page-types [options]\n"
784 " -r|--raw Raw mode, for kernel developers\n"
785 " -d|--describe flags Describe flags\n"
786 " -a|--addr addr-spec Walk a range of pages\n"
787 " -b|--bits bits-spec Walk pages with specified bits\n"
788 " -p|--pid pid Walk process address space\n"
789 #if 0 /* planned features */
790 " -f|--file filename Walk file address space\n"
792 " -l|--list Show page details in ranges\n"
793 " -L|--list-each Show page details one by one\n"
794 " -N|--no-summary Don't show summary info\n"
795 " -X|--hwpoison hwpoison pages\n"
796 " -x|--unpoison unpoison pages\n"
797 " -h|--help Show this usage message\n"
799 " 0x10 bitfield format, e.g.\n"
800 " anon bit-name, e.g.\n"
801 " 0x10,anon comma-separated list, e.g.\n"
803 " N one page at offset N (unit: pages)\n"
804 " N+M pages range from N to N+M-1\n"
805 " N,M pages range from N to M-1\n"
806 " N, pages range from N to end\n"
807 " ,M pages range from 0 to M-1\n"
809 " bit1,bit2 (flags & (bit1|bit2)) != 0\n"
810 " bit1,bit2=bit1 (flags & (bit1|bit2)) == bit1\n"
811 " bit1,~bit2 (flags & (bit1|bit2)) == bit1\n"
812 " =bit1,bit2 flags == (bit1|bit2)\n"
816 for (i
= 0, j
= 0; i
< ARRAY_SIZE(page_flag_names
); i
++) {
817 if (!page_flag_names
[i
])
819 printf("%16s%s", page_flag_names
[i
] + 2,
820 page_flag_type(1ULL << i
));
827 "(r) raw mode bits (o) overloaded bits\n");
830 static unsigned long long parse_number(const char *str
)
832 unsigned long long n
;
834 n
= strtoll(str
, NULL
, 0);
836 if (n
== 0 && str
[0] != '0')
837 fatal("invalid name or number: %s\n", str
);
842 static void parse_pid(const char *str
)
847 opt_pid
= parse_number(str
);
849 sprintf(buf
, "/proc/%d/pagemap", opt_pid
);
850 pagemap_fd
= checked_open(buf
, O_RDONLY
);
852 sprintf(buf
, "/proc/%d/maps", opt_pid
);
853 file
= fopen(buf
, "r");
859 while (fgets(buf
, sizeof(buf
), file
) != NULL
) {
860 unsigned long vm_start
;
861 unsigned long vm_end
;
862 unsigned long long pgoff
;
868 n
= sscanf(buf
, "%lx-%lx %c%c%c%c %llx %x:%x %lu",
876 fprintf(stderr
, "unexpected line: %s\n", buf
);
879 pg_start
[nr_vmas
] = vm_start
/ page_size
;
880 pg_end
[nr_vmas
] = vm_end
/ page_size
;
881 if (++nr_vmas
>= MAX_VMAS
) {
882 fprintf(stderr
, "too many VMAs\n");
889 static void parse_file(const char *name
)
893 static void parse_addr_range(const char *optarg
)
895 unsigned long offset
;
899 p
= strchr(optarg
, ',');
901 p
= strchr(optarg
, '+');
905 size
= parse_number(p
+ 1);
907 offset
= parse_number(optarg
);
911 size
= parse_number(p
+ 1);
914 fatal("invalid range: %lu,%lu\n",
920 offset
= parse_number(optarg
);
924 add_addr_range(offset
, size
);
927 static void add_bits_filter(uint64_t mask
, uint64_t bits
)
929 if (nr_bit_filters
>= MAX_BIT_FILTERS
)
930 fatal("too much bit filters\n");
932 opt_mask
[nr_bit_filters
] = mask
;
933 opt_bits
[nr_bit_filters
] = bits
;
937 static uint64_t parse_flag_name(const char *str
, int len
)
944 if (len
<= 8 && !strncmp(str
, "compound", len
))
945 return BITS_COMPOUND
;
947 for (i
= 0; i
< ARRAY_SIZE(page_flag_names
); i
++) {
948 if (!page_flag_names
[i
])
950 if (!strncmp(str
, page_flag_names
[i
] + 2, len
))
954 return parse_number(str
);
957 static uint64_t parse_flag_names(const char *str
, int all
)
963 if (*p
== ',' || *p
== '=' || *p
== '\0') {
964 if ((*str
!= '~') || (*str
== '~' && all
&& *++str
))
965 flags
|= parse_flag_name(str
, p
- str
);
976 static void parse_bits_mask(const char *optarg
)
982 p
= strchr(optarg
, '=');
985 bits
= parse_flag_names(p
+ 1, 0);
987 mask
= parse_flag_names(optarg
, 0);
988 bits
= parse_flag_names(p
+ 1, 0);
989 } else if (strchr(optarg
, '~')) {
990 mask
= parse_flag_names(optarg
, 1);
991 bits
= parse_flag_names(optarg
, 0);
993 mask
= parse_flag_names(optarg
, 0);
997 add_bits_filter(mask
, bits
);
1000 static void describe_flags(const char *optarg
)
1002 uint64_t flags
= parse_flag_names(optarg
, 0);
1004 printf("0x%016llx\t%s\t%s\n",
1005 (unsigned long long)flags
,
1006 page_flag_name(flags
),
1007 page_flag_longname(flags
));
1010 static const struct option opts
[] = {
1011 { "raw" , 0, NULL
, 'r' },
1012 { "pid" , 1, NULL
, 'p' },
1013 { "file" , 1, NULL
, 'f' },
1014 { "addr" , 1, NULL
, 'a' },
1015 { "bits" , 1, NULL
, 'b' },
1016 { "describe" , 1, NULL
, 'd' },
1017 { "list" , 0, NULL
, 'l' },
1018 { "list-each" , 0, NULL
, 'L' },
1019 { "no-summary", 0, NULL
, 'N' },
1020 { "hwpoison" , 0, NULL
, 'X' },
1021 { "unpoison" , 0, NULL
, 'x' },
1022 { "help" , 0, NULL
, 'h' },
1023 { NULL
, 0, NULL
, 0 }
1026 int main(int argc
, char *argv
[])
1030 page_size
= getpagesize();
1032 while ((c
= getopt_long(argc
, argv
,
1033 "rp:f:a:b:d:lLNXxh", opts
, NULL
)) != -1) {
1045 parse_addr_range(optarg
);
1048 parse_bits_mask(optarg
);
1051 describe_flags(optarg
);
1064 prepare_hwpoison_fd();
1068 prepare_hwpoison_fd();
1079 if (opt_list
&& opt_pid
)
1080 printf("voffset\t");
1082 printf("offset\tlen\tflags\n");
1084 printf("offset\tflags\n");
1089 show_page_range(0, 0, 0); /* drain the buffer */