From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A218DC4338F for ; Tue, 27 Jul 2021 01:32:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 88F7360F6B for ; Tue, 27 Jul 2021 01:32:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233812AbhG0AwZ (ORCPT ); Mon, 26 Jul 2021 20:52:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbhG0AwY (ORCPT ); Mon, 26 Jul 2021 20:52:24 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57940C061757 for ; Mon, 26 Jul 2021 18:32:51 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id t66so10926830qkb.0 for ; Mon, 26 Jul 2021 18:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TWbfeNZmjnTcz2HGOF8VXSmVn2/eSAizVGY/kzYPBqQ=; b=ICQPyziFtMqRPneCQJqnIvELj5oraZC5gjp7JnXtqqSCrhUqqycpmcRD6UIh27jsTH RsJ1jLUe9bBergXXo0C4CdrNoXiAolVE2py9vyPxYhFr3VknBUnzL5DC9++M/xYcBLIJ UEILSLxBMtNFCqJKV2M3Fr4cqUpo5Dhi/Md/B2nLXau0NJ4sZgm0Czs0xL89P2p2byxL RPSmHSjDrtWflhW32mp4S5kyOelw371FSDtBIrYcMS/s23E2/yOsAM+asfOzGs7uO7ux pcLuiCJIm+T3HY+NiAmEnf9sHuSWEjIobYBSxLtVY5l83Pxl+9308tHglNgcLaiSFnV7 tA2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TWbfeNZmjnTcz2HGOF8VXSmVn2/eSAizVGY/kzYPBqQ=; b=HyxHJeHXdFu8EMaHXX+0OOT+xmtg6YcGju5J9x56P2MlUPJYaEU1kizHSk4/xVpask y+b1JLrxwI/BzAxHM/K1zi151HrpQqROII5HpfoAOmMQFv0dElsidrcyJyhTcLqvZROO bP0BKpbdpUswt7jLNEpzgLwJf0VjdZs0+KcNSpHfX50WkE4WyjkUZoygNS4pviU4X9Tc Ns3N/H8Fji0IzAjORuZ36xChLOAE5hscAlFEkqnEB7CbmgGwjL+0nqzoCj6leoBYUb1P zxbB4svKLlFjM772/pqIRhSS1SlsQAcaJIsHnhcS0bgbW4yXchShNcYvHHilHbq2ZJR3 NZng== X-Gm-Message-State: AOAM5313V7SA1HUYLTSsHD3JTPsZd/NXz0N2rHtY6jMVg5jd0uVp6532 9Ng3BdyCGocXmsZ40QkcG5wi5hVyUlL+RABemIKomUJOn0I= X-Google-Smtp-Source: ABdhPJwWb4M3ObQbtdTKza+Ui7yxD25UppTflRevqpTN4WITR9ntWMWldph9L4G8NKESBCChfFqSKYwaK36Od3rGBbY= X-Received: by 2002:a05:620a:172c:: with SMTP id az44mr4313377qkb.324.1627349570448; Mon, 26 Jul 2021 18:32:50 -0700 (PDT) MIME-Version: 1.0 References: <1626763658-27748-1-git-send-email-huangzhaoyang@gmail.com> In-Reply-To: From: Zhaoyang Huang Date: Tue, 27 Jul 2021 09:32:24 +0800 Message-ID: Subject: Re: [PATCH] driver: zram: fix wrong counting on pages_store To: Minchan Kim Cc: Sergey Senozhatsky , Zhaoyang Huang , "open list:MEMORY MANAGEMENT" , LKML , Nitin Gupta Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 27, 2021 at 1:53 AM Minchan Kim wrote: > > On Mon, Jul 26, 2021 at 10:27:40AM +0900, Sergey Senozhatsky wrote: > > On (21/07/20 14:47), Huangzhaoyang wrote: > > > It makes the statistic confused when counting pages_store in during writeback. > > > pages_store should just reflect the swapped pages on ZRAM, while bd_writes be > > > responsible for writeback things. > > > > > > Signed-off-by: Zhaoyang Huang > > > --- > > > drivers/block/zram/zram_drv.c | 1 - > > > 1 file changed, 1 deletion(-) > > > > > > diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c > > > index cf8deec..6bdaa9d 100644 > > > --- a/drivers/block/zram/zram_drv.c > > > +++ b/drivers/block/zram/zram_drv.c > > > @@ -765,7 +765,6 @@ static ssize_t writeback_store(struct device *dev, > > > zram_set_flag(zram, index, ZRAM_WB); > > > zram_set_element(zram, index, blk_idx); > > > blk_idx = 0; > > > - atomic64_inc(&zram->stats.pages_stored); > > > > Yeah, I think we don't need it here. > > > > Minchan, what do you think? > > What pages_stored currently represents is orig_data_size from mm_stat > > ================ ============================================================= > orig_data_size uncompressed size of data stored in this disk. > Unit: bytes > > Thus, if we don't increase it after zram_free_page, it loses what's > the original data size which would be important to calculate > compression ratio along with compr_data_size. zram_free_page?? What the commit try to fix is pages_stored being increased incorrectly in writeback_store, which will lead to wrong statistic on orig size of ZRAM. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D7BDC4338F for ; Tue, 27 Jul 2021 01:32:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A541560F8F for ; Tue, 27 Jul 2021 01:32:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A541560F8F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id E1A416B0036; Mon, 26 Jul 2021 21:32:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC8DF8D0001; Mon, 26 Jul 2021 21:32:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB6E26B006C; Mon, 26 Jul 2021 21:32:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id AEB9A6B0036 for ; Mon, 26 Jul 2021 21:32:51 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 554AB1836B068 for ; Tue, 27 Jul 2021 01:32:51 +0000 (UTC) X-FDA: 78406643742.10.B83D49C Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) by imf18.hostedemail.com (Postfix) with ESMTP id 122554001EB6 for ; Tue, 27 Jul 2021 01:32:50 +0000 (UTC) Received: by mail-qk1-f171.google.com with SMTP id 129so10879101qkg.4 for ; Mon, 26 Jul 2021 18:32:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TWbfeNZmjnTcz2HGOF8VXSmVn2/eSAizVGY/kzYPBqQ=; b=ICQPyziFtMqRPneCQJqnIvELj5oraZC5gjp7JnXtqqSCrhUqqycpmcRD6UIh27jsTH RsJ1jLUe9bBergXXo0C4CdrNoXiAolVE2py9vyPxYhFr3VknBUnzL5DC9++M/xYcBLIJ UEILSLxBMtNFCqJKV2M3Fr4cqUpo5Dhi/Md/B2nLXau0NJ4sZgm0Czs0xL89P2p2byxL RPSmHSjDrtWflhW32mp4S5kyOelw371FSDtBIrYcMS/s23E2/yOsAM+asfOzGs7uO7ux pcLuiCJIm+T3HY+NiAmEnf9sHuSWEjIobYBSxLtVY5l83Pxl+9308tHglNgcLaiSFnV7 tA2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TWbfeNZmjnTcz2HGOF8VXSmVn2/eSAizVGY/kzYPBqQ=; b=ERtAYGuI46K/A+HpAIxfhcamoLtW54MO03muJwT6no2pX8qEOTNipcbtT1uDWo8gaB WOlplI7lJLRg0z9lJ9cCHzG2unJ/cmjvGn8wzdRRTvcu+qqm8l2b+Hj4xeXNiyFJFlEB 0B5AxL01BtANl82VYQqtql+nNUhMXJm1UfkAVswN0POixgY9n+c6GRjLFx9rddHlvq/b zWI4fWGD3EQC6QODPncEdO1nklg4QrZN6nR2eS4MkmD/ZIXGUKUjnjp5rklhl8kZageB mdW2pDjIZZ3Ds7OYc7WA73tuRuZCf/TYe6qLyVveyqg7G2wdjLru0K0XEEfXqfbk1Qtw 4scw== X-Gm-Message-State: AOAM5339OVlCmSwhPHdxMs5kL9SBSo31zrWQYNIW+5l9KPcIP9RmCiEz 27XDe8+x6fJyE4wjMUwZL3UXTed9xv/uuGRHM08= X-Google-Smtp-Source: ABdhPJwWb4M3ObQbtdTKza+Ui7yxD25UppTflRevqpTN4WITR9ntWMWldph9L4G8NKESBCChfFqSKYwaK36Od3rGBbY= X-Received: by 2002:a05:620a:172c:: with SMTP id az44mr4313377qkb.324.1627349570448; Mon, 26 Jul 2021 18:32:50 -0700 (PDT) MIME-Version: 1.0 References: <1626763658-27748-1-git-send-email-huangzhaoyang@gmail.com> In-Reply-To: From: Zhaoyang Huang Date: Tue, 27 Jul 2021 09:32:24 +0800 Message-ID: Subject: Re: [PATCH] driver: zram: fix wrong counting on pages_store To: Minchan Kim Cc: Sergey Senozhatsky , Zhaoyang Huang , "open list:MEMORY MANAGEMENT" , LKML , Nitin Gupta Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 122554001EB6 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=ICQPyziF; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of huangzhaoyang@gmail.com designates 209.85.222.171 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com X-Stat-Signature: xfzhyo41b1358nq94eut3zt63uatdjy9 X-HE-Tag: 1627349570-688881 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: On Tue, Jul 27, 2021 at 1:53 AM Minchan Kim wrote: > > On Mon, Jul 26, 2021 at 10:27:40AM +0900, Sergey Senozhatsky wrote: > > On (21/07/20 14:47), Huangzhaoyang wrote: > > > It makes the statistic confused when counting pages_store in during writeback. > > > pages_store should just reflect the swapped pages on ZRAM, while bd_writes be > > > responsible for writeback things. > > > > > > Signed-off-by: Zhaoyang Huang > > > --- > > > drivers/block/zram/zram_drv.c | 1 - > > > 1 file changed, 1 deletion(-) > > > > > > diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c > > > index cf8deec..6bdaa9d 100644 > > > --- a/drivers/block/zram/zram_drv.c > > > +++ b/drivers/block/zram/zram_drv.c > > > @@ -765,7 +765,6 @@ static ssize_t writeback_store(struct device *dev, > > > zram_set_flag(zram, index, ZRAM_WB); > > > zram_set_element(zram, index, blk_idx); > > > blk_idx = 0; > > > - atomic64_inc(&zram->stats.pages_stored); > > > > Yeah, I think we don't need it here. > > > > Minchan, what do you think? > > What pages_stored currently represents is orig_data_size from mm_stat > > ================ ============================================================= > orig_data_size uncompressed size of data stored in this disk. > Unit: bytes > > Thus, if we don't increase it after zram_free_page, it loses what's > the original data size which would be important to calculate > compression ratio along with compr_data_size. zram_free_page?? What the commit try to fix is pages_stored being increased incorrectly in writeback_store, which will lead to wrong statistic on orig size of ZRAM.