Signed-off-by: Anatol Pomozov <anatol.pomozov(a)gmail.com>
---
memory.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/memory.c b/memory.c
index b57c1ed..56df54a 100755
--- a/memory.c
+++ b/memory.c
@@ -323,6 +323,7 @@ vm_init(void)
int i, len, dimension;
struct syment *sp_array[2];
ulong value1, value2;
+ char *kmem_cache_node_struct;
MEMBER_OFFSET_INIT(task_struct_mm, "task_struct", "mm");
MEMBER_OFFSET_INIT(mm_struct_mmap, "mm_struct", "mmap");
@@ -548,10 +549,12 @@ vm_init(void)
if (MEMBER_EXISTS("kmem_cache", "lists"))
MEMBER_OFFSET_INIT(kmem_cache_s_lists, "kmem_cache", "lists");
- else if (MEMBER_EXISTS("kmem_cache", "nodelists")) {
+ else if (MEMBER_EXISTS("kmem_cache", "nodelists") ||
+ MEMBER_EXISTS("kmem_cache", "node")) {
+ char *nodelists_field = MEMBER_EXISTS("kmem_cache", "node") ?
"node" : "nodelists";
vt->flags |= PERCPU_KMALLOC_V2_NODES;
- MEMBER_OFFSET_INIT(kmem_cache_s_lists, "kmem_cache",
"nodelists");
- if (MEMBER_TYPE("kmem_cache", "nodelists") == TYPE_CODE_PTR) {
+ MEMBER_OFFSET_INIT(kmem_cache_s_lists, "kmem_cache", nodelists_field);
+ if (MEMBER_TYPE("kmem_cache", nodelists_field) == TYPE_CODE_PTR) {
int nr_node_ids;
/*
* nodelists now a pointer to an outside array
@@ -563,9 +566,12 @@ vm_init(void)
vt->kmem_cache_len_nodes = nr_node_ids;
} else
vt->kmem_cache_len_nodes = 1;
- } else
+ } else {
+ // This should never happen with kmem_cache.node,
+ // only with kmem_cache.nodelists
ARRAY_LENGTH_INIT(vt->kmem_cache_len_nodes, NULL,
"kmem_cache.nodelists", NULL, 0);
+ }
}
MEMBER_OFFSET_INIT(kmem_cache_s_array, "kmem_cache", "array");
ARRAY_LENGTH_INIT(len, NULL, "kmem_cache.array", NULL, 0);
@@ -590,15 +596,17 @@ vm_init(void)
MEMBER_OFFSET_INIT(array_cache_limit, "array_cache", "limit");
STRUCT_SIZE_INIT(array_cache, "array_cache");
+ // kmem_list3 renamed to kmem_cache_node in kernel 3.10
+ kmem_cache_node_struct = STRUCT_EXISTS("kmem_cache_node") ?
"kmem_cache_node" : "kmem_list3";
MEMBER_OFFSET_INIT(kmem_list3_slabs_partial,
- "kmem_list3", "slabs_partial");
+ kmem_cache_node_struct, "slabs_partial");
MEMBER_OFFSET_INIT(kmem_list3_slabs_full,
- "kmem_list3", "slabs_full");
+ kmem_cache_node_struct, "slabs_full");
MEMBER_OFFSET_INIT(kmem_list3_slabs_free,
- "kmem_list3", "slabs_free");
+ kmem_cache_node_struct, "slabs_free");
MEMBER_OFFSET_INIT(kmem_list3_free_objects,
- "kmem_list3", "free_objects");
- MEMBER_OFFSET_INIT(kmem_list3_shared, "kmem_list3", "shared");
+ kmem_cache_node_struct, "free_objects");
+ MEMBER_OFFSET_INIT(kmem_list3_shared, kmem_cache_node_struct, "shared");
} else if (MEMBER_EXISTS("kmem_cache", "cpu_slab") &&
STRUCT_EXISTS("kmem_cache_node")) {
vt->flags |= KMALLOC_SLUB;
--
1.8.3