trace_event_profile.c 844 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * trace event based perf counter profiling
  3. *
  4. * Copyright (C) 2009 Red Hat Inc, Peter Zijlstra <pzijlstr@redhat.com>
  5. *
  6. */
  7. #include <linux/module.h>
  8. #include "trace.h"
  9. int ftrace_profile_enable(int event_id)
  10. {
  11. struct ftrace_event_call *event;
  12. int ret = -EINVAL;
  13. mutex_lock(&event_mutex);
  14. list_for_each_entry(event, &ftrace_events, list) {
  15. if (event->id == event_id && event->profile_enable &&
  16. try_module_get(event->mod)) {
  17. ret = event->profile_enable(event);
  18. break;
  19. }
  20. }
  21. mutex_unlock(&event_mutex);
  22. return ret;
  23. }
  24. void ftrace_profile_disable(int event_id)
  25. {
  26. struct ftrace_event_call *event;
  27. mutex_lock(&event_mutex);
  28. list_for_each_entry(event, &ftrace_events, list) {
  29. if (event->id == event_id) {
  30. event->profile_disable(event);
  31. module_put(event->mod);
  32. break;
  33. }
  34. }
  35. mutex_unlock(&event_mutex);
  36. }