Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1309015 > unrolled thread
| Started by | Joonsoo Kim <js1304@gmail.com> |
|---|---|
| First post | 2016-01-14 06:30 +0100 |
| Last post | 2016-01-14 06:30 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 15/16] mm/slab: factor out debugging initialization in cache_init_objs() Joonsoo Kim <js1304@gmail.com> - 2016-01-14 06:30 +0100
| From | Joonsoo Kim <js1304@gmail.com> |
|---|---|
| Date | 2016-01-14 06:30 +0100 |
| Subject | [PATCH 15/16] mm/slab: factor out debugging initialization in cache_init_objs() |
| Message-ID | <qQIDV-2oH-13@gated-at.bofh.it> |
cache_init_objs() will be changed in following patch and current form
doesn't fit well for that change. So, before doing it, this patch
separates debugging initialization. This would cause two loop iteration
when debugging is enabled, but, this overhead seems too light than
debug feature itself so effect may not be visible. This patch will
greatly simplify changes in cache_init_objs() in following patch.
Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
---
mm/slab.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/mm/slab.c b/mm/slab.c
index dbf18ed..a9807c3 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2461,14 +2461,14 @@ static inline void set_free_obj(struct page *page,
((freelist_idx_t *)(page->freelist))[idx] = val;
}
-static void cache_init_objs(struct kmem_cache *cachep,
- struct page *page)
+static void cache_init_objs_debug(struct kmem_cache *cachep, struct page *page)
{
+#if DEBUG
int i;
for (i = 0; i < cachep->num; i++) {
void *objp = index_to_obj(cachep, page, i);
-#if DEBUG
+
if (cachep->flags & SLAB_STORE_USER)
*dbg_userword(cachep, objp) = NULL;
@@ -2497,10 +2497,22 @@ static void cache_init_objs(struct kmem_cache *cachep,
poison_obj(cachep, objp, POISON_FREE);
slab_kernel_map(cachep, objp, 0, 0);
}
-#else
- if (cachep->ctor)
- cachep->ctor(objp);
+ }
#endif
+}
+
+static void cache_init_objs(struct kmem_cache *cachep,
+ struct page *page)
+{
+ int i;
+
+ cache_init_objs_debug(cachep, page);
+
+ for (i = 0; i < cachep->num; i++) {
+ /* constructor could break poison info */
+ if (DEBUG == 0 && cachep->ctor)
+ cachep->ctor(index_to_obj(cachep, page, i));
+
set_free_obj(page, i, i);
}
}
--
1.9.1
Back to top | Article view | linux.kernel
csiph-web