Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

memalloc_attr(3) [osf1 man page]

memalloc_attr(3)					     Library Functions Manual						  memalloc_attr(3)

NAME
memalloc_attr - Query the memory allocation policy and attributes (libnuma library) SYNOPSIS
#include <numa.h> int memalloc_attr( vm_offset_t va, memalloc_attr_t *attr ); PARAMETERS
The user virtual address for which the memory allocation policy is requested. Points to a buffer to receive the memory allocation policy and attributes for the page containing the specified virtual address. DESCRIPTION
The memalloc_attr() function returns the current memory allocation policy and associated attributes in the buffer pointed to by attr for the address specified by va. If radset information about the memory allocation policy is desired, a radset must be allocated through the radsetcreate() function, and the mattr_radset element of the attr argument must point to that radset. Otherwise, a 0 must be specified for the mattr_radset. EXAMPLE
#include <numa.h> main() { vm_offset_t va; memalloc_attr_t attr; int id; int flags = SET_CURSOR_CONSUME; rad_cursor_t cursor = SET_CURSOR_INIT; radsetcreate(&attr.mattr_radset); va = (vm_offset_t)&attr; /* no policy in effect - return zeroes */ if (memalloc_attr(va, &attr) == -1) { perror("memalloc_attr"); radsetdestroy(&attr.mattr_radset); return 0; } printf("mattr_policy = 0x%lx ", attr.mattr_policy); printf("mattr_rad = 0x%lx ", attr.mattr_rad); printf("mattr_stride = 0x%lx ", attr.mattr_stride); printf("mattr_distance = 0x%lx ", attr.mattr_distance); printf("mattr_pagesz = 0x%lx ", attr.mattr_pagesz); /* set policy */ attr.mattr_policy = MPOL_DIRECTED; attr.mattr_rad = 0; if (nmadvise((void *)va, sizeof(memalloc_attr_t), 0, &attr) == -1) { perror("nmadvise"); radsetdestroy(&attr.mattr_radset); return 0; } if (memalloc_attr(va, &attr) == -1) { perror("memalloc_attr"); radsetdestroy(&attr.mattr_radset); return 0; } printf("mattr_policy = 0x%lx ", attr.mattr_policy); printf("mattr_rad = 0x%lx ", attr.mattr_rad); printf("mattr_stride = 0x%lx ", attr.mattr_stride); printf("mattr_distance = 0x%lx ", attr.mattr_distance); printf("mattr_pagesz = 0x%lx ", attr.mattr_pagesz); /* enumerate the mattr_radset */ printf(" Enumerating radset members: "); while ((id = rad_foreach(attr.mattr_radset, flags, &cursor)) != RAD_NONE) { if ((id % 8) == 0) printf(" "); printf("%3d, ", id); } printf(" "); } RETURN VALUES
Success. In this case, the function stores the requested memory allocation policy and attributes in the buffer pointed to by attr. If no memory allocation policy has been set for the specified virtual address (e.g., madvise() or nmadvise()) not called for that address), a zeroed attr structure is returned. Failure. In this case, the function sets errno to indicate the error. ERRORS
If the memalloc_attr() function fails, it sets errno to one of the following values: The address pointed to by va, attr, or mattr_radset is invalid. The mattr_radset element of the attr argument points to an invalid RAD set, possibly one that has not been created by a rad- setcreate() call. SEE ALSO
Functions: numa_intro(3) Files: numa_types(4) memalloc_attr(3)

Check Out this Related Man Page

nmmap(3)						     Library Functions Manual							  nmmap(3)

NAME
nmmap - Maps an open file into a process's address space (libnuma library). SYNOPSIS
#include <numa.h> #include <sys/numa.h> void *nmmap( void *addr, size_t len, int prot, ulong_t flags, int filedes, off_t off, memalloc_attr_t *attr ); PARAMETERS
The parameters for nmmap() are the same as for mmap() with the addition of the following NUMA-specific parameter: Points to a memory allo- cation policy and attributes structure that will be assigned to the memory object created by the mapping. See mmap(2) for descriptions of the remaining parameters. DESCRIPTION
If the attr argument is NULL, the nmmap() function behaves identically to the mmap() function. If the attr argument is non-NULL, it points to a memory allocation policy and attributes structure that specifies where the pages for the new memory object should be allocated. If, in the structure pointed to by attr, the value of mattr_policy is MPOL_DIRECTED and the value of mattr_rad is RAD_NONE, the mattr_rad- set value specifies the set of Resource Affinity Domains (RADs) from which the system will choose the RAD where the pages of the new memory object will be allocated. If mattr_radset is set to NULL, the system will select a RAD for the memory object from among all the RADs in the caller's partition. In this case, the memory object's overflow set will also be the set of all RADs in the caller's partition. RETURN VALUES
Success. A value returned to addr indicates success and is the starting address of the region (truncated to the nearest page boundary) where the new memory object has been mapped. Failure. In this case, errno is set to indicate the error. ERRORS
If the nmmap() function fails, it sets errno to one of the values described in the ERRORS section of mmap(2), or to one of the following values for the reason specified: A non-NULL attr argument points to an invalid address. The structure pointed to by the attr argument con- tains an invalid memory allocation policy, an invalid RAD, or an invalid RAD set. SEE ALSO
Functions: mmap(2), nmadvise(3), numa_intro(3) Files: numa_types(4) nmmap(3)
Man Page