diff options
Diffstat (limited to 'mm/slub.c')
-rw-r--r-- | mm/slub.c | 38 |
1 files changed, 22 insertions, 16 deletions
@@ -1004,21 +1004,19 @@ static inline void slab_free_hook(struct kmem_cache *s, void *x) | |||
1004 | static void add_full(struct kmem_cache *s, | 1004 | static void add_full(struct kmem_cache *s, |
1005 | struct kmem_cache_node *n, struct page *page) | 1005 | struct kmem_cache_node *n, struct page *page) |
1006 | { | 1006 | { |
1007 | lockdep_assert_held(&n->list_lock); | ||
1008 | |||
1009 | if (!(s->flags & SLAB_STORE_USER)) | 1007 | if (!(s->flags & SLAB_STORE_USER)) |
1010 | return; | 1008 | return; |
1011 | 1009 | ||
1010 | lockdep_assert_held(&n->list_lock); | ||
1012 | list_add(&page->lru, &n->full); | 1011 | list_add(&page->lru, &n->full); |
1013 | } | 1012 | } |
1014 | 1013 | ||
1015 | static void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct page *page) | 1014 | static void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct page *page) |
1016 | { | 1015 | { |
1017 | lockdep_assert_held(&n->list_lock); | ||
1018 | |||
1019 | if (!(s->flags & SLAB_STORE_USER)) | 1016 | if (!(s->flags & SLAB_STORE_USER)) |
1020 | return; | 1017 | return; |
1021 | 1018 | ||
1019 | lockdep_assert_held(&n->list_lock); | ||
1022 | list_del(&page->lru); | 1020 | list_del(&page->lru); |
1023 | } | 1021 | } |
1024 | 1022 | ||
@@ -1520,11 +1518,9 @@ static void discard_slab(struct kmem_cache *s, struct page *page) | |||
1520 | /* | 1518 | /* |
1521 | * Management of partially allocated slabs. | 1519 | * Management of partially allocated slabs. |
1522 | */ | 1520 | */ |
1523 | static inline void add_partial(struct kmem_cache_node *n, | 1521 | static inline void |
1524 | struct page *page, int tail) | 1522 | __add_partial(struct kmem_cache_node *n, struct page *page, int tail) |
1525 | { | 1523 | { |
1526 | lockdep_assert_held(&n->list_lock); | ||
1527 | |||
1528 | n->nr_partial++; | 1524 | n->nr_partial++; |
1529 | if (tail == DEACTIVATE_TO_TAIL) | 1525 | if (tail == DEACTIVATE_TO_TAIL) |
1530 | list_add_tail(&page->lru, &n->partial); | 1526 | list_add_tail(&page->lru, &n->partial); |
@@ -1532,15 +1528,27 @@ static inline void add_partial(struct kmem_cache_node *n, | |||
1532 | list_add(&page->lru, &n->partial); | 1528 | list_add(&page->lru, &n->partial); |
1533 | } | 1529 | } |
1534 | 1530 | ||
1535 | static inline void remove_partial(struct kmem_cache_node *n, | 1531 | static inline void add_partial(struct kmem_cache_node *n, |
1536 | struct page *page) | 1532 | struct page *page, int tail) |
1537 | { | 1533 | { |
1538 | lockdep_assert_held(&n->list_lock); | 1534 | lockdep_assert_held(&n->list_lock); |
1535 | __add_partial(n, page, tail); | ||
1536 | } | ||
1539 | 1537 | ||
1538 | static inline void | ||
1539 | __remove_partial(struct kmem_cache_node *n, struct page *page) | ||
1540 | { | ||
1540 | list_del(&page->lru); | 1541 | list_del(&page->lru); |
1541 | n->nr_partial--; | 1542 | n->nr_partial--; |
1542 | } | 1543 | } |
1543 | 1544 | ||
1545 | static inline void remove_partial(struct kmem_cache_node *n, | ||
1546 | struct page *page) | ||
1547 | { | ||
1548 | lockdep_assert_held(&n->list_lock); | ||
1549 | __remove_partial(n, page); | ||
1550 | } | ||
1551 | |||
1544 | /* | 1552 | /* |
1545 | * Remove slab from the partial list, freeze it and | 1553 | * Remove slab from the partial list, freeze it and |
1546 | * return the pointer to the freelist. | 1554 | * return the pointer to the freelist. |
@@ -2906,12 +2914,10 @@ static void early_kmem_cache_node_alloc(int node) | |||
2906 | inc_slabs_node(kmem_cache_node, node, page->objects); | 2914 | inc_slabs_node(kmem_cache_node, node, page->objects); |
2907 | 2915 | ||
2908 | /* | 2916 | /* |
2909 | * the lock is for lockdep's sake, not for any actual | 2917 | * No locks need to be taken here as it has just been |
2910 | * race protection | 2918 | * initialized and there is no concurrent access. |
2911 | */ | 2919 | */ |
2912 | spin_lock(&n->list_lock); | 2920 | __add_partial(n, page, DEACTIVATE_TO_HEAD); |
2913 | add_partial(n, page, DEACTIVATE_TO_HEAD); | ||
2914 | spin_unlock(&n->list_lock); | ||
2915 | } | 2921 | } |
2916 | 2922 | ||
2917 | static void free_kmem_cache_nodes(struct kmem_cache *s) | 2923 | static void free_kmem_cache_nodes(struct kmem_cache *s) |
@@ -3197,7 +3203,7 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) | |||
3197 | 3203 | ||
3198 | list_for_each_entry_safe(page, h, &n->partial, lru) { | 3204 | list_for_each_entry_safe(page, h, &n->partial, lru) { |
3199 | if (!page->inuse) { | 3205 | if (!page->inuse) { |
3200 | remove_partial(n, page); | 3206 | __remove_partial(n, page); |
3201 | discard_slab(s, page); | 3207 | discard_slab(s, page); |
3202 | } else { | 3208 | } else { |
3203 | list_slab_objects(s, page, | 3209 | list_slab_objects(s, page, |