From patchwork Wed Nov 9 11:50: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: 13037460 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 AE485C433FE for ; Wed, 9 Nov 2022 11:51:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5040A6B0075; Wed, 9 Nov 2022 06:51:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 465E58E0006; Wed, 9 Nov 2022 06:51:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32C8A8E0005; Wed, 9 Nov 2022 06:51:58 -0500 (EST) 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 2686D6B0075 for ; Wed, 9 Nov 2022 06:51:58 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 88BD41414D4 for ; Wed, 9 Nov 2022 11:51:53 +0000 (UTC) X-FDA: 80113739706.01.E9180E1 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf29.hostedemail.com (Postfix) with ESMTP id 3649E120014 for ; Wed, 9 Nov 2022 11:51:47 +0000 (UTC) Received: by mail-pf1-f180.google.com with SMTP id m6so16501672pfb.0 for ; Wed, 09 Nov 2022 03:51:47 -0800 (PST) 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=0dJwSSVWle5wAKsSMx0YgyDVQ6OL2lYtX7lIC3B32aM=; b=HPHG6Yl1KI8mjO7OGpNfDk9YjeU3vICc9sLqJbjbfAmOJLAc5WywPSQFJB18fJuCwG 7+L+GS+xMO9FXwYZsNZrYXG+YjRzsXJIVihSbtuJ/zBxUltuJrhH3vDMFNUNPYo4NYGb 4jwiks5wtyeCwT4bKKf8lTT4cLaN0kL0Hrfnc= 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=0dJwSSVWle5wAKsSMx0YgyDVQ6OL2lYtX7lIC3B32aM=; b=MOUM8NehWlFJgEQEyh++pSqMtlnIlTVw/uEBT34UQ6T80jjljOeW7PWlVG+h4PEmav 0eO3EOVQcYUM2TepZSnKAoyOVBObxRsFWHxMfOk9TEyXg1IOZF+X9Cj49vs2gGT2Labm rXZAd2GTe6Ob3Xfly2lYi95BjhAuaw3KXlVI8gEg8hCllg/Kxhp1zwgJZn1LrtCBzaN6 LMHc8Uw7UWtfNTcjRscTRsz+kdzkKVX8rLB819+OjknLqvlpWSwm72aLIXYbR/eoSODd r/8xovdgK8dDHX7DPyFmZ6BANt42RayPfLir3HFUabepc0DeM9g6IRHxIj7KWdbgSvw1 c1+Q== X-Gm-Message-State: ACrzQf1JgRL2/c4YBrnaw9/tZGQkjbmrHXewEQazkp57tYXQ/OMYnzvC Otu5cLd8pJSjI4zSD4lQXXudxQ== X-Google-Smtp-Source: AMsMyM4qP0VAZ/9g6k/1c2ELzDcyARTP25CtfOUKLGpwh2OuBRIs5q2CH788dxqVBNgKjab/wWnGJg== X-Received: by 2002:a63:5a63:0:b0:42f:e143:80d4 with SMTP id k35-20020a635a63000000b0042fe14380d4mr53000571pgm.456.1667994688240; Wed, 09 Nov 2022 03:51:28 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:61f1:44d3:3f47:2cdb]) by smtp.gmail.com with ESMTPSA id f5-20020a655505000000b00434760ee36asm7292311pgr.16.2022.11.09.03.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 03:51:27 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: Nitin Gupta , Suleiman Souhlal , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv5 13/13] zram: Add incompressible flag to read_block_state() Date: Wed, 9 Nov 2022 20:50:47 +0900 Message-Id: <20221109115047.2921851-14-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog In-Reply-To: <20221109115047.2921851-1-senozhatsky@chromium.org> References: <20221109115047.2921851-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=1667994708; 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=0dJwSSVWle5wAKsSMx0YgyDVQ6OL2lYtX7lIC3B32aM=; b=ZgDqrvhveHbf5Kuq1MHtSQM8oaOO7qRgkZaoO8bkx4TIPKC/gAxzJrtIAHR1qeQYycRRcf wv70ktyn8NY5NYrs47XlEhA1b2nQhlHtj9HHymF+o51PCeQh3d3Sz8YIs+Q6b7euKSZMQ1 HotLSx3UW9ENcRl9vSzZ1tLaBGO5Ypo= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=HPHG6Yl1; spf=pass (imf29.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.180 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=1667994708; a=rsa-sha256; cv=none; b=Zr7RScNBtrjTJNSNXQOsXBesjAPzY+kSafOiJnpXZLJolemZTJtoip7fUm/i1UwPNPSDbJ 27Xd7/QZEizPBhXpU/qqR5Zg/AN0iz7TzWF9wsKHaepqWJbNYDv1Wi+ol/wUtePej6Bhs9 8WaedgvfhdJY6WU7FgciSmCRSiorqBo= X-Rspam-User: X-Stat-Signature: 6d1on3gbdke7kpu3qoafrz6bc46eq46x X-Rspamd-Queue-Id: 3649E120014 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=HPHG6Yl1; spf=pass (imf29.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.180 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam07 X-HE-Tag: 1667994707-327147 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 is incompressible: that none of the algorithm (including secondary ones) could compress it. Suggested-by: Minchan Kim Signed-off-by: Sergey Senozhatsky --- Documentation/admin-guide/blockdev/zram.rst | 11 +++++++---- drivers/block/zram/zram_drv.c | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Documentation/admin-guide/blockdev/zram.rst b/Documentation/admin-guide/blockdev/zram.rst index f14c8c2e42f3..e4551579cb12 100644 --- a/Documentation/admin-guide/blockdev/zram.rst +++ b/Documentation/admin-guide/blockdev/zram.rst @@ -497,10 +497,11 @@ 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. - 303 62.801919 ....r + 300 75.033841 .wh... + 301 63.806904 s..... + 302 63.806919 ..hi.. + 303 62.801919 ....r. + 304 146.781902 ..hi.n First column zram's block index. @@ -519,6 +520,8 @@ Third column idle page r: recompressed page (secondary compression algorithm) + n: + none (including secondary) of algorithms could compress it 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 2e4ef1ba1973..3447df3ca75e 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c @@ -949,14 +949,16 @@ 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%c\n", + "%12zd %12lld.%06lu %c%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_get_priority(zram, index) ? 'r' : '.'); + zram_get_priority(zram, index) ? 'r' : '.', + zram_test_flag(zram, index, + ZRAM_INCOMPRESSIBLE) ? 'n' : '.'); if (count <= copied) { zram_slot_unlock(zram, index);