Commit 43afc194 authored by Vitaly Wool's avatar Vitaly Wool Committed by Linus Torvalds

mm/z3fold.c: avoid modifying HEADLESS page and minor cleanup

Fix erroneous z3fold header access in a HEADLESS page in reclaim
function, and change one remaining direct handle-to-buddy conversion to
use the appropriate helper.

Link: http://lkml.kernel.org/r/5748706F.9020208@gmail.comSigned-off-by: default avatarVitaly Wool <vitalywool@gmail.com>
Reviewed-by: default avatarDan Streetman <ddstreet@ieee.org>
Cc: Seth Jennings <sjenning@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3a06bb78
...@@ -412,7 +412,7 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle) ...@@ -412,7 +412,7 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)
/* HEADLESS page stored */ /* HEADLESS page stored */
bud = HEADLESS; bud = HEADLESS;
} else { } else {
bud = (handle - zhdr->first_num) & BUDDY_MASK; bud = handle_to_buddy(handle);
switch (bud) { switch (bud) {
case FIRST: case FIRST:
...@@ -572,15 +572,19 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries) ...@@ -572,15 +572,19 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries)
pool->pages_nr--; pool->pages_nr--;
spin_unlock(&pool->lock); spin_unlock(&pool->lock);
return 0; return 0;
} else if (zhdr->first_chunks != 0 && } else if (!test_bit(PAGE_HEADLESS, &page->private)) {
zhdr->last_chunks != 0 && zhdr->middle_chunks != 0) { if (zhdr->first_chunks != 0 &&
/* Full, add to buddied list */ zhdr->last_chunks != 0 &&
list_add(&zhdr->buddy, &pool->buddied); zhdr->middle_chunks != 0) {
} else if (!test_bit(PAGE_HEADLESS, &page->private)) { /* Full, add to buddied list */
z3fold_compact_page(zhdr); list_add(&zhdr->buddy, &pool->buddied);
/* add to unbuddied list */ } else {
freechunks = num_free_chunks(zhdr); z3fold_compact_page(zhdr);
list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); /* add to unbuddied list */
freechunks = num_free_chunks(zhdr);
list_add(&zhdr->buddy,
&pool->unbuddied[freechunks]);
}
} }
/* add to beginning of LRU */ /* add to beginning of LRU */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment