Page MenuHomeFreeBSD

LinuxKPI: Implement kthread_worker related functions
ClosedPublic

Authored by wulf on Apr 24 2022, 11:42 PM.

Details

Summary

Kthread worker is a single thread workqueue which can be used in cases
where specific kthread association is necessary, for example, when it
should have RT priority or be assigned to certain cgroup.

This change implements Linux v4.9 interface which mostly hides kthread
internals from users thus allowing to use ordinary taskqueue(9) KPI.
As kthread worker prohibits enqueueing of already pending or canceling
tasks some minimal changes to taskqueue(9) were done.
taskqueue_enqueue_flags() was added to taskqueue KPI which accepts extra
parameter called flags which supports following values:

TQFLG_FAILIF_CANCELING - taskqueue_enqueue_flags() fails if task is in

canceling state returning ECANCELED to caller.

TQFLG_FAILIF_PENDING - taskqueue_enqueue_flags() fails if task is already

scheduled to execution. EEXIST is returned to caller in that case and
ta_pending counter value remains the same.

TBD: manpage update.

Required by: drm-kmod 5.10

Diff Detail

Repository
rG FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

wulf requested review of this revision.Apr 24 2022, 11:42 PM
sys/kern/subr_taskqueue.c
128

Please expand this macro before commit.

243

Maybe use __predict_false() here.

255

ditto

sys/sys/taskqueue.h
64

Name this TASKQUEUE_FAIL_IF_PENDING and TASKQUEUE_FAIL_IF_CANCELING

89

flags -> fail_flags ?

  • task_is_running() macro is expanded
  • flags renamed to TASKQUEUE_FAIL_IF_PENDING and TASKQUEUE_FAIL_IF_CANCELING
  • __predict_false() added to taskqueue_enqueue ifs
  • manpage
wulf marked 4 inline comments as done.Apr 25 2022, 8:37 PM

Looks good!

Update commit message and add manual pages changes.

This revision is now accepted and ready to land.Apr 26 2022, 6:44 AM
pauamma_gundo.com added inline comments.
share/man/man9/taskqueue.9
230
238
240
245
This revision now requires changes to proceed.Apr 27 2022, 1:48 AM
wulf marked 4 inline comments as done.Apr 27 2022, 9:11 PM

fix manpage according to @pauamma request

This revision is now accepted and ready to land.Apr 27 2022, 11:46 PM