]> Git Repo - linux.git/commitdiff
Merge branch 'slab/next' of git://git.kernel.org/pub/scm/linux/kernel/git/penberg...
authorLinus Torvalds <[email protected]>
Sun, 15 Sep 2013 11:15:06 +0000 (07:15 -0400)
committerLinus Torvalds <[email protected]>
Sun, 15 Sep 2013 11:15:06 +0000 (07:15 -0400)
Pull SLAB update from Pekka Enberg:
 "Nothing terribly exciting here apart from Christoph's kmalloc
  unification patches that brings sl[aou]b implementations closer to
  each other"

* 'slab/next' of git://git.kernel.org/pub/scm/linux/kernel/git/penberg/linux:
  slab: Use correct GFP_DMA constant
  slub: remove verify_mem_not_deleted()
  mm/sl[aou]b: Move kmallocXXX functions to common code
  mm, slab_common: add 'unlikely' to size check of kmalloc_slab()
  mm/slub.c: beautify code for removing redundancy 'break' statement.
  slub: Remove unnecessary page NULL check
  slub: don't use cpu partial pages on UP
  mm/slub: beautify code for 80 column limitation and tab alignment
  mm/slub: remove 'per_cpu' which is useless variable

1  2 
init/Kconfig
mm/slub.c

diff --combined init/Kconfig
index 18bd9e3d327496b94c62e0c0555167ede4159148,63c67de99c105f678ae3c9a5a3ac171e228f6428..3ecd8a1178f102d832cdf3b4af0a908997ea648b
@@@ -470,7 -470,6 +470,7 @@@ config TREE_RC
  config TREE_PREEMPT_RCU
        bool "Preemptible tree-based hierarchical RCU"
        depends on PREEMPT
 +      select IRQ_WORK
        help
          This option selects the RCU implementation that is
          designed for very large SMP systems with hundreds or
@@@ -528,29 -527,13 +528,29 @@@ config RCU_USER_Q
  config CONTEXT_TRACKING_FORCE
        bool "Force context tracking"
        depends on CONTEXT_TRACKING
 -      default CONTEXT_TRACKING
 +      default y if !NO_HZ_FULL
        help
 -        Probe on user/kernel boundaries by default in order to
 -        test the features that rely on it such as userspace RCU extended
 -        quiescent states.
 -        This test is there for debugging until we have a real user like the
 -        full dynticks mode.
 +        The major pre-requirement for full dynticks to work is to
 +        support the context tracking subsystem. But there are also
 +        other dependencies to provide in order to make the full
 +        dynticks working.
 +
 +        This option stands for testing when an arch implements the
 +        context tracking backend but doesn't yet fullfill all the
 +        requirements to make the full dynticks feature working.
 +        Without the full dynticks, there is no way to test the support
 +        for context tracking and the subsystems that rely on it: RCU
 +        userspace extended quiescent state and tickless cputime
 +        accounting. This option copes with the absence of the full
 +        dynticks subsystem by forcing the context tracking on all
 +        CPUs in the system.
 +
 +        Say Y only if you're working on the developpement of an
 +        architecture backend for the context tracking.
 +
 +        Say N otherwise, this option brings an overhead that you
 +        don't want in production.
 +
  
  config RCU_FANOUT
        int "Tree-based hierarchical RCU fanout value"
