vm_release Kernel Service

Note: The vm_release subroutine is not supported for use on large pages.

Purpose

Releases virtual memory resources for the specified address range.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include  <sys/vmuser.h>

int  vm_release ( vaddr,  nbytes)
caddr_t vaddr;
int nbytes;

Description

The vm_release kernel service releases pages that intersect the specified address range from the vaddr parameter to the vaddr parameter plus the number of bytes specified by the nbytes parameter. The value in the nbytes parameter must be nonnegative and the caller must have write access to the pages specified by the address range.

Each page that intersects the byte range is logically reset to 0, and any page frame is discarded. A page frame in I/O state is marked for discard at I/O completion. That is, the page frame is placed on the free list when the I/O operation completes.

Note: All of the pages to be released must be in the same virtual memory object.

Parameters

Item Description
vaddr Specifies the address of the first byte in the address range to be released.
nbytes Specifies the number of bytes to be released.

Execution Environment

The vm_release kernel service can be called from the process environment only.

Return Values

Item Description
0 Indicates successful completion.
EACCES Indicates that the caller does not have write access to the specified pages.
EINVAL Indicates one of the following errors:
  • The specified region is not mapped.
  • The specified region is an I/O region.
  • The length specified in the nbytes parameter is negative.
  • The specified address range crosses a virtual memory object boundary.
  • One or more large pages lie in the target page range.