From: Christoph Lameter <clameter@sgi.com>
To: akpm@osdl.org
Cc: linux-mm@kvack.org, Christoph Lameter <clameter@sgi.com>
Subject: [SLUB 2/5] Use enum for tracking modes instead of integers
Date: Mon, 9 Apr 2007 20:29:17 -0700 (PDT) [thread overview]
Message-ID: <20070410032917.18967.55114.sendpatchset@schroedinger.engr.sgi.com> (raw)
In-Reply-To: <20070410032912.18967.67076.sendpatchset@schroedinger.engr.sgi.com>
Use enum for tracking modes instead of integers.
Integers caused some confusion. This cleans it up and uses symbolic constants
throughout.
Signed-off-by: Christoph Lameter <clameter@sgi.com>
Index: linux-2.6.21-rc6-mm1/mm/slub.c
===================================================================
--- linux-2.6.21-rc6-mm1.orig/mm/slub.c 2007-04-09 15:30:59.000000000 -0700
+++ linux-2.6.21-rc6-mm1/mm/slub.c 2007-04-09 15:32:10.000000000 -0700
@@ -211,7 +211,10 @@ struct track {
unsigned long when; /* When did the operation occur */
};
-struct track *get_track(struct kmem_cache *s, void *object, int alloc)
+enum track_item { TRACK_ALLOC, TRACK_FREE };
+
+struct track *get_track(struct kmem_cache *s, void *object,
+ enum track_item alloc)
{
struct track *p;
@@ -224,7 +227,7 @@ struct track *get_track(struct kmem_cach
}
static void set_track(struct kmem_cache *s, void *object,
- int alloc, void *addr)
+ enum track_item alloc, void *addr)
{
struct track *p;
@@ -249,8 +252,8 @@ static void set_track(struct kmem_cache
static void init_tracking(struct kmem_cache *s, void *object)
{
if (s->flags & SLAB_STORE_USER) {
- set_track(s, object, 0, NULL);
- set_track(s, object, 1, NULL);
+ set_track(s, object, TRACK_FREE, NULL);
+ set_track(s, object, TRACK_ALLOC, NULL);
}
}
@@ -298,8 +301,8 @@ static void print_trailer(struct kmem_ca
off = s->inuse;
if (s->flags & SLAB_STORE_USER) {
- print_track("Last alloc", get_track(s, p, 0));
- print_track("Last free ", get_track(s, p, 1));
+ print_track("Last alloc", get_track(s, p, TRACK_ALLOC));
+ print_track("Last free ", get_track(s, p, TRACK_FREE));
off += 2 * sizeof(struct track);
}
@@ -1186,7 +1189,7 @@ debug:
if (!alloc_object_checks(s, page, object))
goto another_slab;
if (s->flags & SLAB_STORE_USER)
- set_tracking(s, object, 0);
+ set_tracking(s, object, TRACK_ALLOC);
goto have_object;
}
@@ -1274,7 +1277,7 @@ void kmem_cache_free(struct kmem_cache *
page = virt_to_head_page(x);
if (unlikely(PageError(page) && (s->flags & SLAB_STORE_USER)))
- set_tracking(s, x, 1);
+ set_tracking(s, x, TRACK_FREE);
slab_free(s, page, x);
}
EXPORT_SYMBOL(kmem_cache_free);
@@ -1894,7 +1897,7 @@ void kfree(const void *x)
s = page->slab;
if (unlikely(PageError(page) && (s->flags & SLAB_STORE_USER)))
- set_tracking(s, (void *)x, 1);
+ set_tracking(s, (void *)x, TRACK_FREE);
slab_free(s, page, (void *)x);
}
EXPORT_SYMBOL(kfree);
@@ -2254,7 +2257,7 @@ void *__kmalloc_track_caller(size_t size
object = kmem_cache_alloc(s, gfpflags);
if (object && (s->flags & SLAB_STORE_USER))
- set_track(s, object, 0, caller);
+ set_track(s, object, TRACK_ALLOC, caller);
return object;
}
@@ -2271,7 +2274,7 @@ void *__kmalloc_node_track_caller(size_t
object = kmem_cache_alloc_node(s, gfpflags, node);
if (object && (s->flags & SLAB_STORE_USER))
- set_track(s, object, 0, caller);
+ set_track(s, object, TRACK_ALLOC, caller);
return object;
}
--
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:[~2007-04-10 3:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-10 3:29 [SLUB 1/5] Minor fixes Christoph Lameter
2007-04-10 3:29 ` Christoph Lameter [this message]
2007-04-10 3:29 ` [SLUB 3/5] Fix object tracking Christoph Lameter
2007-04-10 3:29 ` [SLUB 4/5] Fix another NUMA bootstrap issue Christoph Lameter
2007-04-10 3:29 ` [SLUB 5/5] Update slabinfo.c Christoph Lameter
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=20070410032917.18967.55114.sendpatchset@schroedinger.engr.sgi.com \
--to=clameter@sgi.com \
--cc=akpm@osdl.org \
--cc=linux-mm@kvack.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