From patchwork Sun Oct 9 09:07:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13001950 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 000E3C43217 for ; Sun, 9 Oct 2022 09:07:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7086F6B007D; Sun, 9 Oct 2022 05:07:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B91C6B007E; Sun, 9 Oct 2022 05:07:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 55952900002; Sun, 9 Oct 2022 05:07:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 429EC6B007D for ; Sun, 9 Oct 2022 05:07:45 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1BC15160723 for ; Sun, 9 Oct 2022 09:07:45 +0000 (UTC) X-FDA: 80000833290.19.95198BD Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf11.hostedemail.com (Postfix) with ESMTP id BB9164001A for ; Sun, 9 Oct 2022 09:07:44 +0000 (UTC) Received: by mail-pj1-f44.google.com with SMTP id o9-20020a17090a0a0900b0020ad4e758b3so8080819pjo.4 for ; Sun, 09 Oct 2022 02:07:44 -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=5N+idb9Meu8bPgxV55r58/HUuOBKJs8gG9ElyKqtXIc=; b=Y9iTT0+zRaa4UXFiqtUyNe+GZMNhwGfWFvD2qw8EcyhN30/JkANHqh6exb6Tvly/D2 ozVLLGVefoQfieaWnBXFVKNSFSvVNfgcfNpFVTyp0JuWTvz3d6lhQytCAr0PB0S/K1Gr xjkMHUwZuSW9W4NSn0+pi1i4T6+rRDN/i8bH4= 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=5N+idb9Meu8bPgxV55r58/HUuOBKJs8gG9ElyKqtXIc=; b=hnxfhumZGCkHmryG+yMkTLRr5hRpu6wn5jFFMKN4QvCn4nUozjiJitdm0X4InlXe0l BOmvURV3mrY0fXqYdEV9l2o9tJWoYXwHKVNoAdFbvxaDlrCi2e0HjWuvqZQDHN9rT//O SN4DOQrrhY88PqtY0nzZS4WFKWdpvXRzYraXBNsJFzervSF/3ipqu8bCbjdZRajae88Z 6h3qkldTmCJWD5tauMrSA3jFA/GAkwoqx9Ls+ZN61ogGs/1g/ixsD6AjGQKsZtEZ6O+3 MmR2XGo6o59DkKWWadBM54Rktd/KqRKxjbJhEOa3cGNfHXIb8bTYaoJXId0gkUEcNpSy o0Dw== X-Gm-Message-State: ACrzQf0yYG8z6YbyDLfZBB3Z/lf0L+WPtqYY4uTbBQ+HIQx/6cSo5nFX GAOoPANi9r6/XDdmMVmAKJv8h1DL2j6V6g== X-Google-Smtp-Source: AMsMyM4wsiBlX1NkUhAfcaouRhXX8PAS3oIjVVHLWLI0PncP5Tf5uAod8RAj/q7gd5Nan0SlLp2qHg== X-Received: by 2002:a17:902:ec8d:b0:178:2914:b5a0 with SMTP id x13-20020a170902ec8d00b001782914b5a0mr13430611plg.17.1665306463751; Sun, 09 Oct 2022 02:07:43 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:8517:d51e:5fe9:9be7]) by smtp.gmail.com with ESMTPSA id q194-20020a632acb000000b00439d071c110sm4335148pgq.43.2022.10.09.02.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Oct 2022 02:07:43 -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: [PATCHv3 7/8] zram: Add recompress flag to read_block_state() Date: Sun, 9 Oct 2022 18:07:19 +0900 Message-Id: <20221009090720.1040633-8-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221009090720.1040633-1-senozhatsky@chromium.org> References: <20221009090720.1040633-1-senozhatsky@chromium.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665306464; a=rsa-sha256; cv=none; b=UeXiTtHMZjGjmleLT/9ZXWopWZvlPjh3waPYiUsebxgQ++wOAGWMIkBG3Dv3u/5pOpeGhX oJk4ndzMGO1OFwj5LnCtnsO7jXqssJN9RHobQaZzW99Xq4yO56O2Xgmx5m1qmgpwWyelXS Ys3H9fTGlaTMlb6fqLEVtx8qLlO6IWc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Y9iTT0+z; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.44 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665306464; 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=5N+idb9Meu8bPgxV55r58/HUuOBKJs8gG9ElyKqtXIc=; b=cQ/PEucDGlTRE54SX9XQWvPHuXKg7RrwVmFHFpHVZ1j53aBtBoTJ2cXI7ALpB584ZltaYR cpZ7ajKjLC4WLxGakeBgUFagbNCHndYfB++W5yuV/7yHkfaQr0foGy8RG4CJzNFq/Zt7Ut j1AJz+wvyyfk60UJiCK2A0IraudFFSg= X-Stat-Signature: zwfnjphccaqqha54imc58yrbtzbdeqzj X-Rspamd-Queue-Id: BB9164001A Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Y9iTT0+z; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.44 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1665306464-917642 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 7285a85b4054..34bb21691cee 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);