From patchwork Wed Nov 9 11:50:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13037462 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D99DBC433FE for ; Wed, 9 Nov 2022 11:52:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 836156B0078; Wed, 9 Nov 2022 06:52:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E7A68E0005; Wed, 9 Nov 2022 06:52:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6AE656B007D; Wed, 9 Nov 2022 06:52:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 607686B0078 for ; Wed, 9 Nov 2022 06:52:06 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2F782C1400 for ; Wed, 9 Nov 2022 11:52:06 +0000 (UTC) X-FDA: 80113740252.14.01C7344 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf18.hostedemail.com (Postfix) with ESMTP id D66EE1C0003 for ; Wed, 9 Nov 2022 11:52:05 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id b11so16492282pjp.2 for ; Wed, 09 Nov 2022 03:52:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LTJSMGQnVr536MHmH+z5uAcQ4mxEF9ubNphP3SWXc38=; b=JugrdxVHc3EVPtfDqUoNOLZ1kNs5JPOJ8YZcAaOous+St7ne5PyANDUJXAtNY2rhEi n//X6QGWh/U5eKuz/qRvjJjhPJDLKEKXuOXggdKo3dJVy++tIRmqYSSouzcUMrqrK99F y82p7gDbtsucgtq6MfVMebxhThBUzWo1dXpBE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LTJSMGQnVr536MHmH+z5uAcQ4mxEF9ubNphP3SWXc38=; b=XSoKQrbmODc/K8ekSHAJIhy/0pTqBLr4ITGX8hOln6zdWqa8t2KbUI1pZJgguIjzeg tnsNkI322Uxc/kUHbhvgC5sS6XebUFHNuucmRdSN7brwCbkLqKHjgFvWLMXD0hwjM5eU 3ZLJm98sR/q8UnbVcQAWb0t6ApJAiWDu8+Cw2ksHhcS4j1R328+RKSpSZhILJJDLWmyS rA5vCOat06yJeaR1sYwQW73sTsGXFK6K5pAs9no0kmZ9t4uNVhrU0gJv6gtzKmYRzj/s eSoMNC8Q2tEr4k/VF2Vn1PdApYXVvyj/2mN7wu1CzihTTMhn22frv2oqiov9S00aVpjB CBGw== X-Gm-Message-State: ACrzQf0wPRrL4dahDwruw9Ph/V/rPR9Ri9Mm8nuU7D0xxcCUoPK/nKuo kNPxCP3wq2XAGNEYk/i2jBPUpw== X-Google-Smtp-Source: AMsMyM7MLI40Iy3R2HZvtqnUxgbgUMiou0kBc/wNNyE+pA7d0aC//esy4rrsRm2ejyOyrIpOAHrfIA== X-Received: by 2002:a17:90a:f414:b0:212:cacf:42c3 with SMTP id ch20-20020a17090af41400b00212cacf42c3mr79536832pjb.198.1667994677913; Wed, 09 Nov 2022 03:51:17 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:61f1:44d3:3f47:2cdb]) by smtp.gmail.com with ESMTPSA id f5-20020a655505000000b00434760ee36asm7292311pgr.16.2022.11.09.03.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 03:51:17 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: Nitin Gupta , Suleiman Souhlal , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv5 09/13] zram: remove redundant checks from zram_recompress() Date: Wed, 9 Nov 2022 20:50:43 +0900 Message-Id: <20221109115047.2921851-10-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109115047.2921851-1-senozhatsky@chromium.org> References: <20221109115047.2921851-1-senozhatsky@chromium.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667994725; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LTJSMGQnVr536MHmH+z5uAcQ4mxEF9ubNphP3SWXc38=; b=hllDdaddn3HM6d2qEsHET5R4RXrP8YlX2+Dvd750COdE48+AHZcqINH0YxFTdZ9haeNPM3 C6VPnG8yedRLoap722pz7aU4zf3B53FsVfNbtyUyKPraW8Socd9L/SUwVdr38vBG7WzPph X6acJpVGAnDVSjJZv66Ul6ZsvmCrNAU= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=JugrdxVH; spf=pass (imf18.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.48 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667994725; a=rsa-sha256; cv=none; b=M31c3h078qhqb4aH/uArrgL2qcJVYZX68Pev3Rzljbmh+sRpf5y3TEuQ7fEVdPrlfWju12 r/sH/DcQjyXej+0EDK6J7nz9kmZt7UOfLqNt6pilFtv2l+FGBvqqATWzsdNumrdhUVHv/s bU/vxKivscg9AbX0GgYk2TCw6U3PqYk= X-Rspamd-Queue-Id: D66EE1C0003 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=JugrdxVH; spf=pass (imf18.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.48 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam10 X-Rspam-User: X-Stat-Signature: dy5sj1trdz8ydfn85wypa4taop7tkef6 X-HE-Tag: 1667994725-836285 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Size class index comparison is powerful enough so we can remove object size comparisons. Signed-off-by: Sergey Senozhatsky --- drivers/block/zram/zram_drv.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 383d967ef4c7..67b58f2255db 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1725,9 +1725,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; @@ -1750,9 +1748,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; }