zram: further limit recompression threshold
authorSergey Senozhatsky <senozhatsky@chromium.org>
Wed, 14 Jun 2023 14:13:12 +0000 (23:13 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 19 Jun 2023 23:19:33 +0000 (16:19 -0700)
Recompression threshold should be below huge-size-class watermark.  Any
object larger than huge-size-class is a "huge object" and occupies a
whole physical page on the zsmalloc side, in other words it's
incompressible, as far as zsmalloc is concerned.

Link: https://lkml.kernel.org/r/20230614141338.3480029-1-senozhatsky@chromium.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Suggested-by: Brian Geffon <bgeffon@google.com>
Acked-by: Brian Geffon <bgeffon@google.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/block/zram/zram_drv.c

index f6d90f1..5d258a2 100644 (file)
@@ -1753,7 +1753,7 @@ static ssize_t recompress_store(struct device *dev,
                }
        }
 
-       if (threshold >= PAGE_SIZE)
+       if (threshold >= huge_class_size)
                return -EINVAL;
 
        down_read(&zram->init_lock);