Skip to content

Commit

Permalink
zsmalloc: add bp hints to memory allocations
Browse files Browse the repository at this point in the history
These are called frequently.

Add bp hints to avoid pipeline flushes.

Signed-off-by: Park Ju Hyung <[email protected]>
Signed-off-by: Alexander Winkowski <[email protected]>
  • Loading branch information
arter97 authored and dereference23 committed Feb 10, 2022
1 parent 88d356e commit 4438239
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mm/zsmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ static struct zspage *alloc_zspage(struct zs_pool *pool,
struct page *pages[ZS_MAX_PAGES_PER_ZSPAGE];
struct zspage *zspage = cache_alloc_zspage(pool, gfp);

if (!zspage)
if (unlikely(!zspage))
return NULL;

zspage->magic = ZSPAGE_MAGIC;
Expand Down Expand Up @@ -1417,7 +1417,7 @@ unsigned long zs_malloc(struct zs_pool *pool, size_t size, gfp_t gfp)
return 0;

handle = cache_alloc_handle(pool, gfp);
if (!handle)
if (unlikely(!handle))
return 0;

/* extra space in chunk to keep the handle */
Expand All @@ -1439,7 +1439,7 @@ unsigned long zs_malloc(struct zs_pool *pool, size_t size, gfp_t gfp)
spin_unlock(&class->lock);

zspage = alloc_zspage(pool, class, gfp);
if (!zspage) {
if (unlikely(!zspage)) {
cache_free_handle(pool, handle);
return 0;
}
Expand Down

0 comments on commit 4438239

Please sign in to comment.