* [PATCH] zram: set zram bio priority to REQ_PRIO.
@ 2023-07-18 7:11 Huanpeng Xin
2023-07-18 7:49 ` Sergey Senozhatsky
0 siblings, 1 reply; 4+ messages in thread
From: Huanpeng Xin @ 2023-07-18 7:11 UTC (permalink / raw)
To: minchan, ngupta, axboe
Cc: senozhatsky, linux-kernel, linux-block, xinhuanpeng
From: xinhuanpeng <xinhuanpeng@xiaomi.com>
When the system memory pressure is high, set zram bio priority
to REQ_PRIO can quickly swap zarm's memory to backing device,
freeing up more space for zram.
Signed-off-by: xinhuanpeng <xinhuanpeng@xiaomi.com>
---
drivers/block/zram/zram_drv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index b8549c61ff2c..af56766a036b 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -616,7 +616,7 @@ static int read_from_bdev_async(struct zram *zram, struct bio_vec *bvec,
{
struct bio *bio;
- bio = bio_alloc(zram->bdev, 1, parent ? parent->bi_opf : REQ_OP_READ,
+ bio = bio_alloc(zram->bdev, 1, parent ? parent->bi_opf : REQ_OP_READ | REQ_PRIO,
GFP_NOIO);
if (!bio)
return -ENOMEM;
@@ -746,7 +746,7 @@ static ssize_t writeback_store(struct device *dev,
}
bio_init(&bio, zram->bdev, &bio_vec, 1,
- REQ_OP_WRITE | REQ_SYNC);
+ REQ_OP_WRITE | REQ_SYNC | REQ_PRIO);
bio.bi_iter.bi_sector = blk_idx * (PAGE_SIZE >> 9);
bio_add_page(&bio, bvec.bv_page, bvec.bv_len,
--
2.37.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] zram: set zram bio priority to REQ_PRIO.
2023-07-18 7:11 [PATCH] zram: set zram bio priority to REQ_PRIO Huanpeng Xin
@ 2023-07-18 7:49 ` Sergey Senozhatsky
2023-07-18 11:51 ` Sergey Senozhatsky
2023-07-20 8:34 ` Christoph Hellwig
0 siblings, 2 replies; 4+ messages in thread
From: Sergey Senozhatsky @ 2023-07-18 7:49 UTC (permalink / raw)
To: Huanpeng Xin
Cc: minchan, ngupta, axboe, senozhatsky, linux-kernel, linux-block,
xinhuanpeng, Christoph Hellwig
Cc-ing Christoph
On (23/07/18 15:11), Huanpeng Xin wrote:
>
> When the system memory pressure is high, set zram bio priority
> to REQ_PRIO can quickly swap zarm's memory to backing device,
read_from_bdev_async() does the opposite.
[..]
> @@ -616,7 +616,7 @@ static int read_from_bdev_async(struct zram *zram, struct bio_vec *bvec,
> {
> + bio = bio_alloc(zram->bdev, 1, parent ? parent->bi_opf : REQ_OP_READ | REQ_PRIO,
> GFP_NOIO);
[..]
> @@ -746,7 +746,7 @@ static ssize_t writeback_store(struct device *dev,
> ...
> bio_init(&bio, zram->bdev, &bio_vec, 1,
> - REQ_OP_WRITE | REQ_SYNC);
> + REQ_OP_WRITE | REQ_SYNC | REQ_PRIO);
In general, zram writeback is not for situations when the system
is critically low on memory; performance there is not that important,
so I'm not sure whether we want to boost requests' priorities.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] zram: set zram bio priority to REQ_PRIO.
2023-07-18 7:49 ` Sergey Senozhatsky
@ 2023-07-18 11:51 ` Sergey Senozhatsky
2023-07-20 8:34 ` Christoph Hellwig
1 sibling, 0 replies; 4+ messages in thread
From: Sergey Senozhatsky @ 2023-07-18 11:51 UTC (permalink / raw)
To: Huanpeng Xin
Cc: minchan, ngupta, axboe, linux-kernel, linux-block, xinhuanpeng,
Christoph Hellwig, Sergey Senozhatsky
On (23/07/18 16:49), Sergey Senozhatsky wrote:
> On (23/07/18 15:11), Huanpeng Xin wrote:
> >
> > When the system memory pressure is high, set zram bio priority
> > to REQ_PRIO can quickly swap zarm's memory to backing device,
> > freeing up more space for zram.
This is not how zram writeback works. The only time you can be sure
that writeback frees memory is when you writeback ZRAM_HUGE objects,
because each such object uses a whole physical page on the zsmalloc
side. In any other case, compressed objects share physical pages that
zsmalloc pages consist of, so writeback simply punches wholes in zspages,
without actually freeing any memory immediately. You either need zspages
to becomes empty after writeback or pool compaction, otherwise writeback
does not save any memory, no matter how fast it works.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] zram: set zram bio priority to REQ_PRIO.
2023-07-18 7:49 ` Sergey Senozhatsky
2023-07-18 11:51 ` Sergey Senozhatsky
@ 2023-07-20 8:34 ` Christoph Hellwig
1 sibling, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2023-07-20 8:34 UTC (permalink / raw)
To: Sergey Senozhatsky
Cc: Huanpeng Xin, minchan, ngupta, axboe, linux-kernel, linux-block,
xinhuanpeng, Christoph Hellwig
People really need to stop randomly using REQ_PRIO. It was added
back then because I did not want to overload REQ_META for WBT
priorisation, but it looks other added this somewhat bogus
priorisation back anyway. If that is to stay it should probably
just go away entirely, but certainly not added for magic boosters
for normal data I/O.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-07-20 8:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-18 7:11 [PATCH] zram: set zram bio priority to REQ_PRIO Huanpeng Xin
2023-07-18 7:49 ` Sergey Senozhatsky
2023-07-18 11:51 ` Sergey Senozhatsky
2023-07-20 8:34 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox