From patchwork Mon Sep 5 08:15:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 12965751 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 12CF5C6FA86 for ; Mon, 5 Sep 2022 08:16:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A672E801BE; Mon, 5 Sep 2022 04:16:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9EDBF801B3; Mon, 5 Sep 2022 04:16:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83F8F801BE; Mon, 5 Sep 2022 04:16:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6A320801B3 for ; Mon, 5 Sep 2022 04:16:18 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 42B3316024D for ; Mon, 5 Sep 2022 08:16:18 +0000 (UTC) X-FDA: 79877324436.10.ADE32AE Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf11.hostedemail.com (Postfix) with ESMTP id E94D040058 for ; Mon, 5 Sep 2022 08:16:17 +0000 (UTC) Received: by mail-pf1-f179.google.com with SMTP id y29so8006303pfq.0 for ; Mon, 05 Sep 2022 01:16:17 -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=DNUOFwSGpdK+nnrxMG7S20eDsCufcwNG30HnXLUld24=; b=eH5yHC7E3boaNZSJoFGkpKwRTCJkbyHVEkXkQS6xSCqO+cZV0Y8cmWXp03lKyOj7oH d3fWNvodjlK85jXLZNTu43uTDK/eC2fzKm74+52vrd/DXXsl/mwsRxe03esHNX1aBavm ZhQ3qfdoU8OXQplyZFimzo5999MI//98slFvE= 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=DNUOFwSGpdK+nnrxMG7S20eDsCufcwNG30HnXLUld24=; b=D8xPLKVHJw63CHl80B/pO1bwePCyJP1jnGxiFbuxVwdRlBnEq87b3B0fb1wvBvThSY FFjN4UHf6WiIxjpTMHt5Du81pliTsnxt7ldQIRNVWiii0A3RJ5/OIMrVNXm5BVavcZqh ovNC+aoYL5t9Q+igPMFf9i3EdGMSxQhN/RsZWg2KAm57iIo482GFfs15yNyr9ZtO5T/9 SWXqr73YifgMjuu6zHyWTK0hCb5pabgBB5d7nwT6UPdB5+5EoDGopNtIELEYLGFkP0SJ kp5e8BFVSa1ZGyoyxPtS0aFfyU07IvYitYVJhDU8Kfm+WwyN9Q5U7XVI5EQ2yHe1NXR/ ZVpg== X-Gm-Message-State: ACgBeo0P2SehuN+pacMtWXUEn1R91GEVfotJP6P3kq1EmQNV/Xck6CTq deFf/l0GVP+moJtXJPrLVPx+IQ== X-Google-Smtp-Source: AA6agR75YXRxs7K6WXZCwu9cFa53p0bnH4Ss1kJ8jGsE12knaZ8A2T65N2kxadwOs6l6K3OeXznNpw== X-Received: by 2002:a05:6a00:16c4:b0:535:890:d4a with SMTP id l4-20020a056a0016c400b0053508900d4amr49041501pfc.0.1662365777547; Mon, 05 Sep 2022 01:16:17 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 01:16:16 -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 3/3] zram: Add recompress flag to read_block_state() Date: Mon, 5 Sep 2022 17:15:47 +0900 Message-Id: <20220905081552.2740917-6-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=1662365777; a=rsa-sha256; cv=none; b=XCqKPT7VmPFRUIvclFuN2nclFeXQVZjHOGYkxFb/I02gAKxQOfymEJj/QGXsK1hMweDBYT vUc5mhduDk31PM13iWClPzkEw/0oV3akIF4/Bj7EXnAEGROis4Aiq/Vr98ADGJp/7Wy7Lk 3fXKey6WogIjiCOvtfz47zFC0bsVXHI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=eH5yHC7E; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.179 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=1662365777; 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=DNUOFwSGpdK+nnrxMG7S20eDsCufcwNG30HnXLUld24=; b=wDh2qq58XnSLd+jiuhhbpW50A5mSVzb/5Lsq9Vv4tG6QDXyftKi1ep6wTUOq4EiuSQ/wtP 8ePWqVG/BQzD83Ed6gFetUuIDGovOUj4k9dbVO9i+2+ZjV9ZT0X4naxxlGVUqGlnruD29f 5tQFXKT9qBaLuCVrx5faOt1KZaJlS2A= X-Stat-Signature: hrz33pw9fheqbpkren71be6d9bxqts41 X-Rspamd-Queue-Id: E94D040058 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=eH5yHC7E; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.179 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam01 X-HE-Tag: 1662365777-942616 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 f144f31c3c4b..791f798d356d 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);