---
name: "vm_page_busy"
section: "9freebsd"
platform: "linux"
package: "freebsd-manpages"
version: "12.2-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/vm_page_assert_sbusied/9freebsd"
---

# vm\_page\_busy(9freebsd)

protect page identity changes and page content references

Part of [vm\_page\_assert\_sbusied(9freebsd)](/vm_page_assert_sbusied/9freebsd.md).

## NAME

**vm\_page\_busied**, **vm\_page\_busy\_downgrade**, **vm\_page\_busy\_sleep**, **vm\_page\_sbusied**, **vm\_page\_sbusy**, **vm\_page\_sleep\_if\_busy**, **vm\_page\_sunbusy**, **vm\_page\_trysbusy**, **vm\_page\_tryxbusy**, **vm\_page\_xbusied**, **vm\_page\_xbusy**, **vm\_page\_xunbusy**, **vm\_page\_assert\_sbusied**, **vm\_page\_assert\_unbusied**, **vm\_page\_assert\_xbusied** – protect page identity changes and page content references

## SYNOPSIS

**#include \<sys/param.h\>**

**#include \<vm/vm.h\>**

**#include \<vm/vm\_page.h\>**

*int*\

**vm\_page\_busied**(*vm\_page\_t m*);

*void*\

**vm\_page\_busy\_downgrade**(*vm\_page\_t m*);

*void*\

**vm\_page\_busy\_sleep**(*vm\_page\_t m*, *const char \*msg*);

*int*\

**vm\_page\_sbusied**(*vm\_page\_t m*);

*void*\

**vm\_page\_sbusy**(*vm\_page\_t m*);

*int*\

**vm\_page\_sleep\_if\_busy**(*vm\_page\_t m*, *const char \*msg*);

*void*\

**vm\_page\_sunbusy**(*vm\_page\_t m*);

*int*\

**vm\_page\_trysbusy**(*vm\_page\_t m*);

*int*\

**vm\_page\_tryxbusy**(*vm\_page\_t m*);

*int*\

**vm\_page\_xbusied**(*vm\_page\_t m*);

*void*\

**vm\_page\_xbusy**(*vm\_page\_t m*);

*void*\

**vm\_page\_xunbusy**(*vm\_page\_t m*);

**options INVARIANTS** **options INVARIANT\_SUPPORT**

*void*\

**vm\_page\_assert\_sbusied**(*vm\_page\_t m*);

*void*\

**vm\_page\_assert\_unbusied**(*vm\_page\_t m*);

*void*\

**vm\_page\_assert\_xbusied**(*vm\_page\_t m*);

## DESCRIPTION

Page identity is usually protected by higher level locks like vm\_object locks and vm page locks. However, sometimes it is not possible to hold such locks for the time necessary to complete the identity change. In such case the page can be exclusively busied by a thread which needs to own the identity for a certain amount of time.

In other situations, threads do not need to change the identity of the page but they want to prevent other threads from changing the identity themselves. For example, when a thread wants to access or update page contents without a lock held the page is shared busied.

Before busying a page the vm\_object lock must be held. The same rule applies when a page is unbusied. This makes the vm\_object lock a real busy interlock.

The **vm\_page\_busied**() function returns non-zero if the current thread busied *m* in either exclusive or shared mode. Returns zero otherwise.

The **vm\_page\_busy\_downgrade**() function must be used to downgrade *m* from an exclusive busy state to a shared busy state.

The **vm\_page\_busy\_sleep**() function puts the invoking thread to sleep using the appropriate waitchannels for the busy mechanism. The parameter *msg* is a string describing the sleep condition for userland tools.

The **vm\_page\_busied**() function returns non-zero if the current thread busied *m* in shared mode. Returns zero otherwise.

The **vm\_page\_sbusy**() function shared busies *m*.

The **vm\_page\_sleep\_if\_busy**() function puts the invoking thread to sleep, using the appropriate waitchannels for the busy mechanism, if *m*. is busied in either exclusive or shared mode. If the invoking thread slept a non-zero value is returned, otherwise 0 is returned. The parameter *msg* is a string describing the sleep condition for userland tools.

The **vm\_page\_sunbusy**() function shared unbusies *m*.

The **vm\_page\_trysbusy**() attempts to shared busy *m*. If the operation cannot immediately succeed **vm\_page\_trysbusy**() returns 0, otherwise a non-zero value is returned.

The **vm\_page\_tryxbusy**() attempts to exclusive busy *m*. If the operation cannot immediately succeed **vm\_page\_tryxbusy**() returns 0, otherwise a non-zero value is returned.

The **vm\_page\_xbusied**() function returns non-zero if the current thread busied *m* in exclusive mode. Returns zero otherwise.

The **vm\_page\_xbusy**() function exclusive busies *m*.

The **vm\_page\_xunbusy**() function exclusive unbusies *m*. Assertions on the busy state allow kernels compiled with **options INVARIANTS** and **options INVARIANT\_SUPPORT** to panic if they are not respected.

The **vm\_page\_assert\_sbusied**() function panics if *m* is not shared busied.

The **vm\_page\_assert\_unbusied**() function panics if *m* is not unbusied.

The **vm\_page\_assert\_xbusied**() function panics if *m* is not exclusive busied.

## SEE ALSO

[vm\_page\_aflag(9)](/vm_page_aflag/9.md), [vm\_page\_alloc(9)](/vm_page_alloc/9.md), [vm\_page\_deactivate(9)](/vm_page_deactivate/9.md), [vm\_page\_free(9)](/vm_page_free/9.md), [vm\_page\_grab(9)](/vm_page_grab/9.md), [vm\_page\_insert(9)](/vm_page_insert/9.md), [vm\_page\_lookup(9)](/vm_page_lookup/9.md), [vm\_page\_rename(9)](/vm_page_rename/9.md), [VOP\_GETPAGES(9)](/VOP_GETPAGES/9.md)
