2013-07-01 16:30:08

by Zhang Yanfei

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Zhang Yanfei <[email protected]>
---
mm/slab.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/slab.c b/mm/slab.c
index 8ccd296..c2076c2 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -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);
--
1.7.1


2013-07-01 16:36:25

by Zhang Yanfei

[permalink] [raw]
Subject: Re: [PATCH] mm, slab: Drop unnecessary slabp->inuse < cachep->num test

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

On 07/02/2013 12:29 AM, Zhang Yanfei wrote:
> 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.
>
> Signed-off-by: Zhang Yanfei <[email protected]>
> ---
> mm/slab.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/mm/slab.c b/mm/slab.c
> index 8ccd296..c2076c2 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -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);


--
Thanks.
Zhang Yanfei

Subject: Re: [PATCH] mm, slab: Drop unnecessary slabp->inuse < cachep->num test

On Tue, 2 Jul 2013, Zhang Yanfei wrote:

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