Skip to contentSkip to conversation

+ zsmalloc-move-it-under-mm.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Dec 11, 2013

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

Subject: + zsmalloc-move-it-under-mm.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Wed, 11 Dec 2013 15:57:38 -0800

The patch titled
Subject: zsmalloc: move it under mm
has been added to the -mm tree. Its filename is
zsmalloc-move-it-under-mm.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/zsmalloc-move-it-under-mm.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/zsmalloc-move-it-under-mm.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: Minchan Kim <[email protected]>
Subject: zsmalloc: move it under mm

This patch moves zsmalloc under mm directory.

Before that, description will explain why we have needed custom allocator.

Zsmalloc is a new slab-based memory allocator for storing compressed pages. It is designed for low fragmentation and high allocation success rate on large object, but <= PAGE_SIZE allocations.

zsmalloc differs from the kernel slab allocator in two primary ways to achieve these design goals.

zsmalloc never requires high order page allocations to back slabs, or "size classes" in zsmalloc terms. Instead it allows multiple single-order pages to be stitched together into a "zspage" which backs the slab. This allows for higher allocation success rate under memory pressure.

Also, zsmalloc allows objects to span page boundaries within the zspage. This allows for lower fragmentation than could be had with the kernel slab allocator for objects between PAGE_SIZE/2 and PAGE_SIZE. With the kernel slab allocator, if a page compresses to 60% of it original size, the memory savings gained through compression is lost in fragmentation because another object of the same size can't be stored in the leftover space.

This ability to span pages results in zsmalloc allocations not being directly addressable by the user. The user is given an non-dereferencable handle in response to an allocation request. That handle must be mapped, using zs_map_object(), which returns a pointer to the mapped region that can be used. The mapping is necessary since the object data may reside in two different noncontigious pages.

The zsmalloc fulfills the allocation needs for zram perfectly

