• Sergey Senozhatsky's avatar
    zsmalloc: introduce zs_huge_class_size() · 010b495e
    Sergey Senozhatsky authored
    Patch series "zsmalloc/zram: drop zram's max_zpage_size", v3.
    
    ZRAM's max_zpage_size is a bad thing.  It forces zsmalloc to store
    normal objects as huge ones, which results in bigger zsmalloc memory
    usage.  Drop it and use actual zsmalloc huge-class value when decide if
    the object is huge or not.
    
    This patch (of 2):
    
    Not every object can be share its zspage with other objects, e.g.  when
    the object is as big as zspage or nearly as big a zspage.  For such
    objects zsmalloc has a so called huge class - every object which belongs
    to huge class consumes the entire zspage (which consists of a physical
    page).  On x86_64, PAGE_SHIFT 12 box, the first non-huge class size is
    3264, so starting down from size 3264, objects can share page(-s) and
    thus minimize memory wastage.
    
    ZRAM, however, has its own statically defined watermark for huge
    objects, namely "3 * PAGE_SIZE / 4 = 3072", and forcibly stores every
    object larger than this watermark (3072) as a PAGE_SIZE object, in other
    words, to a huge class, while zsmalloc can keep some of those objects in
    non-huge classes.  This results in increased memory consumption.
    
    zsmalloc knows better if the object is huge or not.  Introduce
    zs_huge_class_size() function which tells if the given object can be
    stored in one of non-huge classes or not.  This will let us to drop
    ZRAM's huge object watermark and fully rely on zsmalloc when we decide
    if the object is huge.
    
    [sergey.senozhatsky.work@gmail.com: add pool param to zs_huge_class_size()]
      Link: http://lkml.kernel.org/r/20180314081833.1096-2-sergey.senozhatsky@gmail.com
    Link: http://lkml.kernel.org/r/20180306070639.7389-2-sergey.senozhatsky@gmail.comSigned-off-by: default avatarSergey Senozhatsky <sergey.senozhatsky@gmail.com>
    Acked-by: default avatarMinchan Kim <minchan@kernel.org>
    Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    010b495e
zsmalloc.c 60.3 KB