Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ftrace: Add 32 bit apps [and function execution time support -- discarded] #3080

Merged
merged 1 commit into from
Jul 1, 2019

Conversation

b49020
Copy link
Contributor

@b49020 b49020 commented Jun 12, 2019

This patch-set adds ftrace support for 32 bit apps as well as function execution time. So after this patch-set function graph would look something like:

              | __ta_entry() {
              |  __utee_entry() {
     1.168 us |   ta_header_get_session();
     1.392 us |   __utee_to_param();
              |   TA_InvokeCommandEntryPoint() {
              |    ta_entry_params_access_rights() {
    31.392 us |     TEE_CheckMemoryAccessRights();
    28.176 us |     TEE_CheckMemoryAccessRights();
   173.984 us |    }
   202.448 us |   }
     1.152 us |   __utee_from_param();
              |   ta_header_save_params() {
      .656 us |    memset();
     5.488 us |   }
   275.824 us |  }
   281.424 us | }

Looking forward to your valuable feedback/comments.

Regards,
Sumit

@jforissier
Copy link
Contributor

That is quite cool 👍

I'd like to make sure I understand correctly the meaning of the time values. From what I can tell, each value is placed at a function exit point and indicates the elapsed time between the entry and the exit of that particular function.
For instance, in the example above:

  • ta_header_get_session() took 1.168 us
  • TA_InvokeCommandEntryPoint() took 202.448 us
  • __ta_entry() took 281.424 us

Is this correct?

I'm not sure the time values can be called timestamps, they are actually deltas (elapsed time).

@b49020
Copy link
Contributor Author

b49020 commented Jun 12, 2019

Is this correct?

Yes.

I'm not sure the time values can be called timestamps, they are actually deltas (elapsed time).

Agree. Timestamps are basically used to calculate these deltas. So should I use deltas or elapsed time in commit messages? Or something like function execution time?

@jbech-linaro
Copy link
Contributor

I'd like to make sure I understand correctly the meaning of the time values. From what I can tell, each value is placed at a function exit point and indicates the elapsed time between the entry and the exit of that particular function.
For instance, in the example above:

  • ta_header_get_session() took 1.168 us
  • TA_InvokeCommandEntryPoint() took 202.448 us
  • __ta_entry() took 281.424 us

Is this correct?

I'm not sure the time values can be called timestamps, they are actually deltas (elapsed time).

I guess it mimics the function tracer in Linux and they simply say "measure of a function’s time execution". So, change commit message to "... enable function runtime statistics" or something like that?

@jforissier
Copy link
Contributor

"Execution time" sounds good (to me at least!)

@b49020
Copy link
Contributor Author

b49020 commented Jun 12, 2019

I guess it mimics the function tracer in Linux and they simply say "measure of a function’s time execution".

Yeah I have tried to keep this implementation on similar lines as Linux function tracer.

@b49020
Copy link
Contributor Author

b49020 commented Jun 12, 2019

"Execution time" sounds good (to me at least!)

Ok then, will use it instead.

@b49020 b49020 changed the title ftrace: Add 32 bit apps and timestamps support ftrace: Add 32 bit apps and function execution time support Jun 12, 2019
@b49020
Copy link
Contributor Author

b49020 commented Jun 12, 2019

Updated.

Copy link
Contributor

@jforissier jforissier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing "ftrace: Enable support for 32 bit apps".

core/arch/arm/arm.mk Outdated Show resolved Hide resolved
lib/libutils/isoc/arch/arm/sub.mk Show resolved Hide resolved
lib/libutils/isoc/include/setjmp.h Show resolved Hide resolved
ta/arch/arm/user_ta_header.c Show resolved Hide resolved
@b49020
Copy link
Contributor Author

b49020 commented Jun 17, 2019

Addressed comments.

Copy link
Contributor

@jforissier jforissier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • For commits "ftrace: Enable support for 32 bit apps" and "core: ftrace: Enable user-space access to counter regs":
    Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
  • Why is "ftrace: Add 32 bit apps and function execution time support" not squashed with "libutee: ftrace: Add function execution time support" (and libutee: removed from the subject)? Without that, the first commit does not work as expected it seems.

