aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/oprofile/oprof.c
diff options
context:
space:
mode:
authorRobert Richter <robert.richter@amd.com>2010-10-04 15:09:36 -0400
committerRobert Richter <robert.richter@amd.com>2010-10-12 11:25:06 -0400
commit7df01d96b295e400167e78061b81d4c91630b12d (patch)
tree52782cc1d78c24030d627f719cdaa29846c42efb /drivers/oprofile/oprof.c
parent0361e02342f60b64a7075755d5851ed4e6f98c7d (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/oprof.c')
-rw-r--r--drivers/oprofile/oprof.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
index b4a685719dba..f9bda64fcd1b 100644
--- a/drivers/oprofile/oprof.c
+++ b/drivers/oprofile/oprof.c
@@ -225,26 +225,17 @@ post_sync:
225 mutex_unlock(&start_mutex); 225 mutex_unlock(&start_mutex);
226} 226}
227 227
228int oprofile_set_backtrace(unsigned long val) 228int oprofile_set_ulong(unsigned long *addr, unsigned long val)
229{ 229{
230 int err = 0; 230 int err = -EBUSY;
231 231
232 mutex_lock(&start_mutex); 232 mutex_lock(&start_mutex);
233 233 if (!oprofile_started) {
234 if (oprofile_started) { 234 *addr = val;
235 err = -EBUSY; 235 err = 0;
236 goto out;
237 } 236 }
238
239 if (!oprofile_ops.backtrace) {
240 err = -EINVAL;
241 goto out;
242 }
243
244 oprofile_backtrace_depth = val;
245
246out:
247 mutex_unlock(&start_mutex); 237 mutex_unlock(&start_mutex);
238
248 return err; 239 return err;
249} 240}
250 241