We are going to use kthread_worker more widely and delayed workswill be pretty useful.

The implementation is inspired by workqueues. It uses a timer toqueue the work after the requested delay. If the delay is zero,the work is queued immediately.

In compare with workqueues, each work is associated with a singleworker (kthread). Therefore the implementation could be much easier.In particular, we use the worker->lock to synchronized all theoperations with the work. And we do not use any flags variable.

On the other hand, we add a pointer[*] to the timer into the structkthread_work. The kthread worker need to know if the work is usedand if it could clear work->worker. For this, it needs to knowwhether the timer is active or not.

Finally, the timer callback knows only about the struct work.It is better be paranoid and try to get the worker->lock carefully.The try_lock_thread_work() function will be later useful also whencanceling the work.

[*] I considered also adding the entire struct timer_list into struct kthread_work. But it would increase the size from 40 to 120 bytes on x86_64 with an often unused stuff.

Another alternative was to add a flags variable. But this would add an extra code to synchronize it with the state of the timer.