diff options
author | Robert Richter <robert.richter@amd.com> | 2010-10-04 15:09:36 -0400 |
---|---|---|
committer | Robert Richter <robert.richter@amd.com> | 2010-10-12 11:25:06 -0400 |
commit | 7df01d96b295e400167e78061b81d4c91630b12d (patch) | |
tree | 52782cc1d78c24030d627f719cdaa29846c42efb /drivers/oprofile/oprofilefs.c | |
parent | 0361e02342f60b64a7075755d5851ed4e6f98c7d (diff) |
oprofile: disable write access to oprofilefs while profiler is running
Oprofile counters are setup when profiling is disabled. Thus, writing
to oprofilefs has no immediate effect. Changes are updated only after
oprofile is reenabled.
To keep userland and kernel states synchronized, we now allow
configuration of oprofile only if profiling is disabled. In this case
it checks if the profiler is running and then disables write access to
oprofilefs by returning -EBUSY. The change should be backward
compatible with current oprofile userland daemon.
Acked-by: Maynard Johnson <maynardj@us.ibm.com>
Cc: William Cohen <wcohen@redhat.com>
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Diffstat (limited to 'drivers/oprofile/oprofilefs.c')
-rw-r--r-- | drivers/oprofile/oprofilefs.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c index 789a1a857ddf..1944621930d9 100644 --- a/drivers/oprofile/oprofilefs.c +++ b/drivers/oprofile/oprofilefs.c | |||
@@ -91,16 +91,20 @@ static ssize_t ulong_read_file(struct file *file, char __user *buf, size_t count | |||
91 | 91 | ||
92 | static ssize_t ulong_write_file(struct file *file, char const __user *buf, size_t count, loff_t *offset) | 92 | static ssize_t ulong_write_file(struct file *file, char const __user *buf, size_t count, loff_t *offset) |
93 | { | 93 | { |
94 | unsigned long *value = file->private_data; | 94 | unsigned long value; |
95 | int retval; | 95 | int retval; |
96 | 96 | ||
97 | if (*offset) | 97 | if (*offset) |
98 | return -EINVAL; | 98 | return -EINVAL; |
99 | 99 | ||
100 | retval = oprofilefs_ulong_from_user(value, buf, count); | 100 | retval = oprofilefs_ulong_from_user(&value, buf, count); |
101 | if (retval) | ||
102 | return retval; | ||
101 | 103 | ||
104 | retval = oprofile_set_ulong(file->private_data, value); | ||
102 | if (retval) | 105 | if (retval) |
103 | return retval; | 106 | return retval; |
107 | |||
104 | return count; | 108 | return count; |
105 | } | 109 | } |
106 | 110 | ||