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

Multi-threads in pta #7195

Open
hikrisyy opened this issue Dec 23, 2024 · 3 comments
Open

Multi-threads in pta #7195

hikrisyy opened this issue Dec 23, 2024 · 3 comments

Comments

@hikrisyy
Copy link

hikrisyy commented Dec 23, 2024

Hello

I hava some questiones about multi-threads in pta.

  1. If op-tee runs on a hardware platform with 4 CPU cores, whether the PTA can run on different CPU cores in parallel when two REE threads invoke one PTA at a same time?
  2. If op-tee runs on a hardware platform with one CPU core, when two REE threads invoke one PTA at a same time, how to handle in PTA? The scheduler is in tee or ree?
@ivila
Copy link

ivila commented Dec 24, 2024

  1. If op-tee runs on a hardware platform with 4 CPU cores, whether the PTA can run on different CPU cores in parallel when two REE threads invoke one PTA at a same time?

I think all the current PTAs in optee-os defined SINGLE_INSTANCE | MULTIPLE_SESSION | KEEP_ALIVE (check this link)
So, they can invoke the PTA at the same time.
Check this for what those properties means: optee.readthedocs.io-properties

  1. If op-tee runs on a hardware platform with one CPU core, when two REE threads invoke one PTA at a same time, how to handle in PTA? The scheduler is in tee or ree?
  1. If a PTA defines TA_FLAG_CONCURRENT, the requests would be handle concurrently (check this commit for detail), for example, pta hwrng defines it so you can call it concurrently.
  2. If a PTA doesn't define TA_FLAG_CONCURRENT, the requests would be handle sequentially (however, you can still make them run concurrently by CFG_CONCURRENT_SINGLE_INSTANCE_TA=y when compiling optee_os, check this commit for detail)

And linux kernel do the schedule job of REE, there is no scheduling in TEE.

For more about scheduling, you may check:

  1. optee.readthedocs.io-trusted-thread-scheduling
  2. Questions about TA concurrency #5983

@sunnybird
Copy link

sunnybird commented Dec 25, 2024

Hello,
I did some research on this issue.

the TA can run on different CPU cores , depends REE scheduler.
but , two REE threads invoke the TA not in parallel. this call will execute one by one .

when thread 1 is doing invoke , the thread 2 will wait until thread 1 finish .

releated code :
https://github.com/OP-TEE/optee_os/blob/master/core/tee/entry_std.c#L431
https://github.com/OP-TEE/optee_os/blob/master/core/kernel/tee_ta_manager.c#L261

@gagachang
Copy link
Contributor

when thread 1 is doing invoke , the thread 2 will wait until thread 1 finish .

Maybe you need to open two sessions, session 1 for thread 1 and session 2 for thread 2 ?

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

No branches or pull requests

4 participants