Hi Vipin. On Wed, Feb 16, 2022 at 09:37:45AM -0800, Vipin Sharma <vipinsh@xxxxxxxxxx> wrote: > On Thu, Jan 20, 2022 at 7:05 AM Michal Koutný <mkoutny@xxxxxxxx> wrote: > > Have I missed an obstacle? Aha... [ > I used few other combination where I put kernel_wait() call after > put_task_struct(k) call. > > Every time during the module exit, kernel was crashing like: Thanks for trying this out. ] > Do you have any suggestions what might be the right way to use this API? ...it has occured to me now -- the KVM kthread is not a child of the wanna-wait user task. So the kernel_wait() silently errs with -ECHILD and task_struct is released too early and that (probably) brings about the crash. I'm sorry for not realizing that initially. (Generally, any kthread_create'd task would be affected by this. I guess the KVM worker threads can't be forked from the kvm_create_vm() callers? (It could prevent the double migration to and from caller's cgroup though.)) Michal