Skip to content

Commit

Permalink
mm/z3fold.c: avoid modifying HEADLESS page and minor cleanup
Browse files Browse the repository at this point in the history
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.com
Signed-off-by: Vitaly Wool <vitalywool@gmail.com>
Reviewed-by: Dan Streetman <ddstreet@ieee.org>
Cc: Seth Jennings <sjenning@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
vwool authored and torvalds committed Jun 3, 2016
1 parent 3a06bb7 commit 43afc19
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions mm/z3fold.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)
/* HEADLESS page stored */
bud = HEADLESS;
} else {
bud = (handle - zhdr->first_num) & BUDDY_MASK;
bud = handle_to_buddy(handle);

switch (bud) {
case FIRST:
Expand Down Expand Up @@ -572,15 +572,19 @@ static int z3fold_reclaim_page(struct z3fold_pool *pool, unsigned int retries)
pool->pages_nr--;
spin_unlock(&pool->lock);
return 0;
} else if (zhdr->first_chunks != 0 &&
zhdr->last_chunks != 0 && zhdr->middle_chunks != 0) {
/* Full, add to buddied list */
list_add(&zhdr->buddy, &pool->buddied);
} else if (!test_bit(PAGE_HEADLESS, &page->private)) {
z3fold_compact_page(zhdr);
/* add to unbuddied list */
freechunks = num_free_chunks(zhdr);
list_add(&zhdr->buddy, &pool->unbuddied[freechunks]);
} else if (!test_bit(PAGE_HEADLESS, &page->private)) {
if (zhdr->first_chunks != 0 &&
zhdr->last_chunks != 0 &&
zhdr->middle_chunks != 0) {
/* Full, add to buddied list */
list_add(&zhdr->buddy, &pool->buddied);
} else {
z3fold_compact_page(zhdr);
/* add to unbuddied list */
freechunks = num_free_chunks(zhdr);
list_add(&zhdr->buddy,
&pool->unbuddied[freechunks]);
}
}

/* add to beginning of LRU */
Expand Down

0 comments on commit 43afc19

Please sign in to comment.