slab: do ClearSlabPfmemalloc() for all pages of slab
PATCH 1/2 slab: do ClearSlabPfmemalloc() for all pages of slab
Now, we just do ClearSlabPfmemalloc() for first page of slab when we clear SlabPfmemalloc flag. It is a problem because we sometimes test flag of page which is not first page of slab in __ac_put_obj().
So add code to do ClearSlabPfmemalloc for all pages of slab.
---
This patch based on Pekka's slab/next tree
mm/slab.c +5 -2
@@ -992,8 +992,11 @@ static void *__ac_get_obj(struct kmem_cache *cachep, struct array_cache *ac,*/ l3 = cachep->nodelists[numa_mem_id ()];if (!list_empty (&l3->slabs_free) && force_refill) { -struct slab *slabp =virt_to_slab (objp); -ClearPageSlabPfmemalloc (virt_to_page (slabp->s_mem)); +int i, nr_pages = (1 << cachep->gfporder); +struct page *page =virt_to_head_page (objp); + +for (i =0 ; i < nr_pages; i++) +ClearPageSlabPfmemalloc (page + i);clear_obj_pfmemalloc (&objp);recheck_pfmemalloc_active (cachep, ac);return objp;
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/2 slab: fix starting index for finding another object
In array cache, there is a object at index 0.
So fix it.
mm/slab.c +1 -1
@@ -976,7 +976,7 @@ static void *__ac_get_obj(struct kmem_cache *cachep, struct array_cache *ac, }/* The caller cannot use PFMEMALLOC objects, find another one */ -for (i =1 ; i < ac->avail; i++) { +for (i =0 ; i < ac->avail; i++) {/* If a !PFMEMALLOC object is found, swap them */ if (!is_obj_pfmemalloc (ac->entry[i])) { objp = ac->entry[i];
Signature · 7 lines
1.7.9.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
It took me a while to getting around to reviewing this due to attending kernel summit. Sorry about that.
Quoted 4 lines · Joonsoo Kim
Now, we just do
ClearSlabPfmemalloc()for first page of slab when we clear SlabPfmemalloc flag. It is a problem because we sometimes test flag of page which is not first page of slab in__ac_put_obj().
Well spotted.
The impact is marginal as far as pfmemalloc protection is concerned. I do not believe that any of the slabs that use high-order allocations are used in for the swap-over-network paths. It would be unfortunate if that ever changed.
Quoted 2 lines
So add code to do ClearSlabPfmemalloc for all pages of slab.
I would prefer if the pfmemalloc information was kept on the head page. Would the following patch also address your concerns?
mm/slab.c +2 -2
@@ -1000,7 +1000,7 @@ static void *__ac_get_obj(struct kmem_cache *cachep, struct array_cache *ac, l3 = cachep->nodelists[numa_mem_id ()];if (!list_empty (&l3->slabs_free) && force_refill) {struct slab *slabp =virt_to_slab (objp); -ClearPageSlabPfmemalloc (virt_to_page (slabp->s_mem)); +ClearPageSlabPfmemalloc (virt_to_head_page (slabp->s_mem));clear_obj_pfmemalloc (&objp);recheck_pfmemalloc_active (cachep, ac);return objp;
@@ -1032,7 +1032,7 @@ static void *__ac_put_obj(struct kmem_cache *cachep, struct array_cache *ac, {if (unlikely (pfmemalloc_active)) {/* Some pfmemalloc slabs exist, check if this is one */ -struct page *page =virt_to_page (objp); +struct page *page =virt_to_head_page (objp);if (PageSlabPfmemalloc (page))set_obj_pfmemalloc (&objp); }
Signature · 8 lines
Mel Gorman SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>