Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1239651lqh; Mon, 6 May 2024 01:04:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWhjkvqO4Nsf/U63oPIFxvqE0NnfyNgFKVKBAOiot0nIL+N4TxXjbGpDl3STHTLAqnmbeUOH5kfPjTrWxH56yL31KVlokp8mwlb6b8HpA== X-Google-Smtp-Source: AGHT+IHibi+0TrO7C9EtDrt0d3AQzk3gOhRN1jxWhvLDZUpYw16uivdrCbjuq60JlNP5Zzh2sJiy X-Received: by 2002:a05:6a00:240b:b0:6ec:d972:c3d8 with SMTP id z11-20020a056a00240b00b006ecd972c3d8mr10676319pfh.10.1714982640676; Mon, 06 May 2024 01:04:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714982640; cv=pass; d=google.com; s=arc-20160816; b=s5sWIqiGHCuEH0VgfvyE697Ruzm34aJsOCMOUrzGSnv1aQ1lIjpbGfpHusehhNE1pX 0WYvndnbHexpWMTOXe8M18aOAMsVyLW/ufqNCKnDnrUrLMYGdbIqJiDmNG48l+QqZR/U 3yKZC25LB+DigeVwQURb+k+JKJkONcFIWaMMhaBA8GE5YxYLeNksxLKpzvWt5huZWOPY NG+U9JEMF/TZFoFClDgJQBWJz3GPOUTdpKZjlgtd8fqV5hsC8CkixVJs/VKIk4JX4WuV FAjbkuhPoHtrPo6/zNZKQGHPixCdxt0gYJK22Rs0dLSlX6LRgjLC+sP7qibM0EwHuOQc 9VoQ== 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=HEX4sXVDTPATVu0QjS6d/t+2oSV1kOT9NNqjylBPRwZO2yowrxWV74zf6yE0/k1kQF H+zxV7+nmAPl+kPhscMbOf8PUwYf16rmvAMU+6fWb5PQZHHBs+KPi9vL8rjQ3STRlrW2 lRToP4NGzE96/30hjHBbgmPUtZ8AUKWdZl8YM8vyXljjtEhvgQWIeV+AaE1otKZddFp1 JBndewqSJfuSgP8Mf0v+Ex0KR7Vkwp0SKFONkn6SIPjsDQZ07Y8OTmLG0m6XUwevsEAI mQRWEj79HZFbhvJK6Glc9jpLuKqcSNMsQVuRmvj0H8PvuE1CTJEP8eAU+DAhG1dp/8nu GG5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mURkW0J1; 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-169455-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169455-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. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x22-20020a056a00189600b006f46d401cc8si3004519pfh.108.2024.05.06.01.04.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 01:04:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169455-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mURkW0J1; 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-169455-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169455-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 274A0B21B26 for ; Mon, 6 May 2024 08:02:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E119142E9A; Mon, 6 May 2024 07:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="mURkW0J1" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 DEC38143884 for ; Mon, 6 May 2024 07:59:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714982356; cv=none; b=Uhr9rjS2GEKn61PAC6CNjqeOpwY4lmo2hF1J9a82AWQ6TTM6YEtRV+q0n33z2QGMtBTypgH+8zhSRSvFt2aM4BofLGDuxQp8z5p2fkLJo4sAsW+xHv+lrLSMwC8CwI7cu0RO2gRys1O5cAmJ0W7b8U/UWUuZckY1goNUeAtI9MM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714982356; c=relaxed/simple; bh=d4UQf/ZsLZS7cvretx2WXvAFWLig4xky110hNJGk3Zc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RlwL5KONHECkKvQC4hbFZckFlB6HkBdyF7lxIXAOMg/48d2i852lUAArEJytXSuCheAbyh3DZ8gE8rzGKT/IqRWO19LOZu3SPk3aXYXG9fLG0MW+Z7rYqJYWlyjtnNi9HlKa8huvu5qbq24rMGtNpRtnIykAr9A7YCdijSRogRE= 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=mURkW0J1; arc=none smtp.client-ip=209.85.214.177 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-f177.google.com with SMTP id d9443c01a7336-1e3c3aa8938so9163715ad.1 for ; Mon, 06 May 2024 00:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714982354; x=1715587154; 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=mURkW0J12TLZ9IAGFzMJD7zTYRO3Ji6THYvcqwKHdIMigAmVH2G102S1sPzby08G8M CeRG9SSaYjBxJi85pBHskG8rYFSwnLftoJ8Jy5LlCSS1D/rY6UmmGanVNhFx1hu6AaiR BmQwbrULcPsgFOMiAGIo24Fd84LhwSKdIhExg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714982354; x=1715587154; 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=SiY9Z/KTkORbnkryEIdhTcD0lNe0bwLUrfSItgvgLfhttwiAh5se0xOjET6YxLD/gK QqsxRfkqFhoiufLQOlpWX4/16Tzr0q/yiHXR32rQQFmC20efHdT61jG+CYFNgZi6gQW+ AJC/0HH5+7Jcfp1vT7fjIU7T7KF+rKdONoptjwTDFvX/Z9E1hbSLpA1JcaGPZYCSCg95 JBeYkerxRVMfsppY37TCpeuQEe+ZZuwhPx/HQWc95scyynDKD1GWMPpFMqksCzZ+6W4+ ifjxbc24hFg81tRk2oLKePrGuhuCFcAaSdN7jM6HpQrNelivrUDDRpvBzPetqwpq10Yf 7Ezg== X-Gm-Message-State: AOJu0Ywpy/7lwIEF+flqw+6Pau2GSNsERSEBDjYMdhuxu1QxG9JxaAQv LiiKXsGKfWHl6jm9V8ODOBOlRFAxw72N2G20Rjtfiwkrsgz9j75qfZCLUlztXQ== X-Received: by 2002:a17:902:6806:b0:1e0:e85f:3882 with SMTP id h6-20020a170902680600b001e0e85f3882mr9682647plk.38.1714982354399; Mon, 06 May 2024 00:59:14 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:4e24:10c3:4b65:e126]) by smtp.gmail.com with ESMTPSA id h6-20020a170902f54600b001ec64b128dasm7633772plf.129.2024.05.06.00.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 00:59:14 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv2 12/17] zram: support compression level comp config Date: Mon, 6 May 2024 16:58:25 +0900 Message-ID: <20240506075834.302472-13-senozhatsky@chromium.org> X-Mailer: git-send-email 2.45.0.rc1.225.g2a3ae87e7f-goog In-Reply-To: <20240506075834.302472-1-senozhatsky@chromium.org> References: <20240506075834.302472-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