slab: avoid unnecessary touching of a partial slab
PATCH RESEND 2/2 slab: avoid unnecessary touching of a partial slab
In cache_alloc_refill(), after refilling from a partial slab, if the slab remains partial, it would be deleted from and then added again to the partial list. As the slab is the first element in the list before deletion, such behavior has no effect. This patch avoids touching the slab in this case.
--- mm/slab.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
mm/slab.c +3 -4
@@ -3121,11 +3121,10 @@ retry:check_slabp (cachep, slabp);/* move slabp to correct slabp list: */ -list_del (&slabp->list);if (slabp->free ==BUFCTL_END ) -list_add (&slabp->list, &l3->slabs_full); -else -list_add (&slabp->list, &l3->slabs_partial); +list_move (entry, &l3->slabs_full); +else if (entry != l3->slabs_partial.next) +list_move (entry, &l3->slabs_partial); } must_grow:
Signature · 1 line
1.7.4.1
[ Replying to an old patch that I seem to have missed. ]
Quoted 7 lines · Zhao Jin
In
cache_alloc_refill(), after refilling from a partial slab, if the slab remains partial, it would be deleted from and then added again to the partial list. As the slab is the first element in the list before deletion, such behavior has no effect. This patch avoids touching the slab in this case.Signed-off-by Zhao Jin <[email protected]>
Looks good to me, Christoph, David?
Quoted 27 lines
---
mm/slab.c| 7 +++----1 files changed, 3 insertions(+), 4 deletions(-)mm/slab.c +3
-4@@ -3121,11 +3121,10 @@ retry:check_slabp (cachep, slabp);/* move slabp to correct slabp list: */ -list_del (&slabp->list);if (slabp->free ==BUFCTL_END ) -list_add (&slabp->list, &l3->slabs_full); -else -list_add (&slabp->list, &l3->slabs_partial); +list_move (entry, &l3->slabs_full); +else if (entry != l3->slabs_partial.next) +list_move (entry, &l3->slabs_partial); }
must_grow:Signature · 1 line
1.7.4.1
Quoted 7 lines · Pekka Enberg
Quoted 7 lines
mm/slab.c +0
-0@@ -3121,11 +3121,10 @@ retry:check_slabp (cachep, slabp);
Quoted 8 lines
mm/slab.c retry: · line 3126
Quoted 8 lines
mm/slab.c +2
-4/* move slabp to correct slabp list: */ -list_del (&slabp->list);if (slabp->free ==BUFCTL_END ) -list_add (&slabp->list, &l3->slabs_full); -else -list_add (&slabp->list, &l3->slabs_partial); +list_move (entry, &l3->slabs_full); +else if (entry != l3->slabs_partial.next)
Why is the check for entry necessary? We are holding a lock that prevents modifications to the list after all.
Just a list_move when the partial slab is drained seems to be sufficient.