Skip to content

Commit

Permalink
zsmalloc: make zspage chain size configurable
Browse files Browse the repository at this point in the history
Remove hard coded limit on the maximum number of physical pages
per-zspage.

This will allow tuning of zsmalloc pool as zspage chain size changes
`pages per-zspage` and `objects per-zspage` characteristics of size
classes which also affects size classes clustering (the way size classes
are merged).

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Sergey Senozhatsky <[email protected]>
Acked-by: Minchan Kim <[email protected]>
Cc: Mike Kravetz <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
sergey-senozhatsky authored and dereference23 committed Jun 18, 2023
1 parent a42e329 commit 26865fc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
19 changes: 19 additions & 0 deletions mm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,25 @@ config ZSMALLOC_STAT
information to userspace via debugfs.
If unsure, say N.

config ZSMALLOC_CHAIN_SIZE
int "Maximum number of physical pages per-zspage"
default 4
range 4 16
depends on ZSMALLOC
help
This option sets the upper limit on the number of physical pages
that a zmalloc page (zspage) can consist of. The optimal zspage
chain size is calculated for each size class during the
initialization of the pool.

Changing this option can alter the characteristics of size classes,
such as the number of pages per zspage and the number of objects
per zspage. This can also result in different configurations of
the pool, as zsmalloc merges size classes with similar
characteristics.

For more information, see zsmalloc documentation.

config DIRECT_RECLAIM_FILE_PAGES_ONLY
bool "Reclaim file pages only on direct reclaim path"
default n
Expand Down
12 changes: 4 additions & 8 deletions mm/zsmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@
*/
#define ZS_ALIGN 8

/*
* A single 'zspage' is composed of up to 2^N discontiguous 0-order (single)
* pages. ZS_MAX_ZSPAGE_ORDER defines upper limit on N.
*/
#define ZS_MAX_ZSPAGE_ORDER 2
#define ZS_MAX_PAGES_PER_ZSPAGE (_AC(1, UL) << ZS_MAX_ZSPAGE_ORDER)

#define ZS_HANDLE_SIZE (sizeof(unsigned long))

/*
Expand Down Expand Up @@ -121,10 +114,13 @@
#define HUGE_BITS 1
#define FULLNESS_BITS 2
#define CLASS_BITS 8
#define ISOLATED_BITS 3
#define ISOLATED_BITS 5
#define MAGIC_VAL_BITS 8

#define MAX(a, b) ((a) >= (b) ? (a) : (b))

#define ZS_MAX_PAGES_PER_ZSPAGE (_AC(CONFIG_ZSMALLOC_CHAIN_SIZE, UL))

/* ZS_MIN_ALLOC_SIZE must be multiple of ZS_ALIGN */
#define ZS_MIN_ALLOC_SIZE \
MAX(32, (ZS_MAX_PAGES_PER_ZSPAGE << PAGE_SHIFT >> OBJ_INDEX_BITS))
Expand Down

0 comments on commit 26865fc

Please sign in to comment.