From: Christoph Lameter <cl@linux.com>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: linux-mm@kvack.org, David Rientjes <rientjes@google.com>
Subject: [Slub cleanup5 3/3] slub: extract common code to remove objects from partial list without locking
Date: Tue, 28 Sep 2010 08:10:28 -0500 [thread overview]
Message-ID: <20100928131057.767067382@linux.com> (raw)
In-Reply-To: 20100928131025.319846721@linux.com
[-- Attachment #1: cleanup_remove_partial --]
[-- Type: text/plain, Size: 2174 bytes --]
There are a couple of places where repeat the same statements when removing
a page from the partial list. Consolidate that into __remove_partial().
Signed-off-by: Christoph Lameter <cl@linux.com>
---
mm/slub.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
Index: linux-2.6/mm/slub.c
===================================================================
--- linux-2.6.orig/mm/slub.c 2010-09-28 08:05:49.000000000 -0500
+++ linux-2.6/mm/slub.c 2010-09-28 08:05:50.000000000 -0500
@@ -1312,13 +1312,19 @@ static void add_partial(struct kmem_cach
spin_unlock(&n->list_lock);
}
+static inline void __remove_partial(struct kmem_cache_node *n,
+ struct page *page)
+{
+ list_del(&page->lru);
+ n->nr_partial--;
+}
+
static void remove_partial(struct kmem_cache *s, struct page *page)
{
struct kmem_cache_node *n = get_node(s, page_to_nid(page));
spin_lock(&n->list_lock);
- list_del(&page->lru);
- n->nr_partial--;
+ __remove_partial(n, page);
spin_unlock(&n->list_lock);
}
@@ -1331,8 +1337,7 @@ static inline int lock_and_freeze_slab(s
struct page *page)
{
if (slab_trylock(page)) {
- list_del(&page->lru);
- n->nr_partial--;
+ __remove_partial(n, page);
__SetPageSlubFrozen(page);
return 1;
}
@@ -2464,9 +2469,8 @@ static void free_partial(struct kmem_cac
spin_lock_irqsave(&n->list_lock, flags);
list_for_each_entry_safe(page, h, &n->partial, lru) {
if (!page->inuse) {
- list_del(&page->lru);
+ __remove_partial(n, page);
discard_slab(s, page);
- n->nr_partial--;
} else {
list_slab_objects(s, page,
"Objects remaining on kmem_cache_close()");
@@ -2824,8 +2828,7 @@ int kmem_cache_shrink(struct kmem_cache
* may have freed the last object and be
* waiting to release the slab.
*/
- list_del(&page->lru);
- n->nr_partial--;
+ __remove_partial(n, page);
slab_unlock(page);
discard_slab(s, page);
} else {
--
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:[~2010-09-28 13:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-28 13:10 [Slub cleanup5 0/3] SLUB: Cleanups V5 Christoph Lameter
2010-09-28 13:10 ` [Slub cleanup5 1/3] slub: reduce differences between SMP and NUMA Christoph Lameter
2010-09-28 14:34 ` Pekka Enberg
2010-09-28 14:43 ` Christoph Lameter
2010-09-29 0:33 ` David Rientjes
2010-09-28 13:10 ` [Slub cleanup5 2/3] SLUB: Pass active and inactive redzone flags instead of boolean to debug functions Christoph Lameter
2010-09-29 0:38 ` David Rientjes
2010-09-29 12:15 ` Christoph Lameter
2010-09-29 20:01 ` David Rientjes
2010-09-28 13:10 ` Christoph Lameter [this message]
2010-09-29 0:38 ` [Slub cleanup5 3/3] slub: extract common code to remove objects from partial list without locking David Rientjes
2010-10-02 8:50 ` [Slub cleanup5 0/3] SLUB: Cleanups V5 Pekka Enberg
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=20100928131057.767067382@linux.com \
--to=cl@linux.com \
--cc=linux-mm@kvack.org \
--cc=penberg@cs.helsinki.fi \
--cc=rientjes@google.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).