git: 6c25e63c0694 - stable/13 - linuxkpi: Add cond_resched_lock
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 27 Apr 2022 15:16:18 UTC
The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=6c25e63c0694482c65e97ddadfd54016d103ef31 commit 6c25e63c0694482c65e97ddadfd54016d103ef31 Author: Emmanuel Vadot <manu@FreeBSD.org> AuthorDate: 2022-03-21 10:14:05 +0000 Commit: Emmanuel Vadot <manu@FreeBSD.org> CommitDate: 2022-04-27 16:34:47 +0000 linuxkpi: Add cond_resched_lock If we need to resched it takes the lock, resched, release the lock and returns 1, otherwise simply returns 0. Needed by drm v5.9 MFC after: 1 month Reviewed by: hselasky Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D34620 (cherry picked from commit 9b8016548ef61e2c42271c7dce35d0322540d2f1) --- sys/compat/linuxkpi/common/include/linux/sched.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/sched.h b/sys/compat/linuxkpi/common/include/linux/sched.h index d003d12ec89e..4ad95446301f 100644 --- a/sys/compat/linuxkpi/common/include/linux/sched.h +++ b/sys/compat/linuxkpi/common/include/linux/sched.h @@ -45,6 +45,7 @@ #include <linux/pid.h> #include <linux/slab.h> #include <linux/string.h> +#include <linux/spinlock.h> #include <linux/time.h> #include <asm/atomic.h> @@ -126,6 +127,18 @@ put_task_struct(struct task_struct *task) #define need_resched() (curthread->td_flags & TDF_NEEDRESCHED) +static inline int +cond_resched_lock(spinlock_t *lock) +{ + + if (need_resched() == 0) + return (0); + spin_lock(lock); + cond_resched(); + spin_unlock(lock); + return (1); +} + bool linux_signal_pending(struct task_struct *task); bool linux_fatal_signal_pending(struct task_struct *task); bool linux_signal_pending_state(long state, struct task_struct *task);