linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] staging: zsmalloc: remove SPARSEMEM dependency
@ 2012-03-05 17:33 Seth Jennings
  2012-03-05 17:33 ` [PATCH 1/5] staging: zsmalloc: move object/handle masking defines Seth Jennings
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Seth Jennings @ 2012-03-05 17:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Seth Jennings, Dan Magenheimer, Thadeu Lima de Souza Cascardo,
	Konrad Rzeszutek Wilk, Nitin Gupta, Robert Jennings, devel,
	linux-kernel, linux-mm

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(-)

-- 
1.7.5.4


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] staging: zsmalloc: move object/handle masking defines
  2012-03-05 17:33 [PATCH 0/5] staging: zsmalloc: remove SPARSEMEM dependency Seth Jennings
@ 2012-03-05 17:33 ` Seth Jennings
  2012-03-05 17:33 ` [PATCH 2/5] staging: zsmalloc: add ZS_MAX_PAGES_PER_ZSPAGE Seth Jennings
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Seth Jennings @ 2012-03-05 17:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Seth Jennings, Dan Magenheimer, Konrad Rzeszutek Wilk,
	Nitin Gupta, Robert Jennings, devel, linux-kernel, linux-mm

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

Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
---
 drivers/staging/zsmalloc/zsmalloc-main.c |   12 ------------
 drivers/staging/zsmalloc/zsmalloc_int.h  |   12 ++++++++++++
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
index 455fc2f..240bcbf 100644
--- a/drivers/staging/zsmalloc/zsmalloc-main.c
+++ b/drivers/staging/zsmalloc/zsmalloc-main.c
@@ -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);
 
diff --git a/drivers/staging/zsmalloc/zsmalloc_int.h b/drivers/staging/zsmalloc/zsmalloc_int.h
index 354a020..e06e142 100644
--- a/drivers/staging/zsmalloc/zsmalloc_int.h
+++ b/drivers/staging/zsmalloc/zsmalloc_int.h
@@ -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
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] staging: zsmalloc: add ZS_MAX_PAGES_PER_ZSPAGE
  2012-03-05 17:33 [PATCH 0/5] staging: zsmalloc: remove SPARSEMEM dependency Seth Jennings
  2012-03-05 17:33 ` [PATCH 1/5] staging: zsmalloc: move object/handle masking defines Seth Jennings
@ 2012-03-05 17:33 ` Seth Jennings
  2012-03-05 17:33 ` [PATCH 3/5] staging: zsmalloc: calculate MAX_PHYSMEM_BITS if not defined Seth Jennings
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Seth Jennings @ 2012-03-05 17:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Seth Jennings, Dan Magenheimer, Konrad Rzeszutek Wilk,
	Nitin Gupta, Robert Jennings, devel, linux-kernel, linux-mm

This 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.

Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
---
 drivers/staging/zsmalloc/zsmalloc-main.c |    2 +-
 drivers/staging/zsmalloc/zsmalloc_int.h  |   13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
index 240bcbf..09caa4f 100644
--- a/drivers/staging/zsmalloc/zsmalloc-main.c
+++ b/drivers/staging/zsmalloc/zsmalloc-main.c
@@ -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;
 
diff --git a/drivers/staging/zsmalloc/zsmalloc_int.h b/drivers/staging/zsmalloc/zsmalloc_int.h
index e06e142..4d66d2d 100644
--- a/drivers/staging/zsmalloc/zsmalloc_int.h
+++ b/drivers/staging/zsmalloc/zsmalloc_int.h
@@ -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 {
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] staging: zsmalloc: calculate MAX_PHYSMEM_BITS if not defined
  2012-03-05 17:33 [PATCH 0/5] staging: zsmalloc: remove SPARSEMEM dependency Seth Jennings
  2012-03-05 17:33 ` [PATCH 1/5] staging: zsmalloc: move object/handle masking defines Seth Jennings
  2012-03-05 17:33 ` [PATCH 2/5] staging: zsmalloc: add ZS_MAX_PAGES_PER_ZSPAGE Seth Jennings
@ 2012-03-05 17:33 ` Seth Jennings
  2012-03-05 17:33 ` [PATCH 4/5] staging: zsmalloc: change ZS_MIN_ALLOC_SIZE Seth Jennings
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Seth Jennings @ 2012-03-05 17:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Seth Jennings, Dan Magenheimer, Konrad Rzeszutek Wilk,
	Nitin Gupta, Robert Jennings, devel, linux-kernel, linux-mm

This 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)

Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
---
 drivers/staging/zsmalloc/zsmalloc_int.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/zsmalloc/zsmalloc_int.h b/drivers/staging/zsmalloc/zsmalloc_int.h
