All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Emelyanov <xemul@parallels.com>
To: Christoph Lameter <cl@linux-foundation.org>,
	Pekka Enberg <penberg@kernel.org>, Matt Mackall <mpm@selenic.com>,
	linux-mm@kvack.org
Cc: Glauber Costa <glommer@parallels.com>,
	Cyrill Gorcunov <gorcunov@openvz.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 3/5] slab_id: Slab support for IDs
Date: Thu, 06 Oct 2011 20:23:55 +0400	[thread overview]
Message-ID: <4E8DD61B.5050009@parallels.com> (raw)
In-Reply-To: <4E8DD5B9.4060905@parallels.com>

Just place the slab ID generation into proper places of slab.c

The slab ID value is stored right after the bufctl array.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>

---
 mm/slab.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 81a2063..f87eb25 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2183,6 +2183,10 @@ static inline size_t __slab_size(int nr_objs, unsigned long flags)
 	size_t ret;
 
 	ret = sizeof(struct slab) + nr_objs * sizeof(kmem_bufctl_t);
+#ifdef CONFIG_SLAB_OBJECT_IDS
+	if (flags & SLAB_WANT_OBJIDS)
+		ret += sizeof(u64);
+#endif
 
 	return ret;
 }
@@ -2703,6 +2707,39 @@ static inline kmem_bufctl_t *slab_bufctl(struct slab *slabp)
 	return (kmem_bufctl_t *) (slabp + 1);
 }
 
+#ifdef CONFIG_SLAB_OBJECT_IDS
+static void slab_pick_id(struct kmem_cache *c, struct slab *s)
+{
+	if (c->flags & SLAB_WANT_OBJIDS)
+		__slab_pick_id((u64 *)(slab_bufctl(s) + c->num));
+}
+
+void k_object_id(const void *x, u64 *id)
+{
+	struct page *p;
+	struct kmem_cache *c;
+	struct slab *s;
+
+	id[0] = id[1] = 0;
+
+	if (x == NULL)
+		return;
+
+	p = virt_to_head_page(x);
+	c = page_get_cache(p);
+	if (!(c->flags & SLAB_WANT_OBJIDS))
+		return;
+
+	s = page_get_slab(p);
+	__slab_get_id(id, *(u64 *)(slab_bufctl(s) + c->num),
+			obj_to_index(c, s, x));
+}
+#else
+static inline void slab_pick_id(struct kmem_cache *c, struct slab *s)
+{
+}
+#endif
+
 /*
  * Get the memory for a slab management obj.
  * For a slab cache when the slab descriptor is off-slab, slab descriptors
@@ -2743,6 +2780,7 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
 	slabp->s_mem = objp + colour_off;
 	slabp->nodeid = nodeid;
 	slabp->free = 0;
+	slab_pick_id(cachep, slabp);
 	return slabp;
 }
 
-- 
1.5.5.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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2011-10-06 16:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-06 16:22 [PATCH 0/5] Slab objects identifiers Pavel Emelyanov
2011-10-06 16:23 ` [PATCH 1/5] slab: Tossing bits around Pavel Emelyanov
2011-10-06 16:23 ` [PATCH 2/5] slab_id: Generic slab ID infrastructure Pavel Emelyanov
2011-10-07  8:27   ` Glauber Costa
2011-10-07  8:31     ` Pavel Emelyanov
2011-10-06 16:23 ` Pavel Emelyanov [this message]
2011-10-06 16:24 ` [PATCH 4/5] slab_id: Slub support for IDs Pavel Emelyanov
2011-10-06 16:24 ` [PATCH 5/5] slab_id: Show the task's mm ID in proc Pavel Emelyanov
2011-10-07 17:03 ` [PATCH 0/5] Slab objects identifiers Christoph Lameter
2011-10-10 10:20   ` Pavel Emelyanov
2011-10-10 15:24     ` Christoph Lameter
2011-10-10 15:46       ` Pavel Emelyanov
2011-10-13  7:12     ` Pekka Enberg
2011-10-13 11:25       ` Pavel Emelyanov
2011-10-13 12:12         ` Pekka Enberg
2011-10-13 12:23           ` Pavel Emelyanov
2011-10-10 18:59 ` Matt Helsley
2011-10-11  7:50   ` Pavel Emelyanov

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=4E8DD61B.5050009@parallels.com \
    --to=xemul@parallels.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=glommer@parallels.com \
    --cc=gorcunov@openvz.org \
    --cc=linux-mm@kvack.org \
    --cc=mpm@selenic.com \
    --cc=penberg@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 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.