linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] driver: zram: fix wrong counting on pages_store
@ 2021-07-20  6:47 Huangzhaoyang
  2021-07-25  1:19 ` [Resend PATCH] " Zhaoyang Huang
  2021-07-26  1:27 ` [PATCH] " Sergey Senozhatsky
  0 siblings, 2 replies; 6+ messages in thread
From: Huangzhaoyang @ 2021-07-20  6:47 UTC (permalink / raw)
  To: Minchan Kim, Zhaoyang Huang, linux-mm, linux-kernel, Nitin Gupta,
	Sergey Senozhatsky

From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

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 <zhaoyang.huang@unisoc.com>
---
 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);
 		spin_lock(&zram->wb_limit_lock);
 		if (zram->wb_limit_enable && zram->bd_wb_limit > 0)
 			zram->bd_wb_limit -=  1UL << (PAGE_SHIFT - 12);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Resend PATCH] driver: zram: fix wrong counting on pages_store
  2021-07-20  6:47 [PATCH] driver: zram: fix wrong counting on pages_store Huangzhaoyang
@ 2021-07-25  1:19 ` Zhaoyang Huang
  2021-07-26  1:27 ` [PATCH] " Sergey Senozhatsky
  1 sibling, 0 replies; 6+ messages in thread
From: Zhaoyang Huang @ 2021-07-25  1:19 UTC (permalink / raw)
  To: Minchan Kim, Zhaoyang Huang, open list:MEMORY MANAGEMENT, LKML,
	Nitin Gupta, Sergey Senozhatsky

Subject: [PATCH] driver: zram: fix wrong counting on pages_store
Date: Tue, 20 Jul 2021 14:47:38 +0800
Message-Id: <1626763658-27748-1-git-send-email-huangzhaoyang@gmail.com>
X-Mailer: git-send-email 1.7.9.5

From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

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 <zhaoyang.huang@unisoc.com>
---
 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);
  spin_lock(&zram->wb_limit_lock);
  if (zram->wb_limit_enable && zram->bd_wb_limit > 0)
  zram->bd_wb_limit -=  1UL << (PAGE_SHIFT - 12);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] driver: zram: fix wrong counting on pages_store
  2021-07-20  6:47 [PATCH] driver: zram: fix wrong counting on pages_store Huangzhaoyang
  2021-07-25  1:19 ` [Resend PATCH] " Zhaoyang Huang
@ 2021-07-26  1:27 ` Sergey Senozhatsky
  2021-07-26 17:53   ` Minchan Kim
  1 sibling, 1 reply; 6+ messages in thread
From: Sergey Senozhatsky @ 2021-07-26  1:27 UTC (permalink / raw)
  To: Minchan Kim, Huangzhaoyang
  Cc: Zhaoyang Huang, linux-mm, linux-kernel, Nitin Gupta, Sergey Senozhatsky

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 <zhaoyang.huang@unisoc.com>
> ---
>  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?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] driver: zram: fix wrong counting on pages_store
  2021-07-26  1:27 ` [PATCH] " Sergey Senozhatsky
@ 2021-07-26 17:53   ` Minchan Kim
  2021-07-27  1:32     ` Zhaoyang Huang
  0 siblings, 1 reply; 6+ messages in thread
From: Minchan Kim @ 2021-07-26 17:53 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: Huangzhaoyang, Zhaoyang Huang, linux-mm, linux-kernel, Nitin Gupta

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 <zhaoyang.huang@unisoc.com>
> > ---
> >  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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] driver: zram: fix wrong counting on pages_store
  2021-07-26 17:53   ` Minchan Kim
@ 2021-07-27  1:32     ` Zhaoyang Huang
  2021-07-27  5:45       ` Zhaoyang Huang
  0 siblings, 1 reply; 6+ messages in thread
From: Zhaoyang Huang @ 2021-07-27  1:32 UTC (permalink / raw)
  To: Minchan Kim
  Cc: Sergey Senozhatsky, Zhaoyang Huang, open list:MEMORY MANAGEMENT,
	LKML, Nitin Gupta

On Tue, Jul 27, 2021 at 1:53 AM Minchan Kim <minchan@kernel.org> 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 <zhaoyang.huang@unisoc.com>
> > > ---
> > >  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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] driver: zram: fix wrong counting on pages_store
  2021-07-27  1:32     ` Zhaoyang Huang
@ 2021-07-27  5:45       ` Zhaoyang Huang
  0 siblings, 0 replies; 6+ messages in thread
From: Zhaoyang Huang @ 2021-07-27  5:45 UTC (permalink / raw)
  To: Minchan Kim
  Cc: Sergey Senozhatsky, Zhaoyang Huang, open list:MEMORY MANAGEMENT,
	LKML, Nitin Gupta

On Tue, Jul 27, 2021 at 9:32 AM Zhaoyang Huang <huangzhaoyang@gmail.com> wrote:
>
> On Tue, Jul 27, 2021 at 1:53 AM Minchan Kim <minchan@kernel.org> 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 <zhaoyang.huang@unisoc.com>
> > > > ---
> > > >  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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-27  5:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-20  6:47 [PATCH] driver: zram: fix wrong counting on pages_store Huangzhaoyang
2021-07-25  1:19 ` [Resend PATCH] " Zhaoyang Huang
2021-07-26  1:27 ` [PATCH] " Sergey Senozhatsky
2021-07-26 17:53   ` Minchan Kim
2021-07-27  1:32     ` Zhaoyang Huang
2021-07-27  5:45       ` Zhaoyang Huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).