Skip to content

Commit

Permalink
mm/z3fold.c: improve compression by extending search
Browse files Browse the repository at this point in the history
The current z3fold implementation only searches this CPU's page lists for
a fitting page to put a new object into.  This patch adds quick search for
very well fitting pages (i.  e.  those having exactly the required number
of free space) on other CPUs too, before allocating a new page for that
object.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Vitaly Wool <[email protected]>
Cc: Bartlomiej Zolnierkiewicz <[email protected]>
Cc: Dan Streetman <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Oleksiy Avramchenko <[email protected]>
Cc: Uladzislau Rezki <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
vwool authored and torvalds committed May 14, 2019
1 parent 9050cce commit 351618b
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions mm/z3fold.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,42 @@ static inline struct z3fold_header *__z3fold_alloc(struct z3fold_pool *pool,
}
put_cpu_ptr(pool->unbuddied);

if (!zhdr) {
int cpu;

/* look for _exact_ match on other cpus' lists */
for_each_online_cpu(cpu) {
struct list_head *l;

unbuddied = per_cpu_ptr(pool->unbuddied, cpu);
spin_lock(&pool->lock);
l = &unbuddied[chunks];

zhdr = list_first_entry_or_null(READ_ONCE(l),
struct z3fold_header, buddy);

if (!zhdr || !z3fold_page_trylock(zhdr)) {
spin_unlock(&pool->lock);
zhdr = NULL;
continue;
}
list_del_init(&zhdr->buddy);
zhdr->cpu = -1;
spin_unlock(&pool->lock);

page = virt_to_page(zhdr);
if (test_bit(NEEDS_COMPACTING, &page->private)) {
z3fold_page_unlock(zhdr);
zhdr = NULL;
if (can_sleep)
cond_resched();
continue;
}
kref_get(&zhdr->refcount);
break;
}
}

return zhdr;
}

Expand Down

0 comments on commit 351618b

Please sign in to comment.