Skip to contentSkip to conversation

Slub code refine

PATCH In review Wei Yang 2 participants 7 messages Oct 21, 2015 – Oct 22, 2015

Subsystems (2)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

cover Slub code refine

Here are three patches for slub code refine.

Some of them are acked/reviewed, resend by including Andrew for comments. No code change.

Wei Yang (3):
mm/slub: correct the comment in calculate_order() mm/slub: use get_order() instead of fls()
mm/slub: calculate start order with reserved in consideration

 mm/slub.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
Signature · 7 lines
2.5.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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#1 lore raw

PATCH 1/3 mm/slub: correct the comment in calculate_order()

In calculate_order(), it tries to calculate the best order by adjusting the fraction and min_objects. On each iteration on min_objects, fraction iterates on 16, 8, 4. Which means the acceptable waste increases with 1/16, 1/8, 1/4.

This patch corrects the comment according to the code.

---
 mm/slub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/slub.c +1 -1
index f68c0e5..e171b10 100644
@@ -2839,7 +2839,7 @@ static inline int calculate_order(int size, int reserved)
 	 * works by first attempting to generate a layout with
 	 * the best configuration and backing off gradually.
 	 *
-	 * First we reduce the acceptable waste in a slab. Then
+	 * First we increase the acceptable waste in a slab. Then
 	 * we reduce the minimum objects required in a slab.
 	 */
 	min_objects = slub_min_objects;
Signature · 7 lines
2.5.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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] mm/slub: correct the comment in calculate_order()

Quoted 4 lines · Wei Yang

In calculate_order(), it tries to calculate the best order by adjusting the fraction and min_objects. On each iteration on min_objects, fraction iterates on 16, 8, 4. Which means the acceptable waste increases with 1/16, 1/8, 1/4.

--
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>

author
#3 lore raw

PATCH 2/3 mm/slub: use get_order() instead of fls()

In reply to Wei Yang

get_order() is more easy to understand.

This patch just replaces it.

Pekka Enberg <[email protected]>

---
 mm/slub.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
mm/slub.c +1 -2
index e171b10..37552f8 100644
@@ -2808,8 +2808,7 @@ static inline int slab_order(int size, int min_objects,
 	if (order_objects(min_order, size, reserved) > MAX_OBJS_PER_PAGE)
 		return get_order(size * MAX_OBJS_PER_PAGE) - 1;
 
-	for (order = max(min_order,
-				fls(min_objects * size - 1) - PAGE_SHIFT);
+	for (order = max(min_order, get_order(min_objects * size));
 			order <= max_order; order++) {
 
 		unsigned long slab_size = PAGE_SIZE << order;
Signature · 7 lines
2.5.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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author Reviewed-by Pekka Enberg
#5 lore raw

Re: [PATCH 2/3] mm/slub: use get_order() instead of fls()

Quoted 7 lines · Christoph Lameter
Quoted 2 lines · Wei Yang

Pekka Enberg <[email protected]>

Acked-by ?

Oh, missed copy.

Signature · 8 lines
Richard Yang
Help you, Help me

--
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>
author
#6 lore raw

PATCH 3/3 mm/slub: calculate start order with reserved in consideration

In reply to Wei Yang

In function slub_order(), the order starts from max(min_order, get_order(min_objects * size)). When (min_objects * size) has different order with (min_objects * size + reserved), it will skip this order by the check in the loop.

This patch optimizes this a little by calculating the start order with reserved in consideration and remove the check in loop.

---
 mm/slub.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
mm/slub.c +1 -5
index 37552f8..62b228e 100644
@@ -2808,19 +2808,15 @@ static inline int slab_order(int size, int min_objects,
 	if (order_objects(min_order, size, reserved) > MAX_OBJS_PER_PAGE)
 		return get_order(size * MAX_OBJS_PER_PAGE) - 1;
 
-	for (order = max(min_order, get_order(min_objects * size));
+	for (order = max(min_order, get_order(min_objects * size + reserved));
 			order <= max_order; order++) {
 
 		unsigned long slab_size = PAGE_SIZE << order;
 
-		if (slab_size < min_objects * size + reserved)
-			continue;
-
 		rem = (slab_size - reserved) % size;
 
 		if (rem <= slab_size / fract_leftover)
 			break;
-
 	}
 
 	return order;
Signature · 7 lines
2.5.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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>