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:
Jim Warner 2016-08-11 10:10:10 -05:00 committed by Craig Small
parent 41f7a90afd
commit 09e1886c9e
2 changed files with 29 additions and 2 deletions

View File

@ -91,6 +91,10 @@ struct meminfo_data {
unsigned long derived_mem_lo_used; unsigned long derived_mem_lo_used;
unsigned long derived_mem_used; unsigned long derived_mem_used;
unsigned long derived_swap_used; unsigned long derived_swap_used;
// new with kernel 4.8
unsigned long ShmemHugePages;
unsigned long ShmemPmdMapped;
}; };
struct mem_hist { struct mem_hist {
@ -225,6 +229,12 @@ MEM_set(SWAP_FREE, ul_int, SwapFree)
MEM_set(SWAP_TOTAL, ul_int, SwapTotal) MEM_set(SWAP_TOTAL, ul_int, SwapTotal)
MEM_set(SWAP_USED, ul_int, derived_swap_used) 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 setDECL
#undef MEM_set #undef MEM_set
#undef HST_set #undef HST_set
@ -344,13 +354,19 @@ static struct {
{ RS(SWAP_TOTAL), TS(ul_int) }, { RS(SWAP_TOTAL), TS(ul_int) },
{ RS(SWAP_USED), 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 ... // dummy entry corresponding to MEMINFO_logical_end ...
{ NULL, NULL } { NULL, NULL }
}; };
/* please note, /* please note,
* this enum MUST be 1 greater than the highest value of any enum */ * 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 setNAME
#undef RS #undef RS
@ -527,6 +543,10 @@ static int make_hash_failed (
htVAL(Writeback) htVAL(Writeback)
htVAL(WritebackTmp) htVAL(WritebackTmp)
// new with kernel 4.8
htVAL(ShmemHugePages)
htVAL(ShmemPmdMapped)
return 0; return 0;
#undef htVAL #undef htVAL
#undef htXTRA #undef htXTRA

View File

@ -120,7 +120,14 @@ enum meminfo_item {
MEMINFO_SWAP_CACHED, // ul_int MEMINFO_SWAP_CACHED, // ul_int
MEMINFO_SWAP_FREE, // ul_int MEMINFO_SWAP_FREE, // ul_int
MEMINFO_SWAP_TOTAL, // 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
}; };