task_work.h 979 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_TASK_WORK_H
  3. #define _LINUX_TASK_WORK_H
  4. #include <linux/list.h>
  5. #include <linux/sched.h>
  6. typedef void (*task_work_func_t)(struct callback_head *);
  7. static inline void
  8. init_task_work(struct callback_head *twork, task_work_func_t func)
  9. {
  10. twork->func = func;
  11. }
  12. enum task_work_notify_mode {
  13. TWA_NONE,
  14. TWA_RESUME,
  15. TWA_SIGNAL,
  16. TWA_SIGNAL_NO_IPI,
  17. };
  18. static inline bool task_work_pending(struct task_struct *task)
  19. {
  20. return READ_ONCE(task->task_works);
  21. }
  22. int task_work_add(struct task_struct *task, struct callback_head *twork,
  23. enum task_work_notify_mode mode);
  24. struct callback_head *task_work_cancel_match(struct task_struct *task,
  25. bool (*match)(struct callback_head *, void *data), void *data);
  26. struct callback_head *task_work_cancel(struct task_struct *, task_work_func_t);
  27. void task_work_run(void);
  28. static inline void exit_task_work(struct task_struct *task)
  29. {
  30. task_work_run();
  31. }
  32. #endif /* _LINUX_TASK_WORK_H */