[PATCH 3/5] slab_id: Slab support for IDs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx>

---
 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@xxxxxxxxx.  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@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]