linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] Make frontswap+cleancache and its friend be modularized.
@ 2013-02-01 20:22 Konrad Rzeszutek Wilk
  2013-02-01 20:22 ` [PATCH 01/15] mm: cleancache: lazy initialization to allow tmem backends to build/run as modules Konrad Rzeszutek Wilk
                   ` (15 more replies)
  0 siblings, 16 replies; 27+ messages in thread
From: Konrad Rzeszutek Wilk @ 2013-02-01 20:22 UTC (permalink / raw)
  To: dan.magenheimer, konrad.wilk, sjenning, gregkh, akpm, ngupta, rcj,
	linux-mm, linux-kernel, devel

Parts of this patch have been posted in the post (way back in November), but
this patchset expanded it a bit. The goal of the patches is to make the
different frontswap/cleancache API backends be modules - and load way way after
the swap system (or filesystem) has been initialized. Naturally one can still
build the frontswap+cleancache backend devices in the kernel. The next goal
(after these patches) is to also be able to unload the backend drivers - but
that places some interesting requirements to "reload" the swap device with
swap pages (don't need to worry that much about cleancache as it is a "secondary"
cache and can be dumped). Seth had posted some patches for that in the zswap
backend - and they could be more generally repurporsed.

Anyhow, I did not want to lose the authorship of some of the patches so I
didn't squash the ones that were made by Dan and mine. I can do it for review
if it would make it easier, but from my recollection on how Linus likes things
run he would prefer to keep the history (even the kludge parts).

The general flow prior to these patches was [I am concentrating on the
frontswap here, but the cleancache is similar, just s/swapon/mount/]:

 1) kernel inits frontswap_init
 2) kernel inits zcache (or some other backend)
 3) user does swapon /dev/XX and the writes to the swap disk end up in
    frontswap and then in the backend.

With the module loading, the 1) is still part of the bootup, but the
2) or 3) can be run at anytime. This means one could load the backend
_after_ the swap disk has been initialized and running along. Or
_before_ the swap disk has been setup - but that is similar to the
existing case so not that exciting.

To deal with that scenario the frontswap keeps an queue (actually an atomic
bitmap of the swap disks that have been init) and when the backend registers -
frontswap runs the backend init on the queued up swap disks.

The interesting thing is that we can be to certain degree racy when the
swap system starts steering pages to frontswap. Meaning after the backend
has registered it is OK if the pages are still hitting the disk instead of
the backend. Naturally this is unacceptable if one were to unload the
backend (not yet supported) - as we need to be quite atomic at that stage
and need to stop processing the pages the moment the backend is being
unloaded. To support this, the frontswap is using the struct static_key
which are incredibly light when they are in usage. They are incredibly heavy
when the value switches (on/off), but that is OK. The next part of unloading is
also taking the pages that are in the backend and feed them in the swap
storage (and Seth's patches do some of this).

Also attached is one patch from Minchan that fixes the condition where the
backend was constricted in allocating memory at init - b/c we were holding
a spin-lock. His patch fixes that and we are just holding the swapon_mutex
instead. It has been rebased on top of my patches.

This patchset is based on Greg KH's staging tree (since the zcache2 has
now been renamed to zcache). To be exact, it is based on
085494ac2039433a5df9fdd6fb653579e18b8c71

Dan Magenheimer (4):
      mm: cleancache: lazy initialization to allow tmem backends to build/run as modules
      mm: frontswap: lazy initialization to allow tmem backends to build/run as modules
      staging: zcache: enable ramster to be built/loaded as a module
      xen: tmem: enable Xen tmem shim to be built/loaded as a module

Konrad Rzeszutek Wilk (10):
      frontswap: Make frontswap_init use a pointer for the ops.
      cleancache: Make cleancache_init use a pointer for the ops
      staging: zcache: enable zcache to be built/loaded as a module
      xen/tmem: Remove the subsys call.
      frontswap: Remove the check for frontswap_enabled.
      frontswap: Use static_key instead of frontswap_enabled and frontswap_ops
      cleancache: Remove the check for cleancache_enabled.
      cleancache: Use static_key instead of cleancache_ops and cleancache_enabled.
      zcache/tmem: Better error checking on frontswap_register_ops return     value.
      xen/tmem: Add missing %s in the printk statement.

