From: Jiang Liu <jiang.liu@huawei.com>
To: Christoph Lameter <cl@linux-foundation.org>,
Pekka Enberg <penberg@kernel.org>, Matt Mackall <mpm@selenic.com>,
Mel Gorman <mgorman@suse.de>, Yinghai Lu <yinghai@kernel.org>
Cc: Jiang Liu <jiang.liu@huawei.com>, Tony Luck <tony.luck@intel.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
David Rientjes <rientjes@google.com>,
Minchan Kim <minchan@kernel.org>,
Keping Chen <chenkeping@huawei.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Jiang Liu <liuj97@gmail.com>
Subject: [RFC PATCH 3/4] SLAB: minor code cleanup
Date: Tue, 3 Jul 2012 11:57:16 +0800 [thread overview]
Message-ID: <1341287837-7904-3-git-send-email-jiang.liu@huawei.com> (raw)
In-Reply-To: <1341287837-7904-1-git-send-email-jiang.liu@huawei.com>
Minor code cleanup for SLAB allocator.
Signed-off-by: Jiang Liu <liuj97@gmail.com>
---
mm/slab.c | 26 ++++++--------------------
1 files changed, 6 insertions(+), 20 deletions(-)
diff --git a/mm/slab.c b/mm/slab.c
index e901a36..cd163d1 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -499,34 +499,23 @@ static inline void page_set_cache(struct page *page, struct kmem_cache *cache)
page->lru.next = (struct list_head *)cache;
}
-static inline struct kmem_cache *page_get_cache(struct page *page)
-{
- page = compound_head(page);
- BUG_ON(!PageSlab(page));
- return (struct kmem_cache *)page->lru.next;
-}
-
static inline void page_set_slab(struct page *page, struct slab *slab)
{
page->lru.prev = (struct list_head *)slab;
}
-static inline struct slab *page_get_slab(struct page *page)
-{
- BUG_ON(!PageSlab(page));
- return (struct slab *)page->lru.prev;
-}
-
static inline struct kmem_cache *virt_to_cache(const void *obj)
{
struct page *page = virt_to_head_page(obj);
- return page_get_cache(page);
+ BUG_ON(!PageSlab(page));
+ return (struct kmem_cache *)page->lru.next;
}
static inline struct slab *virt_to_slab(const void *obj)
{
struct page *page = virt_to_head_page(obj);
- return page_get_slab(page);
+ BUG_ON(!PageSlab(page));
+ return (struct slab *)page->lru.prev;
}
static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
@@ -3047,7 +3036,6 @@ static inline void verify_redzone_free(struct kmem_cache *cache, void *obj)
static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp,
void *caller)
{
- struct page *page;
unsigned int objnr;
struct slab *slabp;
@@ -3055,9 +3043,7 @@ static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp,
objp -= obj_offset(cachep);
kfree_debugcheck(objp);
- page = virt_to_head_page(objp);
-
- slabp = page_get_slab(page);
+ slabp = virt_to_slab(objp);
if (cachep->flags & SLAB_RED_ZONE) {
verify_redzone_free(cachep, objp);
@@ -3261,7 +3247,7 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
struct slab *slabp;
unsigned objnr;
- slabp = page_get_slab(virt_to_head_page(objp));
+ slabp = virt_to_slab(objp);
objnr = (unsigned)(objp - slabp->s_mem) / cachep->buffer_size;
slab_bufctl(slabp)[objnr] = BUFCTL_ACTIVE;
}
--
1.7.1
--
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:[~2012-07-03 3:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-03 3:57 [RFC PATCH 1/4] mm: introduce a safer interface to check whether a page is managed by SLxB Jiang Liu
2012-07-03 3:57 ` [RFC PATCH 2/4] mm: make consistent use of PG_slab flag Jiang Liu
2012-07-05 14:47 ` Christoph Lameter
2012-07-05 16:15 ` Jiang Liu
2012-07-05 17:37 ` Christoph Lameter
2012-07-06 8:30 ` Jiang Liu
2012-07-06 13:53 ` Christoph Lameter
2012-07-03 3:57 ` Jiang Liu [this message]
2012-07-03 10:02 ` [RFC PATCH 3/4] SLAB: minor code cleanup Cong Wang
2012-07-03 3:57 ` [RFC PATCH 4/4] mm: change slob's struct page definition to accomodate struct page changes Jiang Liu
2012-07-03 10:22 ` Cong Wang
2012-07-03 9:56 ` [RFC PATCH 1/4] mm: introduce a safer interface to check whether a page is managed by SLxB Cong Wang
2012-07-05 14:45 ` Christoph Lameter
2012-07-05 15:55 ` Jiang Liu
2012-07-05 17:36 ` Christoph Lameter
2012-07-06 7:29 ` Jiang Liu
2012-07-06 13:50 ` Christoph Lameter
2012-07-06 15:36 ` Jiang Liu
2012-09-04 9:18 ` Wen Congyang
2012-09-04 12:13 ` Jiang Liu
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=1341287837-7904-3-git-send-email-jiang.liu@huawei.com \
--to=jiang.liu@huawei.com \
--cc=chenkeping@huawei.com \
--cc=cl@linux-foundation.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liuj97@gmail.com \
--cc=mgorman@suse.de \
--cc=minchan@kernel.org \
--cc=mpm@selenic.com \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
--cc=tony.luck@intel.com \
--cc=yinghai@kernel.org \
/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).