Skip to contentSkip to conversation

slub: reduce a variable in __slab_free()

PATCH In review Alex,Shi 2 participants 2 messages Sep 9, 2011 – Sep 12, 2011

Subsystems (2)
lore
Share & tools
lore

Alex,Shi

author
#0 lore raw

PATCH 2/2 slub: reduce a variable in __slab_free()

After the compxchg, the new.inuse are fixed in __slab_free as a local variable, so we don't need a extra variable for it.

This patch is also base on 'slub/partial' head of penberg's tree.

---
 mm/slub.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
mm/slub.c +1 -3
index bca8eee..c1f803f 100644
@@ -2452,7 +2452,6 @@ static void __slab_free(struct kmem_cache *s, struct page *page,
 	void *prior;
 	void **object = (void *)x;
 	int was_frozen;
-	int inuse;
 	struct page new;
 	unsigned long counters;
 	struct kmem_cache_node *n = NULL;
@@ -2495,7 +2494,6 @@ static void __slab_free(struct kmem_cache *s, struct page *page,
 
 			}
 		}
-		inuse = new.inuse;
 
 	} while (!cmpxchg_double_slab(s, page,
 		prior, counters,
@@ -2526,7 +2524,7 @@ static void __slab_free(struct kmem_cache *s, struct page *page,
 	 */
 	if (was_frozen)
 		stat(s, FREE_FROZEN);
-	else if (unlikely(!inuse && n->nr_partial > s->min_partial))
+	else if (unlikely(!new.inuse && n->nr_partial > s->min_partial))
                         goto slab_empty;
 
 	spin_unlock_irqrestore(&n->list_lock, flags);
Signature · 10 lines
1.7.0



--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 2 lines · Alex,Shi

After the compxchg, the new.inuse are fixed in __slab_free as a local variable, so we don't need a extra variable for it.

True but its an easier read otherwise and the contents are extracted from the 16 bit value into a long which is easier to handle for the compiler later. Check to see if there is a code difference due to this patch.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>