ftrace.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * ftrace graph code
  3. *
  4. * Copyright (C) 2009 Analog Devices Inc.
  5. * Licensed under the GPL-2 or later.
  6. */
  7. #include <linux/ftrace.h>
  8. #include <linux/kernel.h>
  9. #include <linux/sched.h>
  10. #include <asm/atomic.h>
  11. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  12. /*
  13. * Hook the return address and push it in the stack of return addrs
  14. * in current thread info.
  15. */
  16. void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
  17. unsigned long frame_pointer)
  18. {
  19. struct ftrace_graph_ent trace;
  20. unsigned long return_hooker = (unsigned long)&return_to_handler;
  21. if (unlikely(atomic_read(&current->tracing_graph_pause)))
  22. return;
  23. if (ftrace_push_return_trace(*parent, self_addr, &trace.depth,
  24. frame_pointer) == -EBUSY)
  25. return;
  26. trace.func = self_addr;
  27. /* Only trace if the calling function expects to */
  28. if (!ftrace_graph_entry(&trace)) {
  29. current->curr_ret_stack--;
  30. return;
  31. }
  32. /* all is well in the world ! hijack RETS ... */
  33. *parent = return_hooker;
  34. }
  35. #endif