0

PFB the pseudo code:

struct work_struct my_work;

my_wq = alloc_workqueue();

INIT_WORK(&my_work, worker_func);

void worker_func() {

  if (condition)
      queue_work(my_wq, my_work);

}

Is this allowed?

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 01 '21 at 17:14

1 Answers1

0

Yes, it is perfectly allowed to re-submit a work while its function is executed.

It is also allowed to de-allocate the work structure which function is executed. Workqueue implementation is ready for that (kernel/workqueue.c):

It is permissible to free the struct work_struct from inside the function that is called from it, this we need to take into account for lockdep too...

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153