@@@ -972,7 -955,7 +972,7 @@@ config MEMCG_SWAP_ENABLE
          Memory Resource Controller Swap Extension comes with its price in
          a bigger memory consumption. General purpose distribution kernels
          which want to enable the feature but keep it disabled by default
 -        and let the user enable it by swapaccount boot command line
 +        and let the user enable it by swapaccount=1 boot command line
          parameter should have this option unselected.
          For those who want to have the feature enabled by default should
          select this option (if, for some reason, they need to disable it
@@@ -1123,6 -1106,7 +1123,6 @@@ config IPC_N
  
  config USER_NS
        bool "User namespace"
 -      depends on UIDGID_CONVERTED
        select UIDGID_STRICT_TYPE_CHECKS
  
        default n
@@@ -1156,8 -1140,20 +1156,8 @@@ config NET_N
  
  endif # NAMESPACES
  
 -config UIDGID_CONVERTED
 -      # True if all of the selected software conmponents are known
 -      # to have uid_t and gid_t converted to kuid_t and kgid_t
 -      # where appropriate and are otherwise safe to use with
 -      # the user namespace.
 -      bool
 -      default y
 -
 -      # Filesystems
 -      depends on XFS_FS = n
 -
  config UIDGID_STRICT_TYPE_CHECKS
        bool "Require conversions between uid/gids and their internal representation"
 -      depends on UIDGID_CONVERTED
        default n
        help
         While the nececessary conversions are being added to all subsystems this option allows
@@@ -1602,7 -1598,7 +1602,7 @@@ endchoic
  
  config SLUB_CPU_PARTIAL
        default y
-       depends on SLUB
+       depends on SLUB && SMP
        bool "SLUB per cpu partial cache"
        help
          Per cpu partial caches accellerate objects allocation and freeing
@@@ -1670,7 -1666,6 +1670,7 @@@ config BASE_SMAL
  
  menuconfig MODULES
        bool "Enable loadable module support"
 +      option modules
        help
          Kernel modules are small pieces of compiled code which can
          be inserted in the running kernel, rather than being
diff --combined mm/slub.c
index 51df8272cfaf166dd9658b6e41c184fef1108b1c,9162c99fb307ff443d9889ca2719f8dfdfb2bc27..c3eb3d3ca83565b925e197f2ad44ac2c313345b8
+++ b/mm/slub.c
@@@ -373,7 -373,8 +373,8 @@@ static inline bool __cmpxchg_double_sla
  #endif
        {
                slab_lock(page);
-               if (page->freelist == freelist_old && page->counters == counters_old) {
+               if (page->freelist == freelist_old &&
+                                       page->counters == counters_old) {
                        page->freelist = freelist_new;
                        page->counters = counters_new;
                        slab_unlock(page);
@@@ -411,7 -412,8 +412,8 @@@ static inline bool cmpxchg_double_slab(
  
                local_irq_save(flags);
                slab_lock(page);
-               if (page->freelist == freelist_old && page->counters == counters_old) {
+               if (page->freelist == freelist_old &&
+                                       page->counters == counters_old) {
                        page->freelist = freelist_new;
                        page->counters = counters_new;
                        slab_unlock(page);
@@@ -553,8 -555,9 +555,9 @@@ static void print_tracking(struct kmem_
  
  static void print_page_info(struct page *page)
  {
-       printk(KERN_ERR "INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=0x%04lx\n",
-               page, page->objects, page->inuse, page->freelist, page->flags);
+       printk(KERN_ERR
+              "INFO: Slab 0x%p objects=%u used=%u fp=0x%p flags=0x%04lx\n",
+              page, page->objects, page->inuse, page->freelist, page->flags);
  
  }
  
@@@ -629,7 -632,8 +632,8 @@@ static void object_err(struct kmem_cach
        print_trailer(s, page, object);
  }
  
- static void slab_err(struct kmem_cache *s, struct page *page, const char *fmt, ...)
+ static void slab_err(struct kmem_cache *s, struct page *page,
+                       const char *fmt, ...)
  {
        va_list args;
        char buf[100];
@@@ -788,7 -792,8 +792,8 @@@ static int check_object(struct kmem_cac
        } else {
                if ((s->flags & SLAB_POISON) && s->object_size < s->inuse) {
                        check_bytes_and_report(s, page, p, "Alignment padding",
-                               endobject, POISON_INUSE, s->inuse - s->object_size);
+                               endobject, POISON_INUSE,
+                               s->inuse - s->object_size);
                }
        }
  
@@@ -873,7 -878,6 +878,6 @@@ static int on_freelist(struct kmem_cach
                                object_err(s, page, object,
                                        "Freechain corrupt");
                                set_freepointer(s, object, NULL);
-                               break;
                        } else {
                                slab_err(s, page, "Freepointer corrupt");
                                page->freelist = NULL;
@@@ -918,7 -922,8 +922,8 @@@ static void trace(struct kmem_cache *s
                        page->freelist);
  
                if (!alloc)
-                       print_section("Object ", (void *)object, s->object_size);
+                       print_section("Object ", (void *)object,
+                                       s->object_size);
  
                dump_stack();
        }
@@@ -937,7 -942,8 +942,8 @@@ static inline int slab_pre_alloc_hook(s
        return should_failslab(s->object_size, flags, s->flags);
  }
  
- static inline void slab_post_alloc_hook(struct kmem_cache *s, gfp_t flags, void *object)
+ static inline void slab_post_alloc_hook(struct kmem_cache *s,
+                                       gfp_t flags, void *object)
  {
        flags &= gfp_allowed_mask;
        kmemcheck_slab_alloc(s, flags, object, slab_ksize(s));
@@@ -1039,7 -1045,8 +1045,8 @@@ static void setup_object_debug(struct k
        init_tracking(s, object);
  }
  
- static noinline int alloc_debug_processing(struct kmem_cache *s, struct page *page,
+ static noinline int alloc_debug_processing(struct kmem_cache *s,
+                                       struct page *page,
                                        void *object, unsigned long addr)
  {
        if (!check_slab(s, page))
@@@ -1743,7 -1750,8 +1750,8 @@@ static void init_kmem_cache_cpus(struc
  /*
   * Remove the cpu slab
   */
- static void deactivate_slab(struct kmem_cache *s, struct page *page, void *freelist)
+ static void deactivate_slab(struct kmem_cache *s, struct page *page,
+                               void *freelist)
  {
        enum slab_modes { M_NONE, M_PARTIAL, M_FULL, M_FREE };
        struct kmem_cache_node *n = get_node(s, page_to_nid(page));
@@@ -1968,6 -1976,9 +1976,6 @@@ static void put_cpu_partial(struct kmem
        int pages;
        int pobjects;
  
 -      if (!s->cpu_partial)
 -              return;
 -
        do {
                pages = 0;
                pobjects = 0;
                page->pobjects = pobjects;
                page->next = oldpage;
  
-       } while (this_cpu_cmpxchg(s->cpu_slab->partial, oldpage, page) != oldpage);
+       } while (this_cpu_cmpxchg(s->cpu_slab->partial, oldpage, page)
+                                                               != oldpage);
  #endif
  }
  
@@@ -2169,8 -2181,8 +2178,8 @@@ static inline bool pfmemalloc_match(str
  }
  
  /*
-  * Check the page->freelist of a page and either transfer the freelist to the per cpu freelist
-  * or deactivate the page.
+  * Check the page->freelist of a page and either transfer the freelist to the
+  * per cpu freelist or deactivate the page.
   *
   * The page is still frozen if the return value is not NULL.
   *
@@@ -2314,7 -2326,8 +2323,8 @@@ new_slab
                goto load_freelist;
  
        /* Only entered in the debug case */
-       if (kmem_cache_debug(s) && !alloc_debug_processing(s, page, freelist, addr))
+       if (kmem_cache_debug(s) &&
+                       !alloc_debug_processing(s, page, freelist, addr))
                goto new_slab;  /* Slab failed checks. Next slab needed */
  
        deactivate_slab(s, page, get_freepointer(s, freelist));
@@@ -2372,7 -2385,7 +2382,7 @@@ redo
  
        object = c->freelist;
        page = c->page;
-       if (unlikely(!object || !page || !node_match(page, node)))
+       if (unlikely(!object || !node_match(page, node)))
                object = __slab_alloc(s, gfpflags, node, addr, c);
  
        else {
                 * The cmpxchg will only match if there was no additional
                 * operation and if we are on the right processor.
                 *
-                * The cmpxchg does the following atomically (without lock semantics!)
+                * The cmpxchg does the following atomically (without lock
+                * semantics!)
                 * 1. Relocate first pointer to the current per cpu area.
                 * 2. Verify that tid and freelist have not been changed
                 * 3. If they were not changed replace tid and freelist
                 *
-                * Since this is without lock semantics the protection is only against
-                * code executing on this cpu *not* from access by other cpus.
+                * Since this is without lock semantics the protection is only
+                * against code executing on this cpu *not* from access by
+                * other cpus.
                 */
                if (unlikely(!this_cpu_cmpxchg_double(
                                s->cpu_slab->freelist, s->cpu_slab->tid,
@@@ -2420,7 -2435,8 +2432,8 @@@ void *kmem_cache_alloc(struct kmem_cach
  {
        void *ret = slab_alloc(s, gfpflags, _RET_IP_);
  
-       trace_kmem_cache_alloc(_RET_IP_, ret, s->object_size, s->size, gfpflags);
+       trace_kmem_cache_alloc(_RET_IP_, ret, s->object_size,
+                               s->size, gfpflags);
  
        return ret;
  }
@@@ -2434,14 -2450,6 +2447,6 @@@ void *kmem_cache_alloc_trace(struct kme
        return ret;
  }
  EXPORT_SYMBOL(kmem_cache_alloc_trace);
- void *kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
- {
-       void *ret = kmalloc_order(size, flags, order);
-       trace_kmalloc(_RET_IP_, ret, size, PAGE_SIZE << order, flags);
-       return ret;
- }
- EXPORT_SYMBOL(kmalloc_order_trace);
  #endif
  
  #ifdef CONFIG_NUMA
@@@ -2512,8 -2520,10 +2517,10 @@@ static void __slab_free(struct kmem_cac
                        if (kmem_cache_has_cpu_partial(s) && !prior)
  
                                /*
-                                * Slab was on no list before and will be partially empty
-                                * We can defer the list move and instead freeze it.
+                                * Slab was on no list before and will be
+                                * partially empty
+                                * We can defer the list move and instead
+                                * freeze it.
                                 */
                                new.frozen = 1;
  
@@@ -3071,8 -3081,8 +3078,8 @@@ static int kmem_cache_open(struct kmem_
         * A) The number of objects from per cpu partial slabs dumped to the
         *    per node list when we reach the limit.
         * B) The number of objects in cpu partial slabs to extract from the
-        *    per node list when we run out of per cpu objects. We only fetch 50%
-        *    to keep some capacity around for frees.
+        *    per node list when we run out of per cpu objects. We only fetch
+        *    50% to keep some capacity around for frees.
         */
        if (!kmem_cache_has_cpu_partial(s))
                s->cpu_partial = 0;
@@@ -3099,8 -3109,8 +3106,8 @@@ error
        if (flags & SLAB_PANIC)
                panic("Cannot create slab %s size=%lu realsize=%u "
                        "order=%u offset=%u flags=%lx\n",
-                       s->name, (unsigned long)s->size, s->size, oo_order(s->oo),
-                       s->offset, flags);
+                       s->name, (unsigned long)s->size, s->size,
+                       oo_order(s->oo), s->offset, flags);
        return -EINVAL;
  }
  
@@@ -3316,42 -3326,6 +3323,6 @@@ size_t ksize(const void *object
  }
  EXPORT_SYMBOL(ksize);
  
- #ifdef CONFIG_SLUB_DEBUG
- bool verify_mem_not_deleted(const void *x)
- {
-       struct page *page;
-       void *object = (void *)x;
-       unsigned long flags;
-       bool rv;
-       if (unlikely(ZERO_OR_NULL_PTR(x)))
-               return false;
-       local_irq_save(flags);
-       page = virt_to_head_page(x);
-       if (unlikely(!PageSlab(page))) {
-               /* maybe it was from stack? */
-               rv = true;
-               goto out_unlock;
-       }
-       slab_lock(page);
-       if (on_freelist(page->slab_cache, page, object)) {
-               object_err(page->slab_cache, page, object, "Object is on free-list");
-               rv = false;
-       } else {
-               rv = true;
-       }
-       slab_unlock(page);
- out_unlock:
-       local_irq_restore(flags);
-       return rv;
- }
- EXPORT_SYMBOL(verify_mem_not_deleted);
- #endif
  void kfree(const void *x)
  {
        struct page *page;
@@@ -3770,7 -3744,7 +3741,7 @@@ int __kmem_cache_create(struct kmem_cac
   * Use the cpu notifier to insure that the cpu slabs are flushed when
   * necessary.
   */
 -static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
 +static int slab_cpuup_callback(struct notifier_block *nfb,
                unsigned long action, void *hcpu)
  {
        long cpu = (long)hcpu;
        return NOTIFY_OK;
  }
  
 -static struct notifier_block __cpuinitdata slab_notifier = {
 +static struct notifier_block slab_notifier = {
        .notifier_call = slab_cpuup_callback
  };
  
@@@ -4162,15 -4136,17 +4133,17 @@@ static int list_locations(struct kmem_c
                                !cpumask_empty(to_cpumask(l->cpus)) &&
                                len < PAGE_SIZE - 60) {
                        len += sprintf(buf + len, " cpus=");
-                       len += cpulist_scnprintf(buf + len, PAGE_SIZE - len - 50,
+                       len += cpulist_scnprintf(buf + len,
+                                                PAGE_SIZE - len - 50,
                                                 to_cpumask(l->cpus));
                }
  
                if (nr_online_nodes > 1 && !nodes_empty(l->nodes) &&
                                len < PAGE_SIZE - 60) {
                        len += sprintf(buf + len, " nodes=");
-                       len += nodelist_scnprintf(buf + len, PAGE_SIZE - len - 50,
-                                       l->nodes);
+                       len += nodelist_scnprintf(buf + len,
+                                                 PAGE_SIZE - len - 50,
+                                                 l->nodes);
                }
  
                len += sprintf(buf + len, "\n");
@@@ -4268,18 -4244,17 +4241,17 @@@ static ssize_t show_slab_objects(struc
        int node;
        int x;
        unsigned long *nodes;
-       unsigned long *per_cpu;
  
-       nodes = kzalloc(2 * sizeof(unsigned long) * nr_node_ids, GFP_KERNEL);
+       nodes = kzalloc(sizeof(unsigned long) * nr_node_ids, GFP_KERNEL);
        if (!nodes)
                return -ENOMEM;
-       per_cpu = nodes + nr_node_ids;
  
        if (flags & SO_CPU) {
                int cpu;
  
                for_each_possible_cpu(cpu) {
-                       struct kmem_cache_cpu *c = per_cpu_ptr(s->cpu_slab, cpu);
+                       struct kmem_cache_cpu *c = per_cpu_ptr(s->cpu_slab,
+                                                              cpu);
                        int node;
                        struct page *page;
  
                                total += x;
                                nodes[node] += x;
                        }
-                       per_cpu[node]++;
                }
        }
  
                for_each_node_state(node, N_NORMAL_MEMORY) {
                        struct kmem_cache_node *n = get_node(s, node);
  
-               if (flags & SO_TOTAL)
-                       x = atomic_long_read(&n->total_objects);
-               else if (flags & SO_OBJECTS)
-                       x = atomic_long_read(&n->total_objects) -
-                               count_partial(n, count_free);
+                       if (flags & SO_TOTAL)
+                               x = atomic_long_read(&n->total_objects);
+                       else if (flags & SO_OBJECTS)
+                               x = atomic_long_read(&n->total_objects) -
+                                       count_partial(n, count_free);
                        else
                                x = atomic_long_read(&n->nr_slabs);
                        total += x;
@@@ -4420,7 -4392,7 +4389,7 @@@ static ssize_t order_store(struct kmem_
        unsigned long order;
        int err;
  
 -      err = strict_strtoul(buf, 10, &order);
 +      err = kstrtoul(buf, 10, &order);
        if (err)
                return err;
  
@@@ -4448,7 -4420,7 +4417,7 @@@ static ssize_t min_partial_store(struc
        unsigned long min;
        int err;
  
 -      err = strict_strtoul(buf, 10, &min);
 +      err = kstrtoul(buf, 10, &min);
        if (err)
                return err;
  
@@@ -4468,7 -4440,7 +4437,7 @@@ static ssize_t cpu_partial_store(struc
        unsigned long objects;
        int err;
  
 -      err = strict_strtoul(buf, 10, &objects);
 +      err = kstrtoul(buf, 10, &objects);
        if (err)
                return err;
        if (objects && !kmem_cache_has_cpu_partial(s))
@@@ -4784,7 -4756,7 +4753,7 @@@ static ssize_t remote_node_defrag_ratio
        unsigned long ratio;
        int err;
  
 -      err = strict_strtoul(buf, 10, &ratio);
 +      err = kstrtoul(buf, 10, &ratio);
        if (err)
                return err;
  
@@@ -5136,7 -5108,8 +5105,8 @@@ static char *create_unique_id(struct km
  
  #ifdef CONFIG_MEMCG_KMEM
        if (!is_root_cache(s))
-               p += sprintf(p, "-%08d", memcg_cache_id(s->memcg_params->memcg));
+               p += sprintf(p, "-%08d",
+                               memcg_cache_id(s->memcg_params->memcg));
  #endif
  
        BUG_ON(p > name + ID_STR_LENGTH - 1);
This page took 0.103681 seconds and 4 git commands to generate.