Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1655466lqm; Fri, 3 May 2024 02:21:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXZJUJXUVSFpRKjghwHOpwpaOyPXOxuWCC61sZJs1osegDM2nzFqF+W6X0r0tQ5au0zpGjXfXVucoq4fMAYt1/vG22AH7j1By4p/ydDDw== X-Google-Smtp-Source: AGHT+IGlbkIeq2hF1BjIHFY7GnoF6E/PI9gR8sO+kqaw7Fl7HTY11IOlgd9aXcww7CQ3W01o0F/m X-Received: by 2002:a05:6214:21c4:b0:6a0:a98a:487d with SMTP id d4-20020a05621421c400b006a0a98a487dmr2348435qvh.2.1714728107364; Fri, 03 May 2024 02:21:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714728107; cv=pass; d=google.com; s=arc-20160816; b=gZ8gxQobPhlPyFsMrCmI4+mnZfbJxtLKa66xMOJABt8yuXsvEee1UlPu6jdeTfl9Qw S5Z6sciOx3HefypWNUM2ZGEb7P959qzVIQ+MYunGPWSa2Jc5dsDKw2kXVVAYDc4v9UgG s4p7zFu3RFtjStfl4cAf3BLwnOoUHMf1MQBaWfvU/XIEKrsCGZ0RJCq6Kn9+IAjH570f b7HSkUQT+A091Ty5+N0g7B+PzGRh6kWtwfoUGH8g46vw8QxKRb7PAjYkaB/+Iy9ka+Vo 8ozU/P6G4dRA+E1JE84YlSAG82/0o9rUbNYe1UDQAK35s4AjjfNUyAr7KidclBj/bA2M 3y3A== 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=wIlqiB/ZJyLpyyyQGB102ierEcV1ZXWEtzUdufZbr+0=; fh=UKstJvjqAQ3P/Vkvglih02Z8FmmRnlaJbql9clnU9dw=; b=LPLy6gJNmacP3KzOSEBmzftWFwAFzmKncNdcopEWMBzz0EndQnMxSV8/8h+hcg9CnG 2JOFt3AAfZXJA6XJHz/9UwSt1YRJvwBoXZblVz3Oj4kkslu8YnaGqYv86pcGvQN5Lk04 yG/qUltfg3LYT6P5C12jRTH0UlnwPRiVxz78RHmN1i5Mf826I880JOXTN2N7UqO+P5Nq bK2HBHwumhuPWm3hsmE1Maxf2D6LVuaXjB0VZectg4L/t2hsWN2AxunuTgQrP0EHP/HT i70/UWGnTlBb39KoSdlqG7QY351WRO4AcDTbHqgNUihVxfASSqi0xfA9INK7n9OX+X4g edCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Wak1oHTl; 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-167451-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167451-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id iu1-20020ad45cc1000000b0069b3b41d564si2849178qvb.136.2024.05.03.02.21.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 02:21:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167451-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Wak1oHTl; 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-167451-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167451-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1EC8A1C21B48 for ; Fri, 3 May 2024 09:21:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6EDA11534E4; Fri, 3 May 2024 09:19:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Wak1oHTl" Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (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 3C48015357D for ; Fri, 3 May 2024 09:19:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714727943; cv=none; b=inm84u7uT/wACbYn5tOW2MO91IMefdWCdQ58ek+zwNDVmzGNME1ZISzQ4LxF9ffHt0uYUawR9plG6VzIuIRi6X2vre8xBJ4yQ1gLc3Gt2Qtf2gIJA/WpQPurnfUR7t1MpeVF3JG/LCHNuLI4huxVQzZhjU4B212ERCgXHzn2FPw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714727943; c=relaxed/simple; bh=d4UQf/ZsLZS7cvretx2WXvAFWLig4xky110hNJGk3Zc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uDPD/ytTsRR0q7ujZbBDxu8bKGKFkO7g7Mor279BOcdZ2RyZs57xB7FhGx7kHDL16KAoEGu6Bp81FX7Tt1Js0B/fUCs5RKUwKWQZW7yhJV8Cry5c9GLTKEEGdKo07ASnt6h7pEdvvjq/YCx7LV8x3xe9ZCJtI5vlljgv64NscsA= 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=Wak1oHTl; arc=none smtp.client-ip=209.85.210.42 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-ot1-f42.google.com with SMTP id 46e09a7af769-6eb8ea5ac95so5174145a34.2 for ; Fri, 03 May 2024 02:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714727941; x=1715332741; 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=wIlqiB/ZJyLpyyyQGB102ierEcV1ZXWEtzUdufZbr+0=; b=Wak1oHTl2uaiKkf7MnYR72iwjwyMvnQXlj1+VEhs/LpSkQDWx6QU4sQ6KyaOWXwake 6TvVKjE+r/smGDor5KfYGT+cb+U+izXYyQpyzrynKsIdSfa+CIHrZbOyZCFJ3Heexvzq egU9d1fhD0+oFvrBNCOzbT/Kb1NWPpy2llWBw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714727941; x=1715332741; 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=wIlqiB/ZJyLpyyyQGB102ierEcV1ZXWEtzUdufZbr+0=; b=amaPwxih7ZEddGZFwnA99MnwCTa9oJ3mNIQXWYVlXWrIdZzcmSnfZEbrHezkxQ8EfK GQYKzW+r57Ag2hQCfAQ1cfAyVDney+3JFjPCRq97dBpWvUIQsZVPRUuwf7vdrMIMUvd9 ApSk4iUJsIIu+CnxT2Hdr9uB16cv8/8VhKEdhHBI6Sk6CLvAdtcxU7YHDqblZ3U0+0nP xI1HFH4mnFgk3L6bDNnwq4JpW0lsvehrW6l8VUWtA1fpe9PKdgRtkOmkhutcYdC+VYwf A/Lkgw25PNPVb//3ChnJiwOzlEJGraFBVx9dJ77TxRWjCr1A7F17AOlkubBHPzNP+d5f N/Sw== X-Gm-Message-State: AOJu0Yzm279E9SleAx/Y5aprTih+4KnoWCho//qZgkqBoXDpE7T39PS2 282CIsZs28mJyoUbG4mMojf/5hOVJ8oTeI51EvqKKqcKBTFQfJj9T7Tc7zQF1w== X-Received: by 2002:a9d:5f09:0:b0:6ee:39ac:a757 with SMTP id f9-20020a9d5f09000000b006ee39aca757mr2471155oti.21.1714727941257; Fri, 03 May 2024 02:19:01 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:dc60:24a3:e365:f27c]) by smtp.gmail.com with ESMTPSA id j6-20020aa78d06000000b006ecec1f4b08sm2621938pfe.118.2024.05.03.02.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 02:19:00 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Sergey Senozhatsky Subject: [PATCH 11/14] zram: support compression level comp config Date: Fri, 3 May 2024 18:17:36 +0900 Message-ID: <20240503091823.3616962-12-senozhatsky@chromium.org> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog In-Reply-To: <20240503091823.3616962-1-senozhatsky@chromium.org> References: <20240503091823.3616962-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 bd8433363cbe..89a2eb37e26c 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1013,6 +1013,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) @@ -1030,6 +1036,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); @@ -1049,12 +1056,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; } @@ -1087,6 +1103,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); @@ -1107,6 +1124,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) @@ -1115,7 +1139,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