ftrace.c 964 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 2013 Linaro Limited
  4. * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
  5. * Copyright (C) 2017 Andes Technology Corporation
  6. */
  7. #include <linux/ftrace.h>
  8. /*
  9. * Most of this file is copied from arm64.
  10. */
  11. void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
  12. unsigned long frame_pointer)
  13. {
  14. unsigned long return_hooker = (unsigned long)&return_to_handler;
  15. unsigned long old;
  16. struct ftrace_graph_ent trace;
  17. int err;
  18. if (unlikely(atomic_read(&current->tracing_graph_pause)))
  19. return;
  20. /*
  21. * We don't suffer access faults, so no extra fault-recovery assembly
  22. * is needed here.
  23. */
  24. old = *parent;
  25. trace.func = self_addr;
  26. trace.depth = current->curr_ret_stack + 1;
  27. if (!ftrace_graph_entry(&trace))
  28. return;
  29. err = ftrace_push_return_trace(old, self_addr, &trace.depth,
  30. frame_pointer, NULL);
  31. if (err == -EBUSY)
  32. return;
  33. *parent = return_hooker;
  34. }