From patchwork Wed Oct 5 02:40:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 12998840 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 C6BA1C433FE for ; Wed, 5 Oct 2022 02:40:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F6296B007E; Tue, 4 Oct 2022 22:40:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5559B6B0080; Tue, 4 Oct 2022 22:40:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D0706B0081; Tue, 4 Oct 2022 22:40:41 -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 28FF46B007E for ; Tue, 4 Oct 2022 22:40:41 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id ECFA41C66D1 for ; Wed, 5 Oct 2022 02:40:40 +0000 (UTC) X-FDA: 79985342640.05.39AE422 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf09.hostedemail.com (Postfix) with ESMTP id 9289B14000A for ; Wed, 5 Oct 2022 02:40:40 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id l1so1450455pld.13 for ; Tue, 04 Oct 2022 19:40:40 -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=UiMX+a/n3KparVTc03/3zOVAcxR5tnQKucP/xxLwQns=; b=RYDcpGwT8/kxYv0Gsha/XvT0x9/1XAcaUZ9pG1TRfNQLtLFe4bvDwRSYILJ5osgUwk y6Zsku43KObROnjD7CJgNi1RySn4Zaccyjr7YmbyL6JTKrxIYBwbH0sC7NxC4UXvIAmm VjziRJojHHa5UumFdZ7/roPTRpuGH1rIN86Ho= 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=UiMX+a/n3KparVTc03/3zOVAcxR5tnQKucP/xxLwQns=; b=5q/giiWIm1nMdku1TIlcm2P5CHgkIBeAfUWQiuv5JAFvixMvqLA/MYkK/nuSGZoVQt usU01M9WL76jrlnDbfAou565cKvESzWcMVurOk+gA+HXQ4m4wIhaDgveDjqj4cQ1mBPB oa47SffxwQqWf6BJM9cHEudIaxLuJnqkUPi2OL+k7f9Mew+vFkLHTiQkk3PBzatQgtn3 l503D2vHvn+3wNy2VLLzCnHqels2bhRuPl3kzMjj9CTU5aDyCC0Voq6a1+M/2S293+VL ve5wv0/damGNnblSN7cq8OR9SNe8W6vFnhFWrxgg1735yKv5VcouV4etwa7sYrHRgJzJ 9xaA== X-Gm-Message-State: ACrzQf2l9yEXxUTI9j8vG3maNKscObGcuYIff5LZtFfDvq+BWppA95Ei Qr4D+uee2FBfKs1UWfYBKFWrGQ== X-Google-Smtp-Source: AMsMyM6yf6VBk7LFFaROXCkL0h1+X6GqbusXc4YobK7Ck5Pu0fYLuRSJkHP/UIYXXG44c1pXIcGSMw== X-Received: by 2002:a17:90b:4c0b:b0:203:6d81:bb53 with SMTP id na11-20020a17090b4c0b00b002036d81bb53mr2744972pjb.3.1664937639678; Tue, 04 Oct 2022 19:40:39 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:a9d9:6396:ee12:8be8]) by smtp.gmail.com with ESMTPSA id a14-20020aa794ae000000b00561e010a309sm1673579pfl.19.2022.10.04.19.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 19:40:39 -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: [PATCHv2 7/8] zram: Add recompress flag to read_block_state() Date: Wed, 5 Oct 2022 11:40:13 +0900 Message-Id: <20221005024014.22914-8-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221005024014.22914-1-senozhatsky@chromium.org> References: <20221005024014.22914-1-senozhatsky@chromium.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664937640; 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=UiMX+a/n3KparVTc03/3zOVAcxR5tnQKucP/xxLwQns=; b=His1N1oVcXy4omcDB7/ViZw8cYUyJdvzx7vQAFcTYnbmJWtL+4JqPprDqF+ElHsdEPajRs 6gFpJ49t4nNaDriT1mxYQsHWXC1W5qBe39TeDplEHxV15ZWYzT+kFoink2MCqeCWdOCS56 qV1E5MXl16FjL5PwVQB0SDTPubGFW5c= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=RYDcpGwT; spf=pass (imf09.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.175 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664937640; a=rsa-sha256; cv=none; b=YDavpD76OsiYuI7ZEQ0cTkuOOmrJDOEjJbPhNswtYZhpY3bvnXN+M2NSUUem9SoIOfbAF3 Tlunh3OZ0evbqt2QbAi0pmcsCasjXSmFUr2nbyQh3g1bzlnaesjYSHZQmVq/jFDU88Lb0k 3wbT8jSJUJGanFl3U9XtKjwnHLWMzFQ= X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=RYDcpGwT; spf=pass (imf09.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.175 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 9289B14000A X-Stat-Signature: 9dmk1g8pjdpdx5jigxmkqgcouay6s965 X-HE-Tag: 1664937640-618942 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 75fc89de21e3..ce9413040ad4 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);