Skip to content

Commit 6dfd1b6

Browse files
Tobin C. Hardingtorvalds
authored andcommitted
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/[email protected] Signed-off-by: Tobin C. Harding <[email protected]> Acked-by: Christoph Lameter <[email protected]> Reviewed-by: Roman Gushchin <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: David Rientjes <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Pekka Enberg <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent adab7b6 commit 6dfd1b6

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

mm/slub.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ static void *get_any_partial(struct kmem_cache *s, gfp_t flags,
19421942
}
19431943
}
19441944
} while (read_mems_allowed_retry(cpuset_mems_cookie));
1945-
#endif
1945+
#endif /* CONFIG_NUMA */
19461946
return NULL;
19471947
}
19481948

@@ -2240,7 +2240,7 @@ static void unfreeze_partials(struct kmem_cache *s,
22402240
discard_slab(s, page);
22412241
stat(s, FREE_SLAB);
22422242
}
2243-
#endif
2243+
#endif /* CONFIG_SLUB_CPU_PARTIAL */
22442244
}
22452245

22462246
/*
@@ -2299,7 +2299,7 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain)
22992299
local_irq_restore(flags);
23002300
}
23012301
preempt_enable();
2302-
#endif
2302+
#endif /* CONFIG_SLUB_CPU_PARTIAL */
23032303
}
23042304

23052305
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,
28042804
}
28052805
EXPORT_SYMBOL(kmem_cache_alloc_node_trace);
28062806
#endif
2807-
#endif
2807+
#endif /* CONFIG_NUMA */
28082808

28092809
/*
28102810
* 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)
38393839
return ret;
38403840
}
38413841
EXPORT_SYMBOL(__kmalloc_node);
3842-
#endif
3842+
#endif /* CONFIG_NUMA */
38433843

38443844
#ifdef CONFIG_HARDENED_USERCOPY
38453845
/*
@@ -4057,7 +4057,7 @@ void __kmemcg_cache_deactivate(struct kmem_cache *s)
40574057
*/
40584058
slab_deactivate_memcg_cache_rcu_sched(s, kmemcg_cache_deact_after_rcu);
40594059
}
4060-
#endif
4060+
#endif /* CONFIG_MEMCG */
40614061

40624062
static int slab_mem_going_offline_callback(void *arg)
40634063
{
@@ -4690,7 +4690,7 @@ static int list_locations(struct kmem_cache *s, char *buf,
46904690
len += sprintf(buf, "No data\n");
46914691
return len;
46924692
}
4693-
#endif
4693+
#endif /* CONFIG_SLUB_DEBUG */
46944694

46954695
#ifdef SLUB_RESILIENCY_TEST
46964696
static void __init resiliency_test(void)
@@ -4750,7 +4750,7 @@ static void __init resiliency_test(void)
47504750
#ifdef CONFIG_SYSFS
47514751
static void resiliency_test(void) {};
47524752
#endif
4753-
#endif
4753+
#endif /* SLUB_RESILIENCY_TEST */
47544754

47554755
#ifdef CONFIG_SYSFS
47564756
enum slab_stat_type {
@@ -5407,7 +5407,7 @@ STAT_ATTR(CPU_PARTIAL_ALLOC, cpu_partial_alloc);
54075407
STAT_ATTR(CPU_PARTIAL_FREE, cpu_partial_free);
54085408
STAT_ATTR(CPU_PARTIAL_NODE, cpu_partial_node);
54095409
STAT_ATTR(CPU_PARTIAL_DRAIN, cpu_partial_drain);
5410-
#endif
5410+
#endif /* CONFIG_SLUB_STATS */
54115411

54125412
static struct attribute *slab_attrs[] = {
54135413
&slab_size_attr.attr,
@@ -5608,7 +5608,7 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s)
56085608

56095609
if (buffer)
56105610
free_page((unsigned long)buffer);
5611-
#endif
5611+
#endif /* CONFIG_MEMCG */
56125612
}
56135613

56145614
static void kmem_cache_release(struct kobject *k)

0 commit comments

Comments
 (0)