diff --git a/proc/diskstats.c b/proc/diskstats.c index f1017fcd..f4f86826 100644 --- a/proc/diskstats.c +++ b/proc/diskstats.c @@ -248,13 +248,13 @@ static struct { { RS(DISKSTATS_DELTA_IO_TIME), QS(s_int) }, { RS(DISKSTATS_DELTA_IO_WTIME), QS(s_int) }, - // dummy entry corresponding to PROCPS_DISKSTATS_logical_end ... + // dummy entry corresponding to DISKSTATS_logical_end ... { NULL, NULL } }; /* please note, * this enum MUST be 1 greater than the highest value of any enum */ -enum diskstats_item PROCPS_DISKSTATS_logical_end = PROCPS_DISKSTATS_DELTA_IO_WTIME + 1; +enum diskstats_item DISKSTATS_logical_end = DISKSTATS_DELTA_IO_WTIME + 1; #undef setNAME #undef srtNAME @@ -313,15 +313,15 @@ static void node_classify ( checks /sys/block and changes a device found there into a disk. if /sys/block cannot have the directory read, all devices are then treated as disks. */ - this->type = PROCPS_DISKSTATS_TYPE_PARTITION; + this->type = DISKSTATS_TYPE_PARTITION; if (!(dirp = opendir(SYSBLOCK_DIR))) { - this->type = PROCPS_DISKSTATS_TYPE_DISK; + this->type = DISKSTATS_TYPE_DISK; return; } while((dent = readdir(dirp))) { if (strcmp(this->name, dent->d_name) == 0) { - this->type = PROCPS_DISKSTATS_TYPE_DISK; + this->type = DISKSTATS_TYPE_DISK; break; } } @@ -415,7 +415,7 @@ static inline void assign_results ( for (;;) { enum diskstats_item item = this->item; - if (item >= PROCPS_DISKSTATS_logical_end) + if (item >= DISKSTATS_logical_end) break; Item_table[item].setsfunc(this, node); ++this; @@ -428,9 +428,9 @@ static inline void cleanup_stack ( struct diskstats_result *this) { for (;;) { - if (this->item >= PROCPS_DISKSTATS_logical_end) + if (this->item >= DISKSTATS_logical_end) break; - if (this->item > PROCPS_DISKSTATS_noop) + if (this->item > DISKSTATS_noop) this->result.ul_int = 0; ++this; } @@ -507,18 +507,18 @@ static inline int items_check_failed ( * offer any sort of warning like the following: * * warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'enum diskstats_item *' - * my_stack = procps_diskstats_select(info, PROCPS_DISKSTATS_noop, num); + * my_stack = procps_diskstats_select(info, DISKSTATS_noop, num); * ^~~~~~~~~~~~~~~~ */ if (numitems < 1 - || (void *)items < (void *)(unsigned long)(2 * PROCPS_DISKSTATS_logical_end)) + || (void *)items < (void *)(unsigned long)(2 * DISKSTATS_logical_end)) return -1; for (i = 0; i < numitems; i++) { // a diskstats_item is currently unsigned, but we'll protect our future if (items[i] < 0) return -1; - if (items[i] >= PROCPS_DISKSTATS_logical_end) + if (items[i] >= DISKSTATS_logical_end) return -1; } @@ -711,11 +711,11 @@ static int stacks_reconfig_maybe ( if so, gotta' redo all of our stacks stuff ... */ if (this->numitems != numitems + 1 || memcmp(this->items, items, sizeof(enum diskstats_item) * numitems)) { - // allow for our PROCPS_DISKSTATS_logical_end + // allow for our DISKSTATS_logical_end if (!(this->items = realloc(this->items, sizeof(enum diskstats_item) * (numitems + 1)))) return -ENOMEM; memcpy(this->items, items, sizeof(enum diskstats_item) * numitems); - this->items[numitems] = PROCPS_DISKSTATS_logical_end; + this->items[numitems] = DISKSTATS_logical_end; this->numitems = numitems + 1; if (this->extents) extents_free_all(this); @@ -831,7 +831,7 @@ PROCPS_EXPORT struct diskstats_result *procps_diskstats_get ( if (info == NULL) return NULL; - if (item < 0 || item >= PROCPS_DISKSTATS_logical_end) + if (item < 0 || item >= DISKSTATS_logical_end) return NULL; /* we will NOT read the diskstat file with every call - rather, we'll offer @@ -844,7 +844,7 @@ PROCPS_EXPORT struct diskstats_result *procps_diskstats_get ( info->get_this.item = item; // with 'get', we must NOT honor the usual 'noop' guarantee -// if (item > PROCPS_DISKSTATS_noop) +// if (item > DISKSTATS_noop) info->get_this.result.ul_int = 0; if (!(node = node_get(info, name))) @@ -950,9 +950,9 @@ PROCPS_EXPORT struct diskstats_stack **procps_diskstats_sort ( return NULL; // a diskstats_item is currently unsigned, but we'll protect our future - if (sortitem < 0 || sortitem >= PROCPS_DISKSTATS_logical_end) + if (sortitem < 0 || sortitem >= DISKSTATS_logical_end) return NULL; - if (order != PROCPS_DISKSTATS_SORT_ASCEND && order != PROCPS_DISKSTATS_SORT_DESCEND) + if (order != DISKSTATS_SORT_ASCEND && order != DISKSTATS_SORT_DESCEND) return NULL; if (numstacked < 2) return stacks; @@ -963,7 +963,7 @@ PROCPS_EXPORT struct diskstats_stack **procps_diskstats_sort ( if (p->item == sortitem) break; ++offset; - if (p->item == PROCPS_DISKSTATS_logical_end) + if (p->item == DISKSTATS_logical_end) return NULL; ++p; } diff --git a/proc/diskstats.h b/proc/diskstats.h index 8ca66fd9..55e67636 100644 --- a/proc/diskstats.h +++ b/proc/diskstats.h @@ -1,5 +1,5 @@ /* - * diskstats - Disk statistics - part of procps + * libprocps - Library to read proc filesystem * * Copyright (c) 2003 Fabian Frederick * Copyright (C) 2003 Albert Cahalan @@ -28,42 +28,42 @@ __BEGIN_DECLS enum diskstats_item { - PROCPS_DISKSTATS_noop, // ( never altered ) - PROCPS_DISKSTATS_extra, // ( reset to zero ) + DISKSTATS_noop, // ( never altered ) + DISKSTATS_extra, // ( reset to zero ) - PROCPS_DISKSTATS_NAME, // str - PROCPS_DISKSTATS_TYPE, // s_int - PROCPS_DISKSTATS_MAJOR, // s_int - PROCPS_DISKSTATS_MINOR, // s_int + DISKSTATS_NAME, // str + DISKSTATS_TYPE, // s_int + DISKSTATS_MAJOR, // s_int + DISKSTATS_MINOR, // s_int - PROCPS_DISKSTATS_READS, // ul_int - PROCPS_DISKSTATS_READS_MERGED, // ul_int - PROCPS_DISKSTATS_READ_SECTORS, // ul_int - PROCPS_DISKSTATS_READ_TIME, // ul_int - PROCPS_DISKSTATS_WRITES, // ul_int - PROCPS_DISKSTATS_WRITES_MERGED, // ul_int - PROCPS_DISKSTATS_WRITE_SECTORS, // ul_int - PROCPS_DISKSTATS_WRITE_TIME, // ul_int - PROCPS_DISKSTATS_IO_TIME, // ul_int - PROCPS_DISKSTATS_IO_WTIME, // ul_int + DISKSTATS_READS, // ul_int + DISKSTATS_READS_MERGED, // ul_int + DISKSTATS_READ_SECTORS, // ul_int + DISKSTATS_READ_TIME, // ul_int + DISKSTATS_WRITES, // ul_int + DISKSTATS_WRITES_MERGED, // ul_int + DISKSTATS_WRITE_SECTORS, // ul_int + DISKSTATS_WRITE_TIME, // ul_int + DISKSTATS_IO_TIME, // ul_int + DISKSTATS_IO_WTIME, // ul_int - PROCPS_DISKSTATS_IO_INPROGRESS, // s_int + DISKSTATS_IO_INPROGRESS, // s_int - PROCPS_DISKSTATS_DELTA_READS, // s_int - PROCPS_DISKSTATS_DELTA_READS_MERGED, // s_int - PROCPS_DISKSTATS_DELTA_READ_SECTORS, // s_int - PROCPS_DISKSTATS_DELTA_READ_TIME, // s_int - PROCPS_DISKSTATS_DELTA_WRITES, // s_int - PROCPS_DISKSTATS_DELTA_WRITES_MERGED, // s_int - PROCPS_DISKSTATS_DELTA_WRITE_SECTORS, // s_int - PROCPS_DISKSTATS_DELTA_WRITE_TIME, // s_int - PROCPS_DISKSTATS_DELTA_IO_TIME, // s_int - PROCPS_DISKSTATS_DELTA_IO_WTIME // s_int + DISKSTATS_DELTA_READS, // s_int + DISKSTATS_DELTA_READS_MERGED, // s_int + DISKSTATS_DELTA_READ_SECTORS, // s_int + DISKSTATS_DELTA_READ_TIME, // s_int + DISKSTATS_DELTA_WRITES, // s_int + DISKSTATS_DELTA_WRITES_MERGED, // s_int + DISKSTATS_DELTA_WRITE_SECTORS, // s_int + DISKSTATS_DELTA_WRITE_TIME, // s_int + DISKSTATS_DELTA_IO_TIME, // s_int + DISKSTATS_DELTA_IO_WTIME // s_int }; enum diskstats_sort_order { - PROCPS_DISKSTATS_SORT_ASCEND = +1, - PROCPS_DISKSTATS_SORT_DESCEND = -1 + DISKSTATS_SORT_ASCEND = +1, + DISKSTATS_SORT_DESCEND = -1 }; @@ -86,13 +86,13 @@ struct diskstats_reap { }; -#define PROCPS_DISKSTATS_TYPE_DISK -11111 -#define PROCPS_DISKSTATS_TYPE_PARTITION -22222 +#define DISKSTATS_TYPE_DISK -11111 +#define DISKSTATS_TYPE_PARTITION -22222 -#define PROCPS_DISKSTATS_GET( info, actual_enum, type ) \ +#define DISKSTATS_GET( info, actual_enum, type ) \ procps_diskstats_get( info, actual_enum ) -> result . type -#define PROCPS_DISKSTATS_VAL( relative_enum, type, stack) \ +#define DISKSTATS_VAL( relative_enum, type, stack) \ stack -> head [ relative_enum ] . result . type diff --git a/proc/meminfo.c b/proc/meminfo.c index e61e0ef6..d0153cdb 100644 --- a/proc/meminfo.c +++ b/proc/meminfo.c @@ -339,13 +339,13 @@ static struct { { RS(SWAP_TOTAL) }, { RS(SWAP_USED) }, - // dummy entry corresponding to PROCPS_MEMINFO_logical_end ... + // dummy entry corresponding to MEMINFO_logical_end ... { NULL, } }; /* please note, * this enum MUST be 1 greater than the highest value of any enum */ -enum meminfo_item PROCPS_MEMINFO_logical_end = PROCPS_MEMINFO_SWAP_USED + 1; +enum meminfo_item MEMINFO_logical_end = MEMINFO_SWAP_USED + 1; #undef setNAME #undef RS @@ -361,7 +361,7 @@ static inline void assign_results ( for (;;) { enum meminfo_item item = this->item; - if (item >= PROCPS_MEMINFO_logical_end) + if (item >= MEMINFO_logical_end) break; Item_table[item].setsfunc(this, hist); ++this; @@ -374,9 +374,9 @@ static inline void cleanup_stack ( struct meminfo_result *this) { for (;;) { - if (this->item >= PROCPS_MEMINFO_logical_end) + if (this->item >= MEMINFO_logical_end) break; - if (this->item > PROCPS_MEMINFO_noop) + if (this->item > MEMINFO_noop) this->result.ul_int = 0; ++this; } @@ -437,18 +437,18 @@ static inline int items_check_failed ( * offer any sort of warning like the following: * * warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'enum meminfo_item *' - * my_stack = procps_meminfo_select(info, PROCPS_MEMINFO_noop, num); + * my_stack = procps_meminfo_select(info, MEMINFO_noop, num); * ^~~~~~~~~~~~~~~~ */ if (numitems < 1 - || (void *)items < (void *)(unsigned long)(2 * PROCPS_MEMINFO_logical_end)) + || (void *)items < (void *)(unsigned long)(2 * MEMINFO_logical_end)) return -1; for (i = 0; i < numitems; i++) { // a meminfo_item is currently unsigned, but we'll protect our future if (items[i] < 0) return -1; - if (items[i] >= PROCPS_MEMINFO_logical_end) + if (items[i] >= MEMINFO_logical_end) return -1; } @@ -780,7 +780,7 @@ PROCPS_EXPORT struct meminfo_result *procps_meminfo_get ( if (info == NULL) return NULL; - if (item < 0 || item >= PROCPS_MEMINFO_logical_end) + if (item < 0 || item >= MEMINFO_logical_end) return NULL; /* we will NOT read the meminfo file with every call - rather, we'll offer @@ -794,7 +794,7 @@ PROCPS_EXPORT struct meminfo_result *procps_meminfo_get ( info->get_this.item = item; // with 'get', we must NOT honor the usual 'noop' guarantee -// if (item > PROCPS_MEMINFO_noop) +// if (item > MEMINFO_noop) info->get_this.result.ul_int = 0; Item_table[item].setsfunc(&info->get_this, &info->hist); @@ -823,11 +823,11 @@ PROCPS_EXPORT struct meminfo_stack *procps_meminfo_select ( if so, gotta' redo all of our stacks stuff ... */ if (info->numitems != numitems + 1 || memcmp(info->items, items, sizeof(enum meminfo_item) * numitems)) { - // allow for our PROCPS_MEMINFO_logical_end + // allow for our MEMINFO_logical_end if (!(info->items = realloc(info->items, sizeof(enum meminfo_item) * (numitems + 1)))) return NULL; memcpy(info->items, items, sizeof(enum meminfo_item) * numitems); - info->items[numitems] = PROCPS_MEMINFO_logical_end; + info->items[numitems] = MEMINFO_logical_end; info->numitems = numitems + 1; if (info->extents) extents_free_all(info); diff --git a/proc/meminfo.h b/proc/meminfo.h index 02bb53c9..cc24afa7 100644 --- a/proc/meminfo.h +++ b/proc/meminfo.h @@ -19,106 +19,108 @@ #ifndef PROC_MEMINFO_H #define PROC_MEMINFO_H +#include + __BEGIN_DECLS enum meminfo_item { - PROCPS_MEMINFO_noop, // ( never altered ) - PROCPS_MEMINFO_extra, // ( reset to zero ) + MEMINFO_noop, // ( never altered ) + MEMINFO_extra, // ( reset to zero ) /* note: all of the following values are exressed as KiB */ - PROCPS_MEMINFO_MEM_ACTIVE, // ul_int - PROCPS_MEMINFO_MEM_ACTIVE_ANON, // ul_int - PROCPS_MEMINFO_MEM_ACTIVE_FILE, // ul_int - PROCPS_MEMINFO_MEM_ANON, // ul_int - PROCPS_MEMINFO_MEM_AVAILABLE, // ul_int - PROCPS_MEMINFO_MEM_BOUNCE, // ul_int - PROCPS_MEMINFO_MEM_BUFFERS, // ul_int - PROCPS_MEMINFO_MEM_CACHED, // ul_int - PROCPS_MEMINFO_MEM_COMMIT_LIMIT, // ul_int - PROCPS_MEMINFO_MEM_COMMITTED_AS, // ul_int - PROCPS_MEMINFO_MEM_HARD_CORRUPTED, // ul_int - PROCPS_MEMINFO_MEM_DIRTY, // ul_int - PROCPS_MEMINFO_MEM_FREE, // ul_int - PROCPS_MEMINFO_MEM_HUGE_ANON, // ul_int - PROCPS_MEMINFO_MEM_HUGE_FREE, // ul_int - PROCPS_MEMINFO_MEM_HUGE_RSVD, // ul_int - PROCPS_MEMINFO_MEM_HUGE_SIZE, // ul_int - PROCPS_MEMINFO_MEM_HUGE_SURPLUS, // ul_int - PROCPS_MEMINFO_MEM_HUGE_TOTAL, // ul_int - PROCPS_MEMINFO_MEM_INACTIVE, // ul_int - PROCPS_MEMINFO_MEM_INACTIVE_ANON, // ul_int - PROCPS_MEMINFO_MEM_INACTIVE_FILE, // ul_int - PROCPS_MEMINFO_MEM_KERNEL_STACK, // ul_int - PROCPS_MEMINFO_MEM_LOCKED, // ul_int - PROCPS_MEMINFO_MEM_MAPPED, // ul_int - PROCPS_MEMINFO_MEM_NFS_UNSTABLE, // ul_int - PROCPS_MEMINFO_MEM_PAGE_TABLES, // ul_int - PROCPS_MEMINFO_MEM_SHARED, // ul_int - PROCPS_MEMINFO_MEM_SLAB, // ul_int - PROCPS_MEMINFO_MEM_SLAB_RECLAIM, // ul_int - PROCPS_MEMINFO_MEM_SLAB_UNRECLAIM, // ul_int - PROCPS_MEMINFO_MEM_TOTAL, // ul_int - PROCPS_MEMINFO_MEM_UNEVICTABLE, // ul_int - PROCPS_MEMINFO_MEM_USED, // ul_int - PROCPS_MEMINFO_MEM_VM_ALLOC_CHUNK, // ul_int - PROCPS_MEMINFO_MEM_VM_ALLOC_TOTAL, // ul_int - PROCPS_MEMINFO_MEM_VM_ALLOC_USED, // ul_int - PROCPS_MEMINFO_MEM_WRITEBACK, // ul_int - PROCPS_MEMINFO_MEM_WRITEBACK_TMP, // ul_int + MEMINFO_MEM_ACTIVE, // ul_int + MEMINFO_MEM_ACTIVE_ANON, // ul_int + MEMINFO_MEM_ACTIVE_FILE, // ul_int + MEMINFO_MEM_ANON, // ul_int + MEMINFO_MEM_AVAILABLE, // ul_int + MEMINFO_MEM_BOUNCE, // ul_int + MEMINFO_MEM_BUFFERS, // ul_int + MEMINFO_MEM_CACHED, // ul_int + MEMINFO_MEM_COMMIT_LIMIT, // ul_int + MEMINFO_MEM_COMMITTED_AS, // ul_int + MEMINFO_MEM_HARD_CORRUPTED, // ul_int + MEMINFO_MEM_DIRTY, // ul_int + MEMINFO_MEM_FREE, // ul_int + MEMINFO_MEM_HUGE_ANON, // ul_int + MEMINFO_MEM_HUGE_FREE, // ul_int + MEMINFO_MEM_HUGE_RSVD, // ul_int + MEMINFO_MEM_HUGE_SIZE, // ul_int + MEMINFO_MEM_HUGE_SURPLUS, // ul_int + MEMINFO_MEM_HUGE_TOTAL, // ul_int + MEMINFO_MEM_INACTIVE, // ul_int + MEMINFO_MEM_INACTIVE_ANON, // ul_int + MEMINFO_MEM_INACTIVE_FILE, // ul_int + MEMINFO_MEM_KERNEL_STACK, // ul_int + MEMINFO_MEM_LOCKED, // ul_int + MEMINFO_MEM_MAPPED, // ul_int + MEMINFO_MEM_NFS_UNSTABLE, // ul_int + MEMINFO_MEM_PAGE_TABLES, // ul_int + MEMINFO_MEM_SHARED, // ul_int + MEMINFO_MEM_SLAB, // ul_int + MEMINFO_MEM_SLAB_RECLAIM, // ul_int + MEMINFO_MEM_SLAB_UNRECLAIM, // ul_int + MEMINFO_MEM_TOTAL, // ul_int + MEMINFO_MEM_UNEVICTABLE, // ul_int + MEMINFO_MEM_USED, // ul_int + MEMINFO_MEM_VM_ALLOC_CHUNK, // ul_int + MEMINFO_MEM_VM_ALLOC_TOTAL, // ul_int + MEMINFO_MEM_VM_ALLOC_USED, // ul_int + MEMINFO_MEM_WRITEBACK, // ul_int + MEMINFO_MEM_WRITEBACK_TMP, // ul_int - PROCPS_MEMINFO_DELTA_ACTIVE, // s_int - PROCPS_MEMINFO_DELTA_ACTIVE_ANON, // s_int - PROCPS_MEMINFO_DELTA_ACTIVE_FILE, // s_int - PROCPS_MEMINFO_DELTA_ANON, // s_int - PROCPS_MEMINFO_DELTA_AVAILABLE, // s_int - PROCPS_MEMINFO_DELTA_BOUNCE, // s_int - PROCPS_MEMINFO_DELTA_BUFFERS, // s_int - PROCPS_MEMINFO_DELTA_CACHED, // s_int - PROCPS_MEMINFO_DELTA_COMMIT_LIMIT, // s_int - PROCPS_MEMINFO_DELTA_COMMITTED_AS, // s_int - PROCPS_MEMINFO_DELTA_HARD_CORRUPTED, // s_int - PROCPS_MEMINFO_DELTA_DIRTY, // s_int - PROCPS_MEMINFO_DELTA_FREE, // s_int - PROCPS_MEMINFO_DELTA_HUGE_ANON, // s_int - PROCPS_MEMINFO_DELTA_HUGE_FREE, // s_int - PROCPS_MEMINFO_DELTA_HUGE_RSVD, // s_int - PROCPS_MEMINFO_DELTA_HUGE_SIZE, // s_int - PROCPS_MEMINFO_DELTA_HUGE_SURPLUS, // s_int - PROCPS_MEMINFO_DELTA_HUGE_TOTAL, // s_int - PROCPS_MEMINFO_DELTA_INACTIVE, // s_int - PROCPS_MEMINFO_DELTA_INACTIVE_ANON, // s_int - PROCPS_MEMINFO_DELTA_INACTIVE_FILE, // s_int - PROCPS_MEMINFO_DELTA_KERNEL_STACK, // s_int - PROCPS_MEMINFO_DELTA_LOCKED, // s_int - PROCPS_MEMINFO_DELTA_MAPPED, // s_int - PROCPS_MEMINFO_DELTA_NFS_UNSTABLE, // s_int - PROCPS_MEMINFO_DELTA_PAGE_TABLES, // s_int - PROCPS_MEMINFO_DELTA_SHARED, // s_int - PROCPS_MEMINFO_DELTA_SLAB, // s_int - PROCPS_MEMINFO_DELTA_SLAB_RECLAIM, // s_int - PROCPS_MEMINFO_DELTA_SLAB_UNRECLAIM, // s_int - PROCPS_MEMINFO_DELTA_TOTAL, // s_int - PROCPS_MEMINFO_DELTA_UNEVICTABLE, // s_int - PROCPS_MEMINFO_DELTA_USED, // s_int - PROCPS_MEMINFO_DELTA_VM_ALLOC_CHUNK, // s_int - PROCPS_MEMINFO_DELTA_VM_ALLOC_TOTAL, // s_int - PROCPS_MEMINFO_DELTA_VM_ALLOC_USED, // s_int - PROCPS_MEMINFO_DELTA_WRITEBACK, // s_int - PROCPS_MEMINFO_DELTA_WRITEBACK_TMP, // s_int + MEMINFO_DELTA_ACTIVE, // s_int + MEMINFO_DELTA_ACTIVE_ANON, // s_int + MEMINFO_DELTA_ACTIVE_FILE, // s_int + MEMINFO_DELTA_ANON, // s_int + MEMINFO_DELTA_AVAILABLE, // s_int + MEMINFO_DELTA_BOUNCE, // s_int + MEMINFO_DELTA_BUFFERS, // s_int + MEMINFO_DELTA_CACHED, // s_int + MEMINFO_DELTA_COMMIT_LIMIT, // s_int + MEMINFO_DELTA_COMMITTED_AS, // s_int + MEMINFO_DELTA_HARD_CORRUPTED, // s_int + MEMINFO_DELTA_DIRTY, // s_int + MEMINFO_DELTA_FREE, // s_int + MEMINFO_DELTA_HUGE_ANON, // s_int + MEMINFO_DELTA_HUGE_FREE, // s_int + MEMINFO_DELTA_HUGE_RSVD, // s_int + MEMINFO_DELTA_HUGE_SIZE, // s_int + MEMINFO_DELTA_HUGE_SURPLUS, // s_int + MEMINFO_DELTA_HUGE_TOTAL, // s_int + MEMINFO_DELTA_INACTIVE, // s_int + MEMINFO_DELTA_INACTIVE_ANON, // s_int + MEMINFO_DELTA_INACTIVE_FILE, // s_int + MEMINFO_DELTA_KERNEL_STACK, // s_int + MEMINFO_DELTA_LOCKED, // s_int + MEMINFO_DELTA_MAPPED, // s_int + MEMINFO_DELTA_NFS_UNSTABLE, // s_int + MEMINFO_DELTA_PAGE_TABLES, // s_int + MEMINFO_DELTA_SHARED, // s_int + MEMINFO_DELTA_SLAB, // s_int + MEMINFO_DELTA_SLAB_RECLAIM, // s_int + MEMINFO_DELTA_SLAB_UNRECLAIM, // s_int + MEMINFO_DELTA_TOTAL, // s_int + MEMINFO_DELTA_UNEVICTABLE, // s_int + MEMINFO_DELTA_USED, // s_int + MEMINFO_DELTA_VM_ALLOC_CHUNK, // s_int + MEMINFO_DELTA_VM_ALLOC_TOTAL, // s_int + MEMINFO_DELTA_VM_ALLOC_USED, // s_int + MEMINFO_DELTA_WRITEBACK, // s_int + MEMINFO_DELTA_WRITEBACK_TMP, // s_int - PROCPS_MEMINFO_MEMHI_FREE, // ul_int - PROCPS_MEMINFO_MEMHI_TOTAL, // ul_int - PROCPS_MEMINFO_MEMHI_USED, // ul_int + MEMINFO_MEMHI_FREE, // ul_int + MEMINFO_MEMHI_TOTAL, // ul_int + MEMINFO_MEMHI_USED, // ul_int - PROCPS_MEMINFO_MEMLO_FREE, // ul_int - PROCPS_MEMINFO_MEMLO_TOTAL, // ul_int - PROCPS_MEMINFO_MEMLO_USED, // ul_int + MEMINFO_MEMLO_FREE, // ul_int + MEMINFO_MEMLO_TOTAL, // ul_int + MEMINFO_MEMLO_USED, // ul_int - PROCPS_MEMINFO_SWAP_CACHED, // ul_int - PROCPS_MEMINFO_SWAP_FREE, // ul_int - PROCPS_MEMINFO_SWAP_TOTAL, // ul_int - PROCPS_MEMINFO_SWAP_USED // ul_int + MEMINFO_SWAP_CACHED, // ul_int + MEMINFO_SWAP_FREE, // ul_int + MEMINFO_SWAP_TOTAL, // ul_int + MEMINFO_SWAP_USED // ul_int }; @@ -135,10 +137,10 @@ struct meminfo_stack { }; -#define PROCPS_MEMINFO_GET( info, actual_enum, type ) \ +#define MEMINFO_GET( info, actual_enum, type ) \ procps_meminfo_get( info, actual_enum ) -> result . type -#define PROCPS_MEMINFO_VAL( relative_enum, type, stack) \ +#define MEMINFO_VAL( relative_enum, type, stack) \ stack -> head [ relative_enum ] . result . type diff --git a/proc/pids.c b/proc/pids.c index 45c4eefd..1ad91194 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -501,13 +501,13 @@ static struct { { RS(WCHAN_ADDR), f_stat, NULL, QS(ul_int), 0 }, { RS(WCHAN_NAME), 0, FF(str), QS(str), 0 }, // oldflags: tid already free - // dummy entry corresponding to PROCPS_PIDS_logical_end ... + // dummy entry corresponding to PIDS_logical_end ... { NULL, 0, NULL, NULL, 0 } }; /* please note, * this enum MUST be 1 greater than the highest value of any enum */ -enum pids_item PROCPS_PIDS_logical_end = PROCPS_PIDS_WCHAN_NAME + 1; +enum pids_item PIDS_logical_end = PIDS_WCHAN_NAME + 1; #undef setNAME #undef freNAME @@ -763,7 +763,7 @@ static inline void assign_results ( for (;;) { enum pids_item item = this->item; - if (item >= PROCPS_PIDS_logical_end) + if (item >= PIDS_logical_end) break; Item_table[item].setsfunc(info, this, p); info->dirty_stacks |= Item_table[item].freefunc ? 1 : 0; @@ -778,11 +778,11 @@ static inline void cleanup_stack ( { for (;;) { enum pids_item item = this->item; - if (item >= PROCPS_PIDS_logical_end) + if (item >= PIDS_logical_end) break; if (Item_table[item].freefunc) Item_table[item].freefunc(this); - if (item > PROCPS_PIDS_noop) + if (item > PIDS_noop) this->result.ull_int = 0; ++this; } @@ -885,7 +885,7 @@ static inline int items_check_failed ( * offer any sort of warning like the following: * * warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'enum pids_item *' - * if (procps_pids_new(&info, PROCPS_PIDS_noop, 3) < 0) + * if (procps_pids_new(&info, PIDS_noop, 3) < 0) * ^~~~~~~~~~~~~~~~ */ if (numitems < 1 @@ -895,7 +895,7 @@ static inline int items_check_failed ( // a pids_item is currently unsigned, but we'll protect our future if (items[i] < 0) return -1; - if (items[i] >= PROCPS_PIDS_logical_end) { + if (items[i] >= PIDS_logical_end) { return -1; } } @@ -911,7 +911,7 @@ static inline void libflags_set ( info->oldflags = info->history_yes = 0; for (i = 0; i < info->curitems; i++) { - if (((e = info->items[i])) >= PROCPS_PIDS_logical_end) + if (((e = info->items[i])) >= PIDS_logical_end) break; info->oldflags |= Item_table[e].oldflags; info->history_yes |= Item_table[e].needhist; @@ -1142,14 +1142,14 @@ PROCPS_EXPORT int procps_pids_new ( free(p); return -EINVAL; } - // allow for our PROCPS_PIDS_logical_end + // allow for our PIDS_logical_end p->maxitems = numitems + 1; if (!(p->items = calloc(p->maxitems, sizeof(enum pids_item)))) { free(p); return -ENOMEM; } memcpy(p->items, items, sizeof(enum pids_item) * numitems); - p->items[numitems] = PROCPS_PIDS_logical_end; + p->items[numitems] = PIDS_logical_end; p->curitems = p->maxitems; libflags_set(p); } @@ -1282,7 +1282,7 @@ PROCPS_EXPORT struct pids_stack *procps_pids_get ( return NULL; if (!info->curitems) return NULL; - if (which != PROCPS_FETCH_TASKS_ONLY && which != PROCPS_FETCH_THREADS_TOO) + if (which != PIDS_FETCH_TASKS_ONLY && which != PIDS_FETCH_THREADS_TOO) return NULL; /* with items & numitems technically optional at 'new' time, it's expected 'reset' will have been called -- but just in case ... */ @@ -1333,7 +1333,7 @@ PROCPS_EXPORT struct pids_fetch *procps_pids_reap ( if (info == NULL) return NULL; - if (which != PROCPS_FETCH_TASKS_ONLY && which != PROCPS_FETCH_THREADS_TOO) + if (which != PIDS_FETCH_TASKS_ONLY && which != PIDS_FETCH_THREADS_TOO) return NULL; /* with items & numitems technically optional at 'new' time, it's expected 'reset' will have been called -- but just in case ... */ @@ -1371,7 +1371,7 @@ PROCPS_EXPORT int procps_pids_reset ( if (info->maxitems < newnumitems + 1) { if (info->dirty_stacks) cleanup_stacks_all(info); - // allow for our PROCPS_PIDS_logical_end + // allow for our PIDS_logical_end info->maxitems = newnumitems + 1; if (!(info->items = realloc(info->items, sizeof(enum pids_item) * info->maxitems))) return -ENOMEM; @@ -1382,8 +1382,8 @@ PROCPS_EXPORT int procps_pids_reset ( cleanup_stacks_all(info); memcpy(info->items, newitems, sizeof(enum pids_item) * newnumitems); - info->items[newnumitems] = PROCPS_PIDS_logical_end; - // account for above PROCPS_PIDS_logical_end + info->items[newnumitems] = PIDS_logical_end; + // account for above PIDS_logical_end info->curitems = newnumitems + 1; itemize_stacks_all(info); @@ -1413,14 +1413,14 @@ PROCPS_EXPORT struct pids_fetch *procps_pids_select ( return NULL; if (numthese < 1 || numthese > FILL_ID_MAX) return NULL; - if (which != PROCPS_SELECT_PID && which != PROCPS_SELECT_UID) + if (which != PIDS_SELECT_PID && which != PIDS_SELECT_UID) return NULL; /* with items & numitems technically optional at 'new' time, it's expected 'reset' will have been called -- but just in case ... */ if (!info->curitems) return NULL; - // this zero delimiter is really only needed with PROCPS_SELECT_PID + // this zero delimiter is really only needed with PIDS_SELECT_PID memcpy(ids, these, sizeof(unsigned) * numthese); ids[numthese] = 0; @@ -1460,9 +1460,9 @@ PROCPS_EXPORT struct pids_stack **procps_pids_sort ( if (info == NULL || stacks == NULL) return NULL; // a pids_item is currently unsigned, but we'll protect our future - if (sortitem < 0 || sortitem >= PROCPS_PIDS_logical_end) + if (sortitem < 0 || sortitem >= PIDS_logical_end) return NULL; - if (order != PROCPS_PIDS_ASCEND && order != PROCPS_PIDS_DESCEND) + if (order != PIDS_SORT_ASCEND && order != PIDS_SORT_DESCEND) return NULL; if (numstacked < 2) return stacks; @@ -1475,7 +1475,7 @@ PROCPS_EXPORT struct pids_stack **procps_pids_sort ( ++offset; if (offset >= info->curitems) return NULL; - if (p->item >= PROCPS_PIDS_logical_end) + if (p->item >= PIDS_logical_end) return NULL; ++p; } diff --git a/proc/pids.h b/proc/pids.h index f1c33e64..5b58e2b5 100644 --- a/proc/pids.h +++ b/proc/pids.h @@ -1,5 +1,5 @@ /* - * pids.h - task/thread/process related declarations for libproc + * libprocps - Library to read proc filesystem * * Copyright (C) 1998-2005 Albert Cahalan * Copyright (C) 2015 Craig Small @@ -20,145 +20,147 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _PROC_PIDS_H -#define _PROC_PIDS_H +#ifndef PROC_PIDS_H +#define PROC_PIDS_H + +#include __BEGIN_DECLS enum pids_item { - PROCPS_PIDS_noop, // ( never altered ) - PROCPS_PIDS_extra, // ( reset to zero ) - PROCPS_PIDS_ADDR_END_CODE, // ul_int - PROCPS_PIDS_ADDR_KSTK_EIP, // ul_int - PROCPS_PIDS_ADDR_KSTK_ESP, // ul_int - PROCPS_PIDS_ADDR_START_CODE, // ul_int - PROCPS_PIDS_ADDR_START_STACK, // ul_int - PROCPS_PIDS_ALARM, // sl_int - PROCPS_PIDS_CGNAME, // str - PROCPS_PIDS_CGROUP, // str - PROCPS_PIDS_CGROUP_V, // strv - PROCPS_PIDS_CMD, // str - PROCPS_PIDS_CMDLINE, // str - PROCPS_PIDS_CMDLINE_V, // strv - PROCPS_PIDS_ENVIRON, // str - PROCPS_PIDS_ENVIRON_V, // strv - PROCPS_PIDS_EXIT_SIGNAL, // s_int - PROCPS_PIDS_FLAGS, // ul_int - PROCPS_PIDS_FLT_MAJ, // sl_int - PROCPS_PIDS_FLT_MAJ_C, // sl_int - PROCPS_PIDS_FLT_MAJ_DELTA, // sl_int - PROCPS_PIDS_FLT_MIN, // sl_int - PROCPS_PIDS_FLT_MIN_C, // sl_int - PROCPS_PIDS_FLT_MIN_DELTA, // sl_int - PROCPS_PIDS_ID_EGID, // u_int - PROCPS_PIDS_ID_EGROUP, // str - PROCPS_PIDS_ID_EUID, // u_int - PROCPS_PIDS_ID_EUSER, // str - PROCPS_PIDS_ID_FGID, // u_int - PROCPS_PIDS_ID_FGROUP, // str - PROCPS_PIDS_ID_FUID, // u_int - PROCPS_PIDS_ID_FUSER, // str - PROCPS_PIDS_ID_PGRP, // s_int - PROCPS_PIDS_ID_PID, // s_int - PROCPS_PIDS_ID_PPID, // s_int - PROCPS_PIDS_ID_RGID, // u_int - PROCPS_PIDS_ID_RGROUP, // str - PROCPS_PIDS_ID_RUID, // u_int - PROCPS_PIDS_ID_RUSER, // str - PROCPS_PIDS_ID_SESSION, // s_int - PROCPS_PIDS_ID_SGID, // u_int - PROCPS_PIDS_ID_SGROUP, // str - PROCPS_PIDS_ID_SUID, // u_int - PROCPS_PIDS_ID_SUSER, // str - PROCPS_PIDS_ID_TGID, // s_int - PROCPS_PIDS_ID_TPGID, // s_int - PROCPS_PIDS_LXCNAME, // str - PROCPS_PIDS_MEM_CODE, // sl_int - PROCPS_PIDS_MEM_CODE_KIB, // sl_int - PROCPS_PIDS_MEM_DATA, // sl_int - PROCPS_PIDS_MEM_DATA_KIB, // sl_int - PROCPS_PIDS_MEM_DT, // sl_int - PROCPS_PIDS_MEM_LRS, // sl_int - PROCPS_PIDS_MEM_RES, // sl_int - PROCPS_PIDS_MEM_RES_KIB, // sl_int - PROCPS_PIDS_MEM_SHR, // sl_int - PROCPS_PIDS_MEM_SHR_KIB, // sl_int - PROCPS_PIDS_MEM_VIRT, // sl_int - PROCPS_PIDS_MEM_VIRT_KIB, // sl_int - PROCPS_PIDS_NICE, // sl_int - PROCPS_PIDS_NLWP, // s_int - PROCPS_PIDS_NS_IPC, // ul_int - PROCPS_PIDS_NS_MNT, // ul_int - PROCPS_PIDS_NS_NET, // ul_int - PROCPS_PIDS_NS_PID, // ul_int - PROCPS_PIDS_NS_USER, // ul_int - PROCPS_PIDS_NS_UTS, // ul_int - PROCPS_PIDS_OOM_ADJ, // s_int - PROCPS_PIDS_OOM_SCORE, // s_int - PROCPS_PIDS_PRIORITY, // s_int - PROCPS_PIDS_PROCESSOR, // u_int - PROCPS_PIDS_RSS, // sl_int - PROCPS_PIDS_RSS_RLIM, // ul_int - PROCPS_PIDS_RTPRIO, // ul_int - PROCPS_PIDS_SCHED_CLASS, // ul_int - PROCPS_PIDS_SD_MACH, // str - PROCPS_PIDS_SD_OUID, // str - PROCPS_PIDS_SD_SEAT, // str - PROCPS_PIDS_SD_SESS, // str - PROCPS_PIDS_SD_SLICE, // str - PROCPS_PIDS_SD_UNIT, // str - PROCPS_PIDS_SD_UUNIT, // str - PROCPS_PIDS_SIGBLOCKED, // str - PROCPS_PIDS_SIGCATCH, // str - PROCPS_PIDS_SIGIGNORE, // str - PROCPS_PIDS_SIGNALS, // str - PROCPS_PIDS_SIGPENDING, // str - PROCPS_PIDS_STATE, // s_ch - PROCPS_PIDS_SUPGIDS, // str - PROCPS_PIDS_SUPGROUPS, // str - PROCPS_PIDS_TICS_ALL, // ull_int - PROCPS_PIDS_TICS_ALL_C, // ull_int - PROCPS_PIDS_TICS_DELTA, // sl_int - PROCPS_PIDS_TICS_SYSTEM, // ull_int - PROCPS_PIDS_TICS_SYSTEM_C, // ull_int - PROCPS_PIDS_TICS_USER, // ull_int - PROCPS_PIDS_TICS_USER_C, // ull_int - PROCPS_PIDS_TIME_ALL, // ull_int - PROCPS_PIDS_TIME_ELAPSED, // ull_int - PROCPS_PIDS_TIME_START, // ull_int - PROCPS_PIDS_TTY, // s_int - PROCPS_PIDS_TTY_NAME, // str - PROCPS_PIDS_TTY_NUMBER, // str - PROCPS_PIDS_VM_DATA, // sl_int - PROCPS_PIDS_VM_EXE, // sl_int - PROCPS_PIDS_VM_LIB, // sl_int - PROCPS_PIDS_VM_RSS, // sl_int - PROCPS_PIDS_VM_RSS_ANON, // sl_int - PROCPS_PIDS_VM_RSS_FILE, // sl_int - PROCPS_PIDS_VM_RSS_LOCKED, // sl_int - PROCPS_PIDS_VM_RSS_SHARED, // sl_int - PROCPS_PIDS_VM_SIZE, // sl_int - PROCPS_PIDS_VM_STACK, // sl_int - PROCPS_PIDS_VM_SWAP, // sl_int - PROCPS_PIDS_VM_USED, // sl_int - PROCPS_PIDS_VSIZE_PGS, // ul_int - PROCPS_PIDS_WCHAN_ADDR, // ul_int - PROCPS_PIDS_WCHAN_NAME // str + PIDS_noop, // ( never altered ) + PIDS_extra, // ( reset to zero ) + PIDS_ADDR_END_CODE, // ul_int + PIDS_ADDR_KSTK_EIP, // ul_int + PIDS_ADDR_KSTK_ESP, // ul_int + PIDS_ADDR_START_CODE, // ul_int + PIDS_ADDR_START_STACK, // ul_int + PIDS_ALARM, // sl_int + PIDS_CGNAME, // str + PIDS_CGROUP, // str + PIDS_CGROUP_V, // strv + PIDS_CMD, // str + PIDS_CMDLINE, // str + PIDS_CMDLINE_V, // strv + PIDS_ENVIRON, // str + PIDS_ENVIRON_V, // strv + PIDS_EXIT_SIGNAL, // s_int + PIDS_FLAGS, // ul_int + PIDS_FLT_MAJ, // sl_int + PIDS_FLT_MAJ_C, // sl_int + PIDS_FLT_MAJ_DELTA, // sl_int + PIDS_FLT_MIN, // sl_int + PIDS_FLT_MIN_C, // sl_int + PIDS_FLT_MIN_DELTA, // sl_int + PIDS_ID_EGID, // u_int + PIDS_ID_EGROUP, // str + PIDS_ID_EUID, // u_int + PIDS_ID_EUSER, // str + PIDS_ID_FGID, // u_int + PIDS_ID_FGROUP, // str + PIDS_ID_FUID, // u_int + PIDS_ID_FUSER, // str + PIDS_ID_PGRP, // s_int + PIDS_ID_PID, // s_int + PIDS_ID_PPID, // s_int + PIDS_ID_RGID, // u_int + PIDS_ID_RGROUP, // str + PIDS_ID_RUID, // u_int + PIDS_ID_RUSER, // str + PIDS_ID_SESSION, // s_int + PIDS_ID_SGID, // u_int + PIDS_ID_SGROUP, // str + PIDS_ID_SUID, // u_int + PIDS_ID_SUSER, // str + PIDS_ID_TGID, // s_int + PIDS_ID_TPGID, // s_int + PIDS_LXCNAME, // str + PIDS_MEM_CODE, // sl_int + PIDS_MEM_CODE_KIB, // sl_int + PIDS_MEM_DATA, // sl_int + PIDS_MEM_DATA_KIB, // sl_int + PIDS_MEM_DT, // sl_int + PIDS_MEM_LRS, // sl_int + PIDS_MEM_RES, // sl_int + PIDS_MEM_RES_KIB, // sl_int + PIDS_MEM_SHR, // sl_int + PIDS_MEM_SHR_KIB, // sl_int + PIDS_MEM_VIRT, // sl_int + PIDS_MEM_VIRT_KIB, // sl_int + PIDS_NICE, // sl_int + PIDS_NLWP, // s_int + PIDS_NS_IPC, // ul_int + PIDS_NS_MNT, // ul_int + PIDS_NS_NET, // ul_int + PIDS_NS_PID, // ul_int + PIDS_NS_USER, // ul_int + PIDS_NS_UTS, // ul_int + PIDS_OOM_ADJ, // s_int + PIDS_OOM_SCORE, // s_int + PIDS_PRIORITY, // s_int + PIDS_PROCESSOR, // u_int + PIDS_RSS, // sl_int + PIDS_RSS_RLIM, // ul_int + PIDS_RTPRIO, // ul_int + PIDS_SCHED_CLASS, // ul_int + PIDS_SD_MACH, // str + PIDS_SD_OUID, // str + PIDS_SD_SEAT, // str + PIDS_SD_SESS, // str + PIDS_SD_SLICE, // str + PIDS_SD_UNIT, // str + PIDS_SD_UUNIT, // str + PIDS_SIGBLOCKED, // str + PIDS_SIGCATCH, // str + PIDS_SIGIGNORE, // str + PIDS_SIGNALS, // str + PIDS_SIGPENDING, // str + PIDS_STATE, // s_ch + PIDS_SUPGIDS, // str + PIDS_SUPGROUPS, // str + PIDS_TICS_ALL, // ull_int + PIDS_TICS_ALL_C, // ull_int + PIDS_TICS_DELTA, // sl_int + PIDS_TICS_SYSTEM, // ull_int + PIDS_TICS_SYSTEM_C, // ull_int + PIDS_TICS_USER, // ull_int + PIDS_TICS_USER_C, // ull_int + PIDS_TIME_ALL, // ull_int + PIDS_TIME_ELAPSED, // ull_int + PIDS_TIME_START, // ull_int + PIDS_TTY, // s_int + PIDS_TTY_NAME, // str + PIDS_TTY_NUMBER, // str + PIDS_VM_DATA, // sl_int + PIDS_VM_EXE, // sl_int + PIDS_VM_LIB, // sl_int + PIDS_VM_RSS, // sl_int + PIDS_VM_RSS_ANON, // sl_int + PIDS_VM_RSS_FILE, // sl_int + PIDS_VM_RSS_LOCKED, // sl_int + PIDS_VM_RSS_SHARED, // sl_int + PIDS_VM_SIZE, // sl_int + PIDS_VM_STACK, // sl_int + PIDS_VM_SWAP, // sl_int + PIDS_VM_USED, // sl_int + PIDS_VSIZE_PGS, // ul_int + PIDS_WCHAN_ADDR, // ul_int + PIDS_WCHAN_NAME // str }; enum pids_fetch_type { - PROCPS_FETCH_TASKS_ONLY, - PROCPS_FETCH_THREADS_TOO + PIDS_FETCH_TASKS_ONLY, + PIDS_FETCH_THREADS_TOO }; enum pids_select_type { - PROCPS_SELECT_PID = 0x1000, - PROCPS_SELECT_UID = 0x4000 + PIDS_SELECT_PID = 0x1000, + PIDS_SELECT_UID = 0x4000 }; enum pids_sort_order { - PROCPS_PIDS_ASCEND = +1, - PROCPS_PIDS_DESCEND = -1 + PIDS_SORT_ASCEND = +1, + PIDS_SORT_DESCEND = -1 }; @@ -191,7 +193,7 @@ struct pids_fetch { }; -#define PROCPS_PIDS_VAL( relative_enum, type, stack ) \ +#define PIDS_VAL( relative_enum, type, stack ) \ stack -> head [ relative_enum ] . result . type diff --git a/proc/slabinfo.c b/proc/slabinfo.c index 7f90aaca..e722175c 100644 --- a/proc/slabinfo.c +++ b/proc/slabinfo.c @@ -51,11 +51,11 @@ Because 'select' could, at most, return only node[0] values and since 'reap' | would be forced to duplicate global slabs stuff in every node results stack, | the following #define can be used to enforce strictly logical return values. | - select: allow only PROCPS_SLABINFO & PROCPS_SLABS items - reap: allow only PROCPS_SLABINFO & PROCPS_SLABNODE items + select: allow only SLABINFO & SLABS items + reap: allow only SLABINFO & SLABNODE items Without the #define, these functions always return something even if just 0. | - get: return only PROCPS_SLABS results, else 0 - select: return only PROCPS_SLABINFO & PROCPS_SLABS results, else zero + get: return only SLABS results, else 0 + select: return only SLABINFO & SLABS results, else zero reap: return any requested, even when duplicated in each node's stack */ //#define ENFORCE_LOGICAL // ensure only logical items accepted by select/reap @@ -291,13 +291,13 @@ static struct { { RS(SLABNODE_USE), QS(u_int) }, { RS(SLABNODE_SIZE), QS(ul_int) }, - // dummy entry corresponding to PROCPS_SLABINFO_logical_end ... + // dummy entry corresponding to SLABINFO_logical_end ... { NULL, NULL } }; /* please note, * this enum MUST be 1 greater than the highest value of any enum */ -enum slabinfo_item PROCPS_SLABINFO_logical_end = PROCPS_SLABNODE_SIZE + 1; +enum slabinfo_item SLABINFO_logical_end = SLABNODE_SIZE + 1; #undef setNAME #undef srtNAME @@ -511,7 +511,7 @@ static inline void assign_results ( for (;;) { enum slabinfo_item item = this->item; - if (item >= PROCPS_SLABINFO_logical_end) + if (item >= SLABINFO_logical_end) break; Item_table[item].setsfunc(this, summ, node); ++this; @@ -524,9 +524,9 @@ static inline void cleanup_stack ( struct slabinfo_result *this) { for (;;) { - if (this->item >= PROCPS_SLABINFO_logical_end) + if (this->item >= SLABINFO_logical_end) break; - if (this->item > PROCPS_SLABINFO_noop) + if (this->item > SLABINFO_noop) this->result.ul_int = 0; ++this; } @@ -603,17 +603,17 @@ static inline int items_check_failed ( * offer any sort of warning like the following: * * warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'enum slabinfo_item *' - * my_stack = procps_slabinfo_select(info, PROCPS_SLABINFO_noop, num); + * my_stack = procps_slabinfo_select(info, SLABINFO_noop, num); * ^~~~~~~~~~~~~~~~ */ if (numitems < 1 - || (void *)items < (void *)(unsigned long)(2 * PROCPS_SLABINFO_logical_end)) + || (void *)items < (void *)(unsigned long)(2 * SLABINFO_logical_end)) return -1; for (i = 0; i < numitems; i++) { #ifdef ENFORCE_LOGICAL - if (items[i] == PROCPS_SLABINFO_noop - || (items[i] == PROCPS_SLABINFO_extra)) + if (items[i] == SLABINFO_noop + || (items[i] == SLABINFO_extra)) continue; if (items[i] < this->lowest || (items[i] > this->highest)) @@ -622,7 +622,7 @@ static inline int items_check_failed ( // a slabinfo_item is currently unsigned, but we'll protect our future if (items[i] < 0) return -1; - if (items[i] >= PROCPS_SLABINFO_logical_end) + if (items[i] >= SLABINFO_logical_end) return -1; #endif } @@ -750,11 +750,11 @@ static int stacks_reconfig_maybe ( if so, gotta' redo all of our stacks stuff ... */ if (this->numitems != numitems + 1 || memcmp(this->items, items, sizeof(enum slabinfo_item) * numitems)) { - // allow for our PROCPS_SLABINFO_logical_end + // allow for our SLABINFO_logical_end if (!(this->items = realloc(this->items, sizeof(enum slabinfo_item) * (numitems + 1)))) return -ENOMEM; memcpy(this->items, items, sizeof(enum slabinfo_item) * numitems); - this->items[numitems] = PROCPS_SLABINFO_logical_end; + this->items[numitems] = SLABINFO_logical_end; this->numitems = numitems + 1; if (this->extents) extents_free_all(this); @@ -789,10 +789,10 @@ PROCPS_EXPORT int procps_slabinfo_new ( return -ENOMEM; #ifdef ENFORCE_LOGICAL - p->select_ext.lowest = PROCPS_SLABS_OBJS; - p->select_ext.highest = PROCPS_SLABS_DELTA_SIZE_TOTAL; - p->fetch_ext.lowest = PROCPS_SLABNODE_NAME; - p->fetch_ext.highest = PROCPS_SLABNODE_SIZE; + p->select_ext.lowest = SLABS_OBJS; + p->select_ext.highest = SLABS_DELTA_SIZE_TOTAL; + p->fetch_ext.lowest = SLABNODE_NAME; + p->fetch_ext.highest = SLABNODE_SIZE; #endif p->refcount = 1; @@ -870,7 +870,7 @@ PROCPS_EXPORT struct slabinfo_result *procps_slabinfo_get ( if (info == NULL) return NULL; - if (item < 0 || item >= PROCPS_SLABINFO_logical_end) + if (item < 0 || item >= SLABINFO_logical_end) return NULL; /* we will NOT read the slabinfo file with every call - rather, we'll offer @@ -884,7 +884,7 @@ PROCPS_EXPORT struct slabinfo_result *procps_slabinfo_get ( info->get_this.item = item; // with 'get', we must NOT honor the usual 'noop' guarantee -// if (item > PROCPS_SLABINFO_noop) +// if (item > SLABINFO_noop) info->get_this.result.ul_int = 0; Item_table[item].setsfunc(&info->get_this, &info->hist, &info->nul_node); @@ -981,9 +981,9 @@ PROCPS_EXPORT struct slabinfo_stack **procps_slabinfo_sort ( return NULL; // a slabinfo_item is currently unsigned, but we'll protect our future - if (sortitem < 0 || sortitem >= PROCPS_SLABINFO_logical_end) + if (sortitem < 0 || sortitem >= SLABINFO_logical_end) return NULL; - if (order != PROCPS_SLABINFO_ASCEND && order != PROCPS_SLABINFO_DESCEND) + if (order != SLABINFO_SORT_ASCEND && order != SLABINFO_SORT_DESCEND) return NULL; if (numstacked < 2) return stacks; @@ -994,7 +994,7 @@ PROCPS_EXPORT struct slabinfo_stack **procps_slabinfo_sort ( if (p->item == sortitem) break; ++offset; - if (p->item == PROCPS_SLABINFO_logical_end) + if (p->item == SLABINFO_logical_end) return NULL; ++p; } diff --git a/proc/slabinfo.h b/proc/slabinfo.h index 87890e59..e36b60fd 100644 --- a/proc/slabinfo.h +++ b/proc/slabinfo.h @@ -1,5 +1,5 @@ /* - * slabinfo.h - slab related functions for libproc + * libprocps - Library to read proc filesystem * * Copyright (C) 1998-2005 Albert Cahalan * Copyright (C) 2015 Craig Small @@ -20,58 +20,58 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _PROC_SLAB_H -#define _PROC_SLAB_H +#ifndef PROC_SLAB_H +#define PROC_SLAB_H -#include +#include __BEGIN_DECLS enum slabinfo_item { - PROCPS_SLABINFO_noop, // ( never altered ) - PROCPS_SLABINFO_extra, // ( reset to zero ) + SLABINFO_noop, // ( never altered ) + SLABINFO_extra, // ( reset to zero ) - PROCPS_SLABS_OBJS, // u_int - PROCPS_SLABS_AOBJS, // u_int - PROCPS_SLABS_PAGES, // u_int - PROCPS_SLABS_SLABS, // u_int - PROCPS_SLABS_ASLABS, // u_int - PROCPS_SLABS_CACHES, // u_int - PROCPS_SLABS_ACACHES, // u_int - PROCPS_SLABS_SIZE_AVG, // u_int - PROCPS_SLABS_SIZE_MIN, // u_int - PROCPS_SLABS_SIZE_MAX, // u_int - PROCPS_SLABS_SIZE_ACTIVE, // ul_int - PROCPS_SLABS_SIZE_TOTAL, // ul_int + SLABS_OBJS, // u_int + SLABS_AOBJS, // u_int + SLABS_PAGES, // u_int + SLABS_SLABS, // u_int + SLABS_ASLABS, // u_int + SLABS_CACHES, // u_int + SLABS_ACACHES, // u_int + SLABS_SIZE_AVG, // u_int + SLABS_SIZE_MIN, // u_int + SLABS_SIZE_MAX, // u_int + SLABS_SIZE_ACTIVE, // ul_int + SLABS_SIZE_TOTAL, // ul_int - PROCPS_SLABS_DELTA_OBJS, // s_int - PROCPS_SLABS_DELTA_AOBJS, // s_int - PROCPS_SLABS_DELTA_PAGES, // s_int - PROCPS_SLABS_DELTA_SLABS, // s_int - PROCPS_SLABS_DELTA_ASLABS, // s_int - PROCPS_SLABS_DELTA_CACHES, // s_int - PROCPS_SLABS_DELTA_ACACHES, // s_int - PROCPS_SLABS_DELTA_SIZE_AVG, // s_int - PROCPS_SLABS_DELTA_SIZE_MIN, // s_int - PROCPS_SLABS_DELTA_SIZE_MAX, // s_int - PROCPS_SLABS_DELTA_SIZE_ACTIVE, // s_int - PROCPS_SLABS_DELTA_SIZE_TOTAL, // s_int + SLABS_DELTA_OBJS, // s_int + SLABS_DELTA_AOBJS, // s_int + SLABS_DELTA_PAGES, // s_int + SLABS_DELTA_SLABS, // s_int + SLABS_DELTA_ASLABS, // s_int + SLABS_DELTA_CACHES, // s_int + SLABS_DELTA_ACACHES, // s_int + SLABS_DELTA_SIZE_AVG, // s_int + SLABS_DELTA_SIZE_MIN, // s_int + SLABS_DELTA_SIZE_MAX, // s_int + SLABS_DELTA_SIZE_ACTIVE, // s_int + SLABS_DELTA_SIZE_TOTAL, // s_int - PROCPS_SLABNODE_NAME, // str - PROCPS_SLABNODE_OBJS, // u_int - PROCPS_SLABNODE_AOBJS, // u_int - PROCPS_SLABNODE_OBJ_SIZE, // u_int - PROCPS_SLABNODE_OBJS_PER_SLAB, // u_int - PROCPS_SLABNODE_PAGES_PER_SLAB, // u_int - PROCPS_SLABNODE_SLABS, // u_int - PROCPS_SLABNODE_ASLABS, // u_int - PROCPS_SLABNODE_USE, // u_int - PROCPS_SLABNODE_SIZE // ul_int + SLABNODE_NAME, // str + SLABNODE_OBJS, // u_int + SLABNODE_AOBJS, // u_int + SLABNODE_OBJ_SIZE, // u_int + SLABNODE_OBJS_PER_SLAB, // u_int + SLABNODE_PAGES_PER_SLAB, // u_int + SLABNODE_SLABS, // u_int + SLABNODE_ASLABS, // u_int + SLABNODE_USE, // u_int + SLABNODE_SIZE // ul_int }; enum slabinfo_sort_order { - PROCPS_SLABINFO_ASCEND = +1, - PROCPS_SLABINFO_DESCEND = -1 + SLABINFO_SORT_ASCEND = +1, + SLABINFO_SORT_DESCEND = -1 }; @@ -95,10 +95,10 @@ struct slabinfo_reap { }; -#define PROCPS_SLABINFO_GET( info, actual_enum, type ) \ +#define SLABINFO_GET( info, actual_enum, type ) \ procps_slabinfo_get( info, actual_enum ) -> result . type -#define PROCPS_SLABINFO_VAL( relative_enum, type, stack ) \ +#define SLABINFO_VAL( relative_enum, type, stack ) \ stack -> head [ relative_enum ] . result . type diff --git a/proc/stat.c b/proc/stat.c index 25242752..581f8d17 100644 --- a/proc/stat.c +++ b/proc/stat.c @@ -48,7 +48,7 @@ /* ------------------------------------------------------------------------- + because 'reap' would be forced to duplicate the global SYS stuff in every | TIC type results stack, the following #define can be used to enforce that | - only PROCPS_STAT_noop/extra plus those PROCPS_STAT_TIC items were allowed | */ + only STAT_noop and STAT_extra plus all the STAT_TIC items will be allowed | */ //#define ENFORCE_LOGICAL // ensure only logical items are accepted by reap | // ------------------------------------------------------------------------- + @@ -252,7 +252,7 @@ static struct { { RS(SYS_DELTA_PROC_CREATED) }, { RS(SYS_DELTA_PROC_RUNNING) }, - // dummy entry corresponding to PROCPS_STAT_logical_end ... + // dummy entry corresponding to STAT_logical_end ... { NULL, } }; @@ -260,9 +260,9 @@ static struct { * 1st enum MUST be kept in sync with highest TIC type * 2nd enum MUST be 1 greater than the highest value of any enum */ #ifdef ENFORCE_LOGICAL -enum stat_item PROCPS_STAT_TIC_highest = PROCPS_STAT_TIC_DELTA_GUEST_NICE; +enum stat_item STAT_TIC_highest = STAT_TIC_DELTA_GUEST_NICE; #endif -enum stat_item PROCPS_STAT_logical_end = PROCPS_STAT_SYS_DELTA_PROC_RUNNING + 1; +enum stat_item STAT_logical_end = STAT_SYS_DELTA_PROC_RUNNING + 1; #undef setNAME #undef RS @@ -286,7 +286,7 @@ static inline void assign_results ( for (;;) { enum stat_item item = this->item; - if (item >= PROCPS_STAT_logical_end) + if (item >= STAT_logical_end) break; Item_table[item].setsfunc(this, sys_hist, tic_hist); ++this; @@ -299,9 +299,9 @@ static inline void cleanup_stack ( struct stat_result *this) { for (;;) { - if (this->item >= PROCPS_STAT_logical_end) + if (this->item >= STAT_logical_end) break; - if (this->item > PROCPS_STAT_noop) + if (this->item > STAT_noop) this->result.ull_int = 0; ++this; } @@ -362,18 +362,18 @@ static inline int items_check_failed ( * offer any sort of warning like the following: * * warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'enum stat_item *' - * my_stack = procps_stat_select(info, PROCPS_STAT_noop, num); + * my_stack = procps_stat_select(info, STAT_noop, num); * ^~~~~~~~~~~~~~~~ */ if (numitems < 1 - || (void *)items < (void *)(unsigned long)(2 * PROCPS_STAT_logical_end)) + || (void *)items < (void *)(unsigned long)(2 * STAT_logical_end)) return -1; for (i = 0; i < numitems; i++) { // a stat_item is currently unsigned, but we'll protect our future if (items[i] < 0) return -1; - if (items[i] >= PROCPS_STAT_logical_end) { + if (items[i] >= STAT_logical_end) { return -1; } } @@ -410,7 +410,7 @@ static int make_numa_hist ( memset(info->nodes.hist.tics, 0, info->nodes.hist.n_alloc * sizeof(struct hist_tic)); nod_ptr = info->nodes.hist.tics; for (i = 0; i < info->nodes.total; i++) { - nod_ptr->id = nod_ptr->numa_node = PROCPS_STAT_NODE_INVALID; + nod_ptr->id = nod_ptr->numa_node = STAT_NODE_INVALID; ++nod_ptr; } @@ -490,8 +490,8 @@ static int read_stat_failed ( // remember summary from last time around memcpy(&sum_ptr->old, &sum_ptr->new, sizeof(struct stat_jifs)); - sum_ptr->id = PROCPS_STAT_SUMMARY_ID; // mark as summary - sum_ptr->numa_node = PROCPS_STAT_NODE_INVALID; // mark as invalid + sum_ptr->id = STAT_SUMMARY_ID; // mark as summary + sum_ptr->numa_node = STAT_NODE_INVALID; // mark as invalid // now value the cpu summary tics from line #1 if (8 > sscanf(bp, "cpu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu" @@ -513,7 +513,7 @@ reap_em_again: // remember this cpu from last time around memcpy(&cpu_ptr->old, &cpu_ptr->new, sizeof(struct stat_jifs)); // next can be overridden under 'make_numa_hist' - cpu_ptr->numa_node = PROCPS_STAT_NODE_INVALID; + cpu_ptr->numa_node = STAT_NODE_INVALID; if (8 > (rc = sscanf(bp, "cpu%d %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu" , &cpu_ptr->id @@ -721,11 +721,11 @@ static int stacks_reconfig_maybe ( if so, gotta' redo all of our stacks stuff ... */ if (this->items->num != numitems + 1 || memcmp(this->items->enums, items, sizeof(enum stat_item) * numitems)) { - // allow for our PROCPS_STAT_logical_end + // allow for our STAT_logical_end if (!(this->items->enums = realloc(this->items->enums, sizeof(enum stat_item) * (numitems + 1)))) return -ENOMEM; memcpy(this->items->enums, items, sizeof(enum stat_item) * numitems); - this->items->enums[numitems] = PROCPS_STAT_logical_end; + this->items->enums[numitems] = STAT_logical_end; this->items->num = numitems + 1; extents_free_all(this); return 1; @@ -895,7 +895,7 @@ PROCPS_EXPORT struct stat_result *procps_stat_get ( if (info == NULL) return NULL; - if (item < 0 || item >= PROCPS_STAT_logical_end) + if (item < 0 || item >= STAT_logical_end) return NULL; /* no sense reading the stat with every call from a program like vmstat @@ -909,7 +909,7 @@ PROCPS_EXPORT struct stat_result *procps_stat_get ( info->get_this.item = item; // with 'get', we must NOT honor the usual 'noop' guarantee -// if (item > PROCPS_STAT_noop) +// if (item > STAT_noop) info->get_this.result.ull_int = 0; Item_table[item].setsfunc(&info->get_this, &info->sys_hist, &info->cpu_hist); @@ -939,9 +939,9 @@ PROCPS_EXPORT struct stat_reaped *procps_stat_reap ( #ifdef ENFORCE_LOGICAL { int i; - // those PROCPS_STAT_SYS_type enum's make sense only to 'select' ... + // those STAT_SYS_type enum's make sense only to 'select' ... for (i = 0; i < numitems; i++) { - if (items[i] > PROCPS_STAT_TIC_highest) + if (items[i] > STAT_TIC_highest) return NULL; } } diff --git a/proc/stat.h b/proc/stat.h index 56f31942..fcf3bb0e 100644 --- a/proc/stat.h +++ b/proc/stat.h @@ -19,48 +19,50 @@ #ifndef PROC_STAT_H #define PROC_STAT_H +#include + __BEGIN_DECLS enum stat_item { - PROCPS_STAT_noop, // ( never altered ) - PROCPS_STAT_extra, // ( reset to zero ) + STAT_noop, // ( never altered ) + STAT_extra, // ( reset to zero ) - PROCPS_STAT_TIC_ID, // s_int - PROCPS_STAT_TIC_NUMA_NODE, // s_int - PROCPS_STAT_TIC_USER, // ull_int - PROCPS_STAT_TIC_NICE, // ull_int - PROCPS_STAT_TIC_SYSTEM, // ull_int - PROCPS_STAT_TIC_IDLE, // ull_int - PROCPS_STAT_TIC_IOWAIT, // ull_int - PROCPS_STAT_TIC_IRQ, // ull_int - PROCPS_STAT_TIC_SOFTIRQ, // ull_int - PROCPS_STAT_TIC_STOLEN, // ull_int - PROCPS_STAT_TIC_GUEST, // ull_int - PROCPS_STAT_TIC_GUEST_NICE, // ull_int + STAT_TIC_ID, // s_int + STAT_TIC_NUMA_NODE, // s_int + STAT_TIC_USER, // ull_int + STAT_TIC_NICE, // ull_int + STAT_TIC_SYSTEM, // ull_int + STAT_TIC_IDLE, // ull_int + STAT_TIC_IOWAIT, // ull_int + STAT_TIC_IRQ, // ull_int + STAT_TIC_SOFTIRQ, // ull_int + STAT_TIC_STOLEN, // ull_int + STAT_TIC_GUEST, // ull_int + STAT_TIC_GUEST_NICE, // ull_int - PROCPS_STAT_TIC_DELTA_USER, // sl_int - PROCPS_STAT_TIC_DELTA_NICE, // sl_int - PROCPS_STAT_TIC_DELTA_SYSTEM, // sl_int - PROCPS_STAT_TIC_DELTA_IDLE, // sl_int - PROCPS_STAT_TIC_DELTA_IOWAIT, // sl_int - PROCPS_STAT_TIC_DELTA_IRQ, // sl_int - PROCPS_STAT_TIC_DELTA_SOFTIRQ, // sl_int - PROCPS_STAT_TIC_DELTA_STOLEN, // sl_int - PROCPS_STAT_TIC_DELTA_GUEST, // sl_int - PROCPS_STAT_TIC_DELTA_GUEST_NICE, // sl_int + STAT_TIC_DELTA_USER, // sl_int + STAT_TIC_DELTA_NICE, // sl_int + STAT_TIC_DELTA_SYSTEM, // sl_int + STAT_TIC_DELTA_IDLE, // sl_int + STAT_TIC_DELTA_IOWAIT, // sl_int + STAT_TIC_DELTA_IRQ, // sl_int + STAT_TIC_DELTA_SOFTIRQ, // sl_int + STAT_TIC_DELTA_STOLEN, // sl_int + STAT_TIC_DELTA_GUEST, // sl_int + STAT_TIC_DELTA_GUEST_NICE, // sl_int - PROCPS_STAT_SYS_CTX_SWITCHES, // ul_int - PROCPS_STAT_SYS_INTERRUPTS, // ul_int - PROCPS_STAT_SYS_PROC_BLOCKED, // ul_int - PROCPS_STAT_SYS_PROC_CREATED, // ul_int - PROCPS_STAT_SYS_PROC_RUNNING, // ul_int - PROCPS_STAT_SYS_TIME_OF_BOOT, // ul_int + STAT_SYS_CTX_SWITCHES, // ul_int + STAT_SYS_INTERRUPTS, // ul_int + STAT_SYS_PROC_BLOCKED, // ul_int + STAT_SYS_PROC_CREATED, // ul_int + STAT_SYS_PROC_RUNNING, // ul_int + STAT_SYS_TIME_OF_BOOT, // ul_int - PROCPS_STAT_SYS_DELTA_CTX_SWITCHES, // s_int - PROCPS_STAT_SYS_DELTA_INTERRUPTS, // s_int - PROCPS_STAT_SYS_DELTA_PROC_BLOCKED, // s_int - PROCPS_STAT_SYS_DELTA_PROC_CREATED, // s_int - PROCPS_STAT_SYS_DELTA_PROC_RUNNING // s_int + STAT_SYS_DELTA_CTX_SWITCHES, // s_int + STAT_SYS_DELTA_INTERRUPTS, // s_int + STAT_SYS_DELTA_PROC_BLOCKED, // s_int + STAT_SYS_DELTA_PROC_CREATED, // s_int + STAT_SYS_DELTA_PROC_RUNNING // s_int }; enum stat_reap_type { @@ -94,13 +96,13 @@ struct stat_reaped { }; -#define PROCPS_STAT_SUMMARY_ID -11111 -#define PROCPS_STAT_NODE_INVALID -22222 +#define STAT_SUMMARY_ID -11111 +#define STAT_NODE_INVALID -22222 -#define PROCPS_STAT_GET( info, actual_enum, type ) \ +#define STAT_GET( info, actual_enum, type ) \ procps_stat_get( info, actual_enum ) -> result . type -#define PROCPS_STAT_VAL( relative_enum, type, stack ) \ +#define STAT_VAL( relative_enum, type, stack ) \ stack -> head [ relative_enum ] . result . type diff --git a/proc/vmstat.c b/proc/vmstat.c index 43416cfa..612894d3 100644 --- a/proc/vmstat.c +++ b/proc/vmstat.c @@ -704,13 +704,13 @@ static struct { { RS(DELTA_WORKINGSET_REFAULT) }, { RS(DELTA_ZONE_RECLAIM_FAILED) }, - // dummy entry corresponding to PROCPS_VMSTAT_logical_end ... + // dummy entry corresponding to VMSTAT_logical_end ... { NULL, } }; /* please note, * this enum MUST be 1 greater than the highest value of any enum */ -enum vmstat_item PROCPS_VMSTAT_logical_end = PROCPS_VMSTAT_DELTA_ZONE_RECLAIM_FAILED + 1; +enum vmstat_item VMSTAT_logical_end = VMSTAT_DELTA_ZONE_RECLAIM_FAILED + 1; #undef setNAME #undef RS @@ -726,7 +726,7 @@ static inline void assign_results ( for (;;) { enum vmstat_item item = this->item; - if (item >= PROCPS_VMSTAT_logical_end) + if (item >= VMSTAT_logical_end) break; Item_table[item].setsfunc(this, hist); ++this; @@ -739,9 +739,9 @@ static inline void cleanup_stack ( struct vmstat_result *this) { for (;;) { - if (this->item >= PROCPS_VMSTAT_logical_end) + if (this->item >= VMSTAT_logical_end) break; - if (this->item > PROCPS_VMSTAT_noop) + if (this->item > VMSTAT_noop) this->result.ul_int = 0; ++this; } @@ -802,18 +802,18 @@ static inline int items_check_failed ( * offer any sort of warning like the following: * * warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'enum vmstat_item *' - * my_stack = procps_vmstat_select(info, PROCPS_VMSTAT_noop, num); + * my_stack = procps_vmstat_select(info, VMSTAT_noop, num); * ^~~~~~~~~~~~~~~~ */ if (numitems < 1 - || (void *)items < (void *)(unsigned long)(2 * PROCPS_VMSTAT_logical_end)) + || (void *)items < (void *)(unsigned long)(2 * VMSTAT_logical_end)) return -1; for (i = 0; i < numitems; i++) { // a vmstat_item is currently unsigned, but we'll protect our future if (items[i] < 0) return -1; - if (items[i] >= PROCPS_VMSTAT_logical_end) + if (items[i] >= VMSTAT_logical_end) return -1; } @@ -1176,7 +1176,7 @@ PROCPS_EXPORT struct vmstat_result *procps_vmstat_get ( if (info == NULL) return NULL; - if (item < 0 || item >= PROCPS_VMSTAT_logical_end) + if (item < 0 || item >= VMSTAT_logical_end) return NULL; /* we will NOT read the vmstat file with every call - rather, we'll offer @@ -1190,7 +1190,7 @@ PROCPS_EXPORT struct vmstat_result *procps_vmstat_get ( info->get_this.item = item; // with 'get', we must NOT honor the usual 'noop' guarantee -// if (item > PROCPS_VMSTAT_noop) +// if (item > VMSTAT_noop) info->get_this.result.ul_int = 0; Item_table[item].setsfunc(&info->get_this, &info->hist); @@ -1219,11 +1219,11 @@ PROCPS_EXPORT struct vmstat_stack *procps_vmstat_select ( if so, gotta' redo all of our stacks stuff ... */ if (info->numitems != numitems + 1 || memcmp(info->items, items, sizeof(enum vmstat_item) * numitems)) { - // allow for our PROCPS_VMSTAT_logical_end + // allow for our VMSTAT_logical_end if (!(info->items = realloc(info->items, sizeof(enum vmstat_item) * (numitems + 1)))) return NULL; memcpy(info->items, items, sizeof(enum vmstat_item) * numitems); - info->items[numitems] = PROCPS_VMSTAT_logical_end; + info->items[numitems] = VMSTAT_logical_end; info->numitems = numitems + 1; if (info->extents) extents_free_all(info); diff --git a/proc/vmstat.h b/proc/vmstat.h index 9249916f..0ff8590f 100644 --- a/proc/vmstat.h +++ b/proc/vmstat.h @@ -24,251 +24,251 @@ #ifndef PROC_VMSTAT_H #define PROC_VMSTAT_H -#include +#include __BEGIN_DECLS enum vmstat_item { - PROCPS_VMSTAT_noop, // ( never altered ) - PROCPS_VMSTAT_extra, // ( reset to zero ) + VMSTAT_noop, // ( never altered ) + VMSTAT_extra, // ( reset to zero ) - PROCPS_VMSTAT_ALLOCSTALL, // ul_int - PROCPS_VMSTAT_BALLOON_DEFLATE, // ul_int - PROCPS_VMSTAT_BALLOON_INFLATE, // ul_int - PROCPS_VMSTAT_BALLOON_MIGRATE, // ul_int - PROCPS_VMSTAT_COMPACT_FAIL, // ul_int - PROCPS_VMSTAT_COMPACT_FREE_SCANNED, // ul_int - PROCPS_VMSTAT_COMPACT_ISOLATED, // ul_int - PROCPS_VMSTAT_COMPACT_MIGRATE_SCANNED, // ul_int - PROCPS_VMSTAT_COMPACT_STALL, // ul_int - PROCPS_VMSTAT_COMPACT_SUCCESS, // ul_int - PROCPS_VMSTAT_DROP_PAGECACHE, // ul_int - PROCPS_VMSTAT_DROP_SLAB, // ul_int - PROCPS_VMSTAT_HTLB_BUDDY_ALLOC_FAIL, // ul_int - PROCPS_VMSTAT_HTLB_BUDDY_ALLOC_SUCCESS, // ul_int - PROCPS_VMSTAT_KSWAPD_HIGH_WMARK_HIT_QUICKLY, // ul_int - PROCPS_VMSTAT_KSWAPD_INODESTEAL, // ul_int - PROCPS_VMSTAT_KSWAPD_LOW_WMARK_HIT_QUICKLY, // ul_int - PROCPS_VMSTAT_NR_ACTIVE_ANON, // ul_int - PROCPS_VMSTAT_NR_ACTIVE_FILE, // ul_int - PROCPS_VMSTAT_NR_ALLOC_BATCH, // ul_int - PROCPS_VMSTAT_NR_ANON_PAGES, // ul_int - PROCPS_VMSTAT_NR_ANON_TRANSPARENT_HUGEPAGES, // ul_int - PROCPS_VMSTAT_NR_BOUNCE, // ul_int - PROCPS_VMSTAT_NR_DIRTIED, // ul_int - PROCPS_VMSTAT_NR_DIRTY, // ul_int - PROCPS_VMSTAT_NR_DIRTY_BACKGROUND_THRESHOLD, // ul_int - PROCPS_VMSTAT_NR_DIRTY_THRESHOLD, // ul_int - PROCPS_VMSTAT_NR_FILE_PAGES, // ul_int - PROCPS_VMSTAT_NR_FREE_CMA, // ul_int - PROCPS_VMSTAT_NR_FREE_PAGES, // ul_int - PROCPS_VMSTAT_NR_INACTIVE_ANON, // ul_int - PROCPS_VMSTAT_NR_INACTIVE_FILE, // ul_int - PROCPS_VMSTAT_NR_ISOLATED_ANON, // ul_int - PROCPS_VMSTAT_NR_ISOLATED_FILE, // ul_int - PROCPS_VMSTAT_NR_KERNEL_STACK, // ul_int - PROCPS_VMSTAT_NR_MAPPED, // ul_int - PROCPS_VMSTAT_NR_MLOCK, // ul_int - PROCPS_VMSTAT_NR_PAGES_SCANNED, // ul_int - PROCPS_VMSTAT_NR_PAGE_TABLE_PAGES, // ul_int - PROCPS_VMSTAT_NR_SHMEM, // ul_int - PROCPS_VMSTAT_NR_SLAB_RECLAIMABLE, // ul_int - PROCPS_VMSTAT_NR_SLAB_UNRECLAIMABLE, // ul_int - PROCPS_VMSTAT_NR_UNEVICTABLE, // ul_int - PROCPS_VMSTAT_NR_UNSTABLE, // ul_int - PROCPS_VMSTAT_NR_VMSCAN_IMMEDIATE_RECLAIM, // ul_int - PROCPS_VMSTAT_NR_VMSCAN_WRITE, // ul_int - PROCPS_VMSTAT_NR_WRITEBACK, // ul_int - PROCPS_VMSTAT_NR_WRITEBACK_TEMP, // ul_int - PROCPS_VMSTAT_NR_WRITTEN, // ul_int - PROCPS_VMSTAT_NUMA_FOREIGN, // ul_int - PROCPS_VMSTAT_NUMA_HINT_FAULTS, // ul_int - PROCPS_VMSTAT_NUMA_HINT_FAULTS_LOCAL, // ul_int - PROCPS_VMSTAT_NUMA_HIT, // ul_int - PROCPS_VMSTAT_NUMA_HUGE_PTE_UPDATES, // ul_int - PROCPS_VMSTAT_NUMA_INTERLEAVE, // ul_int - PROCPS_VMSTAT_NUMA_LOCAL, // ul_int - PROCPS_VMSTAT_NUMA_MISS, // ul_int - PROCPS_VMSTAT_NUMA_OTHER, // ul_int - PROCPS_VMSTAT_NUMA_PAGES_MIGRATED, // ul_int - PROCPS_VMSTAT_NUMA_PTE_UPDATES, // ul_int - PROCPS_VMSTAT_PAGEOUTRUN, // ul_int - PROCPS_VMSTAT_PGACTIVATE, // ul_int - PROCPS_VMSTAT_PGALLOC_DMA, // ul_int - PROCPS_VMSTAT_PGALLOC_DMA32, // ul_int - PROCPS_VMSTAT_PGALLOC_MOVABLE, // ul_int - PROCPS_VMSTAT_PGALLOC_NORMAL, // ul_int - PROCPS_VMSTAT_PGDEACTIVATE, // ul_int - PROCPS_VMSTAT_PGFAULT, // ul_int - PROCPS_VMSTAT_PGFREE, // ul_int - PROCPS_VMSTAT_PGINODESTEAL, // ul_int - PROCPS_VMSTAT_PGMAJFAULT, // ul_int - PROCPS_VMSTAT_PGMIGRATE_FAIL, // ul_int - PROCPS_VMSTAT_PGMIGRATE_SUCCESS, // ul_int - PROCPS_VMSTAT_PGPGIN, // ul_int - PROCPS_VMSTAT_PGPGOUT, // ul_int - PROCPS_VMSTAT_PGREFILL_DMA, // ul_int - PROCPS_VMSTAT_PGREFILL_DMA32, // ul_int - PROCPS_VMSTAT_PGREFILL_MOVABLE, // ul_int - PROCPS_VMSTAT_PGREFILL_NORMAL, // ul_int - PROCPS_VMSTAT_PGROTATED, // ul_int - PROCPS_VMSTAT_PGSCAN_DIRECT_DMA, // ul_int - PROCPS_VMSTAT_PGSCAN_DIRECT_DMA32, // ul_int - PROCPS_VMSTAT_PGSCAN_DIRECT_MOVABLE, // ul_int - PROCPS_VMSTAT_PGSCAN_DIRECT_NORMAL, // ul_int - PROCPS_VMSTAT_PGSCAN_DIRECT_THROTTLE, // ul_int - PROCPS_VMSTAT_PGSCAN_KSWAPD_DMA, // ul_int - PROCPS_VMSTAT_PGSCAN_KSWAPD_DMA32, // ul_int - PROCPS_VMSTAT_PGSCAN_KSWAPD_MOVEABLE, // ul_int - PROCPS_VMSTAT_PGSCAN_KSWAPD_NORMAL, // ul_int - PROCPS_VMSTAT_PGSTEAL_DIRECT_DMA, // ul_int - PROCPS_VMSTAT_PGSTEAL_DIRECT_DMA32, // ul_int - PROCPS_VMSTAT_PGSTEAL_DIRECT_MOVABLE, // ul_int - PROCPS_VMSTAT_PGSTEAL_DIRECT_NORMAL, // ul_int - PROCPS_VMSTAT_PGSTEAL_KSWAPD_DMA, // ul_int - PROCPS_VMSTAT_PGSTEAL_KSWAPD_DMA32, // ul_int - PROCPS_VMSTAT_PGSTEAL_KSWAPD_MOVABLE, // ul_int - PROCPS_VMSTAT_PGSTEAL_KSWAPD_NORMAL, // ul_int - PROCPS_VMSTAT_PSWPIN, // ul_int - PROCPS_VMSTAT_PSWPOUT, // ul_int - PROCPS_VMSTAT_SLABS_SCANNED, // ul_int - PROCPS_VMSTAT_THP_COLLAPSE_ALLOC, // ul_int - PROCPS_VMSTAT_THP_COLLAPSE_ALLOC_FAILED, // ul_int - PROCPS_VMSTAT_THP_FAULT_ALLOC, // ul_int - PROCPS_VMSTAT_THP_FAULT_FALLBACK, // ul_int - PROCPS_VMSTAT_THP_SPLIT, // ul_int - PROCPS_VMSTAT_THP_ZERO_PAGE_ALLOC, // ul_int - PROCPS_VMSTAT_THP_ZERO_PAGE_ALLOC_FAILED, // ul_int - PROCPS_VMSTAT_UNEVICTABLE_PGS_CLEARED, // ul_int - PROCPS_VMSTAT_UNEVICTABLE_PGS_CULLED, // ul_int - PROCPS_VMSTAT_UNEVICTABLE_PGS_MLOCKED, // ul_int - PROCPS_VMSTAT_UNEVICTABLE_PGS_MUNLOCKED, // ul_int - PROCPS_VMSTAT_UNEVICTABLE_PGS_RESCUED, // ul_int - PROCPS_VMSTAT_UNEVICTABLE_PGS_SCANNED, // ul_int - PROCPS_VMSTAT_UNEVICTABLE_PGS_STRANDED, // ul_int - PROCPS_VMSTAT_WORKINGSET_ACTIVATE, // ul_int - PROCPS_VMSTAT_WORKINGSET_NODERECLAIM, // ul_int - PROCPS_VMSTAT_WORKINGSET_REFAULT, // ul_int - PROCPS_VMSTAT_ZONE_RECLAIM_FAILED, // ul_int + VMSTAT_ALLOCSTALL, // ul_int + VMSTAT_BALLOON_DEFLATE, // ul_int + VMSTAT_BALLOON_INFLATE, // ul_int + VMSTAT_BALLOON_MIGRATE, // ul_int + VMSTAT_COMPACT_FAIL, // ul_int + VMSTAT_COMPACT_FREE_SCANNED, // ul_int + VMSTAT_COMPACT_ISOLATED, // ul_int + VMSTAT_COMPACT_MIGRATE_SCANNED, // ul_int + VMSTAT_COMPACT_STALL, // ul_int + VMSTAT_COMPACT_SUCCESS, // ul_int + VMSTAT_DROP_PAGECACHE, // ul_int + VMSTAT_DROP_SLAB, // ul_int + VMSTAT_HTLB_BUDDY_ALLOC_FAIL, // ul_int + VMSTAT_HTLB_BUDDY_ALLOC_SUCCESS, // ul_int + VMSTAT_KSWAPD_HIGH_WMARK_HIT_QUICKLY, // ul_int + VMSTAT_KSWAPD_INODESTEAL, // ul_int + VMSTAT_KSWAPD_LOW_WMARK_HIT_QUICKLY, // ul_int + VMSTAT_NR_ACTIVE_ANON, // ul_int + VMSTAT_NR_ACTIVE_FILE, // ul_int + VMSTAT_NR_ALLOC_BATCH, // ul_int + VMSTAT_NR_ANON_PAGES, // ul_int + VMSTAT_NR_ANON_TRANSPARENT_HUGEPAGES, // ul_int + VMSTAT_NR_BOUNCE, // ul_int + VMSTAT_NR_DIRTIED, // ul_int + VMSTAT_NR_DIRTY, // ul_int + VMSTAT_NR_DIRTY_BACKGROUND_THRESHOLD, // ul_int + VMSTAT_NR_DIRTY_THRESHOLD, // ul_int + VMSTAT_NR_FILE_PAGES, // ul_int + VMSTAT_NR_FREE_CMA, // ul_int + VMSTAT_NR_FREE_PAGES, // ul_int + VMSTAT_NR_INACTIVE_ANON, // ul_int + VMSTAT_NR_INACTIVE_FILE, // ul_int + VMSTAT_NR_ISOLATED_ANON, // ul_int + VMSTAT_NR_ISOLATED_FILE, // ul_int + VMSTAT_NR_KERNEL_STACK, // ul_int + VMSTAT_NR_MAPPED, // ul_int + VMSTAT_NR_MLOCK, // ul_int + VMSTAT_NR_PAGES_SCANNED, // ul_int + VMSTAT_NR_PAGE_TABLE_PAGES, // ul_int + VMSTAT_NR_SHMEM, // ul_int + VMSTAT_NR_SLAB_RECLAIMABLE, // ul_int + VMSTAT_NR_SLAB_UNRECLAIMABLE, // ul_int + VMSTAT_NR_UNEVICTABLE, // ul_int + VMSTAT_NR_UNSTABLE, // ul_int + VMSTAT_NR_VMSCAN_IMMEDIATE_RECLAIM, // ul_int + VMSTAT_NR_VMSCAN_WRITE, // ul_int + VMSTAT_NR_WRITEBACK, // ul_int + VMSTAT_NR_WRITEBACK_TEMP, // ul_int + VMSTAT_NR_WRITTEN, // ul_int + VMSTAT_NUMA_FOREIGN, // ul_int + VMSTAT_NUMA_HINT_FAULTS, // ul_int + VMSTAT_NUMA_HINT_FAULTS_LOCAL, // ul_int + VMSTAT_NUMA_HIT, // ul_int + VMSTAT_NUMA_HUGE_PTE_UPDATES, // ul_int + VMSTAT_NUMA_INTERLEAVE, // ul_int + VMSTAT_NUMA_LOCAL, // ul_int + VMSTAT_NUMA_MISS, // ul_int + VMSTAT_NUMA_OTHER, // ul_int + VMSTAT_NUMA_PAGES_MIGRATED, // ul_int + VMSTAT_NUMA_PTE_UPDATES, // ul_int + VMSTAT_PAGEOUTRUN, // ul_int + VMSTAT_PGACTIVATE, // ul_int + VMSTAT_PGALLOC_DMA, // ul_int + VMSTAT_PGALLOC_DMA32, // ul_int + VMSTAT_PGALLOC_MOVABLE, // ul_int + VMSTAT_PGALLOC_NORMAL, // ul_int + VMSTAT_PGDEACTIVATE, // ul_int + VMSTAT_PGFAULT, // ul_int + VMSTAT_PGFREE, // ul_int + VMSTAT_PGINODESTEAL, // ul_int + VMSTAT_PGMAJFAULT, // ul_int + VMSTAT_PGMIGRATE_FAIL, // ul_int + VMSTAT_PGMIGRATE_SUCCESS, // ul_int + VMSTAT_PGPGIN, // ul_int + VMSTAT_PGPGOUT, // ul_int + VMSTAT_PGREFILL_DMA, // ul_int + VMSTAT_PGREFILL_DMA32, // ul_int + VMSTAT_PGREFILL_MOVABLE, // ul_int + VMSTAT_PGREFILL_NORMAL, // ul_int + VMSTAT_PGROTATED, // ul_int + VMSTAT_PGSCAN_DIRECT_DMA, // ul_int + VMSTAT_PGSCAN_DIRECT_DMA32, // ul_int + VMSTAT_PGSCAN_DIRECT_MOVABLE, // ul_int + VMSTAT_PGSCAN_DIRECT_NORMAL, // ul_int + VMSTAT_PGSCAN_DIRECT_THROTTLE, // ul_int + VMSTAT_PGSCAN_KSWAPD_DMA, // ul_int + VMSTAT_PGSCAN_KSWAPD_DMA32, // ul_int + VMSTAT_PGSCAN_KSWAPD_MOVEABLE, // ul_int + VMSTAT_PGSCAN_KSWAPD_NORMAL, // ul_int + VMSTAT_PGSTEAL_DIRECT_DMA, // ul_int + VMSTAT_PGSTEAL_DIRECT_DMA32, // ul_int + VMSTAT_PGSTEAL_DIRECT_MOVABLE, // ul_int + VMSTAT_PGSTEAL_DIRECT_NORMAL, // ul_int + VMSTAT_PGSTEAL_KSWAPD_DMA, // ul_int + VMSTAT_PGSTEAL_KSWAPD_DMA32, // ul_int + VMSTAT_PGSTEAL_KSWAPD_MOVABLE, // ul_int + VMSTAT_PGSTEAL_KSWAPD_NORMAL, // ul_int + VMSTAT_PSWPIN, // ul_int + VMSTAT_PSWPOUT, // ul_int + VMSTAT_SLABS_SCANNED, // ul_int + VMSTAT_THP_COLLAPSE_ALLOC, // ul_int + VMSTAT_THP_COLLAPSE_ALLOC_FAILED, // ul_int + VMSTAT_THP_FAULT_ALLOC, // ul_int + VMSTAT_THP_FAULT_FALLBACK, // ul_int + VMSTAT_THP_SPLIT, // ul_int + VMSTAT_THP_ZERO_PAGE_ALLOC, // ul_int + VMSTAT_THP_ZERO_PAGE_ALLOC_FAILED, // ul_int + VMSTAT_UNEVICTABLE_PGS_CLEARED, // ul_int + VMSTAT_UNEVICTABLE_PGS_CULLED, // ul_int + VMSTAT_UNEVICTABLE_PGS_MLOCKED, // ul_int + VMSTAT_UNEVICTABLE_PGS_MUNLOCKED, // ul_int + VMSTAT_UNEVICTABLE_PGS_RESCUED, // ul_int + VMSTAT_UNEVICTABLE_PGS_SCANNED, // ul_int + VMSTAT_UNEVICTABLE_PGS_STRANDED, // ul_int + VMSTAT_WORKINGSET_ACTIVATE, // ul_int + VMSTAT_WORKINGSET_NODERECLAIM, // ul_int + VMSTAT_WORKINGSET_REFAULT, // ul_int + VMSTAT_ZONE_RECLAIM_FAILED, // ul_int - PROCPS_VMSTAT_DELTA_ALLOCSTALL, // sl_int - PROCPS_VMSTAT_DELTA_BALLOON_DEFLATE, // sl_int - PROCPS_VMSTAT_DELTA_BALLOON_INFLATE, // sl_int - PROCPS_VMSTAT_DELTA_BALLOON_MIGRATE, // sl_int - PROCPS_VMSTAT_DELTA_COMPACT_FAIL, // sl_int - PROCPS_VMSTAT_DELTA_COMPACT_FREE_SCANNED, // sl_int - PROCPS_VMSTAT_DELTA_COMPACT_ISOLATED, // sl_int - PROCPS_VMSTAT_DELTA_COMPACT_MIGRATE_SCANNED, // sl_int - PROCPS_VMSTAT_DELTA_COMPACT_STALL, // sl_int - PROCPS_VMSTAT_DELTA_COMPACT_SUCCESS, // sl_int - PROCPS_VMSTAT_DELTA_DROP_PAGECACHE, // sl_int - PROCPS_VMSTAT_DELTA_DROP_SLAB, // sl_int - PROCPS_VMSTAT_DELTA_HTLB_BUDDY_ALLOC_FAIL, // sl_int - PROCPS_VMSTAT_DELTA_HTLB_BUDDY_ALLOC_SUCCESS, // sl_int - PROCPS_VMSTAT_DELTA_KSWAPD_HIGH_WMARK_HIT_QUICKLY, // sl_int - PROCPS_VMSTAT_DELTA_KSWAPD_INODESTEAL, // sl_int - PROCPS_VMSTAT_DELTA_KSWAPD_LOW_WMARK_HIT_QUICKLY, // sl_int - PROCPS_VMSTAT_DELTA_NR_ACTIVE_ANON, // sl_int - PROCPS_VMSTAT_DELTA_NR_ACTIVE_FILE, // sl_int - PROCPS_VMSTAT_DELTA_NR_ALLOC_BATCH, // sl_int - PROCPS_VMSTAT_DELTA_NR_ANON_PAGES, // sl_int - PROCPS_VMSTAT_DELTA_NR_ANON_TRANSPARENT_HUGEPAGES, // sl_int - PROCPS_VMSTAT_DELTA_NR_BOUNCE, // sl_int - PROCPS_VMSTAT_DELTA_NR_DIRTIED, // sl_int - PROCPS_VMSTAT_DELTA_NR_DIRTY, // sl_int - PROCPS_VMSTAT_DELTA_NR_DIRTY_BACKGROUND_THRESHOLD, // sl_int - PROCPS_VMSTAT_DELTA_NR_DIRTY_THRESHOLD, // sl_int - PROCPS_VMSTAT_DELTA_NR_FILE_PAGES, // sl_int - PROCPS_VMSTAT_DELTA_NR_FREE_CMA, // sl_int - PROCPS_VMSTAT_DELTA_NR_FREE_PAGES, // sl_int - PROCPS_VMSTAT_DELTA_NR_INACTIVE_ANON, // sl_int - PROCPS_VMSTAT_DELTA_NR_INACTIVE_FILE, // sl_int - PROCPS_VMSTAT_DELTA_NR_ISOLATED_ANON, // sl_int - PROCPS_VMSTAT_DELTA_NR_ISOLATED_FILE, // sl_int - PROCPS_VMSTAT_DELTA_NR_KERNEL_STACK, // sl_int - PROCPS_VMSTAT_DELTA_NR_MAPPED, // sl_int - PROCPS_VMSTAT_DELTA_NR_MLOCK, // sl_int - PROCPS_VMSTAT_DELTA_NR_PAGES_SCANNED, // sl_int - PROCPS_VMSTAT_DELTA_NR_PAGE_TABLE_PAGES, // sl_int - PROCPS_VMSTAT_DELTA_NR_SHMEM, // sl_int - PROCPS_VMSTAT_DELTA_NR_SLAB_RECLAIMABLE, // sl_int - PROCPS_VMSTAT_DELTA_NR_SLAB_UNRECLAIMABLE, // sl_int - PROCPS_VMSTAT_DELTA_NR_UNEVICTABLE, // sl_int - PROCPS_VMSTAT_DELTA_NR_UNSTABLE, // sl_int - PROCPS_VMSTAT_DELTA_NR_VMSCAN_IMMEDIATE_RECLAIM, // sl_int - PROCPS_VMSTAT_DELTA_NR_VMSCAN_WRITE, // sl_int - PROCPS_VMSTAT_DELTA_NR_WRITEBACK, // sl_int - PROCPS_VMSTAT_DELTA_NR_WRITEBACK_TEMP, // sl_int - PROCPS_VMSTAT_DELTA_NR_WRITTEN, // sl_int - PROCPS_VMSTAT_DELTA_NUMA_FOREIGN, // sl_int - PROCPS_VMSTAT_DELTA_NUMA_HINT_FAULTS, // sl_int - PROCPS_VMSTAT_DELTA_NUMA_HINT_FAULTS_LOCAL, // sl_int - PROCPS_VMSTAT_DELTA_NUMA_HIT, // sl_int - PROCPS_VMSTAT_DELTA_NUMA_HUGE_PTE_UPDATES, // sl_int - PROCPS_VMSTAT_DELTA_NUMA_INTERLEAVE, // sl_int - PROCPS_VMSTAT_DELTA_NUMA_LOCAL, // sl_int - PROCPS_VMSTAT_DELTA_NUMA_MISS, // sl_int - PROCPS_VMSTAT_DELTA_NUMA_OTHER, // sl_int - PROCPS_VMSTAT_DELTA_NUMA_PAGES_MIGRATED, // sl_int - PROCPS_VMSTAT_DELTA_NUMA_PTE_UPDATES, // sl_int - PROCPS_VMSTAT_DELTA_PAGEOUTRUN, // sl_int - PROCPS_VMSTAT_DELTA_PGACTIVATE, // sl_int - PROCPS_VMSTAT_DELTA_PGALLOC_DMA, // sl_int - PROCPS_VMSTAT_DELTA_PGALLOC_DMA32, // sl_int - PROCPS_VMSTAT_DELTA_PGALLOC_MOVABLE, // sl_int - PROCPS_VMSTAT_DELTA_PGALLOC_NORMAL, // sl_int - PROCPS_VMSTAT_DELTA_PGDEACTIVATE, // sl_int - PROCPS_VMSTAT_DELTA_PGFAULT, // sl_int - PROCPS_VMSTAT_DELTA_PGFREE, // sl_int - PROCPS_VMSTAT_DELTA_PGINODESTEAL, // sl_int - PROCPS_VMSTAT_DELTA_PGMAJFAULT, // sl_int - PROCPS_VMSTAT_DELTA_PGMIGRATE_FAIL, // sl_int - PROCPS_VMSTAT_DELTA_PGMIGRATE_SUCCESS, // sl_int - PROCPS_VMSTAT_DELTA_PGPGIN, // sl_int - PROCPS_VMSTAT_DELTA_PGPGOUT, // sl_int - PROCPS_VMSTAT_DELTA_PGREFILL_DMA, // sl_int - PROCPS_VMSTAT_DELTA_PGREFILL_DMA32, // sl_int - PROCPS_VMSTAT_DELTA_PGREFILL_MOVABLE, // sl_int - PROCPS_VMSTAT_DELTA_PGREFILL_NORMAL, // sl_int - PROCPS_VMSTAT_DELTA_PGROTATED, // sl_int - PROCPS_VMSTAT_DELTA_PGSCAN_DIRECT_DMA, // sl_int - PROCPS_VMSTAT_DELTA_PGSCAN_DIRECT_DMA32, // sl_int - PROCPS_VMSTAT_DELTA_PGSCAN_DIRECT_MOVABLE, // sl_int - PROCPS_VMSTAT_DELTA_PGSCAN_DIRECT_NORMAL, // sl_int - PROCPS_VMSTAT_DELTA_PGSCAN_DIRECT_THROTTLE, // sl_int - PROCPS_VMSTAT_DELTA_PGSCAN_KSWAPD_DMA, // sl_int - PROCPS_VMSTAT_DELTA_PGSCAN_KSWAPD_DMA32, // sl_int - PROCPS_VMSTAT_DELTA_PGSCAN_KSWAPD_MOVEABLE, // sl_int - PROCPS_VMSTAT_DELTA_PGSCAN_KSWAPD_NORMAL, // sl_int - PROCPS_VMSTAT_DELTA_PGSTEAL_DIRECT_DMA, // sl_int - PROCPS_VMSTAT_DELTA_PGSTEAL_DIRECT_DMA32, // sl_int - PROCPS_VMSTAT_DELTA_PGSTEAL_DIRECT_MOVABLE, // sl_int - PROCPS_VMSTAT_DELTA_PGSTEAL_DIRECT_NORMAL, // sl_int - PROCPS_VMSTAT_DELTA_PGSTEAL_KSWAPD_DMA, // sl_int - PROCPS_VMSTAT_DELTA_PGSTEAL_KSWAPD_DMA32, // sl_int - PROCPS_VMSTAT_DELTA_PGSTEAL_KSWAPD_MOVABLE, // sl_int - PROCPS_VMSTAT_DELTA_PGSTEAL_KSWAPD_NORMAL, // sl_int - PROCPS_VMSTAT_DELTA_PSWPIN, // sl_int - PROCPS_VMSTAT_DELTA_PSWPOUT, // sl_int - PROCPS_VMSTAT_DELTA_SLABS_SCANNED, // sl_int - PROCPS_VMSTAT_DELTA_THP_COLLAPSE_ALLOC, // sl_int - PROCPS_VMSTAT_DELTA_THP_COLLAPSE_ALLOC_FAILED, // sl_int - PROCPS_VMSTAT_DELTA_THP_FAULT_ALLOC, // sl_int - PROCPS_VMSTAT_DELTA_THP_FAULT_FALLBACK, // sl_int - PROCPS_VMSTAT_DELTA_THP_SPLIT, // sl_int - PROCPS_VMSTAT_DELTA_THP_ZERO_PAGE_ALLOC, // sl_int - PROCPS_VMSTAT_DELTA_THP_ZERO_PAGE_ALLOC_FAILED, // sl_int - PROCPS_VMSTAT_DELTA_UNEVICTABLE_PGS_CLEARED, // sl_int - PROCPS_VMSTAT_DELTA_UNEVICTABLE_PGS_CULLED, // sl_int - PROCPS_VMSTAT_DELTA_UNEVICTABLE_PGS_MLOCKED, // sl_int - PROCPS_VMSTAT_DELTA_UNEVICTABLE_PGS_MUNLOCKED, // sl_int - PROCPS_VMSTAT_DELTA_UNEVICTABLE_PGS_RESCUED, // sl_int - PROCPS_VMSTAT_DELTA_UNEVICTABLE_PGS_SCANNED, // sl_int - PROCPS_VMSTAT_DELTA_UNEVICTABLE_PGS_STRANDED, // sl_int - PROCPS_VMSTAT_DELTA_WORKINGSET_ACTIVATE, // sl_int - PROCPS_VMSTAT_DELTA_WORKINGSET_NODERECLAIM, // sl_int - PROCPS_VMSTAT_DELTA_WORKINGSET_REFAULT, // sl_int - PROCPS_VMSTAT_DELTA_ZONE_RECLAIM_FAILED // sl_int + VMSTAT_DELTA_ALLOCSTALL, // sl_int + VMSTAT_DELTA_BALLOON_DEFLATE, // sl_int + VMSTAT_DELTA_BALLOON_INFLATE, // sl_int + VMSTAT_DELTA_BALLOON_MIGRATE, // sl_int + VMSTAT_DELTA_COMPACT_FAIL, // sl_int + VMSTAT_DELTA_COMPACT_FREE_SCANNED, // sl_int + VMSTAT_DELTA_COMPACT_ISOLATED, // sl_int + VMSTAT_DELTA_COMPACT_MIGRATE_SCANNED, // sl_int + VMSTAT_DELTA_COMPACT_STALL, // sl_int + VMSTAT_DELTA_COMPACT_SUCCESS, // sl_int + VMSTAT_DELTA_DROP_PAGECACHE, // sl_int + VMSTAT_DELTA_DROP_SLAB, // sl_int + VMSTAT_DELTA_HTLB_BUDDY_ALLOC_FAIL, // sl_int + VMSTAT_DELTA_HTLB_BUDDY_ALLOC_SUCCESS, // sl_int + VMSTAT_DELTA_KSWAPD_HIGH_WMARK_HIT_QUICKLY, // sl_int + VMSTAT_DELTA_KSWAPD_INODESTEAL, // sl_int + VMSTAT_DELTA_KSWAPD_LOW_WMARK_HIT_QUICKLY, // sl_int + VMSTAT_DELTA_NR_ACTIVE_ANON, // sl_int + VMSTAT_DELTA_NR_ACTIVE_FILE, // sl_int + VMSTAT_DELTA_NR_ALLOC_BATCH, // sl_int + VMSTAT_DELTA_NR_ANON_PAGES, // sl_int + VMSTAT_DELTA_NR_ANON_TRANSPARENT_HUGEPAGES, // sl_int + VMSTAT_DELTA_NR_BOUNCE, // sl_int + VMSTAT_DELTA_NR_DIRTIED, // sl_int + VMSTAT_DELTA_NR_DIRTY, // sl_int + VMSTAT_DELTA_NR_DIRTY_BACKGROUND_THRESHOLD, // sl_int + VMSTAT_DELTA_NR_DIRTY_THRESHOLD, // sl_int + VMSTAT_DELTA_NR_FILE_PAGES, // sl_int + VMSTAT_DELTA_NR_FREE_CMA, // sl_int + VMSTAT_DELTA_NR_FREE_PAGES, // sl_int + VMSTAT_DELTA_NR_INACTIVE_ANON, // sl_int + VMSTAT_DELTA_NR_INACTIVE_FILE, // sl_int + VMSTAT_DELTA_NR_ISOLATED_ANON, // sl_int + VMSTAT_DELTA_NR_ISOLATED_FILE, // sl_int + VMSTAT_DELTA_NR_KERNEL_STACK, // sl_int + VMSTAT_DELTA_NR_MAPPED, // sl_int + VMSTAT_DELTA_NR_MLOCK, // sl_int + VMSTAT_DELTA_NR_PAGES_SCANNED, // sl_int + VMSTAT_DELTA_NR_PAGE_TABLE_PAGES, // sl_int + VMSTAT_DELTA_NR_SHMEM, // sl_int + VMSTAT_DELTA_NR_SLAB_RECLAIMABLE, // sl_int + VMSTAT_DELTA_NR_SLAB_UNRECLAIMABLE, // sl_int + VMSTAT_DELTA_NR_UNEVICTABLE, // sl_int + VMSTAT_DELTA_NR_UNSTABLE, // sl_int + VMSTAT_DELTA_NR_VMSCAN_IMMEDIATE_RECLAIM, // sl_int + VMSTAT_DELTA_NR_VMSCAN_WRITE, // sl_int + VMSTAT_DELTA_NR_WRITEBACK, // sl_int + VMSTAT_DELTA_NR_WRITEBACK_TEMP, // sl_int + VMSTAT_DELTA_NR_WRITTEN, // sl_int + VMSTAT_DELTA_NUMA_FOREIGN, // sl_int + VMSTAT_DELTA_NUMA_HINT_FAULTS, // sl_int + VMSTAT_DELTA_NUMA_HINT_FAULTS_LOCAL, // sl_int + VMSTAT_DELTA_NUMA_HIT, // sl_int + VMSTAT_DELTA_NUMA_HUGE_PTE_UPDATES, // sl_int + VMSTAT_DELTA_NUMA_INTERLEAVE, // sl_int + VMSTAT_DELTA_NUMA_LOCAL, // sl_int + VMSTAT_DELTA_NUMA_MISS, // sl_int + VMSTAT_DELTA_NUMA_OTHER, // sl_int + VMSTAT_DELTA_NUMA_PAGES_MIGRATED, // sl_int + VMSTAT_DELTA_NUMA_PTE_UPDATES, // sl_int + VMSTAT_DELTA_PAGEOUTRUN, // sl_int + VMSTAT_DELTA_PGACTIVATE, // sl_int + VMSTAT_DELTA_PGALLOC_DMA, // sl_int + VMSTAT_DELTA_PGALLOC_DMA32, // sl_int + VMSTAT_DELTA_PGALLOC_MOVABLE, // sl_int + VMSTAT_DELTA_PGALLOC_NORMAL, // sl_int + VMSTAT_DELTA_PGDEACTIVATE, // sl_int + VMSTAT_DELTA_PGFAULT, // sl_int + VMSTAT_DELTA_PGFREE, // sl_int + VMSTAT_DELTA_PGINODESTEAL, // sl_int + VMSTAT_DELTA_PGMAJFAULT, // sl_int + VMSTAT_DELTA_PGMIGRATE_FAIL, // sl_int + VMSTAT_DELTA_PGMIGRATE_SUCCESS, // sl_int + VMSTAT_DELTA_PGPGIN, // sl_int + VMSTAT_DELTA_PGPGOUT, // sl_int + VMSTAT_DELTA_PGREFILL_DMA, // sl_int + VMSTAT_DELTA_PGREFILL_DMA32, // sl_int + VMSTAT_DELTA_PGREFILL_MOVABLE, // sl_int + VMSTAT_DELTA_PGREFILL_NORMAL, // sl_int + VMSTAT_DELTA_PGROTATED, // sl_int + VMSTAT_DELTA_PGSCAN_DIRECT_DMA, // sl_int + VMSTAT_DELTA_PGSCAN_DIRECT_DMA32, // sl_int + VMSTAT_DELTA_PGSCAN_DIRECT_MOVABLE, // sl_int + VMSTAT_DELTA_PGSCAN_DIRECT_NORMAL, // sl_int + VMSTAT_DELTA_PGSCAN_DIRECT_THROTTLE, // sl_int + VMSTAT_DELTA_PGSCAN_KSWAPD_DMA, // sl_int + VMSTAT_DELTA_PGSCAN_KSWAPD_DMA32, // sl_int + VMSTAT_DELTA_PGSCAN_KSWAPD_MOVEABLE, // sl_int + VMSTAT_DELTA_PGSCAN_KSWAPD_NORMAL, // sl_int + VMSTAT_DELTA_PGSTEAL_DIRECT_DMA, // sl_int + VMSTAT_DELTA_PGSTEAL_DIRECT_DMA32, // sl_int + VMSTAT_DELTA_PGSTEAL_DIRECT_MOVABLE, // sl_int + VMSTAT_DELTA_PGSTEAL_DIRECT_NORMAL, // sl_int + VMSTAT_DELTA_PGSTEAL_KSWAPD_DMA, // sl_int + VMSTAT_DELTA_PGSTEAL_KSWAPD_DMA32, // sl_int + VMSTAT_DELTA_PGSTEAL_KSWAPD_MOVABLE, // sl_int + VMSTAT_DELTA_PGSTEAL_KSWAPD_NORMAL, // sl_int + VMSTAT_DELTA_PSWPIN, // sl_int + VMSTAT_DELTA_PSWPOUT, // sl_int + VMSTAT_DELTA_SLABS_SCANNED, // sl_int + VMSTAT_DELTA_THP_COLLAPSE_ALLOC, // sl_int + VMSTAT_DELTA_THP_COLLAPSE_ALLOC_FAILED, // sl_int + VMSTAT_DELTA_THP_FAULT_ALLOC, // sl_int + VMSTAT_DELTA_THP_FAULT_FALLBACK, // sl_int + VMSTAT_DELTA_THP_SPLIT, // sl_int + VMSTAT_DELTA_THP_ZERO_PAGE_ALLOC, // sl_int + VMSTAT_DELTA_THP_ZERO_PAGE_ALLOC_FAILED, // sl_int + VMSTAT_DELTA_UNEVICTABLE_PGS_CLEARED, // sl_int + VMSTAT_DELTA_UNEVICTABLE_PGS_CULLED, // sl_int + VMSTAT_DELTA_UNEVICTABLE_PGS_MLOCKED, // sl_int + VMSTAT_DELTA_UNEVICTABLE_PGS_MUNLOCKED, // sl_int + VMSTAT_DELTA_UNEVICTABLE_PGS_RESCUED, // sl_int + VMSTAT_DELTA_UNEVICTABLE_PGS_SCANNED, // sl_int + VMSTAT_DELTA_UNEVICTABLE_PGS_STRANDED, // sl_int + VMSTAT_DELTA_WORKINGSET_ACTIVATE, // sl_int + VMSTAT_DELTA_WORKINGSET_NODERECLAIM, // sl_int + VMSTAT_DELTA_WORKINGSET_REFAULT, // sl_int + VMSTAT_DELTA_ZONE_RECLAIM_FAILED // sl_int }; @@ -285,10 +285,10 @@ struct vmstat_stack { }; -#define PROCPS_VMSTAT_GET( info, actual_enum, type ) \ +#define VMSTAT_GET( info, actual_enum, type ) \ procps_vmstat_get( info, actual_enum ) -> result . type -#define PROCPS_VMSTAT_VAL( relative_enum, type, stack ) \ +#define VMSTAT_VAL( relative_enum, type, stack ) \ stack -> head [ relative_enum ] . result . type