Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147359
b: refs/heads/master
c: 1ccd154
h: refs/heads/master
i:
  147357: 100d57a
  147355: f6daace
  147351: 97e12fe
  147343: 0632c23
  147327: db52352
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Apr 9, 2009
1 parent f18632b commit 1434459
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9ee318a7825929bc3734110b83ae8e20e53d9de3
refs/heads/master: 1ccd15497869f3ed83b5225d410df53a96e52757
2 changes: 2 additions & 0 deletions trunk/include/linux/perf_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,8 @@ struct perf_callchain_entry {

extern struct perf_callchain_entry *perf_callchain(struct pt_regs *regs);

extern int sysctl_perf_counter_priv;

#else
static inline void
perf_counter_task_sched_in(struct task_struct *task, int cpu) { }
Expand Down
4 changes: 3 additions & 1 deletion trunk/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ static atomic_t nr_mmap_tracking __read_mostly;
static atomic_t nr_munmap_tracking __read_mostly;
static atomic_t nr_comm_tracking __read_mostly;

int sysctl_perf_counter_priv __read_mostly; /* do we need to be privileged */

/*
* Mutex for (sysadmin-configurable) counter reservations:
*/
Expand Down Expand Up @@ -1132,7 +1134,7 @@ static struct perf_counter_context *find_get_context(pid_t pid, int cpu)
*/
if (cpu != -1) {
/* Must be root to operate on a CPU counter: */
if (!capable(CAP_SYS_ADMIN))
if (sysctl_perf_counter_priv && !capable(CAP_SYS_ADMIN))
return ERR_PTR(-EACCES);

if (cpu < 0 || cpu > num_possible_cpus())
Expand Down
11 changes: 11 additions & 0 deletions trunk/kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <linux/reboot.h>
#include <linux/ftrace.h>
#include <linux/slow-work.h>
#include <linux/perf_counter.h>

#include <asm/uaccess.h>
#include <asm/processor.h>
Expand Down Expand Up @@ -920,6 +921,16 @@ static struct ctl_table kern_table[] = {
.child = slow_work_sysctls,
},
#endif
#ifdef CONFIG_PERF_COUNTERS
{
.ctl_name = CTL_UNNUMBERED,
.procname = "perf_counter_privileged",
.data = &sysctl_perf_counter_priv,
.maxlen = sizeof(sysctl_perf_counter_priv),
.mode = 0644,
.proc_handler = &proc_dointvec,
},
#endif
/*
* NOTE: do not add new entries to this table unless you have read
* Documentation/sysctl/ctl_unnumbered.txt
Expand Down

0 comments on commit 1434459

Please sign in to comment.