gramine icon indicating copy to clipboard operation
gramine copied to clipboard

Unsupported system call timer_create

Open qijiax opened this issue 2 years ago • 12 comments

Description of the feature

I was trying to enable TDEngine(a time serious database) to Gramine libOS. It crashed while initializing the taosd. From the Gramine log, a system call "timer_create" is not supported. Is there any workaround for the timer_create? Will Gramine support this system call in future time?

[P1:T17:taosd] warning: Unsupported system call timer_create
[P1:T17:taosd] debug: memory fault at 0x00000004 (IP = 0x28700b814787)
[P1:T17:taosd] debug: killed by signal 11

Why Gramine should implement it?

To support more applications

qijiax avatar Dec 29 '22 05:12 qijiax

Indeed, TDEngine seems to require timer_create() syscall and may fail arbitrarily if the syscall is not implemented: https://github.com/taosdata/TDengine/blob/d290daa197b08564c7b1b587b3cde8cda96e70c1/source/os/src/osTimer.c#L111-L113

(The code quality is... dubious. The author knows that timer_create() may return an error, but simply ignores this fact.)

Is there any workaround for the timer_create? Will Gramine support this system call in future time?

There is no workaround from Gramine side. Ideally, TDEngine app would check that timer_create() is unsupported and would fall back to some other mechanism/syscall.

Gramine may support this syscall in the future, but we didn't prioritize adding support for this... So no promises.

dimakuv avatar Jan 02 '23 13:01 dimakuv

Do you know any syscall that can replace the timer_create? Maybe we can push on TDEngine side.

qijiax avatar Jan 03 '23 02:01 qijiax

@qijiax Gramine currently supports only classic alarm/timer syscalls:

These syscalls are far less powerful than timer_create() unfortunately. But if TDEngine doesn't require anything complicated from timers, then these two syscalls may be enough to implement the functionality.

If you want to dive deep into the supported timer syscalls in Gramine, check this file: https://github.com/gramineproject/gramine/blob/5c312f95d464a3ac69cce129e270838808f1ee31/libos/src/sys/libos_alarm.c

dimakuv avatar Jan 03 '23 08:01 dimakuv

Would be interested in implementing it based on a similar approach to settimer. Or is someone else already working on this?

ghost avatar Mar 09 '23 00:03 ghost

Thanks! I don't know anyone planning to work on it, but let's ping @dimakuv and @kailun-qin so they can check their teams.

mkow avatar Mar 09 '23 01:03 mkow

My team has no ongoing effort around this currently. It's great to have @BraunPhilipp working on it! I'll let @dimakuv double check on the plan/priority.

kailun-qin avatar Mar 09 '23 02:03 kailun-qin

I'm not aware of anyone working on timer_create(), at least from the Intel side.

If possible, you may also want to take a look at timerfd_create() syscall -- maybe it will be fairly trivial to implement it as well?

dimakuv avatar Mar 09 '23 11:03 dimakuv

@BraunPhilipp If you haven't seen it yet, I recently created a comprehensive technical document on Gramine implemented and unimplemented features. It is still a pending PR, but you can read the current version here: https://github.com/gramineproject/gramine/blob/dimakuv/add-gramine-features-doc/Documentation/devel/features.md

dimakuv avatar Mar 09 '23 16:03 dimakuv

Thanks that sounds great! Will start working on it tomorrow.

ghost avatar Mar 11 '23 21:03 ghost

Based on my current understanding adding timer support will require timer_create, timer_settime and timer_delete to be implemented.

ghost avatar Mar 18 '23 23:03 ghost

@dimakuv @mkow moved further discussion here https://github.com/gramineproject/gramine/discussions/1242

ghost avatar Mar 19 '23 00:03 ghost

@BraunPhilipp Replied there.

dimakuv avatar Mar 20 '23 08:03 dimakuv