OP-TEE / optee_os

Trusted side of the TEE
Other
1.51k stars 1.03k forks source link

TA performance #6883

Open shirinebadi opened 2 weeks ago

shirinebadi commented 2 weeks ago

Hi.

I want to get the CPU and Memory Usage of my TA. Using xtest --stats --ta, we can get the TA's heap usage. How about whole memory usage?

And is there a way to get the memory usage of CA?

And how about CPU usage of CA and TA? (reading top?)

Thanks.

shirinebadi commented 2 weeks ago

Also, has there been any updates on Qemuv8 Profiling?

jenswi-linaro commented 2 weeks ago

I want to get the CPU and Memory Usage of my TA. Using xtest --stats --ta, we can get the TA's heap usage. How about whole memory usage?

That's only reported on the (secure) console if a TA is aborted. To report this with the Stats PTA should be an interesting feature.

And is there a way to get the memory usage of CA?

Yes, with the usual Linux userspace tools.

And how about CPU usage of CA and TA? (reading top?)

A TA is scheduled on behalf of the calling client application so top is one option.

shirinebadi commented 2 weeks ago

Thank you for your prompt response. Sorry, I think I didn't follow, so is there a way to read the memory usage of TA? Reading VmSize or VmRSS of /proc/pid/status would report total memory usage of both CA and TA?

jenswi-linaro commented 2 weeks ago

Sorry, I think I didn't follow, so is there a way to read the memory usage of TA?

No, not at the moment.

Reading VmSize or VmRSS of /proc/pid/status would report total memory usage of both CA and TA?

That covers only the normal world usage.

shirinebadi commented 2 weeks ago

Thanks. But cpu usage returned by top is the accumulated usage of CA and TA, right?

jenswi-linaro commented 2 weeks ago

Thanks. But cpu usage returned by top is the accumulated usage of CA and TA, right?

Yes

shirinebadi commented 1 week ago

Thanks. Can you also help me with issue#2975. I'm generating error, but can't see any report on memory.

And also, all TEE_* are using core memory, right? How about secure storages?

jenswi-linaro commented 1 week ago

When a TA crashes you get logs like:

D/TC:1 0 abort_handler:560 [abort] abort in User mode (TA will panic)
E/TC:? 0 
E/TC:? 0 User mode undef-abort at address 0x4002bce8
E/TC:? 0  esr 0x02000000  ttbr0 0x400000e202020   ttbr1 0x00000000   cidr 0x0
E/TC:? 0  cpu #1          cpsr 0x60000100
E/TC:? 0  x0  0000000000000005 x1  0000000000000000
E/TC:? 0  x2  0000000000000000 x3  0000000000000000
E/TC:? 0  x4  000000000000000a x5  0000000000000000
E/TC:? 0  x6  0000000000000000 x7  0000000000000000
E/TC:? 0  x8  000000000000000a x9  0000000000000000
E/TC:? 0  x10 0000000000000000 x11 0000000000000000
E/TC:? 0  x12 0000000000000000 x13 000000004011f780
E/TC:? 0  x14 0000000000000000 x15 0000000000000000
E/TC:? 0  x16 000000000e14aec8 x17 00000000401299ec
E/TC:? 0  x18 0000000000000000 x19 0000000000000000
E/TC:? 0  x20 0000000000000000 x21 0000000000000000
E/TC:? 0  x22 0000000000000000 x23 0000000000000000
E/TC:? 0  x24 0000000000000000 x25 0000000000000000
E/TC:? 0  x26 0000000000000000 x27 0000000000000000
E/TC:? 0  x28 0000000000000000 x29 000000004011f5e0
E/TC:? 0  x30 000000004002bdfc elr 000000004002bce8
E/TC:? 0  sp_el0 000000004011f5e0
E/LD:  Status of TA 5b9e0e40-2636-11e1-ad9e-0002a5d5c51b
E/LD:   arch: aarch64
E/LD:  region  0: va 0x40001000 pa 0x0e34c000 size 0x002000 flags rw-s (ldelf)
E/LD:  region  1: va 0x40003000 pa 0x0e34e000 size 0x010000 flags r-xs (ldelf)
E/LD:  region  2: va 0x40013000 pa 0x0e35e000 size 0x001000 flags rw-s (ldelf)
E/LD:  region  3: va 0x40014000 pa 0x0e35f000 size 0x004000 flags rw-s (ldelf)
E/LD:  region  4: va 0x40018000 pa 0x0e363000 size 0x001000 flags r--s
E/LD:  region  5: va 0x40019000 pa 0x0e364000 size 0x020000 flags r-xs [0]
E/LD:  region  6: va 0x40039000 pa 0x0e384000 size 0x0e4000 flags rw-s [0]
E/LD:  region  7: va 0x4011d000 pa 0x0e468000 size 0x003000 flags rw-s (stack)
E/LD:  region  8: va 0x40120000 pa 0x0e46b000 size 0x031000 flags r-xs [1]
E/LD:  region  9: va 0x40151000 pa 0x0e49c000 size 0x006000 flags rw-s [1]
E/LD:  region 10: va 0x40157000 pa 0x7f933000 size 0x010000 flags rw-- (param)
E/LD:   [0] 5b9e0e40-2636-11e1-ad9e-0002a5d5c51b @ 0x40019000
E/LD:   [1] ffd2bded-ab7d-4988-95ee-e4962fff7154 @ 0x40120000
E/LD:  Call stack:
E/LD:   0x4002bce8
E/LD:   0x4002d18c
E/LD:   0x4012cc48
E/LD:   0x4012cd18
E/LD:   0x4002db04
D/TC:? 0 user_ta_enter:195 tee_user_ta_enter: TA panicked with code 0xdeadbeef

And also, all TEE_* are using core memory, right?

No, that's mostly TA memory.

How about secure storages?

We don't report that at all. Someone needs to implement it first.