Skip to contentSkip to conversation

mm, slab: Drop unnecessary slabp->inuse < cachep->num test

PATCH In review Zhang Yanfei 2 participants 3 messages Jul 1, 2013 Memory management

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm, slab: Drop unnecessary slabp->inuse < cachep->num test

From: Zhang Yanfei <[email protected]>

In function cache_alloc_refill, we have used BUG_ON to ensure that slabp->inuse is less than cachep->num before the while test. And in the while body, we do not change the value of slabp->inuse and cachep->num, so it is not necessary to test if slabp->inuse < cachep->num test for every loop.

---
 mm/slab.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/slab.c +1 -1
index 8ccd296..c2076c2 100644
@@ -3004,7 +3004,7 @@ retry:
 		 */
 		BUG_ON(slabp->inuse >= cachep->num);
 
-		while (slabp->inuse < cachep->num && batchcount--) {
+		while (batchcount--) {
 			STATS_INC_ALLOCED(cachep);
 			STATS_INC_ACTIVE(cachep);
 			STATS_SET_HIGH(cachep);
Signature · 7 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw

Sorry for making noise. I've made a mistake and please ignore this patch.

Quoted 26 lines · Zhang Yanfei

From: Zhang Yanfei <[email protected]>

In function cache_alloc_refill, we have used BUG_ON to ensure that slabp->inuse is less than cachep->num before the while test. And in the while body, we do not change the value of slabp->inuse and cachep->num, so it is not necessary to test if slabp->inuse < cachep->num test for every loop.

---
 mm/slab.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/slab.c +1 -1
index 8ccd296..c2076c2 100644
@@ -3004,7 +3004,7 @@ retry:
 		 */
 		BUG_ON(slabp->inuse >= cachep->num);
 
-		while (slabp->inuse < cachep->num && batchcount--) {
+		while (batchcount--) {
 			STATS_INC_ALLOCED(cachep);
 			STATS_INC_ACTIVE(cachep);
 			STATS_SET_HIGH(cachep);
Signature · 8 lines
Thanks.
Zhang Yanfei

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#2 lore raw
In reply to Zhang Yanfei
Quoted 7 lines · Zhang Yanfei

From: Zhang Yanfei <[email protected]>

In function cache_alloc_refill, we have used BUG_ON to ensure that slabp->inuse is less than cachep->num before the while test. And in the while body, we do not change the value of slabp->inuse and cachep->num, so it is not necessary to test if slabp->inuse < cachep->num test for every loop.

The body calls slab_get_obj which changes slabp->inuse!

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>