[[email protected]: borrow Seth's quote]
Cc Bob Liu <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Jens Axboe <[email protected]>
Cc Luigi Semenzato <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Pekka Enberg <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Seth Jennings <[email protected]>

---

 drivers/staging/Kconfig                  |    2 
 drivers/staging/Makefile                 |    1 
 drivers/staging/zram/zram_drv.h          |    3 
 drivers/staging/zsmalloc/Kconfig         |   24 
 drivers/staging/zsmalloc/Makefile        |    3 
 drivers/staging/zsmalloc/zsmalloc-main.c | 1107 ---------------------
 drivers/staging/zsmalloc/zsmalloc.h      |   50 
 include/linux/zsmalloc.h                 |   50 
 mm/Kconfig                               |   25 
 mm/Makefile                              |    1 
 mm/zsmalloc.c                            | 1106 ++++++++++++++++++++
 11 files changed, 1183 insertions(+), 1189 deletions(-)
drivers/staging/Kconfig renamed from drivers/staging/Kconfig~zsmalloc-move-it-under-mm +0 -2
diff -puN drivers/staging/Kconfig~zsmalloc-move-it-under-mm drivers/staging/Kconfig
@@ -76,8 +76,6 @@ source "drivers/staging/sep/Kconfig"
 
 source "drivers/staging/iio/Kconfig"
 
-source "drivers/staging/zsmalloc/Kconfig"
-
 source "drivers/staging/zram/Kconfig"
 
 source "drivers/staging/wlags49_h2/Kconfig"
drivers/staging/Makefile renamed from drivers/staging/Makefile~zsmalloc-move-it-under-mm +0 -1
diff -puN drivers/staging/Makefile~zsmalloc-move-it-under-mm drivers/staging/Makefile
@@ -33,7 +33,6 @@ obj-$(CONFIG_VME_BUS)		+= vme/
 obj-$(CONFIG_DX_SEP)            += sep/
 obj-$(CONFIG_IIO)		+= iio/
 obj-$(CONFIG_ZRAM)		+= zram/
-obj-$(CONFIG_ZSMALLOC)		+= zsmalloc/
 obj-$(CONFIG_WLAGS49_H2)	+= wlags49_h2/
 obj-$(CONFIG_WLAGS49_H25)	+= wlags49_h25/
 obj-$(CONFIG_FB_SM7XX)		+= sm7xxfb/
drivers/staging/zram/zram_drv.h renamed from drivers/staging/zram/zram_drv.h~zsmalloc-move-it-under-mm +1 -2
diff -puN drivers/staging/zram/zram_drv.h~zsmalloc-move-it-under-mm drivers/staging/zram/zram_drv.h
@@ -17,8 +17,7 @@
 
 #include <linux/spinlock.h>
 #include <linux/mutex.h>
-
-#include "../zsmalloc/zsmalloc.h"
+#include <linux/zsmalloc.h>
 
 /*
  * Some arbitrary value. This is just to catch
drivers/staging/zsmalloc/Kconfig deleted +0 -24
diff -puN drivers/staging/zsmalloc/Kconfig~zsmalloc-move-it-under-mm /dev/null
@@ -1,24 +0,0 @@
-config ZSMALLOC
-	bool "Memory allocator for compressed pages"
-	depends on MMU
-	default n
-	help
-	  zsmalloc is a slab-based memory allocator designed to store
-	  compressed RAM pages.  zsmalloc uses virtual memory mapping
-	  in order to reduce fragmentation.  However, this results in a
-	  non-standard allocator interface where a handle, not a pointer, is
-	  returned by an alloc().  This handle must be mapped in order to
-	  access the allocated space.
-
-config PGTABLE_MAPPING
-	bool "Use page table mapping to access object in zsmalloc"
-	depends on ZSMALLOC
-	help
-	  By default, zsmalloc uses a copy-based object mapping method to
-	  access allocations that span two pages. However, if a particular
-	  architecture (ex, ARM) performs VM mapping faster than copying,
-	  then you should select this. This causes zsmalloc to use page table
-	  mapping rather than copying for object mapping.
-
-	  You can check speed with zsmalloc benchmark[1].
-	  [1] https://github.com/spartacus06/zsmalloc
drivers/staging/zsmalloc/Makefile deleted +0 -3
diff -puN drivers/staging/zsmalloc/Makefile~zsmalloc-move-it-under-mm /dev/null
@@ -1,3 +0,0 @@
-zsmalloc-y 		:= zsmalloc-main.o
-
-obj-$(CONFIG_ZSMALLOC)	+= zsmalloc.o
drivers/staging/zsmalloc/zsmalloc-main.c deleted +0 -1107

1,107 lines not on this page · raw message

drivers/staging/zsmalloc/zsmalloc.h deleted +0 -50

50 lines not on this page · raw message

include/linux/zsmalloc.h new file +50 -0

50 lines not on this page · raw message

mm/Kconfig renamed from mm/Kconfig~zsmalloc-move-it-under-mm +25 -0
diff -puN mm/Kconfig~zsmalloc-move-it-under-mm mm/Kconfig
@@ -552,3 +552,28 @@ config MEM_SOFT_DIRTY
 	  it can be cleared by hands.
 
 	  See Documentation/vm/soft-dirty.txt for more details.
+
+config ZSMALLOC
+	bool "Memory allocator for compressed pages"
+	depends on MMU
+	default n
+	help
+	  zsmalloc is a slab-based memory allocator designed to store
+	  compressed RAM pages.  zsmalloc uses virtual memory mapping
+	  in order to reduce fragmentation.  However, this results in a
+	  non-standard allocator interface where a handle, not a pointer, is
+	  returned by an alloc().  This handle must be mapped in order to
+	  access the allocated space.
+
+config PGTABLE_MAPPING
+	bool "Use page table mapping to access object in zsmalloc"
+	depends on ZSMALLOC
+	help
+	  By default, zsmalloc uses a copy-based object mapping method to
+	  access allocations that span two pages. However, if a particular
+	  architecture (ex, ARM) performs VM mapping faster than copying,
+	  then you should select this. This causes zsmalloc to use page table
+	  mapping rather than copying for object mapping.
+
+	  You can check speed with zsmalloc benchmark[1].
+	  [1] https://github.com/spartacus06/zsmalloc
mm/Makefile renamed from mm/Makefile~zsmalloc-move-it-under-mm +1 -0
diff -puN mm/Makefile~zsmalloc-move-it-under-mm mm/Makefile
@@ -60,3 +60,4 @@ obj-$(CONFIG_DEBUG_KMEMLEAK_TEST) += kme
 obj-$(CONFIG_CLEANCACHE) += cleancache.o
 obj-$(CONFIG_MEMORY_ISOLATION) += page_isolation.o
 obj-$(CONFIG_ZBUD)	+= zbud.o
+obj-$(CONFIG_ZSMALLOC)	+= zsmalloc.o
mm/zsmalloc.c new file +1106 -0

1,106 lines not on this page · raw message

_

Patches currently in -mm which might be from [email protected] are

mm-hugetlb-use-get_page_foll-in-follow_hugetlb_page.patch mm-hugetlbfs-move-the-put-get_page-slab-and-hugetlbfs-optimization-in-a-faster-path.patch mm-thp-optimize-compound_trans_huge.patch mm-tail-page-refcounting-optimization-for-slab-and-hugetlbfs.patch mm-hugetlbfs-use-__compound_tail_refcounted-in-__get_page_tail-too.patch mm-hugetlbc-simplify-pageheadhuge-and-pagehuge.patch mm-swapc-reorganize-put_compound_page.patch mm-hugetlbc-defer-pageheadhuge-symbol-export.patch x86-get-pg_data_ts-memory-from-other-node.patch memblock-numa-introduce-flags-field-into-memblock.patch memblock-mem_hotplug-introduce-memblock_hotplug-flag-to-mark-hotpluggable-regions.patch memblock-make-memblock_set_node-support-different-memblock_type.patch acpi-numa-mem_hotplug-mark-hotpluggable-memory-in-memblock.patch acpi-numa-mem_hotplug-mark-all-nodes-the-kernel-resides-un-hotpluggable.patch memblock-mem_hotplug-make-memblock-skip-hotpluggable-regions-if-needed.patch x86-numa-acpi-memory-hotplug-make-movable_node-have-higher-priority.patch swap-fix-setting-page_size-blocksize-during-swapoff-swapon-race.patch swap-add-a-simple-detector-for-inappropriate-swapin-readahead.patch linux-next.patch
zsmalloc-add-kconfig-for-enabling-page-table-method.patch zsmalloc-add-more-comment.patch
zsmalloc-move-it-under-mm.patch
zram-promote-zram-from-staging.patch debugging-keep-track-of-page-owners.patch