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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]