staging: zsmalloc: remove SPARSEMEM dependency
Subsystems (2)
cover staging: zsmalloc: remove SPARSEMEM dependency
This patch series removes the dependency zsmalloc has on SPARSEMEM; more specifically the assumption that MAX_PHYSMEM_BITS is defined.
Based on greg/staging-next.
Seth Jennings (5):
staging: zsmalloc: move object/handle masking defines
staging: zsmalloc: add ZS_MAX_PAGES_PER_ZSPAGE
staging: zsmalloc: calculate MAX_PHYSMEM_BITS if not defined
staging: zsmalloc: change ZS_MIN_ALLOC_SIZE
staging: zsmalloc: remove SPARSEMEM dep from Kconfig
drivers/staging/zsmalloc/Kconfig | 2 +- drivers/staging/zsmalloc/zsmalloc-main.c | 14 +--------- drivers/staging/zsmalloc/zsmalloc_int.h | 43 +++++++++++++++++++++++++----- 3 files changed, 38 insertions(+), 21 deletions(-)
Signature · 8 lines
1.7.5.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/5 staging: zsmalloc: move object/handle masking defines
This patch moves the definitions of _PFN_BITS, OBJ_INDEX_BITS and OBJ_INDEX_MASK from zsmalloc-main.c to zsmalloc_int.h
They will be needed to determine ZS_MIN_ALLOC_SIZE in the next patch
--- drivers/staging/zsmalloc/zsmalloc-main.c | 12 ------------ drivers/staging/zsmalloc/zsmalloc_int.h | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/staging/zsmalloc/zsmalloc-main.c +0 -12
@@ -40,18 +40,6 @@#define CLASS_IDX_MASK ((1 << CLASS_IDX_BITS) - 1)#define FULLNESS_MASK ((1 << FULLNESS_BITS) - 1) -/* -* Object location (<PFN>, <obj_idx>) is encoded as -* as single (void *) handle value. -* -* Note that object index <obj_idx> is relative to system -* page <PFN> it is stored in, so for each sub-page belonging -* to a zspage, obj_idx starts with 0. -*/ -#define _PFN_BITS (MAX_PHYSMEM_BITS - PAGE_SHIFT) -#define OBJ_INDEX_BITS (BITS_PER_LONG - _PFN_BITS) -#define OBJ_INDEX_MASK ((_AC(1, UL) << OBJ_INDEX_BITS) - 1) -/* per-cpu VM mapping areas for zspage accesses that cross page boundaries */ static DEFINE_PER_CPU(struct mapping_area, zs_map_area);
drivers/staging/zsmalloc/zsmalloc_int.h +12 -0
@@ -25,6 +25,18 @@*/ #define ZS_ALIGN 8 +/* +* Object location (<PFN>, <obj_idx>) is encoded as +* as single (void *) handle value. +* +* Note that object index <obj_idx> is relative to system +* page <PFN> it is stored in, so for each sub-page belonging +* to a zspage, obj_idx starts with 0. +*/ +#define _PFN_BITS (MAX_PHYSMEM_BITS - PAGE_SHIFT) +#define OBJ_INDEX_BITS (BITS_PER_LONG - _PFN_BITS) +#define OBJ_INDEX_MASK ((_AC(1, UL) << OBJ_INDEX_BITS) - 1) +/* ZS_MIN_ALLOC_SIZE must be multiple of ZS_ALIGN */ #define ZS_MIN_ALLOC_SIZE 32#define ZS_MAX_ALLOC_SIZE PAGE_SIZE
Signature · 8 lines
1.7.5.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/5 staging: zsmalloc: add ZS_MAX_PAGES_PER_ZSPAGE
In reply to Seth JenningsThis patch moves where max_zspage_order is declared and changes its meaning. "Order" typically implies 2^order
of something; however, it is currently being used as the "maximum number of single pages in a zspage". To add clarity, ZS_MAX_ZSPAGE_ORDER is now used to calculate ZS_MAX_PAGES_PER_ZSPAGE, which is 2^ZS_MAX_ZSPAGE_ORDER and is the upper bound on the number of pages in a zspage.
--- drivers/staging/zsmalloc/zsmalloc-main.c | 2 +- drivers/staging/zsmalloc/zsmalloc_int.h | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-)
drivers/staging/zsmalloc/zsmalloc-main.c +1 -1
@@ -186,7 +186,7 @@ static int get_zspage_order(int class_size)/* zspage order which gives maximum used size per KB */ int max_usedpc_order =1 ; -for (i =1 ; i <= max_zspage_order; i++) { +for (i =1 ; i <=ZS_MAX_PAGES_PER_ZSPAGE ; i++) {int zspage_size;int waste, usedpc;
drivers/staging/zsmalloc/zsmalloc_int.h +7 -6
@@ -26,6 +26,13 @@#define ZS_ALIGN 8/* +* A single 'zspage' is composed of up to 2^N discontiguous 0-order (single) +* pages. ZS_MAX_ZSPAGE_ORDER defines upper limit on N. +*/ +#define ZS_MAX_ZSPAGE_ORDER 2 +#define ZS_MAX_PAGES_PER_ZSPAGE (_AC(1, UL) << ZS_MAX_ZSPAGE_ORDER) + +/* * Object location (<PFN>, <obj_idx>) is encoded as * as single (void *) handle value. *
@@ -59,12 +66,6 @@ ZS_SIZE_CLASS_DELTA + 1)/* -* A single 'zspage' is composed of N discontiguous 0-order (single) pages. -* This defines upper limit on N. -*/ -static const int max_zspage_order =4 ; - -/* * We do not maintain any list for completely empty or full pages */ enum fullness_group {
Signature · 8 lines
1.7.5.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/5 staging: zsmalloc: calculate MAX_PHYSMEM_BITS if not defined
In reply to Seth JenningsThis patch provides a way to determine or "set a reasonable value for" MAX_PHYSMEM_BITS in the case that it is not defined (i.e. !SPARSEMEM)
--- drivers/staging/zsmalloc/zsmalloc_int.h | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
drivers/staging/zsmalloc/zsmalloc_int.h +14 -0
@@ -39,7 +39,21 @@* Note that object index <obj_idx> is relative to system * page <PFN> it is stored in, so for each sub-page belonging * to a zspage, obj_idx starts with 0. +* +* This is made more complicated by various memory models and PAE. +*/ + +#ifndef MAX_PHYSMEM_BITS +#ifdef CONFIG_HIGHMEM64G +#define MAX_PHYSMEM_BITS 36 +#else /* !CONFIG_HIGHMEM64G */ +/* +* If this definition of MAX_PHYSMEM_BITS is used, OBJ_INDEX_BITS will just +* be PAGE_SHIFT */ +#define MAX_PHYSMEM_BITS BITS_PER_LONG +#endif +#endif #define _PFN_BITS (MAX_PHYSMEM_BITS - PAGE_SHIFT)#define OBJ_INDEX_BITS (BITS_PER_LONG - _PFN_BITS)#define OBJ_INDEX_MASK ((_AC(1, UL) << OBJ_INDEX_BITS) - 1)
Signature · 8 lines
1.7.5.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/5 staging: zsmalloc: change ZS_MIN_ALLOC_SIZE
In reply to Seth JenningsThis patch ensures that the value of ZS_MIN_ALLOC_SIZE, for the PAGE_SIZE and MAX_PHYSMEM_BITS on the system, allows for all possible object ids in the lowest storage class to be encoded in the object handle.
--- drivers/staging/zsmalloc/zsmalloc_int.h | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/staging/zsmalloc/zsmalloc_int.h +3 -1
@@ -58,8 +58,10 @@#define OBJ_INDEX_BITS (BITS_PER_LONG - _PFN_BITS)#define OBJ_INDEX_MASK ((_AC(1, UL) << OBJ_INDEX_BITS) - 1) +#define MAX (a, b) ((a) >= (b) ? (a) : (b))/* ZS_MIN_ALLOC_SIZE must be multiple of ZS_ALIGN */ -#define ZS_MIN_ALLOC_SIZE 32 +#define ZS_MIN_ALLOC_SIZE \ + MAX(32, (ZS_MAX_PAGES_PER_ZSPAGE << PAGE_SHIFT >> OBJ_INDEX_BITS))#define ZS_MAX_ALLOC_SIZE PAGE_SIZE/*
Signature · 8 lines
1.7.5.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 5/5 staging: zsmalloc: remove SPARSEMEM dep from Kconfig
In reply to Seth JenningsThis patch removes the SPARSEMEM from the zsmalloc Kconfig
--- drivers/staging/zsmalloc/Kconfig | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/zsmalloc/Kconfig +1 -1
@@ -3,7 +3,7 @@ config ZSMALLOC # X86 dependency is because of the use of __flush_tlb_one and set_pte # in zsmalloc-main.c. # TODO: convert these to portable functions - depends on SPARSEMEM && X86 + depends on X86 default n help zsmalloc is a slab-based memory allocator designed to store
Signature · 1 line
1.7.5.4
Quoted 12 lines · Seth Jennings
This patch series removes the dependency zsmalloc has on SPARSEMEM; more specifically the assumption that
MAX_PHYSMEM_BITSis defined.Based on greg/staging-next.
Seth Jennings (5):
staging: zsmalloc: move object/handle masking defines
staging: zsmalloc: addZS_MAX_PAGES_PER_ZSPAGE
staging: zsmalloc: calculateMAX_PHYSMEM_BITSif not defined
staging: zsmalloc: changeZS_MIN_ALLOC_SIZE
staging: zsmalloc: remove SPARSEMEM dep fromKconfig
Quoted 5 lines
drivers/staging/zsmalloc/Kconfig | 2 +- drivers/staging/zsmalloc/zsmalloc-main.c | 14 +--------- drivers/staging/zsmalloc/zsmalloc_int.h | 43 +++++++++++++++++++++++++----- 3 files changed, 38 insertions(+), 21 deletions(-)
For the entire series:
Thanks for the fixes.
Nitin
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>