lsds / sgx-lkl

SGX-LKL Library OS for running Linux applications inside of Intel SGX enclaves
MIT License
257 stars 89 forks source link

Benchmarking file system operations in the enclave; caching ? #841

Open AsmX0r opened 3 years ago

AsmX0r commented 3 years ago

Dear SGX-LKL developers,

I would to benchmark some file intensive operations which may take from a couple of milliseconds to a few seconds. I'm aware that SGX-LKL protects the disk I/O calls using dm-crypt and dm-integrity (I currently use those when building the disk image).

When I measure some disk I/O in my program hosted in SGX-LKL (hawdware mode), should I assume the environment persists the changes on the disk image similarly to a regular operating system (e.g., when calling fsync), or does SGX-LKL adds additional caching layers that can delay such operations and therefore, wrongly increases the throughput of my benchmarking (typically faster)? If so, do you provide a convenient way to disable such caching mechanism ?

Many thanks for your work!

prp commented 3 years ago

Hi @AsmX0r, since LKL is the Linux kernel, it will maintain a regular page cache inside the enclave, which will buffer disk I/O operations and flush them to the disk device in the same way as Linux does. You can use direct I/O under Linux to bypass the page cache.