* vm_page_grab_sleep * * Sleep for busy according to VM_ALLOC_ parameters. Returns true * if the caller should retry and false otherwise. * * If the object is locked on entry the object will be unlocked with * false returns and still locked but possibly having been dropped * with true returns. */
| 4372 | * with true returns. |
| 4373 | */ |
| 4374 | static bool |
| 4375 | vm_page_grab_sleep(vm_object_t object, vm_page_t m, vm_pindex_t pindex, |
| 4376 | const char *wmesg, int allocflags, bool locked) |
| 4377 | { |
| 4378 | |
| 4379 | if ((allocflags & VM_ALLOC_NOWAIT) != 0) |
| 4380 | return (false); |
| 4381 | |
| 4382 | /* |
| 4383 | * Reference the page before unlocking and sleeping so that |
| 4384 | * the page daemon is less likely to reclaim it. |
| 4385 | */ |
| 4386 | if (locked && (allocflags & VM_ALLOC_NOCREAT) == 0) |
| 4387 | vm_page_reference(m); |
| 4388 | |
| 4389 | if (_vm_page_busy_sleep(object, m, pindex, wmesg, allocflags, locked) && |
| 4390 | locked) |
| 4391 | VM_OBJECT_WLOCK(object); |
| 4392 | if ((allocflags & VM_ALLOC_WAITFAIL) != 0) |
| 4393 | return (false); |
| 4394 | |
| 4395 | return (true); |
| 4396 | } |
| 4397 | |
| 4398 | /* |
| 4399 | * Assert that the grab flags are valid. |
no test coverage detected