From: Wanpeng Li <liwanp@linux.vnet.ibm.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Dan Magenheimer <dan.magenheimer@oracle.com>,
Seth Jennings <sjenning@linux.vnet.ibm.com>,
Konrad Rzeszutek Wilk <konrad@darnok.org>,
Minchan Kim <minchan@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Bob Liu <bob.liu@oracle.com>,
Wanpeng Li <liwanp@linux.vnet.ibm.com>
Subject: [PATCH 04/10] staging: ramster: Provide accessory functions for counter decrease
Date: Wed, 10 Apr 2013 08:25:54 +0800 [thread overview]
Message-ID: <1365553560-32258-5-git-send-email-liwanp@linux.vnet.ibm.com> (raw)
In-Reply-To: <1365553560-32258-1-git-send-email-liwanp@linux.vnet.ibm.com>
This patch enables these functions to be wrapped and
can disable/enable this with CONFIG_DEBUG_FS.
Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
---
drivers/staging/zcache/ramster/ramster.c | 32 ++++++++++++++++++------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/zcache/ramster/ramster.c b/drivers/staging/zcache/ramster/ramster.c
index b60e884..c3d7f96 100644
--- a/drivers/staging/zcache/ramster/ramster.c
+++ b/drivers/staging/zcache/ramster/ramster.c
@@ -73,6 +73,10 @@ static inline void inc_ramster_flnodes(void)
if (ramster_flnodes > ramster_flnodes_max)
ramster_flnodes_max = ramster_flnodes;
}
+static inline void dec_ramster_flnodes(void)
+{
+ ramster_flnodes = atomic_dec_return(&ramster_flnodes_atomic);
+}
static ssize_t ramster_foreign_eph_pages;
static atomic_t ramster_foreign_eph_pages_atomic = ATOMIC_INIT(0);
static ssize_t ramster_foreign_eph_pages_max;
@@ -83,6 +87,11 @@ static inline void inc_ramster_foreign_eph_pages(void)
if (ramster_foreign_eph_pages > ramster_foreign_eph_pages_max)
ramster_foreign_eph_pages_max = ramster_foreign_eph_pages;
}
+static inline void dec_ramster_foreign_eph_pages(void)
+{
+ ramster_foreign_eph_pages = atomic_dec_return(
+ &ramster_foreign_eph_pages_atomic);
+}
static ssize_t ramster_foreign_pers_pages;
static atomic_t ramster_foreign_pers_pages_atomic = ATOMIC_INIT(0);
static ssize_t ramster_foreign_pers_pages_max;
@@ -93,6 +102,11 @@ static inline void inc_ramster_foreign_pers_pages(void)
if (ramster_foreign_pers_pages > ramster_foreign_pers_pages_max)
ramster_foreign_pers_pages_max = ramster_foreign_pers_pages;
}
+static inline void dec_ramster_foreign_pers_pages(void)
+{
+ ramster_foreign_pers_pages = atomic_dec_return(
+ &ramster_foreign_pers_pages_atomic);
+}
static ssize_t ramster_eph_pages_remoted;
static ssize_t ramster_pers_pages_remoted;
static ssize_t ramster_eph_pages_remote_failed;
@@ -188,10 +202,8 @@ static struct flushlist_node *ramster_flnode_alloc(struct tmem_pool *pool)
static void ramster_flnode_free(struct flushlist_node *flnode,
struct tmem_pool *pool)
{
- int flnodes;
-
- flnodes = atomic_dec_return(&ramster_flnodes_atomic);
- BUG_ON(flnodes < 0);
+ dec_ramster_flnodes();
+ BUG_ON(ramster_flnodes < 0);
kmem_cache_free(ramster_flnode_cache, flnode);
}
@@ -484,26 +496,20 @@ void *ramster_pampd_free(void *pampd, struct tmem_pool *pool,
void ramster_count_foreign_pages(bool eph, int count)
{
- int c;
-
BUG_ON(count != 1 && count != -1);
if (eph) {
if (count > 0) {
inc_ramster_foreign_eph_pages();
} else {
- c = atomic_dec_return(&ramster_foreign_eph_pages_atomic);
- WARN_ON_ONCE(c < 0);
+ dec_ramster_foreign_eph_pages();
+ WARN_ON_ONCE(ramster_foreign_eph_pages < 0);
}
- ramster_foreign_eph_pages = c;
} else {
if (count > 0) {
inc_ramster_foreign_pers_pages();
} else {
- c = atomic_dec_return(
- &ramster_foreign_pers_pages_atomic);
- WARN_ON_ONCE(c < 0);
+ WARN_ON_ONCE(ramster_foreign_pers_pages < 0);
}
- ramster_foreign_pers_pages = c;
}
}
--
1.7.10.4
--
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>
next prev parent reply other threads:[~2013-04-10 0:26 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-10 0:25 [PATCH 00/10] staging: zcache/ramster: fix and ramster/debugfs improvement Wanpeng Li
2013-04-10 0:25 ` [PATCH 01/10] staging: zcache: fix account foregin counters against zero-filled pages Wanpeng Li
2013-04-10 0:25 ` [PATCH 02/10] staging: zcache: remove zcache_freeze Wanpeng Li
2013-04-10 0:25 ` [PATCH 03/10] staging: ramster: Provide accessory functions for counter increase Wanpeng Li
2013-04-10 0:25 ` Wanpeng Li [this message]
2013-04-10 0:25 ` [PATCH 05/10] staging: ramster: Move debugfs code out of ramster.c file Wanpeng Li
2013-04-11 20:04 ` Greg Kroah-Hartman
2013-04-11 23:27 ` Wanpeng Li
2013-04-11 23:27 ` Wanpeng Li
2013-04-10 0:25 ` [PATCH 06/10] staging: ramster/debug: Use an array to initialize/use debugfs attributes Wanpeng Li
2013-04-10 0:25 ` [PATCH 07/10] staging: ramster/debug: Add RAMSTER_DEBUG Kconfig entry Wanpeng Li
2013-04-10 0:25 ` [PATCH 08/10] staging: ramster: Add incremental accessory counters Wanpeng Li
2013-04-10 0:25 ` [PATCH 09/10] staging: zcache/debug: fix coding style Wanpeng Li
2013-04-10 0:26 ` [PATCH 10/10] staging: ramster: add how-to for ramster Wanpeng Li
[not found] <<1365553560-32258-1-git-send-email-liwanp@linux.vnet.ibm.com>
[not found] ` <<1365553560-32258-3-git-send-email-liwanp@linux.vnet.ibm.com>
2013-04-11 17:13 ` [PATCH 02/10] staging: zcache: remove zcache_freeze Dan Magenheimer
2013-04-11 20:05 ` Greg Kroah-Hartman
2013-04-11 23:22 ` Wanpeng Li
2013-04-11 23:22 ` Wanpeng Li
2013-04-11 17:17 ` [PATCH 00/10] staging: zcache/ramster: fix and ramster/debugfs improvement Dan Magenheimer
2013-04-11 23:20 ` Wanpeng Li
2013-04-11 23:20 ` Wanpeng Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1365553560-32258-5-git-send-email-liwanp@linux.vnet.ibm.com \
--to=liwanp@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=bob.liu@oracle.com \
--cc=dan.magenheimer@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=konrad@darnok.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan@kernel.org \
--cc=sjenning@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).