Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 60747
b: refs/heads/master
c: 434e245
h: refs/heads/master
i:
  60745: d67ac82
  60743: 42d9557
v: v3
  • Loading branch information
Christoph Lameter authored and Linus Torvalds committed Jul 17, 2007
1 parent bceb86e commit e65438b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 94f6030ca792c57422f04a73e7a872d8325946d3
refs/heads/master: 434e245ddd3f14aa8eef97cae16c71b863ab092a
39 changes: 25 additions & 14 deletions trunk/mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2764,11 +2764,11 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
}

#if defined(CONFIG_SYSFS) && defined(CONFIG_SLUB_DEBUG)
static int validate_slab(struct kmem_cache *s, struct page *page)
static int validate_slab(struct kmem_cache *s, struct page *page,
unsigned long *map)
{
void *p;
void *addr = page_address(page);
DECLARE_BITMAP(map, s->objects);

if (!check_slab(s, page) ||
!on_freelist(s, page, NULL))
Expand All @@ -2790,10 +2790,11 @@ static int validate_slab(struct kmem_cache *s, struct page *page)
return 1;
}

static void validate_slab_slab(struct kmem_cache *s, struct page *page)
static void validate_slab_slab(struct kmem_cache *s, struct page *page,
unsigned long *map)
{
if (slab_trylock(page)) {
validate_slab(s, page);
validate_slab(s, page, map);
slab_unlock(page);
} else
printk(KERN_INFO "SLUB %s: Skipped busy slab 0x%p\n",
Expand All @@ -2810,7 +2811,8 @@ static void validate_slab_slab(struct kmem_cache *s, struct page *page)
}
}

static int validate_slab_node(struct kmem_cache *s, struct kmem_cache_node *n)
static int validate_slab_node(struct kmem_cache *s,
struct kmem_cache_node *n, unsigned long *map)
{
unsigned long count = 0;
struct page *page;
Expand All @@ -2819,7 +2821,7 @@ static int validate_slab_node(struct kmem_cache *s, struct kmem_cache_node *n)
spin_lock_irqsave(&n->list_lock, flags);

list_for_each_entry(page, &n->partial, lru) {
validate_slab_slab(s, page);
validate_slab_slab(s, page, map);
count++;
}
if (count != n->nr_partial)
Expand All @@ -2830,7 +2832,7 @@ static int validate_slab_node(struct kmem_cache *s, struct kmem_cache_node *n)
goto out;

list_for_each_entry(page, &n->full, lru) {
validate_slab_slab(s, page);
validate_slab_slab(s, page, map);
count++;
}
if (count != atomic_long_read(&n->nr_slabs))
Expand All @@ -2843,17 +2845,23 @@ static int validate_slab_node(struct kmem_cache *s, struct kmem_cache_node *n)
return count;
}

static unsigned long validate_slab_cache(struct kmem_cache *s)
static long validate_slab_cache(struct kmem_cache *s)
{
int node;
unsigned long count = 0;
unsigned long *map = kmalloc(BITS_TO_LONGS(s->objects) *
sizeof(unsigned long), GFP_KERNEL);

if (!map)
return -ENOMEM;

flush_all(s);
for_each_online_node(node) {
struct kmem_cache_node *n = get_node(s, node);

count += validate_slab_node(s, n);
count += validate_slab_node(s, n, map);
}
kfree(map);
return count;
}

Expand Down Expand Up @@ -3467,11 +3475,14 @@ static ssize_t validate_show(struct kmem_cache *s, char *buf)
static ssize_t validate_store(struct kmem_cache *s,
const char *buf, size_t length)
{
if (buf[0] == '1')
validate_slab_cache(s);
else
return -EINVAL;
return length;
int ret = -EINVAL;

if (buf[0] == '1') {
ret = validate_slab_cache(s);
if (ret >= 0)
ret = length;
}
return ret;
}
SLAB_ATTR(validate);

Expand Down

0 comments on commit e65438b

Please sign in to comment.