ftrace.c 930 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. {
  18. struct ftrace_graph_ent trace;
  19. unsigned long return_hooker = (unsigned long)&return_to_handler;
  20. if (unlikely(atomic_read(&current->tracing_graph_pause)))
  21. return;
  22. if (ftrace_push_return_trace(*parent, self_addr, &trace.depth) == -EBUSY)
  23. return;
  24. trace.func = self_addr;
  25. /* Only trace if the calling function expects to */
  26. if (!ftrace_graph_entry(&trace)) {
  27. current->curr_ret_stack--;
  28. return;
  29. }
  30. /* all is well in the world ! hijack RETS ... */
  31. *parent = return_hooker;
  32. }
  33. #endif