*/
#define PTRS_PER_PAGE (PAGE_SIZE / sizeof(void *))
-#define PAGES_PER_POOL (PTRS_PER_PAGE)
#define IDLE_IDX_MAX (100)
#define IDLE_IDX_WEIGHT (3)
struct ptlrpc_page_pool *pool = page_pools[0];
spin_lock(&pool->ppp_lock);
- seq_printf(m, "physical pages: %lu\n"
+ seq_printf(m,
+ "physical pages: %lu\n"
"pages per pool: %lu\n"
"max pages: %lu\n"
"max pools: %u\n"
"max waitqueue depth: %u\n"
"max wait time ms: %lld\n"
"out of mem: %lu\n",
- cfs_totalram_pages(), PAGES_PER_POOL,
+ cfs_totalram_pages(), PTRS_PER_PAGE,
pool->ppp_max_pages,
pool->ppp_max_pools,
pool->ppp_total_pages,
struct ptlrpc_page_pool *pool;
seq_printf(m, "physical_pages: %lu\n"
- "pages per pool: %lu\n\n"
"pools:\n",
- cfs_totalram_pages(), PAGES_PER_POOL);
+ cfs_totalram_pages());
for (pool_order = 0; pool_order < POOLS_COUNT; pool_order++) {
pool = page_pools[pool_order];
LASSERT(pool->ppp_free_pages <= pool->ppp_total_pages);
/* max pool index before the release */
- p_idx_max2 = (pool->ppp_total_pages - 1) / PAGES_PER_POOL;
+ p_idx_max2 = (pool->ppp_total_pages - 1) / PTRS_PER_PAGE;
pool->ppp_free_pages -= npages;
pool->ppp_total_pages -= npages;
/* max pool index after the release */
p_idx_max1 = pool->ppp_total_pages == 0 ? -1 :
- ((pool->ppp_total_pages - 1) / PAGES_PER_POOL);
+ ((pool->ppp_total_pages - 1) / PTRS_PER_PAGE);
- p_idx = pool->ppp_free_pages / PAGES_PER_POOL;
- g_idx = pool->ppp_free_pages % PAGES_PER_POOL;
+ p_idx = pool->ppp_free_pages / PTRS_PER_PAGE;
+ g_idx = pool->ppp_free_pages % PTRS_PER_PAGE;
LASSERT(pool->ppp_pools[p_idx]);
while (npages--) {
pool->ppp_pools[p_idx][g_idx] = NULL;
- if (++g_idx == PAGES_PER_POOL) {
+ if (++g_idx == PTRS_PER_PAGE) {
p_idx++;
g_idx = 0;
}
static inline
int npages_to_npools(unsigned long npages)
{
- return (int) ((npages + PAGES_PER_POOL - 1) / PAGES_PER_POOL);
+ return (int) ((npages + PTRS_PER_PAGE - 1) / PTRS_PER_PAGE);
}
/*
for (i = 0; i < npools; i++) {
if (pools[i]) {
- for (j = 0; j < PAGES_PER_POOL; j++) {
+ for (j = 0; j < PTRS_PER_PAGE; j++) {
if (pools[i][j]) {
if (pool->ppp_order == 0) {
__free_page(pools[i][j]);
* free slots are those left by rent pages, and the extra ones with
* index >= total_pages, locate at the tail of last pool.
*/
- freeslot = page_pool->ppp_total_pages % PAGES_PER_POOL;
+ freeslot = page_pool->ppp_total_pages % PTRS_PER_PAGE;
if (freeslot != 0)
- freeslot = PAGES_PER_POOL - freeslot;
+ freeslot = PTRS_PER_PAGE - freeslot;
freeslot += page_pool->ppp_total_pages - page_pool->ppp_free_pages;
- op_idx = page_pool->ppp_free_pages / PAGES_PER_POOL;
- og_idx = page_pool->ppp_free_pages % PAGES_PER_POOL;
+ op_idx = page_pool->ppp_free_pages / PTRS_PER_PAGE;
+ og_idx = page_pool->ppp_free_pages % PTRS_PER_PAGE;
np_idx = npools - 1;
- ng_idx = (npages - 1) % PAGES_PER_POOL;
+ ng_idx = (npages - 1) % PTRS_PER_PAGE;
while (freeslot) {
LASSERT(page_pool->ppp_pools[op_idx][og_idx] == NULL);
freeslot--;
- if (++og_idx == PAGES_PER_POOL) {
+ if (++og_idx == PTRS_PER_PAGE) {
op_idx++;
og_idx = 0;
}
if (np_idx == 0)
break;
np_idx--;
- ng_idx = PAGES_PER_POOL - 1;
+ ng_idx = PTRS_PER_PAGE - 1;
}
}
/*
* (2) add pools if needed.
*/
- cur_npools = (page_pool->ppp_total_pages + PAGES_PER_POOL - 1) /
- PAGES_PER_POOL;
+ cur_npools = (page_pool->ppp_total_pages + PTRS_PER_PAGE - 1) /
+ PTRS_PER_PAGE;
end_npools = (page_pool->ppp_total_pages + npages +
- PAGES_PER_POOL - 1) / PAGES_PER_POOL;
+ PTRS_PER_PAGE - 1) / PTRS_PER_PAGE;
LASSERT(end_npools <= page_pool->ppp_max_pools);
np_idx = 0;
if (pools[i] == NULL)
goto out_pools;
- for (j = 0; j < PAGES_PER_POOL && alloced < npages; j++) {
+ for (j = 0; j < PTRS_PER_PAGE && alloced < npages; j++) {
if (pool_order == 0)
pools[i][j] = alloc_page(GFP_NOFS |
__GFP_HIGHMEM);
/* proceed with rest of allocation */
page_pool->ppp_free_pages -= count;
- p_idx = page_pool->ppp_free_pages / PAGES_PER_POOL;
- g_idx = page_pool->ppp_free_pages % PAGES_PER_POOL;
+ p_idx = page_pool->ppp_free_pages / PTRS_PER_PAGE;
+ g_idx = page_pool->ppp_free_pages % PTRS_PER_PAGE;
for (i = 0; i < count; i++) {
void **pagep = page_from(array, i);
*pagep = page_pool->ppp_pools[p_idx][g_idx];
page_pool->ppp_pools[p_idx][g_idx] = NULL;
- if (++g_idx == PAGES_PER_POOL) {
+ if (++g_idx == PTRS_PER_PAGE) {
p_idx++;
g_idx = 0;
}
spin_lock(&page_pool->ppp_lock);
- p_idx = page_pool->ppp_free_pages / PAGES_PER_POOL;
- g_idx = page_pool->ppp_free_pages % PAGES_PER_POOL;
+ p_idx = page_pool->ppp_free_pages / PTRS_PER_PAGE;
+ g_idx = page_pool->ppp_free_pages % PTRS_PER_PAGE;
if (page_pool->ppp_free_pages + count > page_pool->ppp_total_pages)
GOTO(out_unlock, rc = -EPROTO);
GOTO(out_unlock, rc = -EPROTO);
page_pool->ppp_pools[p_idx][g_idx] = *pagep;
- if (++g_idx == PAGES_PER_POOL) {
+ if (++g_idx == PTRS_PER_PAGE) {
p_idx++;
g_idx = 0;
}