]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - mm/slub.c
Merge branch 'tracing/core-v2' into tracing-for-linus
[linux-2.6-omap-h63xx.git] / mm / slub.c
index 816734ed8aa3c9c20666676b2cf25fa86d3eb547..7aaa121d0ea9eda5cd2acddbf3707de9536da241 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -375,14 +375,8 @@ static struct track *get_track(struct kmem_cache *s, void *object,
 static void set_track(struct kmem_cache *s, void *object,
                        enum track_item alloc, unsigned long addr)
 {
-       struct track *p;
-
-       if (s->offset)
-               p = object + s->offset + sizeof(void *);
-       else
-               p = object + s->inuse;
+       struct track *p = get_track(s, object, alloc);
 
-       p += alloc;
        if (addr) {
                p->addr = addr;
                p->cpu = smp_processor_id();
@@ -1336,7 +1330,7 @@ static struct page *get_any_partial(struct kmem_cache *s, gfp_t flags)
                n = get_node(s, zone_to_nid(zone));
 
                if (n && cpuset_zone_allowed_hardwall(zone, flags) &&
-                               n->nr_partial > n->min_partial) {
+                               n->nr_partial > s->min_partial) {
                        page = get_partial_node(n);
                        if (page)
                                return page;
@@ -1388,7 +1382,7 @@ static void unfreeze_slab(struct kmem_cache *s, struct page *page, int tail)
                slab_unlock(page);
        } else {
                stat(c, DEACTIVATE_EMPTY);
-               if (n->nr_partial < n->min_partial) {
+               if (n->nr_partial < s->min_partial) {
                        /*
                         * Adding an empty slab to the partial slabs in order
                         * to avoid page allocator overhead. This slab needs
@@ -1754,7 +1748,7 @@ static __always_inline void slab_free(struct kmem_cache *s,
        c = get_cpu_slab(s, smp_processor_id());
        debug_check_no_locks_freed(object, c->objsize);
        if (!(s->flags & SLAB_DEBUG_OBJECTS))
-               debug_check_no_obj_freed(object, s->objsize);
+               debug_check_no_obj_freed(object, c->objsize);
        if (likely(page == c->page && c->node >= 0)) {
                object[c->offset] = c->freelist;
                c->freelist = object;
@@ -1876,6 +1870,7 @@ static inline int calculate_order(int size)
        int order;
        int min_objects;
        int fraction;
+       int max_objects;
 
        /*
         * Attempt to find best configuration for a slab. This
@@ -1888,6 +1883,9 @@ static inline int calculate_order(int size)
        min_objects = slub_min_objects;
        if (!min_objects)
                min_objects = 4 * (fls(nr_cpu_ids) + 1);
+       max_objects = (PAGE_SIZE << slub_max_order)/size;
+       min_objects = min(min_objects, max_objects);
+
        while (min_objects > 1) {
                fraction = 16;
                while (fraction >= 4) {
@@ -1897,7 +1895,7 @@ static inline int calculate_order(int size)
                                return order;
                        fraction /= 2;
                }
-               min_objects /= 2;
+               min_objects --;
        }
 
        /*
@@ -1960,17 +1958,6 @@ static void
 init_kmem_cache_node(struct kmem_cache_node *n, struct kmem_cache *s)
 {
        n->nr_partial = 0;
-
-       /*
-        * The larger the object size is, the more pages we want on the partial
-        * list to avoid pounding the page allocator excessively.
-        */
-       n->min_partial = ilog2(s->size);
-       if (n->min_partial < MIN_PARTIAL)
-               n->min_partial = MIN_PARTIAL;
-       else if (n->min_partial > MAX_PARTIAL)
-               n->min_partial = MAX_PARTIAL;
-
        spin_lock_init(&n->list_lock);
        INIT_LIST_HEAD(&n->partial);
 #ifdef CONFIG_SLUB_DEBUG
@@ -2213,6 +2200,15 @@ static int init_kmem_cache_nodes(struct kmem_cache *s, gfp_t gfpflags)
 }
 #endif
 
+static void set_min_partial(struct kmem_cache *s, unsigned long min)
+{
+       if (min < MIN_PARTIAL)
+               min = MIN_PARTIAL;
+       else if (min > MAX_PARTIAL)
+               min = MAX_PARTIAL;
+       s->min_partial = min;
+}
+
 /*
  * calculate_sizes() determines the order and the distribution of data within
  * a slab object.
@@ -2351,6 +2347,11 @@ static int kmem_cache_open(struct kmem_cache *s, gfp_t gfpflags,
        if (!calculate_sizes(s, -1))
                goto error;
 
+       /*
+        * The larger the object size is, the more pages we want on the partial
+        * list to avoid pounding the page allocator excessively.
+        */
+       set_min_partial(s, ilog2(s->size));
        s->refcount = 1;
 #ifdef CONFIG_NUMA
        s->remote_node_defrag_ratio = 1000;
@@ -3904,6 +3905,26 @@ static ssize_t order_show(struct kmem_cache *s, char *buf)
 }
 SLAB_ATTR(order);
 
+static ssize_t min_partial_show(struct kmem_cache *s, char *buf)
+{
+       return sprintf(buf, "%lu\n", s->min_partial);
+}
+
+static ssize_t min_partial_store(struct kmem_cache *s, const char *buf,
+                                size_t length)
+{
+       unsigned long min;
+       int err;
+
+       err = strict_strtoul(buf, 10, &min);
+       if (err)
+               return err;
+
+       set_min_partial(s, min);
+       return length;
+}
+SLAB_ATTR(min_partial);
+
 static ssize_t ctor_show(struct kmem_cache *s, char *buf)
 {
        if (s->ctor) {
@@ -4219,6 +4240,7 @@ static struct attribute *slab_attrs[] = {
        &object_size_attr.attr,
        &objs_per_slab_attr.attr,
        &order_attr.attr,
+       &min_partial_attr.attr,
        &objects_attr.attr,
        &objects_partial_attr.attr,
        &total_objects_attr.attr,