[PATCH 5/6] mm/slab: cleanup ____cache_alloc()

From: Joonsoo Kim
Date: Sun Jan 04 2015 - 20:38:19 EST


This cleanup makes code more readable and help future changes.
In the following patch, many code will be added to this function.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
---
mm/slab.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 1246ac6..449fc6b 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2939,21 +2939,23 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
local_irq_save(save_flags);

ac = cpu_cache_get(cachep);
- if (likely(ac->avail)) {
- ac->touched = 1;
- objp = ac_get_obj(cachep, ac, flags, false);
+ if (unlikely(!ac->avail))
+ goto slowpath;

- /*
- * Allow for the possibility all avail objects are not allowed
- * by the current flags
- */
- if (objp) {
- STATS_INC_ALLOCHIT(cachep);
- goto out;
- }
- force_refill = true;
+ ac->touched = 1;
+ objp = ac_get_obj(cachep, ac, flags, false);
+
+ /*
+ * Allow for the possibility all avail objects are not allowed
+ * by the current flags
+ */
+ if (likely(objp)) {
+ STATS_INC_ALLOCHIT(cachep);
+ goto out;
}
+ force_refill = true;

+slowpath:
STATS_INC_ALLOCMISS(cachep);
objp = cache_alloc_refill(cachep, flags, force_refill);

--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/