Re: [RFC PATCH 3/3] mm/zsmalloc: change ZS_MAX_PAGES_PER_ZSPAGE
From: Sergey Senozhatsky
Date: Fri Feb 19 2016 - 00:53:56 EST
On (02/19/16 14:38), Sergey Senozhatsky wrote:
[..]
> #define OBJ_ALLOCATED_TAG 1
> #define OBJ_TAG_BITS 1
> #define OBJ_INDEX_BITS (BITS_PER_LONG - _PFN_BITS - OBJ_TAG_BITS)
> #define OBJ_INDEX_MASK ((_AC(1, UL) << OBJ_INDEX_BITS) - 1)
>
> #define ZS_MIN_ALLOC_SIZE \
> MAX(32, (ZS_MAX_PAGES_PER_ZSPAGE << PAGE_SHIFT >> OBJ_INDEX_BITS))
[..]
> -- on 32 bit system, PAGE_SHIFT 12
>
> ZS_MAX_PAGES_PER_ZSPAGE 1 << 4 16
> OBJ_INDEX_BITS (32 - (32 - 12) - 1) 11
> OBJ_INDEX_MASK ((1 << (32 - (32 - 12) - 1)) - 1) 2047
> ZS_MIN_ALLOC_SIZE MAX(32, ((1 << 4) << 12 >> (32 - (32 - 12) - 1))) 32
>
> -- on 64 bit system, PAGE_SHIFT 12
>
> ZS_MAX_PAGES_PER_ZSPAGE 1 << 4 16
> OBJ_INDEX_BITS (64 - (64 - 12) - 1) 11
> OBJ_INDEX_MASK ((1 << (64 - (64 - 12) - 1)) - 1) 2047
> ZS_MIN_ALLOC_SIZE MAX(32, ((1 << 4) << 12 >> (64 - (64 - 12) - 1))) 32
even if it's missing "HANDLE_PIN_BIT 0", it's still OBJ_INDEX_BITS 10,
2<<10 should be enough to keep 32 bytes class around.
> -- on 64 bit system, PAGE_SHIFT 14
>
> ZS_MAX_PAGES_PER_ZSPAGE 1 << 4 16
> OBJ_INDEX_BITS (64 - (64 - 14) - 1) 13
> OBJ_INDEX_MASK ((1 << (64 - (64 - 14) - 1)) - 1) 8191
> ZS_MIN_ALLOC_SIZE MAX(32, ((1 << 4) << 14 >> (64 - (64 - 14) - 1))) 32
OBJ_INDEX_BITS 2<<12 still looks to be good enough.
-ss