From f844fc109357cbb0a54a465255bc8dc087b8be47 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 7 Jan 2008 23:20:30 -0800 Subject: [PATCH] SLUB: Own locking checkpatch fixes. ERROR: do not use assignment in if condition #627: FILE: mm/slub.c:2827: + if (!page->inuse && (state = slab_trylock(page))) { total: 1 errors, 0 warnings, 611 lines checked Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS. Please run checkpatch prior to sending patches Seems nicer this way. Should the `if (page->inuse)' test be marked unlikely()? Cc: Christoph Lameter Cc: Pekka Enberg Signed-off-by: Andrew Morton --- mm/slub.c | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index c2c778c..1a467dc 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -2821,20 +2821,23 @@ int kmem_cache_shrink(struct kmem_cache *s) * list_lock. page->inuse here is the upper limit. */ list_for_each_entry_safe(page, t, &n->partial, lru) { - if (!page->inuse && (state = slab_trylock(page))) { - /* - * Must hold slab lock here because slab_free - * may have freed the last object and be - * waiting to release the slab. - */ - list_del(&page->lru); - n->nr_partial--; - slab_unlock(page, state); - discard_slab(s, page); - } else { + if (page->inuse) { list_move(&page->lru, slabs_by_inuse + page->inuse); + continue; } + state = slab_trylock(page); + if (!state) + continue; + /* + * Must hold slab lock here because slab_free may have + * freed the last object and be waiting to release the + * slab. + */ + list_del(&page->lru); + n->nr_partial--; + slab_unlock(page, state); + discard_slab(s, page); } /* -- debian.1.5.3.7.1-dirty