Lines Matching refs:zhdr
155 struct zbud_header *zhdr = page_address(page); in init_zbud_page() local
156 zhdr->first_chunks = 0; in init_zbud_page()
157 zhdr->last_chunks = 0; in init_zbud_page()
158 INIT_LIST_HEAD(&zhdr->buddy); in init_zbud_page()
159 INIT_LIST_HEAD(&zhdr->lru); in init_zbud_page()
160 zhdr->under_reclaim = false; in init_zbud_page()
161 return zhdr; in init_zbud_page()
165 static void free_zbud_page(struct zbud_header *zhdr) in free_zbud_page() argument
167 __free_page(virt_to_page(zhdr)); in free_zbud_page()
174 static unsigned long encode_handle(struct zbud_header *zhdr, enum buddy bud) in encode_handle() argument
184 handle = (unsigned long)zhdr; in encode_handle()
189 handle += PAGE_SIZE - (zhdr->last_chunks << CHUNK_SHIFT); in encode_handle()
200 static int num_free_chunks(struct zbud_header *zhdr) in num_free_chunks() argument
206 return NCHUNKS - zhdr->first_chunks - zhdr->last_chunks; in num_free_chunks()
272 struct zbud_header *zhdr = NULL; in zbud_alloc() local
286 zhdr = list_first_entry(&pool->unbuddied[i], in zbud_alloc()
288 list_del(&zhdr->buddy); in zbud_alloc()
289 if (zhdr->first_chunks == 0) in zbud_alloc()
304 zhdr = init_zbud_page(page); in zbud_alloc()
309 zhdr->first_chunks = chunks; in zbud_alloc()
311 zhdr->last_chunks = chunks; in zbud_alloc()
313 if (zhdr->first_chunks == 0 || zhdr->last_chunks == 0) { in zbud_alloc()
315 freechunks = num_free_chunks(zhdr); in zbud_alloc()
316 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_alloc()
319 list_add(&zhdr->buddy, &pool->buddied); in zbud_alloc()
323 if (!list_empty(&zhdr->lru)) in zbud_alloc()
324 list_del(&zhdr->lru); in zbud_alloc()
325 list_add(&zhdr->lru, &pool->lru); in zbud_alloc()
327 *handle = encode_handle(zhdr, bud); in zbud_alloc()
345 struct zbud_header *zhdr; in zbud_free() local
349 zhdr = handle_to_zbud_header(handle); in zbud_free()
353 zhdr->last_chunks = 0; in zbud_free()
355 zhdr->first_chunks = 0; in zbud_free()
357 if (zhdr->under_reclaim) { in zbud_free()
364 list_del(&zhdr->buddy); in zbud_free()
366 if (zhdr->first_chunks == 0 && zhdr->last_chunks == 0) { in zbud_free()
368 list_del(&zhdr->lru); in zbud_free()
369 free_zbud_page(zhdr); in zbud_free()
373 freechunks = num_free_chunks(zhdr); in zbud_free()
374 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_free()
418 struct zbud_header *zhdr; in zbud_reclaim_page() local
428 zhdr = list_last_entry(&pool->lru, struct zbud_header, lru); in zbud_reclaim_page()
429 list_del(&zhdr->lru); in zbud_reclaim_page()
430 list_del(&zhdr->buddy); in zbud_reclaim_page()
432 zhdr->under_reclaim = true; in zbud_reclaim_page()
439 if (zhdr->first_chunks) in zbud_reclaim_page()
440 first_handle = encode_handle(zhdr, FIRST); in zbud_reclaim_page()
441 if (zhdr->last_chunks) in zbud_reclaim_page()
442 last_handle = encode_handle(zhdr, LAST); in zbud_reclaim_page()
458 zhdr->under_reclaim = false; in zbud_reclaim_page()
459 if (zhdr->first_chunks == 0 && zhdr->last_chunks == 0) { in zbud_reclaim_page()
464 free_zbud_page(zhdr); in zbud_reclaim_page()
468 } else if (zhdr->first_chunks == 0 || in zbud_reclaim_page()
469 zhdr->last_chunks == 0) { in zbud_reclaim_page()
471 freechunks = num_free_chunks(zhdr); in zbud_reclaim_page()
472 list_add(&zhdr->buddy, &pool->unbuddied[freechunks]); in zbud_reclaim_page()
475 list_add(&zhdr->buddy, &pool->buddied); in zbud_reclaim_page()
479 list_add(&zhdr->lru, &pool->lru); in zbud_reclaim_page()