summaryrefslogtreecommitdiff
path: root/mm/z3fold.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/z3fold.c')
-rw-r--r--mm/z3fold.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/mm/z3fold.c b/mm/z3fold.c
index e84de91ecccb..7c76b396b74c 100644
--- a/mm/z3fold.c
+++ b/mm/z3fold.c
@@ -133,8 +133,6 @@ struct z3fold_header {
* @stale: list of pages marked for freeing
* @pages_nr: number of z3fold pages in the pool.
* @c_handle: cache for z3fold_buddy_slots allocation
- * @zpool: zpool driver
- * @zpool_ops: zpool operations structure with an evict callback
* @compact_wq: workqueue for page layout background optimization
* @release_wq: workqueue for safe page release
* @work: work_struct for safe page release
@@ -480,6 +478,16 @@ static void release_z3fold_page_locked_list(struct kref *ref)
__release_z3fold_page(zhdr, true);
}
+static inline int put_z3fold_locked(struct z3fold_header *zhdr)
+{
+ return kref_put(&zhdr->refcount, release_z3fold_page_locked);
+}
+
+static inline int put_z3fold_locked_list(struct z3fold_header *zhdr)
+{
+ return kref_put(&zhdr->refcount, release_z3fold_page_locked_list);
+}
+
static void free_pages_work(struct work_struct *w)
{
struct z3fold_pool *pool = container_of(w, struct z3fold_pool, work);
@@ -666,7 +674,7 @@ static struct z3fold_header *compact_single_buddy(struct z3fold_header *zhdr)
return new_zhdr;
out_fail:
- if (new_zhdr && !kref_put(&new_zhdr->refcount, release_z3fold_page_locked)) {
+ if (new_zhdr && !put_z3fold_locked(new_zhdr)) {
add_to_unbuddied(pool, new_zhdr);
z3fold_page_unlock(new_zhdr);
}
@@ -741,7 +749,7 @@ static void do_compact_page(struct z3fold_header *zhdr, bool locked)
list_del_init(&zhdr->buddy);
spin_unlock(&pool->lock);
- if (kref_put(&zhdr->refcount, release_z3fold_page_locked))
+ if (put_z3fold_locked(zhdr))
return;
if (test_bit(PAGE_STALE, &page->private) ||
@@ -752,7 +760,7 @@ static void do_compact_page(struct z3fold_header *zhdr, bool locked)
if (!zhdr->foreign_handles && buddy_single(zhdr) &&
zhdr->mapped_count == 0 && compact_single_buddy(zhdr)) {
- if (!kref_put(&zhdr->refcount, release_z3fold_page_locked)) {
+ if (!put_z3fold_locked(zhdr)) {
clear_bit(PAGE_CLAIMED, &page->private);
z3fold_page_unlock(zhdr);
}
@@ -878,7 +886,7 @@ lookup:
return zhdr;
out_fail:
- if (!kref_put(&zhdr->refcount, release_z3fold_page_locked)) {
+ if (!put_z3fold_locked(zhdr)) {
add_to_unbuddied(pool, zhdr);
z3fold_page_unlock(zhdr);
}
@@ -1012,8 +1020,7 @@ retry:
if (zhdr) {
bud = get_free_buddy(zhdr, chunks);
if (bud == HEADLESS) {
- if (!kref_put(&zhdr->refcount,
- release_z3fold_page_locked))
+ if (!put_z3fold_locked(zhdr))
z3fold_page_unlock(zhdr);
pr_err("No free chunks in unbuddied\n");
WARN_ON(1);
@@ -1129,7 +1136,7 @@ static void z3fold_free(struct z3fold_pool *pool, unsigned long handle)
if (!page_claimed)
free_handle(handle, zhdr);
- if (kref_put(&zhdr->refcount, release_z3fold_page_locked_list))
+ if (put_z3fold_locked_list(zhdr))
return;
if (page_claimed) {
/* the page has not been claimed by us */
@@ -1346,7 +1353,7 @@ static void z3fold_page_putback(struct page *page)
if (!list_empty(&zhdr->buddy))
list_del_init(&zhdr->buddy);
INIT_LIST_HEAD(&page->lru);
- if (kref_put(&zhdr->refcount, release_z3fold_page_locked))
+ if (put_z3fold_locked(zhdr))
return;
if (list_empty(&zhdr->buddy))
add_to_unbuddied(pool, zhdr);