Skip to contentSkip to conversation

zram: fix missing zero pages for memory tracking

PATCH In review Minchan Kim 2 participants 5 messages Sep 19, 2018 – Oct 1, 2018

Subsystems (3)
lore
Share & tools
lore

Minchan Kim

author maintainer
#0 lore raw

PATCH 1/1 zram: fix missing zero pages for memory tracking

We need to count zero filled pages as well as other pages in zram. Otherwise, it doesn't match swap page count via pagemap of process so that memory tracking feature in zram doesn't provide accurate information.

Cc Sergey Senozhatsky <[email protected]>
Cc <[email protected]> [4.18+]
---
 drivers/block/zram/zram_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/zram/zram_drv.c +1 -1
index a1d6b5597c17..40d303d8826f 100644
@@ -71,7 +71,7 @@ static inline bool init_done(struct zram *zram)
 static inline bool zram_allocated(struct zram *zram, u32 index)
 {
 
-	return (zram->table[index].value >> (ZRAM_FLAG_SHIFT + 1)) ||
+	return zram->table[index].value >> ZRAM_FLAG_SHIFT ||
 					zram->table[index].handle;
 }
 
Signature · 1 line
2.19.0.397.gdd90340f6a-goog
#1 lore raw
Quoted 1 line · Minchan Kim

We need to count zero filled pages as well as other pages in zram.

A nit,

'ZRAM_FLAG_SHIFT + 1' covers all ZRAM_SAME pages, not only
zero filled pages.

	-ss
author maintainer
#2 lore raw

Hi Sergey,

Quoted 7 lines · Sergey Senozhatsky
Quoted 1 line · Minchan Kim

We need to count zero filled pages as well as other pages in zram.

A nit,

'ZRAM_FLAG_SHIFT + 1' covers all ZRAM_SAME pages, not only
zero filled pages.

Yub, that's what I want.
Currently, it covers only non-zero filled same page, which is inconsistent and user easily miss zero-filled same page.

author maintainer
#3 lore raw
In reply to Sergey Senozhatsky
Quoted 7 lines · Sergey Senozhatsky
Quoted 1 line · Minchan Kim

We need to count zero filled pages as well as other pages in zram.

A nit,

'ZRAM_FLAG_SHIFT + 1' covers all ZRAM_SAME pages, not only
zero filled pages.

Ah, now I got your point. I was brainfart.
I will drop this patch and find other reason I have missed.

Thanks, Sergey.

#4 lore raw
Quoted 10 lines · Minchan Kim
Quoted 7 lines · Sergey Senozhatsky
Quoted 1 line · Minchan Kim

We need to count zero filled pages as well as other pages in zram.

A nit,

'ZRAM_FLAG_SHIFT + 1' covers all ZRAM_SAME pages, not only
zero filled pages.

I was brainfart.

No, never :) And I totally didn't mean it.

	-ss