Source
* This function will attempt to find a free region in the pool large enough to
/*
* z3fold.c
*
* Author: Vitaly Wool <vitaly.wool@konsulko.com>
* Copyright (C) 2016, Sony Mobile Communications Inc.
*
* This implementation is based on zbud written by Seth Jennings.
*
* z3fold is an special purpose allocator for storing compressed pages. It
* can store up to three compressed pages per page which improves the
* compression ratio of zbud while retaining its main concepts (e. g. always
* storing an integral number of objects per page) and simplicity.
* It still has simple and deterministic reclaim properties that make it
* preferable to a higher density approach (with no requirement on integral
* number of object per page) when reclaim is used.
*
* As in zbud, pages are divided into "chunks". The size of the chunks is
* fixed at compile time and is determined by NCHUNKS_ORDER below.
*
* z3fold doesn't export any API and is meant to be used via zpool API.
*/
/*****************
* Structures
*****************/
struct z3fold_pool;
struct z3fold_ops {
int (*evict)(struct z3fold_pool *pool, unsigned long handle);
};
enum buddy {
HEADLESS = 0,
FIRST,
MIDDLE,
LAST,
BUDDIES_MAX
};
/*
* struct z3fold_header - z3fold page metadata occupying first chunks of each
* z3fold page, except for HEADLESS pages
* @buddy: links the z3fold page into the relevant list in the
* pool
* @page_lock: per-page lock
* @refcount: reference count for the z3fold page
* @work: work_struct for page layout optimization
* @pool: pointer to the pool which this page belongs to
* @cpu: CPU which this page "belongs" to
* @first_chunks: the size of the first buddy in chunks, 0 if free