diff options
author | chrisrd <[email protected]> | 2018-02-24 03:50:06 +1100 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-02-23 08:50:06 -0800 |
commit | e9a77290081b578144e9a911ad734f67274df82f (patch) | |
tree | 29036268b80f1a2695867d079e2a4facf916a616 /include | |
parent | 7088545d0166aa05b2c783f18aa821d95a1f023d (diff) |
Fix free memory calculation on v3.14+
Provide infrastructure to auto-configure to enum and API changes in the
global page stats used for our free memory calculations.
arc_free_memory has been broken since an API change in Linux v3.14:
2016-07-28 v4.8 599d0c95 mm, vmscan: move LRU lists to node
2016-07-28 v4.8 75ef7184 mm, vmstat: add infrastructure for per-node
vmstats
These commits moved some of global_page_state() into
global_node_page_state(). The API change was particularly egregious as,
instead of breaking the old code, it silently did the wrong thing and we
continued using global_page_state() where we should have been using
global_node_page_state(), thus indexing into the wrong array via
NR_SLAB_RECLAIMABLE et al.
There have been further API changes along the way:
2017-07-06 v4.13 385386cf mm: vmstat: move slab statistics from zone to
node counters
2017-09-06 v4.14 c41f012a mm: rename global_page_state to
global_zone_page_state
...and various (incomplete, as it turns out) attempts to accomodate
these changes in ZoL:
2017-08-24 2209e409 Linux 4.8+ compatibility fix for vm stats
2017-09-16 787acae0 Linux 3.14 compat: IO acct, global_page_state, etc
2017-09-19 661907e6 Linux 4.14 compat: IO acct, global_page_state, etc
The config infrastructure provided here resolves these issues going back
to the original API change in v3.14 and is robust against further Linux
changes in this area.
Reviewed-by: Giuseppe Di Natale <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Signed-off-by: Chris Dunlop <[email protected]>
Closes #7170
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/Makefile.am | 3 | ||||
-rw-r--r-- | include/linux/page_compat.h | 78 |
2 files changed, 80 insertions, 1 deletions
diff --git a/include/linux/Makefile.am b/include/linux/Makefile.am index 9bb0b3493..89c2689f6 100644 --- a/include/linux/Makefile.am +++ b/include/linux/Makefile.am @@ -9,7 +9,8 @@ KERNEL_H = \ $(top_srcdir)/include/linux/kmap_compat.h \ $(top_srcdir)/include/linux/simd_x86.h \ $(top_srcdir)/include/linux/simd_aarch64.h \ - $(top_srcdir)/include/linux/mod_compat.h + $(top_srcdir)/include/linux/mod_compat.h \ + $(top_srcdir)/include/linux/page_compat.h USER_H = diff --git a/include/linux/page_compat.h b/include/linux/page_compat.h new file mode 100644 index 000000000..95acb7d53 --- /dev/null +++ b/include/linux/page_compat.h @@ -0,0 +1,78 @@ +#ifndef _ZFS_PAGE_COMPAT_H +#define _ZFS_PAGE_COMPAT_H + +/* + * We have various enum members moving between two separate enum types, + * and accessed by different functions at various times. Centralise the + * insanity. + * + * < v4.8: all enums in zone_stat_item, via global_page_state() + * v4.8: some enums moved to node_stat_item, global_node_page_state() introduced + * v4.13: some enums moved from zone_stat_item to node_state_item + * v4.14: global_page_state() rename to global_zone_page_state() + * + * The defines used here are created by config/kernel-global_page_state.m4 + */ + +/* + * Create our own accessor functions to follow the Linux API changes + */ +#if defined(ZFS_GLOBAL_ZONE_PAGE_STATE) + +/* global_zone_page_state() introduced */ +#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_FILE_PAGES) +#define nr_file_pages() global_node_page_state(NR_FILE_PAGES) +#else +#define nr_file_pages() global_zone_page_state(NR_FILE_PAGES) +#endif +#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_INACTIVE_ANON) +#define nr_inactive_anon_pages() global_node_page_state(NR_INACTIVE_ANON) +#else +#define nr_inactive_anon_pages() global_zone_page_state(NR_INACTIVE_ANON) +#endif +#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_INACTIVE_FILE) +#define nr_inactive_file_pages() global_node_page_state(NR_INACTIVE_FILE) +#else +#define nr_inactive_file_pages() global_zone_page_state(NR_INACTIVE_FILE) +#endif +#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_SLAB_RECLAIMABLE) +#define nr_slab_reclaimable_pages() global_node_page_state(NR_SLAB_RECLAIMABLE) +#else +#define nr_slab_reclaimable_pages() global_zone_page_state(NR_SLAB_RECLAIMABLE) +#endif + +#elif defined(ZFS_GLOBAL_NODE_PAGE_STATE) + +/* global_node_page_state() introduced */ +#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_FILE_PAGES) +#define nr_file_pages() global_node_page_state(NR_FILE_PAGES) +#else +#define nr_file_pages() global_page_state(NR_FILE_PAGES) +#endif +#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_INACTIVE_ANON) +#define nr_inactive_anon_pages() global_node_page_state(NR_INACTIVE_ANON) +#else +#define nr_inactive_anon_pages() global_page_state(NR_INACTIVE_ANON) +#endif +#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_INACTIVE_FILE) +#define nr_inactive_file_pages() global_node_page_state(NR_INACTIVE_FILE) +#else +#define nr_inactive_file_pages() global_page_state(NR_INACTIVE_FILE) +#endif +#if defined(ZFS_ENUM_NODE_STAT_ITEM_NR_SLAB_RECLAIMABLE) +#define nr_slab_reclaimable_pages() global_node_page_state(NR_SLAB_RECLAIMABLE) +#else +#define nr_slab_reclaimable_pages() global_page_state(NR_SLAB_RECLAIMABLE) +#endif + +#else + +/* global_page_state() only */ +#define nr_file_pages() global_page_state(NR_FILE_PAGES) +#define nr_inactive_anon_pages() global_page_state(NR_INACTIVE_ANON) +#define nr_inactive_file_pages() global_page_state(NR_INACTIVE_FILE) +#define nr_slab_reclaimable_pages() global_page_state(NR_SLAB_RECLAIMABLE) + +#endif /* ZFS_GLOBAL_ZONE_PAGE_STATE */ + +#endif /* _ZFS_PAGE_COMPAT_H */ |