index 4d66d2d..ffb272f 100644
--- a/drivers/staging/zsmalloc/zsmalloc_int.h
+++ b/drivers/staging/zsmalloc/zsmalloc_int.h
@@ -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)
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] staging: zsmalloc: change ZS_MIN_ALLOC_SIZE
  2012-03-05 17:33 [PATCH 0/5] staging: zsmalloc: remove SPARSEMEM dependency Seth Jennings
                   ` (2 preceding siblings ...)
  2012-03-05 17:33 ` [PATCH 3/5] staging: zsmalloc: calculate MAX_PHYSMEM_BITS if not defined Seth Jennings
@ 2012-03-05 17:33 ` Seth Jennings
  2012-03-05 17:33 ` [PATCH 5/5] staging: zsmalloc: remove SPARSEMEM dep from Kconfig Seth Jennings
  2012-03-05 18:07 ` [PATCH 0/5] staging: zsmalloc: remove SPARSEMEM dependency Nitin Gupta
  5 siblings, 0 replies; 7+ messages in thread
From: Seth Jennings @ 2012-03-05 17:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Seth Jennings, Dan Magenheimer, Konrad Rzeszutek Wilk,
	Nitin Gupta, Robert Jennings, devel, linux-kernel, linux-mm

This 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.

Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
---
 drivers/staging/zsmalloc/zsmalloc_int.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/zsmalloc/zsmalloc_int.h b/drivers/staging/zsmalloc/zsmalloc_int.h
index ffb272f..92eefc6 100644
--- a/drivers/staging/zsmalloc/zsmalloc_int.h
+++ b/drivers/staging/zsmalloc/zsmalloc_int.h
@@ -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
 
 /*
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] staging: zsmalloc: remove SPARSEMEM dep from Kconfig
  2012-03-05 17:33 [PATCH 0/5] staging: zsmalloc: remove SPARSEMEM dependency Seth Jennings
                   ` (3 preceding siblings ...)
  2012-03-05 17:33 ` [PATCH 4/5] staging: zsmalloc: change ZS_MIN_ALLOC_SIZE Seth Jennings
@ 2012-03-05 17:33 ` Seth Jennings
  2012-03-05 18:07 ` [PATCH 0/5] staging: zsmalloc: remove SPARSEMEM dependency Nitin Gupta
  5 siblings, 0 replies; 7+ messages in thread
From: Seth Jennings @ 2012-03-05 17:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Seth Jennings, Dan Magenheimer, Konrad Rzeszutek Wilk,
	Nitin Gupta, Robert Jennings, devel, linux-kernel, linux-mm

This patch removes the SPARSEMEM from the zsmalloc
Kconfig

Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
---
 drivers/staging/zsmalloc/Kconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/zsmalloc/Kconfig b/drivers/staging/zsmalloc/Kconfig
index 8e2c6a0..a5ab720 100644
--- a/drivers/staging/zsmalloc/Kconfig
+++ b/drivers/staging/zsmalloc/Kconfig
@@ -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
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/5] staging: zsmalloc: remove SPARSEMEM dependency
  2012-03-05 17:33 [PATCH 0/5] staging: zsmalloc: remove SPARSEMEM dependency Seth Jennings
                   ` (4 preceding siblings ...)
  2012-03-05 17:33 ` [PATCH 5/5] staging: zsmalloc: remove SPARSEMEM dep from Kconfig Seth Jennings
@ 2012-03-05 18:07 ` Nitin Gupta
  5 siblings, 0 replies; 7+ messages in thread
From: Nitin Gupta @ 2012-03-05 18:07 UTC (permalink / raw)
  To: Seth Jennings
  Cc: Greg Kroah-Hartman, Dan Magenheimer,
	Thadeu Lima de Souza Cascardo, Konrad Rzeszutek Wilk,
	Robert Jennings, devel, linux-kernel, linux-mm

On 03/05/2012 12:33 PM, Seth Jennings wrote:

> 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(-)
> 


For the entire series:

Acked-by: Nitin Gupta <ngupta@vflare.org>


Thanks for the fixes.
Nitin

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-03-05 18:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-05 17:33 [PATCH 0/5] staging: zsmalloc: remove SPARSEMEM dependency Seth Jennings
2012-03-05 17:33 ` [PATCH 1/5] staging: zsmalloc: move object/handle masking defines Seth Jennings
2012-03-05 17:33 ` [PATCH 2/5] staging: zsmalloc: add ZS_MAX_PAGES_PER_ZSPAGE Seth Jennings
2012-03-05 17:33 ` [PATCH 3/5] staging: zsmalloc: calculate MAX_PHYSMEM_BITS if not defined Seth Jennings
2012-03-05 17:33 ` [PATCH 4/5] staging: zsmalloc: change ZS_MIN_ALLOC_SIZE Seth Jennings
2012-03-05 17:33 ` [PATCH 5/5] staging: zsmalloc: remove SPARSEMEM dep from Kconfig Seth Jennings
2012-03-05 18:07 ` [PATCH 0/5] staging: zsmalloc: remove SPARSEMEM dependency Nitin Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).