Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)
5246 Discussões

intel vtune profile sgx application fail

maxdd
Principiante
3.732 Visualizações

This is a follow up question of "intel vtune to profile sgx application".

https://community.intel.com/t5/Intel-Software-Guard-Extensions/intel-vtune-to-profile-sgx-application/m-p/1344450/emcs_t/S2h8ZW1haWx8dG9waWNfc3Vic2NyaXB0aW9ufEtYODZVRU9FVFkzNFJEfDEzNDQ0NTB8U1VCU0NSSVBUSU9OU3xoSw#M5069

 

My real program is complicated and I have to use attaching to a process to profile. There is no way that I can run my program directly from VTune.

I find that starting the application from VTune directly would give a different result than attaching  VTune to a process.

 

I modify the SampleEnclave example a little bit.

I add the following code to Enclave.cpp.

void func1() {
    printf("in func1\n");
    for (int i = 0; i < 1000000000; i++) {}
}

void func2() {
    printf("in func2\n");
    for (int i = 0; i < 1000000000; i++) {}
}

void enc_loop() {
    printf("in the loop\n");

    func1();
    func2();
}

I add the following code to App.cpp. I get the pid and attach the VTune to the program, then I enter a character to let the enclave program continue to run.

printf("Enter a character to start, %d\n", (int)syscall(SYS_gettid));
getchar();

enc_loop(global_eid);

 

If I directly run the application from VTune, I would get the following result

Top Hotspots
Function             Module             Precise Clockticks
-------------------  -----------------  ------------------
func1                enclave.signed.so      13,236,680,000
func2                enclave.signed.so      13,210,000,000
mutex_spin_on_owner  vmlinux                   150,400,000
do_ocall             enclave.signed.so         115,160,000
sgx_spin_lock        enclave.signed.so         104,420,000
[Others]             N/A                       337,860,000

 

If I attaching  VTune to the process, I would get the following result. The func1 and func2 are not shown in the profile result.

Top Hotspots
Function                    Module                    Precise Clockticks
--------------------------  ------------------------  ------------------
__morestack                 libsgx_urts.so.1.1.103.3          14,380,000
[Outside any known module]  [Unknown]                          4,820,000
unmap_page_range            vmlinux                              540,000
find_get_entries            vmlinux                              500,000
free_pcppages_bulk          vmlinux                              300,000
[Others]                    N/A                                4,920,000

 

 

0 Kudos
10 Respostas
Sahira_Intel
Moderador
3.703 Visualizações

Hi,

This is actually a VTune error. I will move this thread to the correct team.


Sincerely,

Sahira


DiyaN_Intel
Moderador
3.683 Visualizações

Hi, 


 Thank you for posting in Intel communities.


Could you please share the following details -

  1. OS and hardware details.
  2. VTune version.
  3. The exact steps and commands you used.


Regards,

Diya


maxdd
Principiante
3.664 Visualizações

hardware: Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz

OS: Ubuntu 18.04.2 LTS (Bionic Beaver)

Vtune: Intel(R) oneAPI VTune(TM) Profiler 2021.9.0 (build 621210) Command Line Tool

command 1: sudo /opt/intel/oneapi/vtune/latest/bin64/vtune -collect sgx-hotspots -knob sampling-interval=.01 ./app

command 2: sudo ./vtune -collect sgx-hotspots -knob sampling-interval=0.01 -target-pid 8692

I use the SampleEnclave example provided by Intel and make some modifications. I also attach the file after modifications.

The 'Enclave.edl.cpp' should be 'Enclave.edl'. For some reason, I can't upload '.edl' file, so I just rename it.

DiyaN_Intel
Moderador
3.652 Visualizações

Hi , 

 

 Thank you for sharing the details.

 We are getting error while creating the executable file from our end because we don't have the header files mentioned in the code.

 Please find the below screenshot.

 

DiyaN_Intel_3-1660719735573.png

 

 Could you please share your .exe file so that we can check from our end.

 

Regards, 

Diya

  

 

maxdd
Principiante
3.637 Visualizações

I upload the whole project code. Please rename it to 'SampleEnclave.tar.gz'.

maxdd
Principiante
3.633 Visualizações

I upload the whole project code.

DiyaN_Intel
Moderador
3.508 Visualizações

Hi, 


Thank you for sharing your details. We are able to reproduce your issue. We are working on this internally. 


Regards, 

Diya


Andrey_I_Intel
Funcionário
3.410 Visualizações

Hi!

VTune dev here. Seeing how you have [Outside any known module] in your attach case, it may be that VTune could collect the samples from the enclave, but had trouble identifying the actual module these belong to.

It may not be apparent from the documentation, but in order for this to work the two conditions must be fulfilled:

  1. SGX SDK has to proactively report the enclave data to VTune, and it does so only when sgx_create_enclave* method is invoked with SGX_DEBUG_FLAG argument and is built with SGX_DEBUG or SGX_PRERELEASE makeflags, for security reasons.
  2. As a consequence of the above, VTune has to receive reports about the enclaves during the collection phase. It sets up the needed environment for the target application automatically when you choose to profile in launch mode, but to enable the reporting in attach mode you will have to prepare the environment for your application manually before launching it. Please refer to this article in the user manual on how to do this (ITT API is used for enclave reporting): https://www.intel.com/content/www/us/en/develop/documentation/vtune-help/top/api-support/instrumentation-and-tracing-technology-apis/basic-usage-and-configuration/attaching-itt-apis-to-a-launched-application.html

Please double check if the above is in place in your profiling environment.

 

BR,

Andrey

DiyaN_Intel
Moderador
3.339 Visualizações

Hi,

 

Good day to you .

 

We have not heard back from you . Is your issue resolved with the above solution?

 

If this resolves your issue, make sure to accept this as a solution. This would help others with similar issue. Thank you!

 

Regards,

Diya

 

DiyaN_Intel
Moderador
3.121 Visualizações

Hi,

 

Good day to you.

 

We assume that your issue is resolved.

 

If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.

 

Thanks and Regards,

Diya Nandy

 

Responder