All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
To: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Seth Jennings <sjenning@linux.vnet.ibm.com>,
	Dan Magenheimer <dan.magenheimer@oracle.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-mm@kvack.org
Subject: [PATCH 07/10] zcache: optimize zcache_do_preload
Date: Tue, 19 Jun 2012 16:35:59 +0800	[thread overview]
Message-ID: <4FE039EF.3030809@linux.vnet.ibm.com> (raw)
In-Reply-To: <4FE0392E.3090300@linux.vnet.ibm.com>

zcache_do_preload is called in zcache_put_page where IRQ is disabled, so, need
not care preempt

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 drivers/staging/zcache/zcache-main.c |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index c18130f..386906d 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -1026,45 +1026,43 @@ static int zcache_do_preload(struct tmem_pool *pool)
 		goto out;
 	if (unlikely(zcache_obj_cache == NULL))
 		goto out;
-	preempt_disable();
+
+	/* IRQ has already been disabled. */
 	kp = &__get_cpu_var(zcache_preloads);
 	while (kp->nr < ARRAY_SIZE(kp->objnodes)) {
-		preempt_enable_no_resched();
 		objnode = kmem_cache_alloc(zcache_objnode_cache,
 				ZCACHE_GFP_MASK);
 		if (unlikely(objnode == NULL)) {
 			zcache_failed_alloc++;
 			goto out;
 		}
-		preempt_disable();
-		kp = &__get_cpu_var(zcache_preloads);
-		if (kp->nr < ARRAY_SIZE(kp->objnodes))
-			kp->objnodes[kp->nr++] = objnode;
-		else
-			kmem_cache_free(zcache_objnode_cache, objnode);
+
+		kp->objnodes[kp->nr++] = objnode;
 	}
-	preempt_enable_no_resched();
+
 	obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK);
 	if (unlikely(obj == NULL)) {
 		zcache_failed_alloc++;
 		goto out;
 	}
+
 	page = (void *)__get_free_page(ZCACHE_GFP_MASK);
 	if (unlikely(page == NULL)) {
 		zcache_failed_get_free_pages++;
 		kmem_cache_free(zcache_obj_cache, obj);
 		goto out;
 	}
-	preempt_disable();
-	kp = &__get_cpu_var(zcache_preloads);
+
 	if (kp->obj == NULL)
 		kp->obj = obj;
 	else
 		kmem_cache_free(zcache_obj_cache, obj);
+
 	if (kp->page == NULL)
 		kp->page = page;
 	else
 		free_page((unsigned long)page);
+
 	ret = 0;
 out:
 	return ret;
@@ -1575,7 +1573,6 @@ static int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp,
 				zcache_failed_pers_puts++;
 		}
 		zcache_put_pool(pool);
