slub: add comments to endif pre-processor macros

SLUB allocator makes heavy use of ifdef/endif pre-processor macros.  The
pairing of these statements is at times hard to follow e.g.  if the pair
are further than a screen apart or if there are nested pairs.  We can
reduce cognitive load by adding a comment to the endif statement of form

       #ifdef CONFIG_FOO
       ...
       #endif /* CONFIG_FOO */

Add comments to endif pre-processor macros if ifdef/endif pair is not
immediately apparent.

Link: http://lkml.kernel.org/r/20190402230545.2929-5-tobin@kernel.org
Signed-off-by: Tobin C. Harding <tobin@kernel.org>
Acked-by: Christoph Lameter <cl@linux.com>
Reviewed-by: Roman Gushchin <guro@fb.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Tobin C. Harding 2019-05-13 17:16:09 -07:00 committed by Linus Torvalds
parent adab7b6818
commit 6dfd1b653c

View File

@ -1942,7 +1942,7 @@ static void *get_any_partial(struct kmem_cache *s, gfp_t flags,
} }
} }
} while (read_mems_allowed_retry(cpuset_mems_cookie)); } while (read_mems_allowed_retry(cpuset_mems_cookie));
#endif #endif /* CONFIG_NUMA */
return NULL; return NULL;
} }
@ -2240,7 +2240,7 @@ static void unfreeze_partials(struct kmem_cache *s,
discard_slab(s, page); discard_slab(s, page);
stat(s, FREE_SLAB); stat(s, FREE_SLAB);
} }
#endif #endif /* CONFIG_SLUB_CPU_PARTIAL */
} }
/* /*
@ -2299,7 +2299,7 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain)
local_irq_restore(flags); local_irq_restore(flags);
} }
preempt_enable(); preempt_enable();
#endif #endif /* CONFIG_SLUB_CPU_PARTIAL */
} }
static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c) static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
@ -2804,7 +2804,7 @@ void *kmem_cache_alloc_node_trace(struct kmem_cache *s,
} }
EXPORT_SYMBOL(kmem_cache_alloc_node_trace); EXPORT_SYMBOL(kmem_cache_alloc_node_trace);
#endif #endif
#endif #endif /* CONFIG_NUMA */
/* /*
* Slow path handling. This may still be called frequently since objects * Slow path handling. This may still be called frequently since objects
@ -3839,7 +3839,7 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
return ret; return ret;
} }
EXPORT_SYMBOL(__kmalloc_node); EXPORT_SYMBOL(__kmalloc_node);
#endif #endif /* CONFIG_NUMA */
#ifdef CONFIG_HARDENED_USERCOPY #ifdef CONFIG_HARDENED_USERCOPY
/* /*
@ -4057,7 +4057,7 @@ void __kmemcg_cache_deactivate(struct kmem_cache *s)
*/ */
slab_deactivate_memcg_cache_rcu_sched(s, kmemcg_cache_deact_after_rcu); slab_deactivate_memcg_cache_rcu_sched(s, kmemcg_cache_deact_after_rcu);
} }
#endif #endif /* CONFIG_MEMCG */
static int slab_mem_going_offline_callback(void *arg) static int slab_mem_going_offline_callback(void *arg)
{ {
@ -4690,7 +4690,7 @@ static int list_locations(struct kmem_cache *s, char *buf,
len += sprintf(buf, "No data\n"); len += sprintf(buf, "No data\n");
return len; return len;
} }
#endif #endif /* CONFIG_SLUB_DEBUG */
#ifdef SLUB_RESILIENCY_TEST #ifdef SLUB_RESILIENCY_TEST
static void __init resiliency_test(void) static void __init resiliency_test(void)
@ -4750,7 +4750,7 @@ static void __init resiliency_test(void)
#ifdef CONFIG_SYSFS #ifdef CONFIG_SYSFS
static void resiliency_test(void) {}; static void resiliency_test(void) {};
#endif #endif
#endif #endif /* SLUB_RESILIENCY_TEST */
#ifdef CONFIG_SYSFS #ifdef CONFIG_SYSFS
enum slab_stat_type { enum slab_stat_type {
@ -5407,7 +5407,7 @@ STAT_ATTR(CPU_PARTIAL_ALLOC, cpu_partial_alloc);
STAT_ATTR(CPU_PARTIAL_FREE, cpu_partial_free); STAT_ATTR(CPU_PARTIAL_FREE, cpu_partial_free);
STAT_ATTR(CPU_PARTIAL_NODE, cpu_partial_node); STAT_ATTR(CPU_PARTIAL_NODE, cpu_partial_node);
STAT_ATTR(CPU_PARTIAL_DRAIN, cpu_partial_drain); STAT_ATTR(CPU_PARTIAL_DRAIN, cpu_partial_drain);
#endif #endif /* CONFIG_SLUB_STATS */
static struct attribute *slab_attrs[] = { static struct attribute *slab_attrs[] = {
&slab_size_attr.attr, &slab_size_attr.attr,
@ -5608,7 +5608,7 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s)
if (buffer) if (buffer)
free_page((unsigned long)buffer); free_page((unsigned long)buffer);
#endif #endif /* CONFIG_MEMCG */
} }
static void kmem_cache_release(struct kobject *k) static void kmem_cache_release(struct kobject *k)