From patchwork Mon Sep 5 08:23:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 12965774 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 ED391ECAAD5 for ; Mon, 5 Sep 2022 08:23:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 892A2801CA; Mon, 5 Sep 2022 04:23:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 841AE8D0050; Mon, 5 Sep 2022 04:23:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 709A0801CA; Mon, 5 Sep 2022 04:23:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5CFB68D0050 for ; Mon, 5 Sep 2022 04:23:52 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 339AEAC410 for ; Mon, 5 Sep 2022 08:23:52 +0000 (UTC) X-FDA: 79877343504.15.27986F2 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf11.hostedemail.com (Postfix) with ESMTP id DF82740061 for ; Mon, 5 Sep 2022 08:23:51 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id y127so7979871pfy.5 for ; Mon, 05 Sep 2022 01:23:51 -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=acK8pXsPob7Y5s+Bg0YkKeVygfkxhsWVef1JJLtRM5ezbfg1jCdDeReYhs5vLFpc3+ 7C2+UY0wr24vSRkT3J9v1mb++EIgdgPbFzDQep88QpoFUDw9Mx7FNM1NK9g3unavDjvT ZwrREvj/gc8m4PHJNEjGYalq9yyae/RaZt7Mg= 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=l7sSvWRA1d81+OfT9kozAj0VWXPIAYIk2rRAAfGt+eFE/93qa4Wc44eiY2B0creZfo vspxkBPFzTfsTx2jriActp0hrmpaGqqFUvuNvTsDPbv8zjK6mp9aABff8UhTARO2oPZ7 ot+b87iJS7dudPMzowJlMR7bTxfeSSSiIb/v9l6mAT3jc+2PNskFZUT7CMK7WpRwpThB gCA5haQs6r2N3aN50CePHyEdh7PDfkign6BrJKhBnq0P4lxBThAuRNOad6QcJWPz8TXe /Vq7QMa9WJV24KpsiWEuwLaRr55W/D1GW1wK6qahIpIbvw7FzuLroiYIoCedFHQM7IRz 3iWg== X-Gm-Message-State: ACgBeo2IAqI3BP/N/MqDeugi6h+HfKYnX6BGagoOMDR6xuWRDA69M5Iw Qxq5i6BD9ZaXBpMYBzp/XEfdTg== X-Google-Smtp-Source: AA6agR7apkwdHRSEq/AOrRxCZYMadHNajCXFhmfCQuwClOVZjsqItLs1Hn/U6/65l19Q0gXR//E8EA== X-Received: by 2002:a63:d1f:0:b0:422:7774:1969 with SMTP id c31-20020a630d1f000000b0042277741969mr40307627pgl.88.1662366231066; Mon, 05 Sep 2022 01:23:51 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:71e2:8444:42d9:4bb0]) by smtp.gmail.com with ESMTPSA id p14-20020a170902e74e00b001641b2d61d4sm6807093plf.30.2022.09.05.01.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 01:23:50 -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:23:23 +0900 Message-Id: <20220905082323.2742399-8-senozhatsky@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220905082323.2742399-1-senozhatsky@chromium.org> References: <20220905082323.2742399-1-senozhatsky@chromium.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662366231; a=rsa-sha256; cv=none; b=iogesG8WeZ8qKZ7p6QcK1cQ2sg8afXsbDilYUqsOtrs3EllWl0Mf4MfZ7MDA0R03U58sAE jl/MjWcx1oCxFLBuoWty1FYobRcnLZg4RZaOo9ZZ9G+U9Wma7gUR1OssTQ3NPHN3VgwchA LVstdjCMqZJ0ZpXkTEZu0etWxDbU1IU= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=acK8pXsP; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.178 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=1662366231; 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=lPXglFqucUajrrDMqwzSRQlfjzITrh3apHcslEYILNSFLdOA1UollvI23DxWrCtxY+BOr+ X91B7i9eT7bBjLSdfGq9bCOw/tMwimbyIFh+v3hNRRbNPPhF0I93En+oZEHEVlahBLmx56 y61uim8JrpRxIF90ur1+PsTGDFUj8t4= Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=acK8pXsP; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.178 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam01 X-Rspam-User: X-Stat-Signature: porayzbuup8ef48iuocpkmbet4n15nbn X-Rspamd-Queue-Id: DF82740061 X-HE-Tag: 1662366231-63064 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);