diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2008-02-08 07:18:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-08 12:22:24 -0500 |
commit | df5f8314ca30d6a76735748e5ba4ca9809c0f434 (patch) | |
tree | e0a6157b1666a320e69586a81c77a3fe83b36a2a | |
parent | a56d3fc74c0178c5f41c48315604d62cff4e746d (diff) |
proc: seqfile convert proc_pid_status to properly handle pid namespaces
Currently we possibly lookup the pid in the wrong pid namespace. So
seq_file convert proc_pid_status which ensures the proper pid namespaces is
passed in.
[akpm@linux-foundation.org: coding-style fixes]
[akpm@linux-foundation.org: build fix]
[akpm@linux-foundation.org: another build fix]
[akpm@linux-foundation.org: s390 build fix]
[akpm@linux-foundation.org: fix task_name() output]
[akpm@linux-foundation.org: fix nommu build]
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Cc: Andrew Morgan <morgan@kernel.org>
Cc: Serge Hallyn <serue@us.ibm.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Paul Menage <menage@google.com>
Cc: Paul Jackson <pj@sgi.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/s390/kernel/traps.c | 24 | ||||
-rw-r--r-- | fs/proc/array.c | 128 | ||||
-rw-r--r-- | fs/proc/base.c | 4 | ||||
-rw-r--r-- | fs/proc/internal.h | 3 | ||||
-rw-r--r-- | fs/proc/task_mmu.c | 6 | ||||
-rw-r--r-- | fs/proc/task_nommu.c | 5 | ||||
-rw-r--r-- | include/asm-s390/processor.h | 3 | ||||
-rw-r--r-- | include/linux/cpuset.h | 9 | ||||
-rw-r--r-- | include/linux/proc_fs.h | 3 | ||||
-rw-r--r-- | kernel/cpuset.c | 19 |
10 files changed, 103 insertions, 101 deletions
diff --git a/arch/s390/kernel/traps.c b/arch/s390/kernel/traps.c index 1a2fdb6991df..a4d29025ddbd 100644 --- a/arch/s390/kernel/traps.c +++ b/arch/s390/kernel/traps.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/smp.h> | 24 | #include <linux/smp.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
27 | #include <linux/seq_file.h> | ||
27 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
28 | #include <linux/module.h> | 29 | #include <linux/module.h> |
29 | #include <linux/kdebug.h> | 30 | #include <linux/kdebug.h> |
@@ -218,41 +219,40 @@ void show_registers(struct pt_regs *regs) | |||
218 | } | 219 | } |
219 | 220 | ||
220 | /* This is called from fs/proc/array.c */ | 221 | /* This is called from fs/proc/array.c */ |
221 | char *task_show_regs(struct task_struct *task, char *buffer) | 222 | void task_show_regs(struct seq_file *m, struct task_struct *task) |
222 | { | 223 | { |
223 | struct pt_regs *regs; | 224 | struct pt_regs *regs; |
224 | 225 | ||
225 | regs = task_pt_regs(task); | 226 | regs = task_pt_regs(task); |
226 | buffer += sprintf(buffer, "task: %p, ksp: %p\n", | 227 | seq_printf(m, "task: %p, ksp: %p\n", |
227 | task, (void *)task->thread.ksp); | 228 | task, (void *)task->thread.ksp); |
228 | buffer += sprintf(buffer, "User PSW : %p %p\n", | 229 | seq_printf(m, "User PSW : %p %p\n", |
229 | (void *) regs->psw.mask, (void *)regs->psw.addr); | 230 | (void *) regs->psw.mask, (void *)regs->psw.addr); |
230 | 231 | ||
231 | buffer += sprintf(buffer, "User GPRS: " FOURLONG, | 232 | seq_printf(m, "User GPRS: " FOURLONG, |
232 | regs->gprs[0], regs->gprs[1], | 233 | regs->gprs[0], regs->gprs[1], |
233 | regs->gprs[2], regs->gprs[3]); | 234 | regs->gprs[2], regs->gprs[3]); |
234 | buffer += sprintf(buffer, " " FOURLONG, | 235 | seq_printf(m, " " FOURLONG, |
235 | regs->gprs[4], regs->gprs[5], | 236 | regs->gprs[4], regs->gprs[5], |
236 | regs->gprs[6], regs->gprs[7]); | 237 | regs->gprs[6], regs->gprs[7]); |
237 | buffer += sprintf(buffer, " " FOURLONG, | 238 | seq_printf(m, " " FOURLONG, |
238 | regs->gprs[8], regs->gprs[9], | 239 | regs->gprs[8], regs->gprs[9], |
239 | regs->gprs[10], regs->gprs[11]); | 240 | regs->gprs[10], regs->gprs[11]); |
240 | buffer += sprintf(buffer, " " FOURLONG, | 241 | seq_printf(m, " " FOURLONG, |
241 | regs->gprs[12], regs->gprs[13], | 242 | regs->gprs[12], regs->gprs[13], |
242 | regs->gprs[14], regs->gprs[15]); | 243 | regs->gprs[14], regs->gprs[15]); |
243 | buffer += sprintf(buffer, "User ACRS: %08x %08x %08x %08x\n", | 244 | seq_printf(m, "User ACRS: %08x %08x %08x %08x\n", |
244 | task->thread.acrs[0], task->thread.acrs[1], | 245 | task->thread.acrs[0], task->thread.acrs[1], |
245 | task->thread.acrs[2], task->thread.acrs[3]); | 246 | task->thread.acrs[2], task->thread.acrs[3]); |
246 | buffer += sprintf(buffer, " %08x %08x %08x %08x\n", | 247 | seq_printf(m, " %08x %08x %08x %08x\n", |
247 | task->thread.acrs[4], task->thread.acrs[5], | 248 | task->thread.acrs[4], task->thread.acrs[5], |
248 | task->thread.acrs[6], task->thread.acrs[7]); | 249 | task->thread.acrs[6], task->thread.acrs[7]); |
249 | buffer += sprintf(buffer, " %08x %08x %08x %08x\n", | 250 | seq_printf(m, " %08x %08x %08x %08x\n", |
250 | task->thread.acrs[8], task->thread.acrs[9], | 251 | task->thread.acrs[8], task->thread.acrs[9], |
251 | task->thread.acrs[10], task->thread.acrs[11]); | 252 | task->thread.acrs[10], task->thread.acrs[11]); |
252 | buffer += sprintf(buffer, " %08x %08x %08x %08x\n", | 253 | seq_printf(m, " %08x %08x %08x %08x\n", |
253 | task->thread.acrs[12], task->thread.acrs[13], | 254 | task->thread.acrs[12], task->thread.acrs[13], |
254 | task->thread.acrs[14], task->thread.acrs[15]); | 255 | task->thread.acrs[14], task->thread.acrs[15]); |
255 | return buffer; | ||
256 | } | 256 | } |
257 | 257 | ||
258 | static DEFINE_SPINLOCK(die_lock); | 258 | static DEFINE_SPINLOCK(die_lock); |
diff --git a/fs/proc/array.c b/fs/proc/array.c index 5540e9575c6d..07d6c4853fe8 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c | |||
@@ -89,18 +89,21 @@ | |||
89 | do { memcpy(buffer, string, strlen(string)); \ | 89 | do { memcpy(buffer, string, strlen(string)); \ |
90 | buffer += strlen(string); } while (0) | 90 | buffer += strlen(string); } while (0) |
91 | 91 | ||
92 | static inline char *task_name(struct task_struct *p, char *buf) | 92 | static inline void task_name(struct seq_file *m, struct task_struct *p) |
93 | { | 93 | { |
94 | int i; | 94 | int i; |
95 | char *buf, *end; | ||
95 | char *name; | 96 | char *name; |
96 | char tcomm[sizeof(p->comm)]; | 97 | char tcomm[sizeof(p->comm)]; |
97 | 98 | ||
98 | get_task_comm(tcomm, p); | 99 | get_task_comm(tcomm, p); |
99 | 100 | ||
100 | ADDBUF(buf, "Name:\t"); | 101 | seq_printf(m, "Name:\t"); |
102 | end = m->buf + m->size; | ||
103 | buf = m->buf + m->count; | ||
101 | name = tcomm; | 104 | name = tcomm; |
102 | i = sizeof(tcomm); | 105 | i = sizeof(tcomm); |
103 | do { | 106 | while (i && (buf < end)) { |
104 | unsigned char c = *name; | 107 | unsigned char c = *name; |
105 | name++; | 108 | name++; |
106 | i--; | 109 | i--; |
@@ -108,20 +111,21 @@ static inline char *task_name(struct task_struct *p, char *buf) | |||
108 | if (!c) | 111 | if (!c) |
109 | break; | 112 | break; |
110 | if (c == '\\') { | 113 | if (c == '\\') { |
111 | buf[1] = c; | 114 | buf++; |
112 | buf += 2; | 115 | if (buf < end) |
116 | *buf++ = c; | ||
113 | continue; | 117 | continue; |
114 | } | 118 | } |
115 | if (c == '\n') { | 119 | if (c == '\n') { |
116 | buf[0] = '\\'; | 120 | *buf++ = '\\'; |
117 | buf[1] = 'n'; | 121 | if (buf < end) |
118 | buf += 2; | 122 | *buf++ = 'n'; |
119 | continue; | 123 | continue; |
120 | } | 124 | } |
121 | buf++; | 125 | buf++; |
122 | } while (i); | 126 | } |
123 | *buf = '\n'; | 127 | m->count = buf - m->buf; |
124 | return buf+1; | 128 | seq_printf(m, "\n"); |
125 | } | 129 | } |
126 | 130 | ||
127 | /* | 131 | /* |
@@ -152,21 +156,20 @@ static inline const char *get_task_state(struct task_struct *tsk) | |||
152 | return *p; | 156 | return *p; |
153 | } | 157 | } |
154 | 158 | ||
155 | static inline char *task_state(struct task_struct *p, char *buffer) | 159 | static inline void task_state(struct seq_file *m, struct pid_namespace *ns, |
160 | struct pid *pid, struct task_struct *p) | ||
156 | { | 161 | { |
157 | struct group_info *group_info; | 162 | struct group_info *group_info; |
158 | int g; | 163 | int g; |
159 | struct fdtable *fdt = NULL; | 164 | struct fdtable *fdt = NULL; |
160 | struct pid_namespace *ns; | ||
161 | pid_t ppid, tpid; | 165 | pid_t ppid, tpid; |
162 | 166 | ||
163 | ns = current->nsproxy->pid_ns; | ||
164 | rcu_read_lock(); | 167 | rcu_read_lock(); |
165 | ppid = pid_alive(p) ? | 168 | ppid = pid_alive(p) ? |
166 | task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; | 169 | task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0; |
167 | tpid = pid_alive(p) && p->ptrace ? | 170 | tpid = pid_alive(p) && p->ptrace ? |
168 | task_pid_nr_ns(rcu_dereference(p->parent), ns) : 0; | 171 | task_pid_nr_ns(rcu_dereference(p->parent), ns) : 0; |
169 | buffer += sprintf(buffer, | 172 | seq_printf(m, |
170 | "State:\t%s\n" | 173 | "State:\t%s\n" |
171 | "Tgid:\t%d\n" | 174 | "Tgid:\t%d\n" |
172 | "Pid:\t%d\n" | 175 | "Pid:\t%d\n" |
@@ -176,7 +179,7 @@ static inline char *task_state(struct task_struct *p, char *buffer) | |||
176 | "Gid:\t%d\t%d\t%d\t%d\n", | 179 | "Gid:\t%d\t%d\t%d\t%d\n", |
177 | get_task_state(p), | 180 | get_task_state(p), |
178 | task_tgid_nr_ns(p, ns), | 181 | task_tgid_nr_ns(p, ns), |
179 | task_pid_nr_ns(p, ns), | 182 | pid_nr_ns(pid, ns), |
180 | ppid, tpid, | 183 | ppid, tpid, |
181 | p->uid, p->euid, p->suid, p->fsuid, | 184 | p->uid, p->euid, p->suid, p->fsuid, |
182 | p->gid, p->egid, p->sgid, p->fsgid); | 185 | p->gid, p->egid, p->sgid, p->fsgid); |
@@ -184,7 +187,7 @@ static inline char *task_state(struct task_struct *p, char *buffer) | |||
184 | task_lock(p); | 187 | task_lock(p); |
185 | if (p->files) | 188 | if (p->files) |
186 | fdt = files_fdtable(p->files); | 189 | fdt = files_fdtable(p->files); |
187 | buffer += sprintf(buffer, | 190 | seq_printf(m, |
188 | "FDSize:\t%d\n" | 191 | "FDSize:\t%d\n" |
189 | "Groups:\t", | 192 | "Groups:\t", |
190 | fdt ? fdt->max_fds : 0); | 193 | fdt ? fdt->max_fds : 0); |
@@ -195,20 +198,18 @@ static inline char *task_state(struct task_struct *p, char *buffer) | |||
195 | task_unlock(p); | 198 | task_unlock(p); |
196 | 199 | ||
197 | for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++) | 200 | for (g = 0; g < min(group_info->ngroups, NGROUPS_SMALL); g++) |
198 | buffer += sprintf(buffer, "%d ", GROUP_AT(group_info, g)); | 201 | seq_printf(m, "%d ", GROUP_AT(group_info, g)); |
199 | put_group_info(group_info); | 202 | put_group_info(group_info); |
200 | 203 | ||
201 | buffer += sprintf(buffer, "\n"); | 204 | seq_printf(m, "\n"); |
202 | return buffer; | ||
203 | } | 205 | } |
204 | 206 | ||
205 | static char *render_sigset_t(const char *header, sigset_t *set, char *buffer) | 207 | static void render_sigset_t(struct seq_file *m, const char *header, |
208 | sigset_t *set) | ||
206 | { | 209 | { |
207 | int i, len; | 210 | int i; |
208 | 211 | ||
209 | len = strlen(header); | 212 | seq_printf(m, "%s", header); |
210 | memcpy(buffer, header, len); | ||
211 | buffer += len; | ||
212 | 213 | ||
213 | i = _NSIG; | 214 | i = _NSIG; |
214 | do { | 215 | do { |
@@ -219,12 +220,10 @@ static char *render_sigset_t(const char *header, sigset_t *set, char *buffer) | |||
219 | if (sigismember(set, i+2)) x |= 2; | 220 | if (sigismember(set, i+2)) x |= 2; |
220 | if (sigismember(set, i+3)) x |= 4; | 221 | if (sigismember(set, i+3)) x |= 4; |
221 | if (sigismember(set, i+4)) x |= 8; | 222 | if (sigismember(set, i+4)) x |= 8; |
222 | *buffer++ = (x < 10 ? '0' : 'a' - 10) + x; | 223 | seq_printf(m, "%x", x); |
223 | } while (i >= 4); | 224 | } while (i >= 4); |
224 | 225 | ||
225 | *buffer++ = '\n'; | 226 | seq_printf(m, "\n"); |
226 | *buffer = 0; | ||
227 | return buffer; | ||
228 | } | 227 | } |
229 | 228 | ||
230 | static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *ign, | 229 | static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *ign, |
@@ -242,7 +241,7 @@ static void collect_sigign_sigcatch(struct task_struct *p, sigset_t *ign, | |||
242 | } | 241 | } |
243 | } | 242 | } |
244 | 243 | ||
245 | static inline char *task_sig(struct task_struct *p, char *buffer) | 244 | static inline void task_sig(struct seq_file *m, struct task_struct *p) |
246 | { | 245 | { |
247 | unsigned long flags; | 246 | unsigned long flags; |
248 | sigset_t pending, shpending, blocked, ignored, caught; | 247 | sigset_t pending, shpending, blocked, ignored, caught; |
@@ -269,67 +268,66 @@ static inline char *task_sig(struct task_struct *p, char *buffer) | |||
269 | } | 268 | } |
270 | rcu_read_unlock(); | 269 | rcu_read_unlock(); |
271 | 270 | ||
272 | buffer += sprintf(buffer, "Threads:\t%d\n", num_threads); | 271 | seq_printf(m, "Threads:\t%d\n", num_threads); |
273 | buffer += sprintf(buffer, "SigQ:\t%lu/%lu\n", qsize, qlim); | 272 | seq_printf(m, "SigQ:\t%lu/%lu\n", qsize, qlim); |
274 | 273 | ||
275 | /* render them all */ | 274 | /* render them all */ |
276 | buffer = render_sigset_t("SigPnd:\t", &pending, buffer); | 275 | render_sigset_t(m, "SigPnd:\t", &pending); |
277 | buffer = render_sigset_t("ShdPnd:\t", &shpending, buffer); | 276 | render_sigset_t(m, "ShdPnd:\t", &shpending); |
278 | buffer = render_sigset_t("SigBlk:\t", &blocked, buffer); | 277 | render_sigset_t(m, "SigBlk:\t", &blocked); |
279 | buffer = render_sigset_t("SigIgn:\t", &ignored, buffer); | 278 | render_sigset_t(m, "SigIgn:\t", &ignored); |
280 | buffer = render_sigset_t("SigCgt:\t", &caught, buffer); | 279 | render_sigset_t(m, "SigCgt:\t", &caught); |
281 | |||
282 | return buffer; | ||
283 | } | 280 | } |
284 | 281 | ||
285 | static char *render_cap_t(const char *header, kernel_cap_t *a, char *buffer) | 282 | static void render_cap_t(struct seq_file *m, const char *header, |
283 | kernel_cap_t *a) | ||
286 | { | 284 | { |
287 | unsigned __capi; | 285 | unsigned __capi; |
288 | 286 | ||
289 | buffer += sprintf(buffer, "%s", header); | 287 | seq_printf(m, "%s", header); |
290 | CAP_FOR_EACH_U32(__capi) { | 288 | CAP_FOR_EACH_U32(__capi) { |
291 | buffer += sprintf(buffer, "%08x", | 289 | seq_printf(m, "%08x", |
292 | a->cap[(_LINUX_CAPABILITY_U32S-1) - __capi]); | 290 | a->cap[(_LINUX_CAPABILITY_U32S-1) - __capi]); |
293 | } | 291 | } |
294 | return buffer + sprintf(buffer, "\n"); | 292 | seq_printf(m, "\n"); |
295 | } | 293 | } |
296 | 294 | ||
297 | static inline char *task_cap(struct task_struct *p, char *buffer) | 295 | static inline void task_cap(struct seq_file *m, struct task_struct *p) |
298 | { | 296 | { |
299 | buffer = render_cap_t("CapInh:\t", &p->cap_inheritable, buffer); | 297 | render_cap_t(m, "CapInh:\t", &p->cap_inheritable); |
300 | buffer = render_cap_t("CapPrm:\t", &p->cap_permitted, buffer); | 298 | render_cap_t(m, "CapPrm:\t", &p->cap_permitted); |
301 | return render_cap_t("CapEff:\t", &p->cap_effective, buffer); | 299 | render_cap_t(m, "CapEff:\t", &p->cap_effective); |
302 | } | 300 | } |
303 | 301 | ||
304 | static inline char *task_context_switch_counts(struct task_struct *p, | 302 | static inline void task_context_switch_counts(struct seq_file *m, |
305 | char *buffer) | 303 | struct task_struct *p) |
306 | { | 304 | { |
307 | return buffer + sprintf(buffer, "voluntary_ctxt_switches:\t%lu\n" | 305 | seq_printf(m, "voluntary_ctxt_switches:\t%lu\n" |
308 | "nonvoluntary_ctxt_switches:\t%lu\n", | 306 | "nonvoluntary_ctxt_switches:\t%lu\n", |
309 | p->nvcsw, | 307 | p->nvcsw, |
310 | p->nivcsw); | 308 | p->nivcsw); |
311 | } | 309 | } |
312 | 310 | ||
313 | int proc_pid_status(struct task_struct *task, char *buffer) | 311 | int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, |
312 | struct pid *pid, struct task_struct *task) | ||
314 | { | 313 | { |
315 | char *orig = buffer; | ||
316 | struct mm_struct *mm = get_task_mm(task); | 314 | struct mm_struct *mm = get_task_mm(task); |
317 | 315 | ||
318 | buffer = task_name(task, buffer); | 316 | task_name(m, task); |
319 | buffer = task_state(task, buffer); | 317 | task_state(m, ns, pid, task); |
320 | 318 | ||
321 | if (mm) { | 319 | if (mm) { |
322 | buffer = task_mem(mm, buffer); | 320 | task_mem(m, mm); |
323 | mmput(mm); | 321 | mmput(mm); |
324 | } | 322 | } |
325 | buffer = task_sig(task, buffer); | 323 | task_sig(m, task); |
326 | buffer = task_cap(task, buffer); | 324 | task_cap(m, task); |
327 | buffer = cpuset_task_status_allowed(task, buffer); | 325 | cpuset_task_status_allowed(m, task); |
328 | #if defined(CONFIG_S390) | 326 | #if defined(CONFIG_S390) |
329 | buffer = task_show_regs(task, buffer); | 327 | task_show_regs(m, task); |
330 | #endif | 328 | #endif |
331 | buffer = task_context_switch_counts(task, buffer); | 329 | task_context_switch_counts(m, task); |
332 | return buffer - orig; | 330 | return 0; |
333 | } | 331 | } |
334 | 332 | ||
335 | /* | 333 | /* |
diff --git a/fs/proc/base.c b/fs/proc/base.c index 9c3e548a6754..8a19a8a1a3e6 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -2274,7 +2274,7 @@ static const struct pid_entry tgid_base_stuff[] = { | |||
2274 | DIR("fdinfo", S_IRUSR|S_IXUSR, fdinfo), | 2274 | DIR("fdinfo", S_IRUSR|S_IXUSR, fdinfo), |
2275 | REG("environ", S_IRUSR, environ), | 2275 | REG("environ", S_IRUSR, environ), |
2276 | INF("auxv", S_IRUSR, pid_auxv), | 2276 | INF("auxv", S_IRUSR, pid_auxv), |
2277 | INF("status", S_IRUGO, pid_status), | 2277 | ONE("status", S_IRUGO, pid_status), |
2278 | INF("limits", S_IRUSR, pid_limits), | 2278 | INF("limits", S_IRUSR, pid_limits), |
2279 | #ifdef CONFIG_SCHED_DEBUG | 2279 | #ifdef CONFIG_SCHED_DEBUG |
2280 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), | 2280 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), |
@@ -2605,7 +2605,7 @@ static const struct pid_entry tid_base_stuff[] = { | |||
2605 | DIR("fdinfo", S_IRUSR|S_IXUSR, fdinfo), | 2605 | DIR("fdinfo", S_IRUSR|S_IXUSR, fdinfo), |
2606 | REG("environ", S_IRUSR, environ), | 2606 | REG("environ", S_IRUSR, environ), |
2607 | INF("auxv", S_IRUSR, pid_auxv), | 2607 | INF("auxv", S_IRUSR, pid_auxv), |
2608 | INF("status", S_IRUGO, pid_status), | 2608 | ONE("status", S_IRUGO, pid_status), |
2609 | INF("limits", S_IRUSR, pid_limits), | 2609 | INF("limits", S_IRUSR, pid_limits), |
2610 | #ifdef CONFIG_SCHED_DEBUG | 2610 | #ifdef CONFIG_SCHED_DEBUG |
2611 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), | 2611 | REG("sched", S_IRUGO|S_IWUSR, pid_sched), |
diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 45bdbfc704e7..ea496ffeabe7 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h | |||
@@ -53,7 +53,8 @@ extern int proc_tid_stat(struct seq_file *m, struct pid_namespace *ns, | |||
53 | struct pid *pid, struct task_struct *task); | 53 | struct pid *pid, struct task_struct *task); |
54 | extern int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns, | 54 | extern int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns, |
55 | struct pid *pid, struct task_struct *task); | 55 | struct pid *pid, struct task_struct *task); |
56 | extern int proc_pid_status(struct task_struct *, char *); | 56 | extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, |
57 | struct pid *pid, struct task_struct *task); | ||
57 | extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns, | 58 | extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns, |
58 | struct pid *pid, struct task_struct *task); | 59 | struct pid *pid, struct task_struct *task); |
59 | extern loff_t mem_lseek(struct file *file, loff_t offset, int orig); | 60 | extern loff_t mem_lseek(struct file *file, loff_t offset, int orig); |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 38338ed98cc6..a34c440f8d25 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
@@ -9,13 +9,14 @@ | |||
9 | #include <linux/mempolicy.h> | 9 | #include <linux/mempolicy.h> |
10 | #include <linux/swap.h> | 10 | #include <linux/swap.h> |
11 | #include <linux/swapops.h> | 11 | #include <linux/swapops.h> |
12 | #include <linux/seq_file.h> | ||
12 | 13 | ||
13 | #include <asm/elf.h> | 14 | #include <asm/elf.h> |
14 | #include <asm/uaccess.h> | 15 | #include <asm/uaccess.h> |
15 | #include <asm/tlbflush.h> | 16 | #include <asm/tlbflush.h> |
16 | #include "internal.h" | 17 | #include "internal.h" |
17 | 18 | ||
18 | char *task_mem(struct mm_struct *mm, char *buffer) | 19 | void task_mem(struct seq_file *m, struct mm_struct *mm) |
19 | { | 20 | { |
20 | unsigned long data, text, lib; | 21 | unsigned long data, text, lib; |
21 | unsigned long hiwater_vm, total_vm, hiwater_rss, total_rss; | 22 | unsigned long hiwater_vm, total_vm, hiwater_rss, total_rss; |
@@ -37,7 +38,7 @@ char *task_mem(struct mm_struct *mm, char *buffer) | |||
37 | data = mm->total_vm - mm->shared_vm - mm->stack_vm; | 38 | data = mm->total_vm - mm->shared_vm - mm->stack_vm; |
38 | text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK)) >> 10; | 39 | text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK)) >> 10; |
39 | lib = (mm->exec_vm << (PAGE_SHIFT-10)) - text; | 40 | lib = (mm->exec_vm << (PAGE_SHIFT-10)) - text; |
40 | buffer += sprintf(buffer, | 41 | seq_printf(m, |
41 | "VmPeak:\t%8lu kB\n" | 42 | "VmPeak:\t%8lu kB\n" |
42 | "VmSize:\t%8lu kB\n" | 43 | "VmSize:\t%8lu kB\n" |
43 | "VmLck:\t%8lu kB\n" | 44 | "VmLck:\t%8lu kB\n" |
@@ -56,7 +57,6 @@ char *task_mem(struct mm_struct *mm, char *buffer) | |||
56 | data << (PAGE_SHIFT-10), | 57 | data << (PAGE_SHIFT-10), |
57 | mm->stack_vm << (PAGE_SHIFT-10), text, lib, | 58 | mm->stack_vm << (PAGE_SHIFT-10), text, lib, |
58 | (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10); | 59 | (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10); |
59 | return buffer; | ||
60 | } | 60 | } |
61 | 61 | ||
62 | unsigned long task_vsize(struct mm_struct *mm) | 62 | unsigned long task_vsize(struct mm_struct *mm) |
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index 1932c2ca3457..cee0231c6cec 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c | |||
@@ -12,7 +12,7 @@ | |||
12 | * each process that owns it. Non-shared memory is counted | 12 | * each process that owns it. Non-shared memory is counted |
13 | * accurately. | 13 | * accurately. |
14 | */ | 14 | */ |
15 | char *task_mem(struct mm_struct *mm, char *buffer) | 15 | void task_mem(struct seq_file *m, struct mm_struct *mm) |
16 | { | 16 | { |
17 | struct vm_list_struct *vml; | 17 | struct vm_list_struct *vml; |
18 | unsigned long bytes = 0, sbytes = 0, slack = 0; | 18 | unsigned long bytes = 0, sbytes = 0, slack = 0; |
@@ -58,14 +58,13 @@ char *task_mem(struct mm_struct *mm, char *buffer) | |||
58 | 58 | ||
59 | bytes += kobjsize(current); /* includes kernel stack */ | 59 | bytes += kobjsize(current); /* includes kernel stack */ |
60 | 60 | ||
61 | buffer += sprintf(buffer, | 61 | seq_printf(m, |
62 | "Mem:\t%8lu bytes\n" | 62 | "Mem:\t%8lu bytes\n" |
63 | "Slack:\t%8lu bytes\n" | 63 | "Slack:\t%8lu bytes\n" |
64 | "Shared:\t%8lu bytes\n", | 64 | "Shared:\t%8lu bytes\n", |
65 | bytes, slack, sbytes); | 65 | bytes, slack, sbytes); |
66 | 66 | ||
67 | up_read(&mm->mmap_sem); | 67 | up_read(&mm->mmap_sem); |
68 | return buffer; | ||
69 | } | 68 | } |
70 | 69 | ||
71 | unsigned long task_vsize(struct mm_struct *mm) | 70 | unsigned long task_vsize(struct mm_struct *mm) |
diff --git a/include/asm-s390/processor.h b/include/asm-s390/processor.h index 4f744609cd11..dfec2d011c0d 100644 --- a/include/asm-s390/processor.h +++ b/include/asm-s390/processor.h | |||
@@ -161,6 +161,7 @@ struct stack_frame { | |||
161 | /* Forward declaration, a strange C thing */ | 161 | /* Forward declaration, a strange C thing */ |
162 | struct task_struct; | 162 | struct task_struct; |
163 | struct mm_struct; | 163 | struct mm_struct; |
164 | struct seq_file; | ||
164 | 165 | ||
165 | /* Free all resources held by a thread. */ | 166 | /* Free all resources held by a thread. */ |
166 | extern void release_thread(struct task_struct *); | 167 | extern void release_thread(struct task_struct *); |
@@ -177,7 +178,7 @@ extern unsigned long thread_saved_pc(struct task_struct *t); | |||
177 | /* | 178 | /* |
178 | * Print register of task into buffer. Used in fs/proc/array.c. | 179 | * Print register of task into buffer. Used in fs/proc/array.c. |
179 | */ | 180 | */ |
180 | extern char *task_show_regs(struct task_struct *task, char *buffer); | 181 | extern void task_show_regs(struct seq_file *m, struct task_struct *task); |
181 | 182 | ||
182 | extern void show_registers(struct pt_regs *regs); | 183 | extern void show_registers(struct pt_regs *regs); |
183 | extern void show_code(struct pt_regs *regs); | 184 | extern void show_code(struct pt_regs *regs); |
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index ecae585ec3da..f8c9a2752f06 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h | |||
@@ -57,7 +57,9 @@ extern int cpuset_memory_pressure_enabled; | |||
57 | extern void __cpuset_memory_pressure_bump(void); | 57 | extern void __cpuset_memory_pressure_bump(void); |
58 | 58 | ||
59 | extern const struct file_operations proc_cpuset_operations; | 59 | extern const struct file_operations proc_cpuset_operations; |
60 | extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer); | 60 | struct seq_file; |
61 | extern void cpuset_task_status_allowed(struct seq_file *m, | ||
62 | struct task_struct *task); | ||
61 | 63 | ||
62 | extern void cpuset_lock(void); | 64 | extern void cpuset_lock(void); |
63 | extern void cpuset_unlock(void); | 65 | extern void cpuset_unlock(void); |
@@ -126,10 +128,9 @@ static inline int cpuset_mems_allowed_intersects(const struct task_struct *tsk1, | |||
126 | 128 | ||
127 | static inline void cpuset_memory_pressure_bump(void) {} | 129 | static inline void cpuset_memory_pressure_bump(void) {} |
128 | 130 | ||
129 | static inline char *cpuset_task_status_allowed(struct task_struct *task, | 131 | static inline void cpuset_task_status_allowed(struct seq_file *m, |
130 | char *buffer) | 132 | struct task_struct *task) |
131 | { | 133 | { |
132 | return buffer; | ||
133 | } | 134 | } |
134 | 135 | ||
135 | static inline void cpuset_lock(void) {} | 136 | static inline void cpuset_lock(void) {} |
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index b04ebf09fb91..e4a8f9aef188 100644 --- a/include/linux/proc_fs.h +++ b/include/linux/proc_fs.h | |||
@@ -118,7 +118,8 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct | |||
118 | int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir); | 118 | int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir); |
119 | unsigned long task_vsize(struct mm_struct *); | 119 | unsigned long task_vsize(struct mm_struct *); |
120 | int task_statm(struct mm_struct *, int *, int *, int *, int *); | 120 | int task_statm(struct mm_struct *, int *, int *, int *, int *); |
121 | char *task_mem(struct mm_struct *, char *); | 121 | void task_mem(struct seq_file *, struct mm_struct *); |
122 | void clear_refs_smap(struct mm_struct *mm); | ||
122 | 123 | ||
123 | struct proc_dir_entry *de_get(struct proc_dir_entry *de); | 124 | struct proc_dir_entry *de_get(struct proc_dir_entry *de); |
124 | void de_put(struct proc_dir_entry *de); | 125 | void de_put(struct proc_dir_entry *de); |
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 67b2bfe27814..3e296ed81d4d 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -2255,13 +2255,14 @@ const struct file_operations proc_cpuset_operations = { | |||
2255 | #endif /* CONFIG_PROC_PID_CPUSET */ | 2255 | #endif /* CONFIG_PROC_PID_CPUSET */ |
2256 | 2256 | ||
2257 | /* Display task cpus_allowed, mems_allowed in /proc/<pid>/status file. */ | 2257 | /* Display task cpus_allowed, mems_allowed in /proc/<pid>/status file. */ |
2258 | char *cpuset_task_status_allowed(struct task_struct *task, char *buffer) | 2258 | void cpuset_task_status_allowed(struct seq_file *m, struct task_struct *task) |
2259 | { | 2259 | { |
2260 | buffer += sprintf(buffer, "Cpus_allowed:\t"); | 2260 | seq_printf(m, "Cpus_allowed:\t"); |
2261 | buffer += cpumask_scnprintf(buffer, PAGE_SIZE, task->cpus_allowed); | 2261 | m->count += cpumask_scnprintf(m->buf + m->count, m->size - m->count, |
2262 | buffer += sprintf(buffer, "\n"); | 2262 | task->cpus_allowed); |
2263 | buffer += sprintf(buffer, "Mems_allowed:\t"); | 2263 | seq_printf(m, "\n"); |
2264 | buffer += nodemask_scnprintf(buffer, PAGE_SIZE, task->mems_allowed); | 2264 | seq_printf(m, "Mems_allowed:\t"); |
2265 | buffer += sprintf(buffer, "\n"); | 2265 | m->count += nodemask_scnprintf(m->buf + m->count, m->size - m->count, |
2266 | return buffer; | 2266 | task->mems_allowed); |
2267 | seq_printf(m, "\n"); | ||
2267 | } | 2268 | } |