-		preempt_enable_no_resched();
 	} else {
 		zcache_put_to_flush++;
 		if (atomic_read(&pool->obj_count) > 0)
-- 
1.7.7.6

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

WARNING: multiple messages have this Message-ID (diff)
From: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
To: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Seth Jennings <sjenning@linux.vnet.ibm.com>,
	Dan Magenheimer <dan.magenheimer@oracle.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-mm@kvack.org
Subject: [PATCH 07/10] zcache: optimize zcache_do_preload
Date: Tue, 19 Jun 2012 16:35:59 +0800	[thread overview]
Message-ID: <4FE039EF.3030809@linux.vnet.ibm.com> (raw)
In-Reply-To: <4FE0392E.3090300@linux.vnet.ibm.com>

zcache_do_preload is called in zcache_put_page where IRQ is disabled, so, need
not care preempt

Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
 drivers/staging/zcache/zcache-main.c |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index c18130f..386906d 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -1026,45 +1026,43 @@ static int zcache_do_preload(struct tmem_pool *pool)
 		goto out;
 	if (unlikely(zcache_obj_cache == NULL))
 		goto out;
-	preempt_disable();
+
+	/* IRQ has already been disabled. */
 	kp = &__get_cpu_var(zcache_preloads);
 	while (kp->nr < ARRAY_SIZE(kp->objnodes)) {
-		preempt_enable_no_resched();
 		objnode = kmem_cache_alloc(zcache_objnode_cache,
 				ZCACHE_GFP_MASK);
 		if (unlikely(objnode == NULL)) {
 			zcache_failed_alloc++;
 			goto out;
 		}
-		preempt_disable();
-		kp = &__get_cpu_var(zcache_preloads);
-		if (kp->nr < ARRAY_SIZE(kp->objnodes))
-			kp->objnodes[kp->nr++] = objnode;
-		else
-			kmem_cache_free(zcache_objnode_cache, objnode);
+
+		kp->objnodes[kp->nr++] = objnode;
 	}
-	preempt_enable_no_resched();
+
 	obj = kmem_cache_alloc(zcache_obj_cache, ZCACHE_GFP_MASK);
 	if (unlikely(obj == NULL)) {
 		zcache_failed_alloc++;
 		goto out;
 	}
+
 	page = (void *)__get_free_page(ZCACHE_GFP_MASK);
 	if (unlikely(page == NULL)) {
 		zcache_failed_get_free_pages++;
 		kmem_cache_free(zcache_obj_cache, obj);
 		goto out;
 	}
-	preempt_disable();
-	kp = &__get_cpu_var(zcache_preloads);
+
 	if (kp->obj == NULL)
 		kp->obj = obj;
 	else
 		kmem_cache_free(zcache_obj_cache, obj);
+
 	if (kp->page == NULL)
 		kp->page = page;
 	else
 		free_page((unsigned long)page);
+
 	ret = 0;
 out:
 	return ret;
@@ -1575,7 +1573,6 @@ static int zcache_put_page(int cli_id, int pool_id, struct tmem_oid *oidp,
 				zcache_failed_pers_puts++;
 		}
 		zcache_put_pool(pool);
-		preempt_enable_no_resched();
 	} else {
 		zcache_put_to_flush++;
 		if (atomic_read(&pool->obj_count) > 0)
-- 
1.7.7.6


  parent reply	other threads:[~2012-06-19  8:36 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-19  8:32 [PATCH 01/10] zcache: fix preemptable memory allocation in atomic context Xiao Guangrong
2012-06-19  8:32 ` Xiao Guangrong
2012-06-19  8:33 ` [PATCH 02/10] zcache: fix refcount leak Xiao Guangrong
2012-06-19  8:33   ` Xiao Guangrong
2012-06-19 14:28   ` Seth Jennings
2012-06-19 14:28     ` Seth Jennings
2012-06-19 19:49     ` Dan Magenheimer
2012-06-19 19:49       ` Dan Magenheimer
2012-06-19 20:06       ` Seth Jennings
2012-06-19 20:06         ` Seth Jennings
2012-06-20  2:54         ` Xiao Guangrong
2012-06-20  2:54           ` Xiao Guangrong
2012-06-20  3:19           ` Xiao Guangrong
2012-06-20  3:19             ` Xiao Guangrong
2012-06-20 22:25             ` Dan Magenheimer
2012-06-20 22:25               ` Dan Magenheimer
2012-06-21  1:44               ` Xiao Guangrong
2012-06-21  1:44                 ` Xiao Guangrong
2012-06-19  8:33 ` [PATCH 03/10] zcache: fix a compile warning Xiao Guangrong
2012-06-19  8:33   ` Xiao Guangrong
2012-06-19 14:30   ` Seth Jennings
2012-06-19 14:30     ` Seth Jennings
2012-06-20  2:55     ` Xiao Guangrong
2012-06-20  2:55       ` Xiao Guangrong
2012-06-19  8:34 ` [PATCH 04/10] zcache: remove unnecessary check of config option dependence Xiao Guangrong
2012-06-19  8:34   ` Xiao Guangrong
2012-06-19 14:36   ` Seth Jennings
2012-06-19 14:36     ` Seth Jennings
2012-06-19  8:35 ` [PATCH 05/10] zcache: mark zbud_init/zcache_comp_init as __init Xiao Guangrong
2012-06-19  8:35   ` Xiao Guangrong
2012-06-19 16:35   ` Seth Jennings
2012-06-19 16:35     ` Seth Jennings
2012-06-19  8:35 ` [PATCH 06/10] zcache: cleanup zbud_init Xiao Guangrong
2012-06-19  8:35   ` Xiao Guangrong
2012-06-19  8:35 ` Xiao Guangrong [this message]
2012-06-19  8:35   ` [PATCH 07/10] zcache: optimize zcache_do_preload Xiao Guangrong
2012-06-19  8:36 ` [PATCH 08/10] zcache: cleanup zcache_do_preload and zcache_put_page Xiao Guangrong
2012-06-19  8:36   ` Xiao Guangrong
2012-06-19  8:37 ` [PATCH 09/10] zcache: introduce get_zcache_client Xiao Guangrong
2012-06-19  8:37   ` Xiao Guangrong
2012-06-19  8:37 ` [PATCH 10/10] cleanup the code between tmem_obj_init and tmem_obj_find Xiao Guangrong
2012-06-19  8:37   ` Xiao Guangrong
2012-06-19 16:49   ` Seth Jennings
2012-06-19 16:49     ` Seth Jennings
2012-06-20  2:53     ` Xiao Guangrong
2012-06-20  2:53       ` Xiao Guangrong
2012-06-19 14:26 ` [PATCH 01/10] zcache: fix preemptable memory allocation in atomic context Seth Jennings
2012-06-19 14:26   ` Seth Jennings
2012-06-20  2:51   ` Xiao Guangrong
2012-06-20  2:51     ` Xiao Guangrong
2012-06-21 18:51 ` Seth Jennings
2012-06-21 18:51   ` Seth Jennings
2012-06-23  3:00   ` Greg Kroah-Hartman
2012-06-23  3:00     ` Greg Kroah-Hartman
2012-06-25 13:48     ` Seth Jennings
2012-06-25 13:48       ` Seth Jennings
2012-06-25 14:11       ` Greg Kroah-Hartman
2012-06-25 14:11         ` Greg Kroah-Hartman
2012-06-26  7:08         ` Xiao Guangrong
2012-06-26  7:08           ` Xiao Guangrong

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=4FE039EF.3030809@linux.vnet.ibm.com \
    --to=xiaoguangrong@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=dan.magenheimer@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.