Page MenuHomeFreeBSD

linuxkpi: Factorize duplicated code in `linux_wait_event_common()` and `linux_schedule_timeout()`
AcceptedPublic

Authored by dumbbell on Sun, Apr 13, 10:07 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 25, 8:15 PM
Unknown Object (File)
Fri, Apr 25, 6:55 AM
Unknown Object (File)
Fri, Apr 25, 5:39 AM
Unknown Object (File)
Thu, Apr 17, 2:45 AM
Unknown Object (File)
Thu, Apr 17, 2:10 AM
Unknown Object (File)
Wed, Apr 16, 8:44 PM
Unknown Object (File)
Wed, Apr 16, 8:09 AM
Unknown Object (File)
Sun, Apr 13, 6:31 PM
Subscribers

Details

Reviewers
markj
Group Reviewers
linuxkpi
Summary

There are two other functions calling linux_add_to_sleepqueue(), but the logic is slightly different. Factorizing them would make the code any cleaner.

This is part of the update of DRM drivers to Linux 6.7. This is a follow-up to D48755.

Sponsored by: The FreeBSD Foundation

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

sys/compat/linuxkpi/common/src/linux_schedule.c
310

We can just pass 0 instead of the state here. linux_add_to_sleepqueue() only cares about whether the sleep is interruptible or not, i.e., the value is only 0 or TASK_INTERRUPTIBLE. I don't think that flag is ever set in task->state.

dumbbell added inline comments.
sys/compat/linuxkpi/common/src/linux_schedule.c
310

I think it is set. Here are two examples from the i915 driver:

prepare_to_wait(&ddat->waitq, &wait, TASK_INTERRUPTIBLE);
// ...
schedule();
prepare_to_wait(wq, &wait, TASK_UNINTERRUPTIBLE);
// ...
timeout = schedule_timeout(timeout);

prepare_to_wait() calls set_task_state() which sets task->state:
https://github.com/dumbbell/freebsd-src/blob/drm-related-linuxkpi-changes/sys/compat/linuxkpi/common/src/linux_schedule.c#L267

then both schedule() and schedule_timeout() call linux_schedule_timeout().

markj added inline comments.
sys/compat/linuxkpi/common/src/linux_schedule.c
310

Thank you, I didn't realize it worked that way.

This revision is now accepted and ready to land.Wed, Apr 16, 5:27 PM