From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754912Ab3A1Vzx (ORCPT ); Mon, 28 Jan 2013 16:55:53 -0500 Received: from e34.co.us.ibm.com ([32.97.110.152]:53473 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754743Ab3A1Vzp (ORCPT ); Mon, 28 Jan 2013 16:55:45 -0500 From: Seth Jennings To: Andrew Morton Cc: Seth Jennings , Greg Kroah-Hartman , Nitin Gupta , Minchan Kim , Konrad Rzeszutek Wilk , Dan Magenheimer , Robert Jennings , Jenifer Hopper , Mel Gorman , Johannes Weiner , Rik van Riel , Larry Woodman , Benjamin Herrenschmidt , Dave Hansen , linux-mm@kvack.org, linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org Subject: [PATCHv3 2/6] zsmalloc: promote to lib/ Date: Mon, 28 Jan 2013 15:49:23 -0600 Message-Id: <1359409767-30092-3-git-send-email-sjenning@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1359409767-30092-1-git-send-email-sjenning@linux.vnet.ibm.com> References: <1359409767-30092-1-git-send-email-sjenning@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13012821-2876-0000-0000-000004A15127 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch promotes the slab-based zsmalloc memory allocator from the staging tree to lib/ zswap depends on this allocator for storing compressed RAM pages in an efficient way under system wide memory pressure where high-order (greater than 0) page allocation are very likely to fail. For more information on zsmalloc and its internals, read the documentation at the top of the zsmalloc.c file. Signed-off-by: Seth Jennings -- This patch is similar to a patch Minchan has on out on the list to promote for use in zram. --- drivers/staging/Kconfig | 2 -- drivers/staging/Makefile | 1 - drivers/staging/zcache/zcache-main.c | 3 +-- drivers/staging/zram/zram_drv.h | 3 +-- drivers/staging/zsmalloc/Kconfig | 10 ---------- drivers/staging/zsmalloc/Makefile | 3 --- .../staging/zsmalloc => include/linux}/zsmalloc.h | 0 lib/Kconfig | 18 ++++++++++++++++++ lib/Makefile | 1 + .../zsmalloc/zsmalloc-main.c => lib/zsmalloc.c | 3 +-- 10 files changed, 22 insertions(+), 22 deletions(-) delete mode 100644 drivers/staging/zsmalloc/Kconfig delete mode 100644 drivers/staging/zsmalloc/Makefile rename {drivers/staging/zsmalloc => include/linux}/zsmalloc.h (100%) rename drivers/staging/zsmalloc/zsmalloc-main.c => lib/zsmalloc.c (99%) diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 329bdb4..c0a7918 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -76,8 +76,6 @@ source "drivers/staging/zram/Kconfig" source "drivers/staging/zcache/Kconfig" -source "drivers/staging/zsmalloc/Kconfig" - source "drivers/staging/wlags49_h2/Kconfig" source "drivers/staging/wlags49_h25/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index c7ec486..1572fe5 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -32,7 +32,6 @@ obj-$(CONFIG_DX_SEP) += sep/ obj-$(CONFIG_IIO) += iio/ obj-$(CONFIG_ZRAM) += zram/ obj-$(CONFIG_ZCACHE) += zcache/ -obj-$(CONFIG_ZSMALLOC) += zsmalloc/ obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/ obj-$(CONFIG_WLAGS49_H25) += wlags49_h25/ obj-$(CONFIG_FB_SM7XX) += sm7xxfb/ diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c index 52b43b7..75c08c5 100644 --- a/drivers/staging/zcache/zcache-main.c +++ b/drivers/staging/zcache/zcache-main.c @@ -32,10 +32,9 @@ #include #include #include +#include #include "tmem.h" -#include "../zsmalloc/zsmalloc.h" - #ifdef CONFIG_CLEANCACHE #include #endif diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h index df2eec4..1e72965 100644 --- a/drivers/staging/zram/zram_drv.h +++ b/drivers/staging/zram/zram_drv.h @@ -17,8 +17,7 @@ #include #include - -#include "../zsmalloc/zsmalloc.h" +#include /* * Some arbitrary value. This is just to catch diff --git a/drivers/staging/zsmalloc/Kconfig b/drivers/staging/zsmalloc/Kconfig deleted file mode 100644 index 9084565..0000000 --- a/drivers/staging/zsmalloc/Kconfig +++ /dev/null @@ -1,10 +0,0 @@ -config ZSMALLOC - tristate "Memory allocator for compressed pages" - 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. diff --git a/drivers/staging/zsmalloc/Makefile b/drivers/staging/zsmalloc/Makefile deleted file mode 100644 index b134848..0000000 --- a/drivers/staging/zsmalloc/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -zsmalloc-y := zsmalloc-main.o - -obj-$(CONFIG_ZSMALLOC) += zsmalloc.o diff --git a/drivers/staging/zsmalloc/zsmalloc.h b/include/linux/zsmalloc.h similarity index 100% rename from drivers/staging/zsmalloc/zsmalloc.h rename to include/linux/zsmalloc.h diff --git a/lib/Kconfig b/lib/Kconfig index 75cdb77..fdab273 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -219,6 +219,24 @@ config DECOMPRESS_LZO config GENERIC_ALLOCATOR boolean +config ZSMALLOC + tristate "Memory allocator for compressed pages" + default n + help + zsmalloc is a slab-based memory allocator designed to store + compressed RAM pages. zsmalloc uses a memory pool that combines + single pages into higher order pages by linking them together + using the fields of the struct page. Allocations are then + mapped through copy buffers or VM mapping, in order to reduce + memory pool fragmentation and increase allocation success rate under + memory pressure. + + This results in a non-standard allocator interface where + a handle, not a pointer, is returned by the allocation function. + This handle must be mapped in order to access the allocated space. + + If unsure, say N. + # # reed solomon support is select'ed if needed # diff --git a/lib/Makefile b/lib/Makefile index 02ed6c0..70b0892 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -65,6 +65,7 @@ obj-$(CONFIG_CRC7) += crc7.o obj-$(CONFIG_LIBCRC32C) += libcrc32c.o obj-$(CONFIG_CRC8) += crc8.o obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o +obj-$(CONFIG_ZSMALLOC) += zsmalloc.o obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/ obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/ diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/lib/zsmalloc.c similarity index 99% rename from drivers/staging/zsmalloc/zsmalloc-main.c rename to lib/zsmalloc.c index 13018b7..d5146c7 100644 --- a/drivers/staging/zsmalloc/zsmalloc-main.c +++ b/lib/zsmalloc.c @@ -78,8 +78,7 @@ #include #include #include - -#include "zsmalloc.h" +#include /* * This must be power of 2 and greater than of equal to sizeof(link_free). -- 1.7.9.5