/* This works OK both with and without CONFIG_PREEMPT. We do strange low-level operations here to prevent schedule() from being called twice (once via spin_unlock(), once by hand).  */
int __cond_resched_lock(spinlock_t *lock)
/* This works OK both with and without CONFIG_PREEMPT. We do strange low-level operations here to prevent schedule() from being called twice (once via spin_unlock(), once by hand).  */
int __cond_resched_lock(spinlock_t *lock)
{
	int resched = should_resched();
	int ret = 0;
	lockdep_assert_held(lock);
	if (spin_needbreak(lock) || resched) {
		spin_unlock(lock);
		if (resched)
			__cond_resched();
		else
			cpu_relax();
		ret = 1;
		spin_lock(lock);
	}
	return ret;
}