This change adds a new vm counter, v_user_wire_count, which counts the
number of user-wired virtual pages. v_wire_count continues to count
user-wired physical pages. The motivation is to implement a system
limit on user-wired pages, replacing the existing limit applied to
Like per-process RLIMIT_MEMLOCK, accounting is done at the VM map layer,
so pages wired into multiple vm_map_entries are counted multiple times.
I initially tried to provide accounting at the physical page layer, but
this turns out to be quite complicated because there is no reliable
method of counting the number of user-wired mappings of a given physical
page. In particular, there are several mechanisms that cause a
user-wired page to be unmapped:
- truncation of the backing vnode or shm object
Thus, when unwiring a physical page, it is not really possible to
determine whether other user wirings exist without some additional
information in the vm_page structure. As a step toward merging
hold_count and wire_count, I therefore followed kib's suggestion of
simply counting virtual pages.
With this change the vm_page_max_wired limit is renamed to
vm_page_max_user_wired and the check is moved into vm_map_wire(). This
ensures that the limit is applied to all user wirings; previously it was
not applied to, e.g., mlockall(2).