pstat_getlocality.2 (2010 09)
p
pstat_getlocality(2) pstat_getlocality(2)
Notes
These functions only return the wide (64 bit) versions of their associated structures. In order for narrow
(32 bit) applications to use these interfaces, the flag
-D_PSTAT64 must be used at compile time. These
interfaces are available for narrow applications written in standard C and extended ANSI, and for all
wide applications.
A discrepancy between the amount of interleave memory reported by
pstat_getlocality()
and the
parstatus command is possible. pstat_getlocality()
reports how HP-UX is actually using
memory. The
parstatus command reports the platform firmware view of memory. Interleaved memory
that has just one cell or blade contributing memory is treated as local memory by HP-UX, where as the
platform firmware considers it interleaved memory. The platform’s firmware has an algorithm to deter-
mine how much interleaved memory can be configured when there are different amounts of memory on
cells or blades, e.g. one cell has 16G and another cell has 24G. The platform firmware cannot always
configure memory according to the user’s specification when cells/blades have unequal memory. So,
pstat_getlocality()
can show the user how much interleaved memory HP-UX can actually use
from the platform firmware allocation of interleaved memory.
RETURN VALUE
pstat_getlocality()
and pstat_getproclocality()
return the following values:
n Successful completion. n is the number of instances returned in buf .
-1 Failure. errno is set to indicate the error.
ERRORS
Upon failure,
errno is set to one of the following values.
[EFAULT] buf points to an invalid address.
[EINVAL] elemsize is less than or equal to zero, or elemsize is larger than the size of the asso-
ciated data structure.
[EINVAL] index is negative.
[ESRCH] for pstat_getproclocality(), the requested pid could not be found.
EXAMPLES
/*
* This program returns system-wide and per-process memory
* locality information. To compile the 32-bit version,
* use -D_PSTAT64. The 64-bit version does not need any
* special compiler flags.
*/
#include <unistd.h>
#include <stdio.h>
#include <sys/param.h>
#include <sys/pstat.h>
#include <sys/errno.h>
#define BURST ((size_t)3)
#define STRSZ 80
unsigned long pgsize;
void pid_locinfo ( pid_t pid );
void sys_locinfo ( void );
void pages_to_str ( uint64_t pages, char *str );
void
usage ( int argc, char **argv )
{
fprintf ( stderr, "Usage: %s [-p pid]\n", argv[0] );
fprintf ( stderr, "This program prints out per locality " );
fprintf ( stderr, "memory usage.\nIf ’pid’ is supplied, " );
fprintf ( stderr, "information on that process is\n" );
HP-UX 11i Version 3: September 2010 − 3 − Hewlett-Packard Company 3