From patchwork Mon Sep 5 08:15:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 12965756 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 88B64ECAAD5 for ; Mon, 5 Sep 2022 08:16:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24E58801C3; Mon, 5 Sep 2022 04:16:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D7E6801B3; Mon, 5 Sep 2022 04:16:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07739801C3; Mon, 5 Sep 2022 04:16:33 -0400 (EDT) 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 E3A5B801B3 for ; Mon, 5 Sep 2022 04:16:32 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BEE9E80A5F for ; Mon, 5 Sep 2022 08:16:32 +0000 (UTC) X-FDA: 79877325024.09.013E4B7 Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by imf11.hostedemail.com (Postfix) with ESMTP id 5D2A240058 for ; Mon, 5 Sep 2022 08:16:32 +0000 (UTC) Received: by mail-pj1-f46.google.com with SMTP id m10-20020a17090a730a00b001fa986fd8eeso11508591pjk.0 for ; Mon, 05 Sep 2022 01:16:32 -0700 (PDT) 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; bh=E05eGk8Ts+47tHWXcyTeAoJzHa+CPKznHpzjFQelL1A=; b=hMS+IdYeixaOeejH5EwOkVTb7PSDps8WRjK2zDsDcvJagB44S5pczLIA0n7xt4fWkF y7fQyebX8JoLNjuppKKvDKTSDodtB/M2YUQEmIt38THD7x0Xn8C76iEZuQNdT552aia3 asNk2qfqEbclqbbGAYcB2fgt4+f6tZDmr0vlM= 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; bh=E05eGk8Ts+47tHWXcyTeAoJzHa+CPKznHpzjFQelL1A=; b=BOP6p0rziACfcp1hxGiaGi6KfnuLZY4aLHVRKW5KpjjtnrmBlo3hHX+/SP2jGqbfAL hwaw/2aiQMlh1MWCs0QUPHBVirqD+hzEvRl1vk26/Pe7rwnOTmTS0bUIj9TvzFRGLw6P cxMuYAVMgKtEnMF1AkAng9MOpKe5BrVT6hGy7ARWD9UFWVzHkYF98omDu3BCvB7NVmyk 0lk84T/RTqlYRU3UrTV/YLaVf7vP9YtaU98//F4EfG7DFRSM7C8EpC0tgRqSdIC1uYt1 O/uTN7pI42DXmkLnozQbmzsaUWjNpDlhHflhkmYc1nCAuRJUeGHuhKSS6qQjuXjH68we 3riA== X-Gm-Message-State: ACgBeo3fkzre+SFeDzA35Y6mzx4++PjTkmAA75BbgImof8VqcP7kKWBP iFDfNsIjKl21QHfWR1etMKRC4w== X-Google-Smtp-Source: AA6agR4p0z+bcR3JUyMiCUus7SiZk2eqFN83s+Wa8NeayAXFyNRr4Yegge5viZfyXgvXyX7C4DNfyw== X-Received: by 2002:a17:90b:30d0:b0:200:22a4:bfcf with SMTP id hi16-20020a17090b30d000b0020022a4bfcfmr10363568pjb.181.1662365791490; Mon, 05 Sep 2022 01:16:31 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:71e2:8444:42d9:4bb0]) by smtp.gmail.com with ESMTPSA id w12-20020aa79a0c000000b005363bc65bafsm7075864pfj.57.2022.09.05.01.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 01:16:30 -0700 (PDT) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: Nitin Gupta , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCH RFC 7/7] zram: Add recompress flag to read_block_state() Date: Mon, 5 Sep 2022 17:15:52 +0900 Message-Id: <20220905081552.2740917-11-senozhatsky@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220905081552.2740917-1-senozhatsky@chromium.org> References: <20220905081552.2740917-1-senozhatsky@chromium.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662365792; a=rsa-sha256; cv=none; b=oHLQJ9SLfgSCOjYqwXwBe4ls0I4rheLUdYwiHpcr2Mh3DTJGwOT19f1wwtmzZlqBC1BR/+ XrJILdvAV43h8nThdt63z1n/EokN2B4yqmy/wLwsPWldEE6Igw/z0F1cyhVGBMpLY7HQzn rTEnOKYLDZtr+4uBl+4t0+gZEbReq6o= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=hMS+IdYe; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.46 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662365792; 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=E05eGk8Ts+47tHWXcyTeAoJzHa+CPKznHpzjFQelL1A=; b=2zFFisamfDpb4HQV2DIDl77UWzCiyTrSKXNVGc68RaFppAwNcY3ioUX9nU0PLA5m8rebT3 oAOkybHtLqjJvgL57/Yii6gEt5eET317msEvnOi6pkd1VZWzyUpL627frzaCAmw1urDzZ7 G8I7EOWF5+iAA3RegZYjGAYg3exdS2w= X-Rspam-User: X-Stat-Signature: porayzbuup8ef48iuocpkmbet4n15nbn X-Rspamd-Queue-Id: 5D2A240058 X-Rspamd-Server: rspam10 Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=hMS+IdYe; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.46 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-HE-Tag: 1662365792-822708 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: Add a new flag to zram block state that shows if the page was recompressed (using alternative compression algorithm). Signed-off-by: Sergey Senozhatsky --- Documentation/admin-guide/blockdev/zram.rst | 9 ++++++--- drivers/block/zram/zram_drv.c | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Documentation/admin-guide/blockdev/zram.rst b/Documentation/admin-guide/blockdev/zram.rst index 88957fcb6ad7..70a3d0243b45 100644 --- a/Documentation/admin-guide/blockdev/zram.rst +++ b/Documentation/admin-guide/blockdev/zram.rst @@ -466,9 +466,10 @@ pages of the process with*pagemap. If you enable the feature, you could see block state via /sys/kernel/debug/zram/zram0/block_state". The output is as follows:: - 300 75.033841 .wh. - 301 63.806904 s... - 302 63.806919 ..hi + 300 75.033841 .wh.. + 301 63.806904 s.... + 302 63.806919 ..hi. + 303 62.801919 ....r First column zram's block index. @@ -485,6 +486,8 @@ Third column huge page i: idle page + r: + recompressed page (secondary compression algorithm) First line of above example says 300th block is accessed at 75.033841sec and the block's state is huge so it is written back to the backing diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 8ed41514b8f0..f3948abce2f7 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -936,13 +936,14 @@ static ssize_t read_block_state(struct file *file, char __user *buf, ts = ktime_to_timespec64(zram->table[index].ac_time); copied = snprintf(kbuf + written, count, - "%12zd %12lld.%06lu %c%c%c%c\n", + "%12zd %12lld.%06lu %c%c%c%c%c\n", index, (s64)ts.tv_sec, ts.tv_nsec / NSEC_PER_USEC, zram_test_flag(zram, index, ZRAM_SAME) ? 's' : '.', zram_test_flag(zram, index, ZRAM_WB) ? 'w' : '.', zram_test_flag(zram, index, ZRAM_HUGE) ? 'h' : '.', - zram_test_flag(zram, index, ZRAM_IDLE) ? 'i' : '.'); + zram_test_flag(zram, index, ZRAM_IDLE) ? 'i' : '.', + zram_test_flag(zram, index, ZRAM_RECOMP) ? 'r' : '.'); if (count <= copied) { zram_slot_unlock(zram, index);