aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/zcache (follow)
AgeCommit message (Collapse)AuthorFilesLines
2012-09-16Merge 3.6-rc6 into staging-nextGreg Kroah-Hartman1-4/+3
This pulls in the staging tree fixes in 3.6-rc6 into our branch to resolve the merge issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-05staging: zcache: fix cleancache race condition with shrinkerSeth Jennings1-4/+3
This patch fixes a race condition that results in memory corruption when using cleancache. The race exists between the zcache shrinker handler, shrink_zcache_memory() and cleancache_get_page(). In most cases, the shrinker will both evict a zbpg from its buddy list and flush it from tmem before a cleancache_get_page() occurs on that page. A subsequent cleancache_get_page() will fail in the tmem layer. In the rare case that two occur together and the cleancache_get_page() path gets through the tmem layer before the shrinker path can flush tmem, zbud_decompress() does a check to see if the zbpg is a "zombie", i.e. not on a buddy list, which means the shrinker is in the process of reclaiming it. If the zbpg is a zombie, zbud_decompress() returns -EINVAL. However, this return code is being ignored by the caller, zcache_pampd_get_data_and_free(), which results in the caller of cleancache_get_page() thinking that the page has been properly retrieved when it has not. This patch modifies zcache_pampd_get_data_and_free() to convey the failure up the stack so that the caller of cleancache_get_page() knows the page retrieval failed. This needs to be applied to stable trees as well. zcache-main.c was named zcache.c before v3.1, so I'm not sure how you want to handle trees earlier than that. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Cc: stable <stable@vger.kernel.org> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Reviewed-by: Minchan Kim <minchan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-05staging: zcache: fix spelling of commentMarcus Karlsson1-1/+1
Fix spelling in tmem.c: Transcedent -> Transcendent Signed-off-by: Marcus Karlsson <mk@acc.umu.se> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-09staging: zsmalloc: add mapping modesSeth Jennings1-3/+3
This patch improves mapping performance in zsmalloc by getting usage information from the user in the form of a "mapping mode" and using it to avoid unnecessary copying for objects that span pages. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-09staging: zcache: cleanup the code between tmem_obj_init and tmem_obj_findXiao Guangrong1-30/+33
tmem_obj_find and insertion tmem-obj have the some logic, we can integrate the code Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-09staging: zcache: introduce get_zcache_clientXiao Guangrong1-23/+23
Introduce get_zcache_client to remove the common code Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-09staging: zcache: cleanup zcache_do_preload and zcache_put_pageXiao Guangrong1-21/+16
Cleanup the code for zcache_do_preload and zcache_put_page Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-09staging: zcache: optimize zcache_do_preloadXiao Guangrong1-12/+9
zcache_do_preload is called in zcache_put_page where IRQ is disabled, so, need not care preempt Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-09staging: zcache: cleanup zbud_initXiao Guangrong1-4/+2
Need not set global parameters to 0 Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-09staging: zcache: mark zbud_init/zcache_comp_init as __initXiao Guangrong1-2/+2
These functions are called only when system is initializing, so mark __init for them to free memory Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-09staging: zcache: remove unnecessary config option dependenceXiao Guangrong1-5/+2
zcache is enabled only if one of CONFIG_CLEANCACHE and CONFIG_FRONTSWAP is enabled, see the Kconfig: depends on (CLEANCACHE || FRONTSWAP) && CRYPTO=y && X86 So, we can remove the check in the source code Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-09staging: zcache: fix a compile warningXiao Guangrong1-0/+2
Fix: drivers/staging/zcache/zcache-main.c: In function ‘zcache_comp_op’: drivers/staging/zcache/zcache-main.c:112:2: warning: ‘ret’ may be used uninitial Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-09staging: zcache: fix refcount leakXiao Guangrong1-1/+2
In zcache_get_pool_by_id, the refcount of zcache_host is not increased, but it is always decreased in zcache_put_pool Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-25staging: zram/zcache: swtich Kconfig dependency from X86 to ZSMALLOCSeth Jennings1-4/+1
This patch switches zcache and zram dependency to ZSMALLOC rather than X86. There is no net change since ZSMALLOC depends on X86, however, this prevent further changes to these files as zsmalloc dependencies change. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-25Merge 3.5-rc4 into staging-nextGreg Kroah-Hartman1-5/+5
This picks up the staging changes made in 3.5-rc4 so that everyone can sync up properly. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-14staging: zcache: don't limit number of pools per clientSasha Levin1-17/+21
Currently the amount of pools each client can use is limited to 16, this is and arbitrary limit which isn't really required by current implementation. This places and arbitrary limit on the number of mounted filesystems that can use cleancache. This patch removes that limit and uses IDR to do sparse mapping of pools in each client. Signed-off-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-11staging: zsmalloc: zsmalloc: use unsigned long instead of void *Minchan Kim1-6/+6
We should use unsigned long as handle instead of void * to avoid any confusion. Without this, users may just treat zs_malloc return value as a pointer and try to deference it. This patch passed compile test(zram, zcache and ramster) and zram is tested on qemu. changelog * from v2 - remove hval pointed out by Nitin - based on next-20120607 * from v1 - change zcache's zv_create return value - baesd on next-20120604 Cc: Dan Magenheimer <dan.magenheimer@oracle.com> Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Minchan Kim <minchan@kernel.org> Acked-by: Nitin Gupta <ngupta@vflare.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-04Merge tag 'stable/frontswap.v16-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/mmLinus Torvalds1-5/+5
Pull frontswap feature from Konrad Rzeszutek Wilk: "Frontswap provides a "transcendent memory" interface for swap pages. In some environments, dramatic performance savings may be obtained because swapped pages are saved in RAM (or a RAM-like device) instead of a swap disk. This tag provides the basic infrastructure along with some changes to the existing backends." Fix up trivial conflict in mm/Makefile due to removal of swap token code changing a line next to the new frontswap entry. This pull request came in before the merge window even opened, it got delayed to after the merge window by me just wanting to make sure it had actual users. Apparently IBM is using this on their embedded side, and Jan Beulich says that it's already made available for SLES and OpenSUSE users. Also acked by Rik van Riel, and Konrad points to other people liking it too. So in it goes. By Dan Magenheimer (4) and Konrad Rzeszutek Wilk (2) via Konrad Rzeszutek Wilk * tag 'stable/frontswap.v16-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/mm: frontswap: s/put_page/store/g s/get_page/load MAINTAINER: Add myself for the frontswap API mm: frontswap: config and doc files mm: frontswap: core frontswap functionality mm: frontswap: core swap subsystem hooks and headers mm: frontswap: add frontswap header file
2012-05-15frontswap: s/put_page/store/g s/get_page/loadKonrad Rzeszutek Wilk1-5/+5
Sounds so much more natural. Suggested-by: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2012-04-24staging: zcache: fix Kconfig crypto dependencySeth Jennings1-1/+1
ZCACHE is a boolean in the Kconfig. When selected, it should require that CRYPTO be builtin (=y). Currently, ZCACHE=y and CRYPTO=m is a valid configuration when it should not be. This patch changes the zcache Kconfig to enforce this dependency. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-03-22Merge tag 'stable/for-linus-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/mmLinus Torvalds1-5/+5
Pull cleancache changes from Konrad Rzeszutek Wilk: "This has some patches for the cleancache API that should have been submitted a _long_ time ago. They are basically cleanups: - rename of flush to invalidate - moving reporting of statistics into debugfs - use __read_mostly as necessary. Oh, and also the MAINTAINERS file change. The files (except the MAINTAINERS file) have been in #linux-next for months now. The late addition of MAINTAINERS file is a brain-fart on my side - didn't realize I needed that just until I was typing this up - and I based that patch on v3.3 - so the tree is on top of v3.3." * tag 'stable/for-linus-3.4' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/mm: MAINTAINERS: Adding cleancache API to the list. mm: cleancache: Use __read_mostly as appropiate. mm: cleancache: report statistics via debugfs instead of sysfs. mm: zcache/tmem/cleancache: s/flush/invalidate/ mm: cleancache: s/flush/invalidate/
2012-03-21Merge branch 'kmap_atomic' of git://github.com/congwang/linuxLinus Torvalds1-6/+6
Pull kmap_atomic cleanup from Cong Wang. It's been in -next for a long time, and it gets rid of the (no longer used) second argument to k[un]map_atomic(). Fix up a few trivial conflicts in various drivers, and do an "evil merge" to catch some new uses that have come in since Cong's tree. * 'kmap_atomic' of git://github.com/congwang/linux: (59 commits) feature-removal-schedule.txt: schedule the deprecated form of kmap_atomic() for removal highmem: kill all __kmap_atomic() [swarren@nvidia.com: highmem: Fix ARM build break due to __kmap_atomic rename] drbd: remove the second argument of k[un]map_atomic() zcache: remove the second argument of k[un]map_atomic() gma500: remove the second argument of k[un]map_atomic() dm: remove the second argument of k[un]map_atomic() tomoyo: remove the second argument of k[un]map_atomic() sunrpc: remove the second argument of k[un]map_atomic() rds: remove the second argument of k[un]map_atomic() net: remove the second argument of k[un]map_atomic() mm: remove the second argument of k[un]map_atomic() lib: remove the second argument of k[un]map_atomic() power: remove the second argument of k[un]map_atomic() kdb: remove the second argument of k[un]map_atomic() udf: remove the second argument of k[un]map_atomic() ubifs: remove the second argument of k[un]map_atomic() squashfs: remove the second argument of k[un]map_atomic() reiserfs: remove the second argument of k[un]map_atomic() ocfs2: remove the second argument of k[un]map_atomic() ntfs: remove the second argument of k[un]map_atomic() ...
2012-03-20zcache: remove the second argument of k[un]map_atomic()Cong Wang1-8/+8
Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Cong Wang <amwang@redhat.com>
2012-03-19Merge branch 'stable/cleancache.v13' into linux-nextKonrad Rzeszutek Wilk1-5/+5
* stable/cleancache.v13: mm: cleancache: Use __read_mostly as appropiate. mm: cleancache: report statistics via debugfs instead of sysfs. mm: zcache/tmem/cleancache: s/flush/invalidate/ mm: cleancache: s/flush/invalidate/
2012-03-16staging/zmem: Use lockdep_assert_held instead of spin_is_lockedAndi Kleen1-1/+1
WARN_ON(!spin_is_locked()) will always trigger on UP. Use lockdep_assert_held instead. Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-03-07staging: zcache: make zcache builtin onlySeth Jennings1-1/+1
zcache cannot currently be loaded as a module. However the Kconfig allows it to be built as a module; something that the user probably does not intend since the module is not loadable. This patch switches zcache from a tristate to a bool in the Kconfig Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-29staging: zcache: fix memory corruption bugSeth Jennings1-4/+2
This patch fixes a bug where the zv code writes before the allocated buffer, resulting in system memory corruption. This was introduced during the switch from xvmalloc to zsmalloc. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-29staging: zcache: fix length type mismatchSeth Jennings1-4/+4
This fixes a type mismatch in the compression code where a size_t pointer was cast to a unsigned int pointer. On little endian archs, there is no issue. However on big endian archs, the value is incorrect, taking the high order bits and truncating the lower order bits. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-24staging: zcache: avoid AB-BA deadlock conditionAndrea Righi1-2/+2
Commit 9256a47 fixed a deadlock condition, being sure that the buddy list spinlock is always taken before the page spinlock. However in zbud_free_and_delist() locking order is the opposite (page lock -> list lock). Possible unsafe locking scenario (reported by lockdep): CPU0 CPU1 ---- ---- lock(&(&zbpg->lock)->rlock); lock(zbud_budlists_spinlock); lock(&(&zbpg->lock)->rlock); lock(zbud_budlists_spinlock); Fix by grabbing the locks in opposite order in zbud_free_and_delist(). Signed-off-by: Andrea Righi <andrea@betterlinux.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-13staging: fix powerpc linux-next break on zsmallocSeth Jennings1-1/+3
linux/vmalloc.h added to zsmalloc-main.c to resolve implicit declaration errors. X86 dependency added to zsmalloc and dependent drivers zcache and zram. This X86 only requirement is not ideal. Working to find portable functions for __flush_tlb_one and set_pte. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-10Merge tag 'staging-3.3-rc3' into staging-nextGreg Kroah-Hartman2-71/+169
This was done to resolve some merge issues with the following files that had changed in both branches: drivers/staging/rtl8712/rtl871x_sta_mgt.c drivers/staging/tidspbridge/rmgr/drv_interface.c drivers/staging/zcache/zcache-main.c Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-09staging: zcache: replace xvmalloc with zsmallocSeth Jennings2-41/+44
Replaces xvmalloc with zsmalloc as the persistent memory allocator for zcache Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-09staging: zcache: fix serialization bug in zv statsSeth Jennings1-7/+7
In a multithreaded workload, the zv_curr_dist_counts and zv_cumul_dist_counts statistics are being corrupted because the increments and decrements in zv_create and zv_free are not atomic. This patch converts these statistics and their corresponding increments/decrements/reads to atomic operations. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-08staging: zcache: crypto API supportSeth Jennings2-31/+126
This patch allow zcache to use the crypto API for page compression. It replaces the direct LZO compress/decompress calls with calls into the crypto compression API. The compressor to be used is specified in the kernel boot line with the zcache parameter like: zcache=lzo or zcache=deflate. If the specified compressor can't be loaded, zcache uses lzo as the default compressor. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-08staging: zcache: fix serialization bug in zv statsSeth Jennings1-7/+7
In a multithreaded workload, the zv_curr_dist_counts and zv_cumul_dist_counts statistics are being corrupted because the increments and decrements in zv_create and zv_free are not atomic. This patch converts these statistics and their corresponding increments/decrements/reads to atomic operations. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-08zcache: Set SWIZ_BITS to 8 to reduce tmem bucket lock contention.Dan Magenheimer1-2/+2
SWIZ_BITS > 8 results in a much larger number of "tmem_obj" allocations, likely one per page-placed-in-frontswap. The tmem_obj is not huge (roughly 100 bytes), but it is large enough to add a not-insignificant memory overhead to zcache. The SWIZ_BITS=8 will get roughly the same lock contention without the space wastage. The effect of SWIZ_BITS can be thought of as "2^SWIZ_BITS is the number of unique oids that be generated" (This concept is limited to frontswap's use of tmem). Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2012-02-08zcache: fix deadlock conditionDan Magenheimer1-4/+3
I discovered this deadlock condition awhile ago working on RAMster but it affects zcache as well. The list spinlock must be locked prior to the page spinlock and released after. As a result, the page copy must also be done while the locks are held. Applies to 3.2. Konrad, please push (via GregKH?)... this is definitely a bug fix so need not be pushed during a -rc0 window. Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2012-01-23mm: zcache/tmem/cleancache: s/flush/invalidate/Dan Magenheimer1-5/+5
Complete the renaming from "flush" to "invalidate" across both tmem frontends (cleancache and frontswap) and both tmem backends (Xen and zcache), as required by akpm. This change is completely cosmetic. [v10: no change] [v9: akpm@linux-foundation.org: change "flush" to "invalidate", part 3] Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com> Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Jan Beulich <JBeulich@novell.com> Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Cc: Jeremy Fitzhardinge <jeremy@goop.org> Cc: Hugh Dickins <hughd@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Nitin Gupta <ngupta@vflare.org> Cc: Matthew Wilcox <matthew@wil.cx> Cc: Chris Mason <chris.mason@oracle.com> Cc: Rik Riel <riel@redhat.com> Cc: Andrew Morton <akpm@linux-foundation.org> [v11: Remove the frontswap part] Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
2011-11-26Staging: zcache: Fix calls to obsolete functionBernhard Heinloth1-3/+3
Function "strict_strtol" replaced by "kstrtol" as suggested by the checkpatch script Signed-off-by: Bernhard Heinloth <bernhard@heinloth.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-25Merge branch 'staging-next' into Linux 3.1Greg Kroah-Hartman1-33/+18
This was done to resolve a conflict in the drivers/staging/comedi/drivers/ni_labpc.c file that resolved a build bugfix in Linus's tree with a "better" bugfix that was in the staging-next tree that resolved the issue in a more complete manner. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-17staging: zcache: remove zcache_direct_reclaim_lockSeth Jennings1-27/+4
zcache_do_preload() currently does a spin_trylock() on the zcache_direct_reclaim_lock. Holding this lock intends to prevent shrink_zcache_memory() from evicting zbud pages as a result of a preload. However, it also prevents two threads from executing zcache_do_preload() at the same time. The first thread will obtain the lock and the second thread's spin_trylock() will fail (an aborted preload) causing the page to be either lost (cleancache) or pushed out to the swap device (frontswap). It also doesn't ensure that the call to shrink_zcache_memory() is on the same thread as the call to zcache_do_preload(). Additional, there is no need for this mechanism because all zcache_do_preload() calls that come down from cleancache already have PF_MEMALLOC set in the process flags which prevents direct reclaim in the memory manager. If the zcache_do_preload() call is done from the frontswap path, we _want_ reclaim to be done (which it isn't right now). This patch removes the zcache_direct_reclaim_lock and related statistics in zcache. Based on v3.1-rc8 Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Reviewed-by: Dave Hansen <dave@linux.vnet.ibm.com> Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-12staging: zcache: reduce tmem bucket lock contentionSeth Jennings1-1/+3
tmem uses hash buckets each with their own rbtree and lock to quickly lookup tmem objects. tmem has TMEM_HASH_BUCKETS (256) buckets per pool. However, because of the way the tmem_oid is generated for frontswap pages, only 16 unique tmem_oids are being generated, resulting in only 16 of the 256 buckets being used. This cause high lock contention for the per bucket locks. This patch changes SWIZ_BITS to include more bits of the offset. The result is that all 256 hash buckets are potentially used resulting in a 95% drop in hash bucket lock contention. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-10-11staging: zcache: fix crash on cpu removeSeth Jennings1-2/+8
In the case that a cpu is taken offline before zcache_do_preload() is ever called on the cpu, the per-cpu zcache_preloads structure will be uninitialized. In the CPU_DEAD case for zcache_cpu_notifier(), kp->obj is not checked before calling kmem_cache_free() on it. If it is NULL, a crash results. This patch ensures that both kp->obj and kp->page are not NULL before calling the respective free functions. In practice, just checking one or the other should be sufficient since they are assigned together in zcache_do_preload(), but I check both for safety. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Acked-by: Dave Hansen <dave@linux.vnet.ibm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-09-20staging: zcache: fix cleancache crashSeth Jennings1-1/+1
After commit c5f5c4db3938 ("staging: zcache: fix crash on high memory swap") cleancache crashes on the first successful get. This was caused by a remaining virt_to_page() call in zcache_pampd_get_data_and_free() that only gets run in the cleancache path. The patch converts the virt_to_page() to struct page casting like was done for other instances in c5f5c4db3938. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Tested-By: Valdis Kletnieks <valdis.kletnieks@vt.edu> Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-08-29Merge 3.1-rc4 into staging-nextGreg Kroah-Hartman1-3/+3
This resolves a conflict with: drivers/staging/brcm80211/brcmsmac/types.h Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-23Staging: zcache: signedness bug in tmem_get()Dan Carpenter1-1/+1
"ret" needs to be signed for the error handling to work properly. Signed-off-by: Dan Carpenter <error27@gmail.com> Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-23staging: zcache: fix crash on high memory swapSeth Jennings1-4/+4
zcache_put_page() was modified to pass page_address(page) instead of the actual page structure. In combination with the function signature changes to tmem_put() and zcache_pampd_create(), zcache_pampd_create() tries to (re)derive the page structure from the virtual address. However, if the original page is a high memory page (or any unmapped page), this virt_to_page() fails because the page_address() in zcache_put_page() returned NULL. This patch changes zcache_put_page() and zcache_get_page() to pass the page structure instead of the page's virtual address, which may or may not exist. Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-23staging: zcache: fix typosSeth Jennings1-2/+2
The patch fixes two typos in zcache-main.c Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-23staging: zcache: fix possible sleep under lockSeth Jennings1-1/+1
zcache_new_pool() calls kmalloc() with GFP_KERNEL which has __GFP_WAIT set. However, zcache_new_pool() gets called on a stack that holds the swap_lock spinlock, leading to a possible sleep-with-lock situation. The lock is obtained in enable_swap_info(). The patch replaces GFP_KERNEL with GFP_ATOMIC. v2: replace with GFP_ATOMIC, not GFP_IOFS Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com> Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-08-08zcache: Fix build error when sysfs is not definedNitin Gupta1-1/+1
Signed-off-by: Nitin Gupta <ngupta@vflare.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>