core/arch/arm/kernel/ftrace.c Outdated Show resolved Hide resolved
@@ -57,6 +57,16 @@ FUNC __ftrace_return, :
ldmia sp!, {r0-r3}
bx lr
END_FUNC __ftrace_return

FUNC read_cntpct, :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is arguably not the best place to have these functions, because they could be useful outside of ftrace. So they could have their own CFG_ and be moved somewhere else.
Not a big deal however, could be done later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are already generated and defined in <out-dir>/core/include/generated/arm32_sysreg.h and as assembly macros in arm32_sysreg.S

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jenswi-linaro excellent 👍

Copy link
Contributor Author

@b49020 b49020 Jun 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jenswi-linaro These seems to used for core build only and not exported for TA library builds. I get following error when I tried to use them:

  AS      out/arm/ta_arm32-lib/libutee/arch/arm/utee_mcount_a32.o
lib/libutee/arch/arm/utee_mcount_a32.S:7:10: fatal error: generated/arm32_sysreg.S: No such file or directory
 #include <generated/arm32_sysreg.S>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
mk/compile.mk:147: recipe for target 'out/arm/ta_arm32-lib/libutee/arch/arm/utee_mcount_a32.o' failed
make[1]: *** [out/arm/ta_arm32-lib/libutee/arch/arm/utee_mcount_a32.o] Error 1
make[1]: Leaving directory '/home/sumit/build/optee/optee_os'
common.mk:396: recipe for target 'optee-os-common' failed
make: *** [optee-os-common] Error 2

Also, similar is the case with arm64.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, perhaps we can generate a subset with the registers which can be accessed from EL0 into <out>/include/generated/arm32_user_sysreg.h. One way could be to copy the relevant lines from core/arch/arm/kernel/arm32_sysreg.txt.

For arm64 it's a bit easier due to the convenient assembly mnemonic, there we can just hand code all the EL0 accessible registers in lib/libutee/include/arm64_user_sysreg.h.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let me try to create a sysreg subset for user access.

@b49020
Copy link
Contributor Author

b49020 commented Jun 17, 2019

Why is "ftrace: Add 32 bit apps and function execution time support" not squashed with "libutee: ftrace: Add function execution time support" (and libutee: removed from the subject)? Without that, the first commit does not work as expected it seems.

I guess you meant core: ftrace: exclude TA suspend time from timestamps instead of ftrace: Add 32 bit apps and function execution time support.

And yes they could be squashed together. The only reason I avoided squash was to ease the review process. So is it fine if I squash after review is complete?

@jforissier
Copy link
Contributor

I guess you meant [...]

Correct, bad copy/paste sorry :-/

core/arch/arm/arm.mk Outdated Show resolved Hide resolved
By default 32 bit trusted applications are compiled in thumb mode but
thumb mode doesn't support function graph tracing due to missing frame
pointer support required to trace function call chain. So rather compile
trusted applications in ARM mode in case function tracing is enabled.

Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
@b49020
Copy link
Contributor Author

b49020 commented Jul 1, 2019

@jforissier @jbech-linaro @jenswi-linaro Currently I have just rebased "ftrace: Enable support for 32 bit apps" on top of master after ldelf PR merge. Is it fine with you to incorporate this patch only for OP-TEE 3.6.0 release? I think it completes ftrace feature.

Regarding timestamp support, I am rebasing stuff for which I can create a separate PR.

@jbech-linaro
Copy link
Contributor

Is it fine with you to incorporate this patch only for OP-TEE 3.6.0 release?

OK for me.

@jforissier
Copy link
Contributor

@b49020 fine with me, too. I will merge this patch now and let's proceed with the timestamp stuff in another PR.

@jforissier jforissier merged commit c96d709 into OP-TEE:master Jul 1, 2019
@jforissier jforissier changed the title ftrace: Add 32 bit apps and function execution time support ftrace: Add 32 bit apps [and function execution time support -- discarded] Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants