Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3141761lqo; Wed, 15 May 2024 00:25:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXaW3WAt5LMi0bonHrL35sKmfLJBN3waOzU0/Im1wPXDnykpc1icdG3/0qhWCtEVi37KWz5tkwKZqtBPxkEiC7cDD+ztZUETbL38/AjDA== X-Google-Smtp-Source: AGHT+IGsypZK9eSQ9dZG4S17vEBQ5INwsxUsyxw2WS7idUnZtREQz/amLmQxZ1fJbJmOU+fM8gdv X-Received: by 2002:a05:6358:4301:b0:192:ba37:f9f1 with SMTP id e5c5f4694b2df-193bb3fc89amr1809350255d.5.1715757934640; Wed, 15 May 2024 00:25:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715757934; cv=pass; d=google.com; s=arc-20160816; b=TAKsGLmrXFFeKHaFfrPvMtr9eFooWDKw4Iqa5GyeH3DQSkzwZWJTL5yZ4o4CdaoWOs XE5lL76fTpgRQzdVylCDLf70SMp+rynZEvc4/jiEct+sdrWO28uBK6lg1Vk+RjZz68nT QJ1cmc9W6UzjJtqLk5xermjfyH/sMgUm/B8XYXZ7Z5vuX6iIoKLYub3m3sfQjnPmE9aN b6tfk+YHEJuAP46SugF6UlAHzx9D9c+b/5SBigruk9CTgTlBO7kQFfnIKCnDKpjFYtTj z941gN24WS3rXuh1RDZyGMUUijnFiqbize3yHKEfbuMJrF8o8soz2dyM9xwakcXHkxig 9+2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=7bmm+z3Y++HgLKjqUQ1k19xvJfVuFLOPQwKCzZQr8AY=; fh=UKstJvjqAQ3P/Vkvglih02Z8FmmRnlaJbql9clnU9dw=; b=pJBRHmxQ3cqeC0ZL1t/35J3W2ZdVYSY5tNe1dvLoNWN/eyaA8Pcj8IcCiNn6NQ4Asa HjYjduLEo9jOZCdGZCGt7bSf2aNh4IJD729UejByFiw3K3aSY57b29yI8McHK7Qn+A0f GXtd67FjyNqZ2lBK6O5A946MYqjAeroAmY8T4sQPRMS7cjqrQaI5eDs6xCcVYHoIduy5 QKOo+KNnyAQVSGzufksdWmfglLtSrSw0ksE1p3uO6tg/1jf3VllJOKcJFLWH4f/cCPLG 6kRoPdhhF5oXSKRZQ9Xf1AnazP8v7ogiuw/R7DTEgfxnx/TbmmStFRJL2V4MmQiVBfKL 2+5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Gx3LeW9i; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-179563-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179563-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-63413d729c4si12962922a12.842.2024.05.15.00.25.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 00:25:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179563-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Gx3LeW9i; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-179563-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179563-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id AEA04B22381 for ; Wed, 15 May 2024 07:20:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E5E9604CE; Wed, 15 May 2024 07:17:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Gx3LeW9i" Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D6B345BAFC for ; Wed, 15 May 2024 07:17:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715757448; cv=none; b=NPwrBJHKV8nuSHBCeYo7RJoYyE+ao6xHgkGEsxhw+flxM2+PJj+w3xh6cIpkgRMeaqMUk/WAN6jqv4Vz2SGrwiO5UrYml9vPPBxilfBRQvITy0AmT02b7OdaGAxKu7zCNXnMMGVy7NvQeXc54nADSfFw4m8U+xnBEuCG6ElbHkY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715757448; c=relaxed/simple; bh=NSsCiPGcIxF0zOQ6vdufDUaR67+LlToiDZLTG5tQTr0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EKQlHEldBCGjZF8Vc0Wfk7+KattgRp7FXzEI5I44DzPh+HYg2Nzf2pAR7yX4u3N4WjYOncpl+ulEU6oI789sUOLIQZ5mfd6OoyNEeDBxIIsi00+/1NlkhP5Tcg555rZCXkhYrum5Uix0hplMRGusFttAK36wfStDYqV783bUWb0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=Gx3LeW9i; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1f082d92864so16527275ad.1 for ; Wed, 15 May 2024 00:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1715757446; x=1716362246; darn=vger.kernel.org; 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=7bmm+z3Y++HgLKjqUQ1k19xvJfVuFLOPQwKCzZQr8AY=; b=Gx3LeW9iM9+zmkNIGCPmc35XkwEQn2XcILyOSg9atjScgmafLHd2uMc1E3NnjIsjEi CALrMw1t6+7leFD8H2qJj0ZJZ7ikkBrsXgjd7+2BJzsQtlzaD3YOWZfZ3LoLdjrXFz2n efgxwgrHjEHQJ1DjBW4GNolYqmi3u+U/W4kr4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715757446; x=1716362246; 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=7bmm+z3Y++HgLKjqUQ1k19xvJfVuFLOPQwKCzZQr8AY=; b=va3jrkGZF7Twbee2Vk55PrNvhgUUM8ztdGccwHFsLIwnCSNoO9fAGw6x41yTGSmbAt +r17KIIgP1OvJHGhJOHbNwX0HE9CrsW7YWkcAoPpR1/5alwcP3X3z1hSLXyBrtfzTU3H 51adCKal2aQJi8qRnaVxOMUriW2d4jf3BevlEgovO+oPxVOdW+kBCRImt26IIXIajapv XFRh/fZZCbHKrHFTe8tnvbwv2EPKAXDmFS0++L/R8GxnSNjr6MkTBf1emN19xL3acSiw hyWLKQ36EjzY3dLRkyF3sGtPfTZaIJFhYASjfwhuOOkSWboWacC0dZvutmwsa5Gw+yRE newQ== X-Gm-Message-State: AOJu0YxuUUk80zKYoDrOK+BokcnEapHIgkmyElhe/iQeSGou7IkbLsa2 EVsr9/2fRoZkQ+VPzs/KoOMILoIs8MFYJmQFTXc9TGKs/3Lxdengnu/RGwJACw== X-Received: by 2002:a17:902:ce11:b0:1e7:d482:9e32 with SMTP id d9443c01a7336-1ef43c0e8d6mr184387855ad.7.1715757446224; Wed, 15 May 2024 00:17:26 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:111d:a618:3172:cd5b]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c136d53sm110941605ad.254.2024.05.15.00.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 00:17:25 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv4 12/21] zram: support compression level comp config Date: Wed, 15 May 2024 16:12:49 +0900 Message-ID: <20240515071645.1788128-13-senozhatsky@chromium.org> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog In-Reply-To: <20240515071645.1788128-1-senozhatsky@chromium.org> References: <20240515071645.1788128-1-senozhatsky@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add support for compression level level=N comp configuration to comp_algorithm and recomp_algorithm knobs. Note that zram cannot verify ranges, it's a task of corresponding backends to make sure that level makes sense. Signed-off-by: Sergey Senozhatsky --- drivers/block/zram/zram_drv.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 7eb500c8fdaa..91706889b63f 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -998,6 +998,12 @@ static int __comp_algorithm_store(struct zram *zram, u32 prio, const char *buf) return 0; } +static int comp_config_store(struct zram *zram, u32 prio, s32 level) +{ + zram->configs[prio].level = level; + return 0; +} + static ssize_t comp_algorithm_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -1015,6 +1021,7 @@ static ssize_t comp_algorithm_store(struct device *dev, struct zram *zram = dev_to_zram(dev); char *args, *param, *val; char *alg = NULL; + s32 level = ZCOMP_CONFIG_NO_LEVEL; int ret; args = skip_spaces(buf); @@ -1034,12 +1041,21 @@ static ssize_t comp_algorithm_store(struct device *dev, alg = val; continue; } + + if (!strcmp(param, "level")) { + ret = kstrtoint(val, 10, &level); + if (ret) + return ret; + continue; + } } if (!alg) return -EINVAL; - ret = __comp_algorithm_store(zram, ZRAM_PRIMARY_COMP, alg); + ret = comp_config_store(zram, ZRAM_PRIMARY_COMP, level); + if (!ret) + ret = __comp_algorithm_store(zram, ZRAM_PRIMARY_COMP, alg); return ret ? ret : len; } @@ -1072,6 +1088,7 @@ static ssize_t recomp_algorithm_store(struct device *dev, int prio = ZRAM_SECONDARY_COMP; char *args, *param, *val; char *alg = NULL; + s32 level = ZCOMP_CONFIG_NO_LEVEL; int ret; args = skip_spaces(buf); @@ -1092,6 +1109,13 @@ static ssize_t recomp_algorithm_store(struct device *dev, return ret; continue; } + + if (!strcmp(param, "level")) { + ret = kstrtoint(val, 10, &level); + if (ret) + return ret; + continue; + } } if (!alg) @@ -1100,7 +1124,9 @@ static ssize_t recomp_algorithm_store(struct device *dev, if (prio < ZRAM_SECONDARY_COMP || prio >= ZRAM_MAX_COMPS) return -EINVAL; - ret = __comp_algorithm_store(zram, prio, alg); + ret = comp_config_store(zram, prio, level); + if (!ret) + ret = __comp_algorithm_store(zram, prio, alg); return ret ? ret : len; } #endif -- 2.45.0.rc1.225.g2a3ae87e7f-goog