• David Sterba's avatar
    btrfs: use shrinker for compression page pool · 4cea422a
    David Sterba authored
    The pages are now allocated and freed centrally, so we can extend the
    logic to manage the lifetime. The main idea is to keep a few recently
    used pages and hand them to all writers. Ideally we won't have to go to
    allocator at all (a slight performance gain) and also raise chance that
    we'll have the pages available (slightly increased reliability).
    
    In order to avoid gathering too many pages, the shrinker is attached to
    the cache so we can free them on when MM demands that. The first
    implementation will drain the whole cache. Further this can be refined
    to keep some minimal number of pages for emergency purposes.  The
    ultimate goal to avoid memory allocation failures on the write out path
    from the compression.
    
    The pool threshold is set to cover full BTRFS_MAX_COMPRESSED / PAGE_SIZE
    for minimal thread pool, which is 8 (btrfs_init_fs_info()). This is 128K
    / 4K * 8 = 256 pages at maximum, which is 1MiB.
    
    This is for all filesystems currently mounted, with heavy use of
    compression IO the allocator is still needed. The cache helps for short
    burst IO.
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    4cea422a
compression.c 41.5 KB