Skip to content

Commit

Permalink
zram: remove redundant checks from zram_recompress()
Browse files Browse the repository at this point in the history
Size class index comparison is powerful enough so we can remove object
size comparisons.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Sergey Senozhatsky <[email protected]>
Acked-by: Minchan Kim <[email protected]>
Cc: Alexey Romanov <[email protected]>
Cc: Nhat Pham <[email protected]>
Cc: Nitin Gupta <[email protected]>
Cc: Suleiman Souhlal <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
sergey-senozhatsky authored and akpm00 committed Nov 30, 2022
1 parent 7c2af30 commit 4942cf6
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions drivers/block/zram/zram_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1722,9 +1722,7 @@ static int zram_recompress(struct zram *zram, u32 index, struct page *page,
comp_len_new);

/* Continue until we make progress */
if (comp_len_new >= huge_class_size ||
comp_len_new >= comp_len_old ||
class_index_new >= class_index_old ||
if (class_index_new >= class_index_old ||
(threshold && comp_len_new >= threshold)) {
zcomp_stream_put(zram->comps[prio]);
continue;
Expand All @@ -1747,9 +1745,7 @@ static int zram_recompress(struct zram *zram, u32 index, struct page *page,
* that would save memory, mark the object as incompressible so that
* we will not try to compress it again.
*/
if (comp_len_new >= huge_class_size ||
comp_len_new >= comp_len_old ||
class_index_new >= class_index_old) {
if (class_index_new >= class_index_old) {
zram_set_flag(zram, index, ZRAM_INCOMPRESSIBLE);
return 0;
}
Expand Down

0 comments on commit 4942cf6

Please sign in to comment.