Skip to content

Commit

Permalink
UPSTREAM: zsmalloc: zsmalloc documentation
Browse files Browse the repository at this point in the history
(cherry-pick from commit d02be50dba649b4246e0c1c4b7cb5d8a8d49de9a)

Create zsmalloc doc which explains design concept and stat information.

Bug: 25951511

Change-Id: Ie1e5ac914186558feabaf8fbea29154395267dda
Signed-off-by: Minchan Kim <[email protected]>
Cc: Juneho Choi <[email protected]>
Cc: Gunho Lee <[email protected]>
Cc: Luigi Semenzato <[email protected]>
Cc: Dan Streetman <[email protected]>
Cc: Seth Jennings <[email protected]>
Cc: Nitin Gupta <[email protected]>
Cc: Jerome Marchand <[email protected]>
Cc: Sergey Senozhatsky <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Signed-off-by: Corinna Vinschen <[email protected]>
  • Loading branch information
minchank authored and ananjaser1211 committed Apr 20, 2021
1 parent d0c40eb commit 7212173
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -9219,6 +9219,7 @@ L: [email protected]
S: Maintained
F: mm/zsmalloc.c
F: include/linux/zsmalloc.h
F: Documentation/vm/zsmalloc.txt

ZSWAP COMPRESSED SWAP CACHING
M: Seth Jennings <[email protected]>
Expand Down
29 changes: 0 additions & 29 deletions mm/zsmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,6 @@
*/

/*
* This allocator is designed for use with zram. Thus, the allocator is
* supposed to work well under low memory conditions. In particular, it
* never attempts higher order page allocation which is very likely to
* fail under memory pressure. On the other hand, if we just use single
* (0-order) pages, it would suffer from very high fragmentation --
* any object of size PAGE_SIZE/2 or larger would occupy an entire page.
* This was one of the major issues with its predecessor (xvmalloc).
*
* To overcome these issues, zsmalloc allocates a bunch of 0-order pages
* and links them together using various 'struct page' fields. These linked
* pages act as a single higher-order page i.e. an object can span 0-order
* page boundaries. The code refers to these linked pages as a single entity
* called zspage.
*
* For simplicity, zsmalloc can only allocate objects of size up to PAGE_SIZE
* since this satisfies the requirements of all its current users (in the
* worst case, page is incompressible and is thus stored "as-is" i.e. in
* uncompressed form). For allocation requests larger than this size, failure
* is returned (see zs_malloc).
*
* Additionally, zs_malloc() does not return a dereferenceable pointer.
* Instead, it returns an opaque handle (unsigned long) which encodes actual
* location of the allocated object. The reason for this indirection is that
* zsmalloc does not keep zspages permanently mapped since that would cause
* issues on 32-bit systems where the VA region for kernel space mappings
* is very small. So, before using the allocating memory, the object has to
* be mapped using zs_map_object() to get a usable pointer and subsequently
* unmapped using zs_unmap_object().
*
* Following is how we use various fields and flags of underlying
* struct page(s) to form a zspage.
*
Expand Down

0 comments on commit 7212173

Please sign in to comment.