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=unavailable 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 3D981C432BE for ; Tue, 27 Jul 2021 05:45:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 20C7E610E9 for ; Tue, 27 Jul 2021 05:45:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235261AbhG0Fpd (ORCPT ); Tue, 27 Jul 2021 01:45:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234867AbhG0Fpb (ORCPT ); Tue, 27 Jul 2021 01:45:31 -0400 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7311C061757 for ; Mon, 26 Jul 2021 22:45:31 -0700 (PDT) Received: by mail-qk1-x72b.google.com with SMTP id 184so11317444qkh.1 for ; Mon, 26 Jul 2021 22:45:31 -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=9UhfJ72ShgnVBe6T+2w7tb78zjNRACqScNORwxlEWgg=; b=fkws12MgMNA+B3+r7nq36hbFE5RF0C4ZmJCZbaAgFxh0fS4rkFoZdYHfPhQ+nFu8wc yp4ibHcbvb845j63tKPbs46ee5FrBknOxFOHGX/GiOJ1Yl0jAcq225ZFhNUGWvGZPilM EhtaCHZML7yVjbcUybrBytytCSJgdGSGB99sYO4WChkdX66I8VWGnRZsfpu03F17cmCU CBH2MEiTnVL/N88r1F5cf+YCOQb7If18NjanbZwNDrhO08JTAbJfkVq13LvE1Ym7JHy+ 70SX2aFc/J7fY21I6OkSnwmZh5uWciqvEq1sDsjw42W/2ZLerTAlRWJ5qTH64AaJ8MfM Nsuw== 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=9UhfJ72ShgnVBe6T+2w7tb78zjNRACqScNORwxlEWgg=; b=Sg19lxwxYJ2jb/zqLheAy4q4oN14YscgxAqIJYSFVtdUV1iRe/VM1exdCPdJCxJo9m ylJQpHXfLsU9gJB5bdADoLP+hHiEcghmnV3iM5UeA76OkvRTWqClqCwnVBRmKGzv7RbV ilWIkhn7yymk4oS4dXRtl5klK8uNnlvsxWeB+r6v99lndyP3mlSPe0pX3F9AzPJRDgVJ FSoXO+X8/ylptmP661QC88dfKoP0dikAdb6EX7vHhzYTxw1ySeQS3yiXmncuHSNovVJM QGdc9r0M110HERd0yVelLLhLZxaf2IXjlbyiRP5OWS+/roe+8zrXNvhO12aryYJKIiWK m3yg== X-Gm-Message-State: AOAM533KeeeCa8j1EEUaU9TvrY+MIUbbZZ0voVb0UT19baieGYv6G+AC QJtWzLj7fDAtpOtaAswI0S36nJWZ8M3EHQ3hyNo= X-Google-Smtp-Source: ABdhPJxUV5CjpXrNTe0ZzNz+2ksAKEtWJaxs8OKEIBYu1Jdn1Z4K7taHur5OwWROvtkutLbb14RhEbE5arYW6Ax6hvg= X-Received: by 2002:a37:ad12:: with SMTP id f18mr20807807qkm.105.1627364730956; Mon, 26 Jul 2021 22:45:30 -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 13:45:04 +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 9:32 AM Zhaoyang Huang wrote: > > 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. OK, if I understand right, I think what you mean is the page count corresponding to SWAP should be still available even if it is written back to the backing dev.So we need to increase page_stored again after zram_free_page free it. 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 AD9B7C4338F for ; Tue, 27 Jul 2021 05:45:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2FADD610FF for ; Tue, 27 Jul 2021 05:45:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2FADD610FF 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 708E78D0001; Tue, 27 Jul 2021 01:45:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B8486B005D; Tue, 27 Jul 2021 01:45:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CDCC8D0001; Tue, 27 Jul 2021 01:45:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 4649A6B0036 for ; Tue, 27 Jul 2021 01:45:32 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id E32EF182B0301 for ; Tue, 27 Jul 2021 05:45:31 +0000 (UTC) X-FDA: 78407280462.29.EB6A0D4 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by imf24.hostedemail.com (Postfix) with ESMTP id A017BB0000B8 for ; Tue, 27 Jul 2021 05:45:31 +0000 (UTC) Received: by mail-qk1-f181.google.com with SMTP id o13so11276454qkk.9 for ; Mon, 26 Jul 2021 22:45:31 -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=9UhfJ72ShgnVBe6T+2w7tb78zjNRACqScNORwxlEWgg=; b=fkws12MgMNA+B3+r7nq36hbFE5RF0C4ZmJCZbaAgFxh0fS4rkFoZdYHfPhQ+nFu8wc yp4ibHcbvb845j63tKPbs46ee5FrBknOxFOHGX/GiOJ1Yl0jAcq225ZFhNUGWvGZPilM EhtaCHZML7yVjbcUybrBytytCSJgdGSGB99sYO4WChkdX66I8VWGnRZsfpu03F17cmCU CBH2MEiTnVL/N88r1F5cf+YCOQb7If18NjanbZwNDrhO08JTAbJfkVq13LvE1Ym7JHy+ 70SX2aFc/J7fY21I6OkSnwmZh5uWciqvEq1sDsjw42W/2ZLerTAlRWJ5qTH64AaJ8MfM Nsuw== 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=9UhfJ72ShgnVBe6T+2w7tb78zjNRACqScNORwxlEWgg=; b=OmKDa68nQp/Ts2G3m/dSk8XCK07cDYmxqk7+y8I/cxmXchyf8oHmmE651pqZMtxbv+ XLypqQVsmOBUj0P30CATOlGImhJL2UVuztPhC47EK/fq79QmeOAbwnIPYELGjlbexoKm gMLBHG4LwXYDQVWyVQfdzSylCty4bddHZed1Ixc4xeVmhmvJQTCq08WvqsVXotpxD9jF Xtzoz76/IBppyB8eeYCwpdJkJD4AxTnPGoX4iT7lx399+FLLGv5KkrpxJnPZi7yRgE1/ SnIn72XcBeydQ+ADwnJvt0YJCe7aRLh5XQB4q4VvS+uHp3jrh2bQdt5FCkNFD4fVv0GX 3vDw== X-Gm-Message-State: AOAM531WWV+/VbfMKzrnfirK9DvRL6vFKtpmgxUq5Qt8UqHkW/t+jks1 rhVJ45QyZUFfc1TSNpoESs75eTKlDS18E3q14vk= X-Google-Smtp-Source: ABdhPJxUV5CjpXrNTe0ZzNz+2ksAKEtWJaxs8OKEIBYu1Jdn1Z4K7taHur5OwWROvtkutLbb14RhEbE5arYW6Ax6hvg= X-Received: by 2002:a37:ad12:: with SMTP id f18mr20807807qkm.105.1627364730956; Mon, 26 Jul 2021 22:45:30 -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 13:45:04 +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: rspam04 X-Rspamd-Queue-Id: A017BB0000B8 Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=fkws12Mg; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of huangzhaoyang@gmail.com designates 209.85.222.181 as permitted sender) smtp.mailfrom=huangzhaoyang@gmail.com X-Stat-Signature: 6kx5ht4h9635r1n5nafrgdkn4wmhk17q X-HE-Tag: 1627364731-104079 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 9:32 AM Zhaoyang Huang wrote: > > 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. OK, if I understand right, I think what you mean is the page count corresponding to SWAP should be still available even if it is written back to the backing dev.So we need to increase page_stored again after zram_free_page free it.