From patchwork Tue Oct 18 04:55:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13009908 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 BCB20C43217 for ; Tue, 18 Oct 2022 04:56:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 533B86B0080; Tue, 18 Oct 2022 00:56:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E3556B0081; Tue, 18 Oct 2022 00:56:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3846C8E0002; Tue, 18 Oct 2022 00:56:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 29CD06B0080 for ; Tue, 18 Oct 2022 00:56:00 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 020711602F0 for ; Tue, 18 Oct 2022 04:55:59 +0000 (UTC) X-FDA: 80032858080.14.B80D47F Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by imf21.hostedemail.com (Postfix) with ESMTP id AFDE11C0023 for ; Tue, 18 Oct 2022 04:55:59 +0000 (UTC) Received: by mail-pg1-f182.google.com with SMTP id s196so11032795pgs.3 for ; Mon, 17 Oct 2022 21:55:59 -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 :message-id:reply-to; bh=xtQh7ZmjoyZo2F0qXeywbofevhcfT59MQNGpxOyNbx8=; b=Ez9/9h1lS/+dC1G6E7jdHeTIahEsqMGdrK+uwr+wyLQfJq+YLjzffrRXXk0guSR6Ye VzU5kwyeOgaqpli2PFTCX+fpqvNyEHxZoVc7VzgNecYXJnNNROFa4+6BvojEANHXNLHN Udu8/kOoLQRV0SokqX/ZR/orQ8KcP4PTdY21k= 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:message-id:reply-to; bh=xtQh7ZmjoyZo2F0qXeywbofevhcfT59MQNGpxOyNbx8=; b=p5+0Hp5QBbk0bGZW2T/U0mHBra8kcAXVeIs1uIXBXzZb/eiSX659445asAvRV/S1UB IKVc6P3wePRi6jCOjZTXuC/UyViYnkToTE1ecBrtFDW/cSyQONhVSRLT/5MPxocebVcF SxXG8zl9ESu1tQbpJRRoErXSPq1rIAYzV7M76+ZiCcN992ahwJ9yNE3XTYM9M8GFycWy RINmOaMCPRKHCm7ChAlq3nJJfEyAJ1SW60hqTwZmCkvlh/eALqqQ9yQ8kyjL5HV5Pbj8 TcEfkz3rkD0FE54yOgI/R/+vbjsWs2Tc/IKBNbdGTET0KnC4qs/l1gxhsTgtgWihg/1R eV3Q== X-Gm-Message-State: ACrzQf3ddG2qvEXciZMBqB+I371BZHbpetaO6QcLEnUUjWUmRimv+pQP DtWoqQdB7XQJjVXq8CJjcgYFEw== X-Google-Smtp-Source: AMsMyM4FOU2/bLgIX42hGV0iONzrzomt7CCu65KWnilogKYyQZoRpCn/IH6cUR0nYi3r5vr3skYaXQ== X-Received: by 2002:a05:6a00:1781:b0:561:7f7f:dc38 with SMTP id s1-20020a056a00178100b005617f7fdc38mr1384946pfg.42.1666068958685; Mon, 17 Oct 2022 21:55:58 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:17a9:73b0:c262:eccd]) by smtp.gmail.com with ESMTPSA id p4-20020a170902e74400b0017b69f99321sm7549220plf.219.2022.10.17.21.55.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 21:55:58 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: Nitin Gupta , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv4 7/9] zram: Add recompress flag to read_block_state() Date: Tue, 18 Oct 2022 13:55:31 +0900 Message-Id: <20221018045533.2396670-8-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog In-Reply-To: <20221018045533.2396670-1-senozhatsky@chromium.org> References: <20221018045533.2396670-1-senozhatsky@chromium.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666068959; a=rsa-sha256; cv=none; b=h2YTSjoT/9yKzxrbCCDw7euLXtweRy96zRjuMqiCM+f+5Pt5cJ1bhyOXmxS+LBbrwFO7BE Icz8aFmNo6TP2jSlzu2b3HiUB7LgnmTQoGRx4k93OXMXpekWAnfOE6aWgvrbk+h7LvCNls V2/zZ/Sxr0mSgUY5wBRzsM6aa1wDTTI= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="Ez9/9h1l"; spf=pass (imf21.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.182 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=1666068959; 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=xtQh7ZmjoyZo2F0qXeywbofevhcfT59MQNGpxOyNbx8=; b=NnTOndxthp0alk/SPVl3+9kAmJkYOqnamHO+m4/7gOmS5bdywENnf3TKofSQiL54PnSI1C RgbHiFG8iMawRmanRt76yVllWlqlbiOeVRLz+2vcDt+m/67fjYiecgikUb5ViPcLEvUP8r 8b04svZ+RS/C83koddSP2+NiMuaL2kQ= X-Stat-Signature: dmku8oh96p3ehxe5dbiqj8hmcmndnex9 X-Rspamd-Queue-Id: AFDE11C0023 X-Rspam-User: X-Rspamd-Server: rspam03 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="Ez9/9h1l"; spf=pass (imf21.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.182 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-HE-Tag: 1666068959-673576 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 c916c2b9da55..010fb05a5999 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 1e9561217466..5d760467e0bc 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -925,13 +925,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);