library: expand fields yet maintain ABI, <MEMINFO> api
With the 4.8 kernel, 2 new fields will be added to the meminfo pseudo file. This commit, soon to be replaced, is intended as an example of how such changes might be incorporated plus still maintain binary compatibility. This actually goes further than is strictly necessary, by retaining meminfo_item ordering for 'set' functions and the creation of hash table entries. However, there is only 1 true requirement, that of Item_table entries which must always agree exactly with item enumerators. All of the other changes could be done alphabetically. Ok, so what happens when an old program encounters the new expanded meminfo items? Well, if it was thoroughly tested against an old library, it won't even see those new fields. On the other hand, if it somehow exceeds a previous MEMINFO_logical_end, then it will just get an extra result structure or two, with no real harm done. [ this patch is being replace by the very next patch ] [ so that our iniitial newlib release can maintain a ] [ strict alphabetic ordering in all areas initially! ] Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
41f7a90afd
commit
09e1886c9e
@ -91,6 +91,10 @@ struct meminfo_data {
|
||||
unsigned long derived_mem_lo_used;
|
||||
unsigned long derived_mem_used;
|
||||
unsigned long derived_swap_used;
|
||||
|
||||
// new with kernel 4.8
|
||||
unsigned long ShmemHugePages;
|
||||
unsigned long ShmemPmdMapped;
|
||||
};
|
||||
|
||||
struct mem_hist {
|
||||
@ -225,6 +229,12 @@ MEM_set(SWAP_FREE, ul_int, SwapFree)
|
||||
MEM_set(SWAP_TOTAL, ul_int, SwapTotal)
|
||||
MEM_set(SWAP_USED, ul_int, derived_swap_used)
|
||||
|
||||
// new with kernel 4.8
|
||||
MEM_set(MEM_SHMEM_HUGE, ul_int, ShmemHugePages)
|
||||
MEM_set(MEM_SHMEM_HUGE_MAP, ul_int, ShmemPmdMapped)
|
||||
HST_set(DELTA_SHMEM_HUGE, s_int, ShmemHugePages)
|
||||
HST_set(DELTA_SHMEM_HUGE_MAP, s_int, ShmemPmdMapped)
|
||||
|
||||
#undef setDECL
|
||||
#undef MEM_set
|
||||
#undef HST_set
|
||||
@ -344,13 +354,19 @@ static struct {
|
||||
{ RS(SWAP_TOTAL), TS(ul_int) },
|
||||
{ RS(SWAP_USED), TS(ul_int) },
|
||||
|
||||
// new with kernel 4.8
|
||||
{ RS(MEM_SHMEM_HUGE), TS(ul_int) },
|
||||
{ RS(MEM_SHMEM_HUGE_MAP), TS(ul_int) },
|
||||
{ RS(DELTA_SHMEM_HUGE), TS(s_int) },
|
||||
{ RS(DELTA_SHMEM_HUGE_MAP), TS(s_int) },
|
||||
|
||||
// dummy entry corresponding to MEMINFO_logical_end ...
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
/* please note,
|
||||
* this enum MUST be 1 greater than the highest value of any enum */
|
||||
enum meminfo_item MEMINFO_logical_end = MEMINFO_SWAP_USED + 1;
|
||||
enum meminfo_item MEMINFO_logical_end = MEMINFO_DELTA_SHMEM_HUGE_MAP + 1;
|
||||
|
||||
#undef setNAME
|
||||
#undef RS
|
||||
@ -527,6 +543,10 @@ static int make_hash_failed (
|
||||
htVAL(Writeback)
|
||||
htVAL(WritebackTmp)
|
||||
|
||||
// new with kernel 4.8
|
||||
htVAL(ShmemHugePages)
|
||||
htVAL(ShmemPmdMapped)
|
||||
|
||||
return 0;
|
||||
#undef htVAL
|
||||
#undef htXTRA
|
||||
|
@ -120,7 +120,14 @@ enum meminfo_item {
|
||||
MEMINFO_SWAP_CACHED, // ul_int
|
||||
MEMINFO_SWAP_FREE, // ul_int
|
||||
MEMINFO_SWAP_TOTAL, // ul_int
|
||||
MEMINFO_SWAP_USED // ul_int
|
||||
MEMINFO_SWAP_USED, // ul_int
|
||||
|
||||
// new with kernel 4.8
|
||||
MEMINFO_MEM_SHMEM_HUGE, // ul_int
|
||||
MEMINFO_MEM_SHMEM_HUGE_MAP, // ul_int
|
||||
|
||||
MEMINFO_DELTA_SHMEM_HUGE, // s_int
|
||||
MEMINFO_DELTA_SHMEM_HUGE_MAP, // s_int
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user