mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +00:00
Fix a few uses of kern_yield() in the TTM and the LinuxKPI.
kern_yield(0) effectively causes the calling thread to be rescheduled immediately since it resets the thread's priority to the highest possible value. This can cause livelocks when the pattern "while (!trylock()) kern_yield(0);" is used since the thread holding the lock may linger on the runqueue for the CPU on which the looping thread is running. MFC after: 1 week
This commit is contained in:
parent
3bd485f968
commit
02fb845bbf
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=318478
@ -435,7 +435,7 @@ linux_cdev_pager_populate(vm_object_t vm_obj, vm_pindex_t pidx, int fault_type,
|
||||
err = vmap->vm_ops->fault(vmap, &vmf);
|
||||
|
||||
while (vmap->vm_pfn_count == 0 && err == VM_FAULT_NOPAGE) {
|
||||
kern_yield(0);
|
||||
kern_yield(PRI_USER);
|
||||
err = vmap->vm_ops->fault(vmap, &vmf);
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ ttm_bo_vm_fault(vm_object_t vm_obj, vm_ooffset_t offset,
|
||||
ret = ttm_bo_reserve(bo, false, false, false, 0);
|
||||
if (unlikely(ret != 0)) {
|
||||
if (ret == -EBUSY) {
|
||||
kern_yield(0);
|
||||
kern_yield(PRI_USER);
|
||||
goto reserve;
|
||||
}
|
||||
}
|
||||
@ -139,7 +139,7 @@ ttm_bo_vm_fault(vm_object_t vm_obj, vm_ooffset_t offset,
|
||||
case -EBUSY:
|
||||
case -ERESTARTSYS:
|
||||
case -EINTR:
|
||||
kern_yield(0);
|
||||
kern_yield(PRI_USER);
|
||||
goto reserve;
|
||||
default:
|
||||
retval = VM_PAGER_ERROR;
|
||||
|
Loading…
Reference in New Issue
Block a user