mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] slub: fix leakage
@ 2007-11-03 17:10 Hugh Dickins
  2007-11-03 17:11 ` [PATCH 2/2] slub: fix Objects count Hugh Dickins
                   ` (4 more replies)
  0 siblings, 5 replies; 34+ messages in thread
From: Hugh Dickins @ 2007-11-03 17:10 UTC (permalink / raw)
  To: Christoph Lameter; +Cc: Linus Torvalds, Andrew Morton, linux-kernel

Slub has been quite leaky under load.  Taking mm_struct as an example, in
a loop of swapping kernel builds, after the first iteration slabinfo shows:
Name        Objects Objsize    Space Slabs/Part/Cpu  O/S O %Fr %Ef Flg
mm_struct        55     840    73.7K         18/7/4    4 0  38  62 A
but Objects and Partials steadily creep up - after the 340th iteration:
mm_struct       110     840   188.4K        46/36/4    4 0  78  49 A

The culprit turns out to be __slab_alloc(), where it copes with the race
that another task has assigned the cpu slab while we were allocating one.
Don't rush off to load_freelist there: that assumes c->freelist is empty,
and will lose all of its free slots when c->page->freelist is not empty.
Instead just do a local allocation from c->freelist when it has one.

Which fixes the leakage: Objects and Partials then remain stable.

Signed-off-by: Hugh Dickins <hugh@veritas.com>
---
I recommend this for 2.6.24-rc2 and 2.6.23-stable.

 mm/slub.c |    5 +++++
 1 file changed, 5 insertions(+)

--- 2.6.24-rc1/mm/slub.c	2007-10-24 07:16:04.000000000 +0100
+++ linux/mm/slub.c	2007-11-03 13:22:31.000000000 +0000
@@ -1525,6 +1525,11 @@ new_slab:
 				 * want the current one since its cache hot
 				 */
 				discard_slab(s, new);
+				if (c->freelist) {
+					object = c->freelist;
+					c->freelist = object[c->offset];
+					return object;
+				}
 				slab_lock(c->page);
 				goto load_freelist;
 			}

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2007-11-06  7:59 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-03 17:10 [PATCH 1/2] slub: fix leakage Hugh Dickins
2007-11-03 17:11 ` [PATCH 2/2] slub: fix Objects count Hugh Dickins
2007-11-03 18:26   ` Christoph Lameter
2007-11-03 19:09     ` Hugh Dickins
2007-11-03 19:33       ` Christoph Lameter
2007-11-03 20:03         ` Hugh Dickins
2007-11-03 17:27 ` [PATCH 1/2] slub: fix leakage Olivér Pintér
2007-11-03 17:50   ` Hugh Dickins
2007-11-03 18:52     ` Hugh Dickins
2007-11-03 19:39       ` Hugh Dickins
2007-11-03 19:47         ` Christoph Lameter
2007-11-03 19:52           ` Hugh Dickins
2007-11-03 19:54             ` Christoph Lameter
2007-11-03 20:10               ` Hugh Dickins
2007-11-03 20:26                 ` Christoph Lameter
2007-11-04 11:18                   ` Hugh Dickins
2007-11-05 18:45                     ` Christoph Lameter
2007-11-05 19:09                       ` Hugh Dickins
2007-11-05 19:15                         ` Christoph Lameter
2007-11-05 19:23                           ` Christoph Lameter
2007-11-05 19:26                           ` Linus Torvalds
2007-11-05 19:31                             ` Christoph Lameter
2007-11-05 19:36                               ` Linus Torvalds
2007-11-06  6:15                       ` Jeff Chua
2007-11-06  7:58                         ` Hugh Dickins
2007-11-03 17:38 ` Willy Tarreau
2007-11-03 17:55   ` Hugh Dickins
2007-11-03 17:59     ` Willy Tarreau
2007-11-03 18:31 ` Christoph Lameter
2007-11-03 18:48 ` Christoph Lameter
2007-11-03 18:51   ` Christoph Lameter
2007-11-03 19:04   ` Hugh Dickins
2007-11-03 19:26     ` Christoph Lameter
2007-11-03 19:35       ` Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®