Skip to contentSkip to conversation

mm/slab.c, kernel <2.4.20>

PATCH In review Shangc 2 participants 3 messages Jan 8, 2003 Memory management

lore
Share & tools
lore

Shangc

author
#0 lore raw

PATCH 1/1 mm/slab.c, kernel <2.4.20>

/**
* --readme--
* make a better initial value for i, which will
reduce the number of
while loop.
* the change can be proved mathematically:
*
* i*size + L1_CACHE_ALIGN(base+i*extra) <= wastage
* ==> i*size + base + i*extra <= wastage
* ==> solve about equation about i
* ==> i <= (wastage - base) / (size + extra) *
* Chen Shang
* [email protected]
*/

slab.c +1 -1
@@ -397,7 +397,7 @@
 		base = sizeof(slab_t);
 		extra = sizeof(kmem_bufctl_t);
 	}
-	i = 0;
+	i = (wastage - base) / (size + extra);
 	while (i*size + L1_CACHE_ALIGN(base+i*extra) <=

wastage)
i++;
if (i > 0)

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

#1 lore raw

On Wednesday 08 January 2003 23:03, Shangc wrote:

Hi Shangc,

slab.c line 403

Quoted 11 lines
slab.c +1 -1
@@ -397,7 +397,7 @@
 		base = sizeof(slab_t);
 		extra = sizeof(kmem_bufctl_t);
 	}
-	i = 0;
+	i = (wastage - base) / (size + extra);
 	while (i*size + L1_CACHE_ALIGN(base+i*extra) <=> wastage)
 		i++;
 	if (i > 0)

if you use this you may also want this.

ciao, Marc

mm/slab.c +2 -2
diff -Naurp a/mm/slab.c b/mm/slab.c
@@ -399,10 +399,10 @@
 		base = sizeof(slab_t);
 		extra = sizeof(kmem_bufctl_t);
 	}
-	i = 0;
+       i = (wastage - base)/(size + extra);
 	while (i*size + L1_CACHE_ALIGN(base+i*extra) <= wastage)
 		i++;
-	if (i > 0)
+       while (i*size + L1_CACHE_ALIGN(base+i*extra) > wastage)
 		i--;
 
 	if (i > SLAB_LIMIT)
author
#2 lore raw

thank you for reply. However, I am not very sure to be vary agree with you.

after assigned the calculated initial value for "i", it is very close to the break value for the next while loop, actually, it is only one loop at most, so "i" never goes to be
i*size + L1_CACHE_ALIGN(base+i*extra) > wastage + L1_CACHE_BYTES

so, we do not need change the line 399 of slab.c.

thanks,

chen

--- Marc-Christian Petersen <[email protected]>

Quoted 35 lines · wrote:

On Wednesday 08 January 2003 23:03, Shangc wrote:

Hi Shangc,

slab.c line 401

Quoted 9 lines
slab.c +1 -1
@@ -397,7 +397,7 @@
 		base = sizeof(slab_t);
 		extra = sizeof(kmem_bufctl_t);
 	}
-	i = 0;
+	i = (wastage - base) / (size + extra);
 	while (i*size + L1_CACHE_ALIGN(base+i*extra) <=>

wastage)

slab.c line 403

Quoted 2 lines
slab.c +0 -0
 		i++;
 	if (i > 0)

if you use this you may also want this.

ciao, Marc> diff -Naurp a/mm/slab.c b/mm/slab.c

mm/slab.c +2 -2
@@ -399,10 +399,10 @@
 		base = sizeof(slab_t);
 		extra = sizeof(kmem_bufctl_t);
 	}
-	i = 0;
+       i = (wastage - base)/(size + extra);
 	while (i*size + L1_CACHE_ALIGN(base+i*extra) <=
 wastage)
 		i++;
-	if (i > 0)
+       while (i*size + L1_CACHE_ALIGN(base+i*extra)
 > wastage)
 		i--;
Quoted 2 lines

if (i > SLAB_LIMIT)

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com