aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/proc_misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc/proc_misc.c')
-rw-r--r--fs/proc/proc_misc.c135
1 files changed, 0 insertions, 135 deletions
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 5ed15ff8fd1d..2ef9ef9bc8c1 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -57,146 +57,11 @@
57#include <asm/div64.h> 57#include <asm/div64.h>
58#include "internal.h" 58#include "internal.h"
59 59
60#ifdef CONFIG_PROC_PAGE_MONITOR
61#define KPMSIZE sizeof(u64)
62#define KPMMASK (KPMSIZE - 1)
63/* /proc/kpagecount - an array exposing page counts
64 *
65 * Each entry is a u64 representing the corresponding
66 * physical page count.
67 */
68static ssize_t kpagecount_read(struct file *file, char __user *buf,
69 size_t count, loff_t *ppos)
70{
71 u64 __user *out = (u64 __user *)buf;
72 struct page *ppage;
73 unsigned long src = *ppos;
74 unsigned long pfn;
75 ssize_t ret = 0;
76 u64 pcount;
77
78 pfn = src / KPMSIZE;
79 count = min_t(size_t, count, (max_pfn * KPMSIZE) - src);
80 if (src & KPMMASK || count & KPMMASK)
81 return -EINVAL;
82
83 while (count > 0) {
84 ppage = NULL;
85 if (pfn_valid(pfn))
86 ppage = pfn_to_page(pfn);
87 pfn++;
88 if (!ppage)
89 pcount = 0;
90 else
91 pcount = page_mapcount(ppage);
92
93 if (put_user(pcount, out++)) {
94 ret = -EFAULT;
95 break;
96 }
97
98 count -= KPMSIZE;
99 }
100
101 *ppos += (char __user *)out - buf;
102 if (!ret)
103 ret = (char __user *)out - buf;
104 return ret;
105}
106
107static struct file_operations proc_kpagecount_operations = {
108 .llseek = mem_lseek,
109 .read = kpagecount_read,
110};
111
112/* /proc/kpageflags - an array exposing page flags
113 *
114 * Each entry is a u64 representing the corresponding
115 * physical page flags.
116 */
117
118/* These macros are used to decouple internal flags from exported ones */
119
120#define KPF_LOCKED 0
121#define KPF_ERROR 1
122#define KPF_REFERENCED 2
123#define KPF_UPTODATE 3
124#define KPF_DIRTY 4
125#define KPF_LRU 5
126#define KPF_ACTIVE 6
127#define KPF_SLAB 7
128#define KPF_WRITEBACK 8
129#define KPF_RECLAIM 9
130#define KPF_BUDDY 10
131
132#define kpf_copy_bit(flags, srcpos, dstpos) (((flags >> srcpos) & 1) << dstpos)
133
134static ssize_t kpageflags_read(struct file *file, char __user *buf,
135 size_t count, loff_t *ppos)
136{
137 u64 __user *out = (u64 __user *)buf;
138 struct page *ppage;
139 unsigned long src = *ppos;
140 unsigned long pfn;
141 ssize_t ret = 0;
142 u64 kflags, uflags;
143
144 pfn = src / KPMSIZE;
145 count = min_t(unsigned long, count, (max_pfn * KPMSIZE) - src);
146 if (src & KPMMASK || count & KPMMASK)
147 return -EINVAL;
148
149 while (count > 0) {
150 ppage = NULL;
151 if (pfn_valid(pfn))
152 ppage = pfn_to_page(pfn);
153 pfn++;
154 if (!ppage)
155 kflags = 0;
156 else
157 kflags = ppage->flags;
158
159 uflags = kpf_copy_bit(KPF_LOCKED, PG_locked, kflags) |
160 kpf_copy_bit(kflags, KPF_ERROR, PG_error) |
161 kpf_copy_bit(kflags, KPF_REFERENCED, PG_referenced) |
162 kpf_copy_bit(kflags, KPF_UPTODATE, PG_uptodate) |
163 kpf_copy_bit(kflags, KPF_DIRTY, PG_dirty) |
164 kpf_copy_bit(kflags, KPF_LRU, PG_lru) |
165 kpf_copy_bit(kflags, KPF_ACTIVE, PG_active) |
166 kpf_copy_bit(kflags, KPF_SLAB, PG_slab) |
167 kpf_copy_bit(kflags, KPF_WRITEBACK, PG_writeback) |
168 kpf_copy_bit(kflags, KPF_RECLAIM, PG_reclaim) |
169 kpf_copy_bit(kflags, KPF_BUDDY, PG_buddy);
170
171 if (put_user(uflags, out++)) {
172 ret = -EFAULT;
173 break;
174 }
175
176 count -= KPMSIZE;
177 }
178
179 *ppos += (char __user *)out - buf;
180 if (!ret)
181 ret = (char __user *)out - buf;
182 return ret;
183}
184
185static struct file_operations proc_kpageflags_operations = {
186 .llseek = mem_lseek,
187 .read = kpageflags_read,
188};
189#endif /* CONFIG_PROC_PAGE_MONITOR */
190
191void __init proc_misc_init(void) 60void __init proc_misc_init(void)
192{ 61{
193 proc_symlink("mounts", NULL, "self/mounts"); 62 proc_symlink("mounts", NULL, "self/mounts");
194 63
195 /* And now for trickier ones */ 64 /* And now for trickier ones */
196#ifdef CONFIG_PROC_PAGE_MONITOR
197 proc_create("kpagecount", S_IRUSR, NULL, &proc_kpagecount_operations);
198 proc_create("kpageflags", S_IRUSR, NULL, &proc_kpageflags_operations);
199#endif
200#ifdef CONFIG_PROC_VMCORE 65#ifdef CONFIG_PROC_VMCORE
201 proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations); 66 proc_vmcore = proc_create("vmcore", S_IRUSR, NULL, &proc_vmcore_operations);
202#endif 67#endif