Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4983969rwe; Mon, 17 Apr 2023 23:44:51 -0700 (PDT) X-Google-Smtp-Source: AKy350Yo11i+5AnQCoLqsZ5rLps1HoeWKSnPiIdfdQ9CUXfbUbw5RCmevfXtjrPrOUuRxLy996Qx X-Received: by 2002:a17:902:d4c8:b0:1a6:e27a:8a4d with SMTP id o8-20020a170902d4c800b001a6e27a8a4dmr1524831plg.2.1681800291628; Mon, 17 Apr 2023 23:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681800291; cv=none; d=google.com; s=arc-20160816; b=qEjPaE73NweBfzmbR+sUiFGfph85SUDQiWsJMClaLwh+dU2L0t7XF5JyptEnD+PUnC KDubEk9HiDCe2/moz+7guH69OpzJ4CrkLvLRbha5nnWT/wY/MPOqV1ecQBUnHm8jOKjc qHWNv7r2huQjSsZwO1Vvc+By8Q+oxzR85Y+23selziM6kWe+lk+u1a0CrPh3KKnHGOrn jhEUGlRFe7byL4lVmjzsFpxXxMuKib+ncpa+i8Pl6ycZThl6DJHMtBFB+bFp71tJO/yc QOEu6VuHRbGUUZxCtsWPLeV0Y8C6t5sGq3X1F/2jmz3HrKJt7tUoh2B51GkGLvhRQjhv OZrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nfgD8CjAt52uLbsRtpG0YlGKoerIw5fnKcSwfy+g/JE=; b=wbJAkGknpK+nj1j6HSMaqkKYM2i4HdHgsgpRSh8L738RDLQ5MpDRwgxCjGe5Qu92mA 36+P9LnhqSl6XkZQMTG7ryupqRTRV2vrduhfAwSMDS8bKbS6CSh1Y53aeGRKc3STcLwy ir3V69SZvlTmWG5t2IikwkVf0WHpMSk7Wezc4dQKxW4WevF/W2yx+POIsn9gZoCSWM2e mLBZJtvHqbeq0IZTuZ3U4yRn3fxkwhmfWnVffO8dswLMUcvR2e1vTT71YAUN/apTjWnU oEy0tB41FhO8wnTykKeeKB/q9uaAWOMA2S24xMcwx0DZEqK14rDpSk84ALanizEtgwGO waqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=Du1ijEM7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u4-20020a170902e80400b001a29280c544si14471684plg.263.2023.04.17.23.44.37; Mon, 17 Apr 2023 23:44:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=Du1ijEM7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230490AbjDRGZZ (ORCPT + 99 others); Tue, 18 Apr 2023 02:25:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230064AbjDRGZS (ORCPT ); Tue, 18 Apr 2023 02:25:18 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6FE11BDA for ; Mon, 17 Apr 2023 23:25:16 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 266405FD5B; Tue, 18 Apr 2023 09:25:15 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1681799115; bh=nfgD8CjAt52uLbsRtpG0YlGKoerIw5fnKcSwfy+g/JE=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Du1ijEM7jXPQlYLuCqUkwMDR9U6uHlm6GPfjO87RePxjdfiJ3HQcQMppmp9vOJMtF xxWMiFe5HXJ+lG5kzPeyi5gj8ZGjqGKoNtjfjzvqGESrMKLf2uhwaj4AN68AtkxZD+ NZvOVJx1Rwgnsc/pqJ9JXd9y55I3ivJkOHeOwp03gKMw6KteyWXpcX/UoVO5D7oDsu DSpS8ifEQvhW3Vg5pfxkgCMeCZ9ps3vSLX/fyIEbti8oxad6yNwA3Ag6Um9OOMLOfn 17xdFTei6ZJBk+cPmnXN/ZGWsmujHQwqIgJqlB+MRUmLSvo9dFHza6kce8z8LBEcOe BmtLDmjOOYRgQ== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Tue, 18 Apr 2023 09:25:15 +0300 (MSK) From: Alexey Romanov To: , , CC: , , , Alexey Romanov Subject: [RFC PATCH v1 4/5] zram: add fold sysfs knob Date: Tue, 18 Apr 2023 09:25:02 +0300 Message-ID: <20230418062503.62121-5-avromanov@sberdevices.ru> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230418062503.62121-1-avromanov@sberdevices.ru> References: <20230418062503.62121-1-avromanov@sberdevices.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH02.sberdevices.ru (172.16.1.5) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/04/18 02:02:00 #21122658 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow zram to fold identical zsmalloc objects into single one: echo 1 > /sys/block/zramX/fold Signed-off-by: Alexey Romanov --- drivers/block/zram/zram_drv.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index e290d6d97047..06a614d1643d 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -1184,6 +1184,25 @@ static ssize_t compact_store(struct device *dev, return len; } +#ifdef CONFIG_ZSMALLOC_FOLD +static ssize_t fold_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t len) +{ + struct zram *zram = dev_to_zram(dev); + + down_read(&zram->init_lock); + if (!init_done(zram)) { + up_read(&zram->init_lock); + return -EINVAL; + } + + zs_fold(zram->mem_pool); + up_read(&zram->init_lock); + + return len; +} +#endif + static ssize_t io_stat_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -2313,6 +2332,9 @@ static DEVICE_ATTR_RW(writeback_limit_enable); static DEVICE_ATTR_RW(recomp_algorithm); static DEVICE_ATTR_WO(recompress); #endif +#ifdef CONFIG_ZSMALLOC_FOLD +static DEVICE_ATTR_WO(fold); +#endif static struct attribute *zram_disk_attrs[] = { &dev_attr_disksize.attr, @@ -2339,6 +2361,9 @@ static struct attribute *zram_disk_attrs[] = { #ifdef CONFIG_ZRAM_MULTI_COMP &dev_attr_recomp_algorithm.attr, &dev_attr_recompress.attr, +#endif +#ifdef CONFIG_ZSMALLOC_FOLD + &dev_attr_fold.attr, #endif NULL, }; -- 2.38.1