Minchan Kim (1):
      frontswap: Get rid of swap_lock dependency


 drivers/staging/zcache/Kconfig                     |   6 +-
 drivers/staging/zcache/Makefile                    |  11 +-
 drivers/staging/zcache/ramster.h                   |   6 +-
 drivers/staging/zcache/ramster/nodemanager.c       |   9 +-
 drivers/staging/zcache/ramster/ramster.c           |  29 ++-
 drivers/staging/zcache/ramster/ramster.h           |   2 +-
 .../staging/zcache/ramster/ramster_nodemanager.h   |   2 +
 drivers/staging/zcache/tmem.c                      |   6 +-
 drivers/staging/zcache/tmem.h                      |   8 +-
 drivers/staging/zcache/zcache-main.c               |  64 +++++-
 drivers/staging/zcache/zcache.h                    |   2 +-
 drivers/xen/Kconfig                                |   4 +-
 drivers/xen/tmem.c                                 |  55 +++--
 drivers/xen/xen-selfballoon.c                      |  13 +-
 include/linux/cleancache.h                         |  27 ++-
 include/linux/frontswap.h                          |  31 +--
 include/xen/tmem.h                                 |   8 +
 mm/cleancache.c                                    | 241 ++++++++++++++++++---
 mm/frontswap.c                                     | 121 ++++++++---
 mm/swapfile.c                                      |   7 +-
 20 files changed, 505 insertions(+), 147 deletions(-)

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2013-02-05  0:39 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-01 20:22 [PATCH v2] Make frontswap+cleancache and its friend be modularized Konrad Rzeszutek Wilk
2013-02-01 20:22 ` [PATCH 01/15] mm: cleancache: lazy initialization to allow tmem backends to build/run as modules Konrad Rzeszutek Wilk
2013-02-03  8:06   ` Ric Mason
2013-02-01 20:22 ` [PATCH 02/15] mm: frontswap: " Konrad Rzeszutek Wilk
2013-02-03  7:07   ` Ric Mason
2013-02-04  5:53     ` Bob Liu
2013-02-05  0:23       ` Ric Mason
2013-02-01 20:22 ` [PATCH 03/15] frontswap: Make frontswap_init use a pointer for the ops Konrad Rzeszutek Wilk
2013-02-01 20:22 ` [PATCH 04/15] cleancache: Make cleancache_init " Konrad Rzeszutek Wilk
2013-02-01 20:22 ` [PATCH 05/15] staging: zcache: enable ramster to be built/loaded as a module Konrad Rzeszutek Wilk
2013-02-01 20:22 ` [PATCH 06/15] staging: zcache: enable zcache " Konrad Rzeszutek Wilk
2013-02-01 20:22 ` [PATCH 07/15] xen: tmem: enable Xen tmem shim " Konrad Rzeszutek Wilk
2013-02-01 20:22 ` [PATCH 08/15] xen/tmem: Remove the subsys call Konrad Rzeszutek Wilk
2013-02-01 20:22 ` [PATCH 09/15] frontswap: Remove the check for frontswap_enabled Konrad Rzeszutek Wilk
2013-02-01 20:22 ` [PATCH 10/15] frontswap: Use static_key instead of frontswap_enabled and frontswap_ops Konrad Rzeszutek Wilk
2013-02-01 20:23 ` [PATCH 11/15] cleancache: Remove the check for cleancache_enabled Konrad Rzeszutek Wilk
2013-02-01 20:23 ` [PATCH 12/15] cleancache: Use static_key instead of cleancache_ops and cleancache_enabled Konrad Rzeszutek Wilk
2013-02-01 20:23 ` [PATCH 13/15] frontswap: Get rid of swap_lock dependency Konrad Rzeszutek Wilk
2013-02-03  8:43   ` Wanpeng Li
2013-02-03  8:43   ` Wanpeng Li
2013-02-03  8:43   ` Wanpeng Li
2013-02-01 20:23 ` [PATCH 14/15] zcache/tmem: Better error checking on frontswap_register_ops return value Konrad Rzeszutek Wilk
2013-02-01 20:23 ` [PATCH 15/15] xen/tmem: Add missing %s in the printk statement Konrad Rzeszutek Wilk
2013-02-03  8:52 ` [PATCH v2] Make frontswap+cleancache and its friend be modularized Ric Mason
2013-02-04 15:14   ` Seth Jennings
2013-02-05  0:21     ` Ric Mason
2013-02-05  0:38       ` Konrad Rzeszutek Wilk

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