zsmalloc: move it under mm
authorMinchan Kim <minchan@kernel.org>
Thu, 30 Jan 2014 23:45:50 +0000 (15:45 -0800)
committerChanho Park <chanho61.park@samsung.com>
Tue, 18 Nov 2014 02:47:17 +0000 (11:47 +0900)
commit58cf58e2ec1c36f33c2bc06f3f381a2a3ecb1ea6
treee505bc041e86190e6cd41b4fff1c6f11f452212f
parent5a461c0448b1f3f5edeb87e9c096c54f12a8b209
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

[sjenning@linux.vnet.ibm.com: borrow Seth's quote]
Signed-off-by: Minchan Kim <minchan@kernel.org>
Acked-by: Nitin Gupta <ngupta@vflare.org>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Bob Liu <bob.liu@oracle.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Luigi Semenzato <semenzato@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Seth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Conflicts:
mm/Kconfig

Change-Id: I57dad090a3c48db4a67c88e6fa20a4bdbb82d984
drivers/staging/Kconfig
drivers/staging/Makefile
drivers/staging/zram/zram_drv.h
drivers/staging/zsmalloc/Kconfig [deleted file]
drivers/staging/zsmalloc/Makefile [deleted file]
include/linux/zsmalloc.h [moved from drivers/staging/zsmalloc/zsmalloc.h with 100% similarity]
mm/Kconfig
mm/Makefile
mm/zsmalloc.c [moved from drivers/staging/zsmalloc/zsmalloc-main.c with 99% similarity]