Commit a0c9f240 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'proc-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc

* 'proc-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc:
  proc: remove write-only variable in proc_pident_lookup()
  proc: fix sparse warning
  proc: add /proc/*/stack
  proc: remove '##' usage
  proc: remove useless WARN_ONs
  proc: stop using BKL
parents 5bb47b9f 230e40fb
...@@ -140,6 +140,7 @@ Table 1-1: Process specific entries in /proc ...@@ -140,6 +140,7 @@ Table 1-1: Process specific entries in /proc
statm Process memory status information statm Process memory status information
status Process status in human readable form status Process status in human readable form
wchan If CONFIG_KALLSYMS is set, a pre-decoded wchan wchan If CONFIG_KALLSYMS is set, a pre-decoded wchan
stack Report full stack trace, enable via CONFIG_STACKTRACE
smaps Extension based on maps, the rss size for each mapped file smaps Extension based on maps, the rss size for each mapped file
.............................................................................. ..............................................................................
......
...@@ -32,7 +32,8 @@ static void save_raw_context_stack(struct stack_trace *trace, ...@@ -32,7 +32,8 @@ static void save_raw_context_stack(struct stack_trace *trace,
} }
} }
static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs) static void save_context_stack(struct stack_trace *trace,
struct task_struct *tsk, struct pt_regs *regs)
{ {
unsigned long sp = regs->regs[29]; unsigned long sp = regs->regs[29];
#ifdef CONFIG_KALLSYMS #ifdef CONFIG_KALLSYMS
...@@ -41,7 +42,7 @@ static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs) ...@@ -41,7 +42,7 @@ static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs)
if (raw_show_trace || !__kernel_text_address(pc)) { if (raw_show_trace || !__kernel_text_address(pc)) {
unsigned long stack_page = unsigned long stack_page =
(unsigned long)task_stack_page(current); (unsigned long)task_stack_page(tsk);
if (stack_page && sp >= stack_page && if (stack_page && sp >= stack_page &&
sp <= stack_page + THREAD_SIZE - 32) sp <= stack_page + THREAD_SIZE - 32)
save_raw_context_stack(trace, sp); save_raw_context_stack(trace, sp);
...@@ -54,7 +55,7 @@ static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs) ...@@ -54,7 +55,7 @@ static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs)
trace->entries[trace->nr_entries++] = pc; trace->entries[trace->nr_entries++] = pc;
if (trace->nr_entries >= trace->max_entries) if (trace->nr_entries >= trace->max_entries)
break; break;
pc = unwind_stack(current, &sp, pc, &ra); pc = unwind_stack(tsk, &sp, pc, &ra);
} while (pc); } while (pc);
#else #else
save_raw_context_stack(trace, sp); save_raw_context_stack(trace, sp);
...@@ -65,13 +66,24 @@ static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs) ...@@ -65,13 +66,24 @@ static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs)
* Save stack-backtrace addresses into a stack_trace buffer. * Save stack-backtrace addresses into a stack_trace buffer.
*/ */
void save_stack_trace(struct stack_trace *trace) void save_stack_trace(struct stack_trace *trace)
{
save_stack_trace_tsk(current, trace);
}
EXPORT_SYMBOL_GPL(save_stack_trace);
void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
{ {
struct pt_regs dummyregs; struct pt_regs dummyregs;
struct pt_regs *regs = &dummyregs; struct pt_regs *regs = &dummyregs;
WARN_ON(trace->nr_entries || !trace->max_entries); WARN_ON(trace->nr_entries || !trace->max_entries);
prepare_frametrace(regs); if (tsk != current) {
save_context_stack(trace, regs); regs->regs[29] = tsk->thread.reg29;
regs->regs[31] = 0;
regs->cp0_epc = tsk->thread.reg31;
} else
prepare_frametrace(regs);
save_context_stack(trace, tsk, regs);
} }
EXPORT_SYMBOL_GPL(save_stack_trace); EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
This diff is collapsed.
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/smp_lock.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/idr.h> #include <linux/idr.h>
#include <linux/namei.h> #include <linux/namei.h>
...@@ -379,7 +378,6 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, ...@@ -379,7 +378,6 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
struct inode *inode = NULL; struct inode *inode = NULL;
int error = -ENOENT; int error = -ENOENT;
lock_kernel();
spin_lock(&proc_subdir_lock); spin_lock(&proc_subdir_lock);
for (de = de->subdir; de ; de = de->next) { for (de = de->subdir; de ; de = de->next) {
if (de->namelen != dentry->d_name.len) if (de->namelen != dentry->d_name.len)
...@@ -397,7 +395,6 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, ...@@ -397,7 +395,6 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
} }
spin_unlock(&proc_subdir_lock); spin_unlock(&proc_subdir_lock);
out_unlock: out_unlock:
unlock_kernel();
if (inode) { if (inode) {
dentry->d_op = &proc_dentry_operations; dentry->d_op = &proc_dentry_operations;
...@@ -432,8 +429,6 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent, ...@@ -432,8 +429,6 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent,
struct inode *inode = filp->f_path.dentry->d_inode; struct inode *inode = filp->f_path.dentry->d_inode;
int ret = 0; int ret = 0;
lock_kernel();
ino = inode->i_ino; ino = inode->i_ino;
i = filp->f_pos; i = filp->f_pos;
switch (i) { switch (i) {
...@@ -487,7 +482,7 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent, ...@@ -487,7 +482,7 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent,
spin_unlock(&proc_subdir_lock); spin_unlock(&proc_subdir_lock);
} }
ret = 1; ret = 1;
out: unlock_kernel(); out:
return ret; return ret;
} }
...@@ -504,6 +499,7 @@ int proc_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -504,6 +499,7 @@ int proc_readdir(struct file *filp, void *dirent, filldir_t filldir)
* the /proc directory. * the /proc directory.
*/ */
static const struct file_operations proc_dir_operations = { static const struct file_operations proc_dir_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir, .read = generic_read_dir,
.readdir = proc_readdir, .readdir = proc_readdir,
}; };
......
...@@ -35,16 +35,13 @@ struct proc_dir_entry *de_get(struct proc_dir_entry *de) ...@@ -35,16 +35,13 @@ struct proc_dir_entry *de_get(struct proc_dir_entry *de)
*/ */
void de_put(struct proc_dir_entry *de) void de_put(struct proc_dir_entry *de)
{ {
lock_kernel();
if (!atomic_read(&de->count)) { if (!atomic_read(&de->count)) {
printk("de_put: entry %s already free!\n", de->name); printk("de_put: entry %s already free!\n", de->name);
unlock_kernel();
return; return;
} }
if (atomic_dec_and_test(&de->count)) if (atomic_dec_and_test(&de->count))
free_proc_entry(de); free_proc_entry(de);
unlock_kernel();
} }
/* /*
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/smp_lock.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/nsproxy.h> #include <linux/nsproxy.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
...@@ -172,6 +171,7 @@ static int proc_tgid_net_readdir(struct file *filp, void *dirent, ...@@ -172,6 +171,7 @@ static int proc_tgid_net_readdir(struct file *filp, void *dirent,
} }
const struct file_operations proc_net_operations = { const struct file_operations proc_net_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir, .read = generic_read_dir,
.readdir = proc_tgid_net_readdir, .readdir = proc_tgid_net_readdir,
}; };
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/smp_lock.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/pid_namespace.h> #include <linux/pid_namespace.h>
...@@ -162,17 +161,12 @@ static int proc_root_readdir(struct file * filp, ...@@ -162,17 +161,12 @@ static int proc_root_readdir(struct file * filp,
unsigned int nr = filp->f_pos; unsigned int nr = filp->f_pos;
int ret; int ret;
lock_kernel();
if (nr < FIRST_PROCESS_ENTRY) { if (nr < FIRST_PROCESS_ENTRY) {
int error = proc_readdir(filp, dirent, filldir); int error = proc_readdir(filp, dirent, filldir);
if (error <= 0) { if (error <= 0)
unlock_kernel();
return error; return error;
}
filp->f_pos = FIRST_PROCESS_ENTRY; filp->f_pos = FIRST_PROCESS_ENTRY;
} }
unlock_kernel();
ret = proc_pid_readdir(filp, dirent, filldir); ret = proc_pid_readdir(filp, dirent, filldir);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment