* [PATCH] slab: avoid unnecessary touching of a partial slab
@ 2011-08-26 5:13 Zhao Jin
2011-08-26 5:58 ` Zhao Jin
2011-08-26 14:08 ` Christoph Lameter
0 siblings, 2 replies; 8+ messages in thread
From: Zhao Jin @ 2011-08-26 5:13 UTC (permalink / raw)
To: cl, penberg, mpm, trivial; +Cc: linux-kernel
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 <cronozhj@gmail.com>
---
mm/slab.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/mm/slab.c b/mm/slab.c
index 6d90a09..3469c6f 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -3121,11 +3121,14 @@ retry:
check_slabp(cachep, slabp);
/* move slabp to correct slabp list: */
- list_del(&slabp->list);
- if (slabp->free == BUFCTL_END)
+ if (slabp->free == BUFCTL_END) {
+ list_del(&slabp->list);
list_add(&slabp->list, &l3->slabs_full);
- else
+ }
+ else if (&slabp->list != l3->slabs_partial.next) {
+ list_del(&slabp->list);
list_add(&slabp->list, &l3->slabs_partial);
+ }
}
must_grow:
--
1.7.4.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] slab: avoid unnecessary touching of a partial slab
2011-08-26 5:13 [PATCH] slab: avoid unnecessary touching of a partial slab Zhao Jin
@ 2011-08-26 5:58 ` Zhao Jin
2011-08-26 14:08 ` Christoph Lameter
1 sibling, 0 replies; 8+ messages in thread
From: Zhao Jin @ 2011-08-26 5:58 UTC (permalink / raw)
To: cl, penberg, mpm, trivial; +Cc: linux-kernel
Sorry, one line in this patch does not conform to the coding style of
kernel source code. Here is the corrected version:
---
mm/slab.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/mm/slab.c b/mm/slab.c
index 6d90a09..0c7a212 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -3121,11 +3121,13 @@ retry:
check_slabp(cachep, slabp);
/* move slabp to correct slabp list: */
- list_del(&slabp->list);
- if (slabp->free == BUFCTL_END)
+ if (slabp->free == BUFCTL_END) {
+ list_del(&slabp->list);
list_add(&slabp->list, &l3->slabs_full);
- else
+ } else if (&slabp->list != l3->slabs_partial.next) {
+ list_del(&slabp->list);
list_add(&slabp->list, &l3->slabs_partial);
+ }
}
must_grow:
--
1.7.4.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] slab: avoid unnecessary touching of a partial slab
2011-08-26 5:13 [PATCH] slab: avoid unnecessary touching of a partial slab Zhao Jin
2011-08-26 5:58 ` Zhao Jin
@ 2011-08-26 14:08 ` Christoph Lameter
2011-08-26 14:46 ` Zhao Jin
1 sibling, 1 reply; 8+ messages in thread
From: Christoph Lameter @ 2011-08-26 14:08 UTC (permalink / raw)
To: Zhao Jin; +Cc: penberg, mpm, trivial, linux-kernel
On Fri, 26 Aug 2011, Zhao Jin wrote:
> 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.
The list_del/list_add action is a list_move.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] slab: avoid unnecessary touching of a partial slab
2011-08-26 14:08 ` Christoph Lameter
@ 2011-08-26 14:46 ` Zhao Jin
2011-08-26 14:50 ` Christoph Lameter
0 siblings, 1 reply; 8+ messages in thread
From: Zhao Jin @ 2011-08-26 14:46 UTC (permalink / raw)
To: Christoph Lameter; +Cc: penberg, mpm, trivial, linux-kernel
On Fri, 2011-08-26 at 09:08 -0500, Christoph Lameter wrote:
> On Fri, 26 Aug 2011, Zhao Jin wrote:
>
> > 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.
>
> The list_del/list_add action is a list_move.
But in cache_alloc_refill(), it is the first slab (that is: its list
field is pointed by the l3->slabs_partial.next) that is picked from the
partial list for refilling. Assume it remains partial after that. Since
list_add inserts a new element after the head (l3->slabs_partial), the
position of the slab in the partial list won't change after
list_del/list_add: it will be still the first element. Therefore,
list_del/list_add has done nothing actually in this case.
Regards,
zhj
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] slab: avoid unnecessary touching of a partial slab
2011-08-26 14:46 ` Zhao Jin
@ 2011-08-26 14:50 ` Christoph Lameter
2011-08-26 15:02 ` Zhao Jin
0 siblings, 1 reply; 8+ messages in thread
From: Christoph Lameter @ 2011-08-26 14:50 UTC (permalink / raw)
To: Zhao Jin; +Cc: penberg, mpm, trivial, linux-kernel
On Fri, 26 Aug 2011, Zhao Jin wrote:
> On Fri, 2011-08-26 at 09:08 -0500, Christoph Lameter wrote:
> > On Fri, 26 Aug 2011, Zhao Jin wrote:
> >
> > > 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.
> >
> > The list_del/list_add action is a list_move.
>
> But in cache_alloc_refill(), it is the first slab (that is: its list
> field is pointed by the l3->slabs_partial.next) that is picked from the
> partial list for refilling. Assume it remains partial after that. Since
> list_add inserts a new element after the head (l3->slabs_partial), the
> position of the slab in the partial list won't change after
> list_del/list_add: it will be still the first element. Therefore,
> list_del/list_add has done nothing actually in this case.
Correct but still tthe del/add is a list_move operation. Convert that the
other case as well?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] slab: avoid unnecessary touching of a partial slab
2011-08-26 14:50 ` Christoph Lameter
@ 2011-08-26 15:02 ` Zhao Jin
2011-08-26 15:05 ` Christoph Lameter
0 siblings, 1 reply; 8+ messages in thread
From: Zhao Jin @ 2011-08-26 15:02 UTC (permalink / raw)
To: Christoph Lameter; +Cc: penberg, mpm, trivial, linux-kernel
On Fri, 2011-08-26 at 09:50 -0500, Christoph Lameter wrote:
> On Fri, 26 Aug 2011, Zhao Jin wrote:
>
> > On Fri, 2011-08-26 at 09:08 -0500, Christoph Lameter wrote:
> > > On Fri, 26 Aug 2011, Zhao Jin wrote:
> > >
> > > > 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.
> > >
> > > The list_del/list_add action is a list_move.
> >
> > But in cache_alloc_refill(), it is the first slab (that is: its list
> > field is pointed by the l3->slabs_partial.next) that is picked from the
> > partial list for refilling. Assume it remains partial after that. Since
> > list_add inserts a new element after the head (l3->slabs_partial), the
> > position of the slab in the partial list won't change after
> > list_del/list_add: it will be still the first element. Therefore,
> > list_del/list_add has done nothing actually in this case.
>
> Correct but still tthe del/add is a list_move operation. Convert that the
> other case as well?
>
Yes. The patch avoids list_del/list_add only if it is the case that a
partial slab was used for refilling and remains partial (that is:
partial => partial). If it is not the case( so it must be either partial
=> full, free => full or free => partial) the patched code behaves the
same as current (list_del/list_add).
Regards,
zhj
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] slab: avoid unnecessary touching of a partial slab
2011-08-26 15:02 ` Zhao Jin
@ 2011-08-26 15:05 ` Christoph Lameter
2011-08-26 15:09 ` Zhao Jin
0 siblings, 1 reply; 8+ messages in thread
From: Christoph Lameter @ 2011-08-26 15:05 UTC (permalink / raw)
To: Zhao Jin; +Cc: penberg, mpm, trivial, linux-kernel
On Fri, 26 Aug 2011, Zhao Jin wrote:
> > Correct but still tthe del/add is a list_move operation. Convert that the
> > other case as well?
> >
> Yes. The patch avoids list_del/list_add only if it is the case that a
> partial slab was used for refilling and remains partial (that is:
> partial => partial). If it is not the case( so it must be either partial
> => full, free => full or free => partial) the patched code behaves the
> same as current (list_del/list_add).
The second case is what I want you to change to list_move.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] slab: avoid unnecessary touching of a partial slab
2011-08-26 15:05 ` Christoph Lameter
@ 2011-08-26 15:09 ` Zhao Jin
0 siblings, 0 replies; 8+ messages in thread
From: Zhao Jin @ 2011-08-26 15:09 UTC (permalink / raw)
To: Christoph Lameter; +Cc: penberg, mpm, trivial, linux-kernel
On Fri, 2011-08-26 at 10:05 -0500, Christoph Lameter wrote:
> On Fri, 26 Aug 2011, Zhao Jin wrote:
>
> > > Correct but still tthe del/add is a list_move operation. Convert that the
> > > other case as well?
> > >
> > Yes. The patch avoids list_del/list_add only if it is the case that a
> > partial slab was used for refilling and remains partial (that is:
> > partial => partial). If it is not the case( so it must be either partial
> > => full, free => full or free => partial) the patched code behaves the
> > same as current (list_del/list_add).
>
> The second case is what I want you to change to list_move.
>
>
Oops. I misunderstood your reply... I shall do it. Thanks a lot for
pointing it out.
Regards,
zhj
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-08-26 15:17 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-26 5:13 [PATCH] slab: avoid unnecessary touching of a partial slab Zhao Jin
2011-08-26 5:58 ` Zhao Jin
2011-08-26 14:08 ` Christoph Lameter
2011-08-26 14:46 ` Zhao Jin
2011-08-26 14:50 ` Christoph Lameter
2011-08-26 15:02 ` Zhao Jin
2011-08-26 15:05 ` Christoph Lameter
2011-08-26 15:09 ` Zhao Jin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox