LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Joey Pabalinas <joeypabalinas@gmail.com>,
	Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Subject: Re: [PATCH v4 7/7] zram: writeback throttle
Date: Mon, 3 Dec 2018 15:02:08 +0900
Message-ID: <20181203060208.GE427@jagdpanzerIV> (raw)
In-Reply-To: <20181203055026.GD427@jagdpanzerIV>

On (12/03/18 14:50), Sergey Senozhatsky wrote:
> On (12/03/18 11:40), Minchan Kim wrote:
> [..]
> > +	down_read(&zram->init_lock);
> > +	atomic64_set(&zram->stats.bd_wb_limit, val);
> > +	if (val == 0)
> > +		zram->stop_writeback = false;
> > +	up_read(&zram->init_lock);
> 
> [..]
> 
> > +		if (zram->stop_writeback) {
> > +			ret = -EIO;
> > +			break;
> > +		}
> > +
> >  		if (!blk_idx) {
> >  			blk_idx = alloc_block_bdev(zram);
> >  			if (!blk_idx) {
> > @@ -694,6 +732,11 @@ static ssize_t writeback_store(struct device *dev,
> >  		zram_set_element(zram, index, blk_idx);
> >  		blk_idx = 0;
> >  		atomic64_inc(&zram->stats.pages_stored);
> > +		if (atomic64_add_unless(&zram->stats.bd_wb_limit,
> > +					-1 << (PAGE_SHIFT - 12), 0)) {
> > +			if (atomic64_read(&zram->stats.bd_wb_limit) == 0)
> > +				zram->stop_writeback = true;
> > +		}
> 
> Do we need ->stop_writeback? It should be identical to
> 
> 	atomic64_read(&zram->stats.bd_wb_limit) == 0

Seems like I misread writeback_limit_store() a bit.

So, if I want to, say, let only 10M of writteback pages, I need to
do

	echo 0 > writeback_limit
	echo 10M > writeback_limit_store	// memparse format is for
						// simplicity only; I know
						// it should be in 4K units.

every day. How about dropping the "echo 0" and ->stop_writeback?
So then we can just do

	echo 10M > writeback_limit_store

every day: if we have ->bd_wb_limit budget then we writeback,
           otherwise we don't.

	-ss

  reply index

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-03  2:40 [PATCH v4 0/7] zram idle page writeback Minchan Kim
2018-12-03  2:40 ` [PATCH v4 1/7] zram: fix lockdep warning of free block handling Minchan Kim
2018-12-03  2:40 ` [PATCH v4 2/7] zram: fix double free backing device Minchan Kim
2018-12-03  2:40 ` [PATCH v4 3/7] zram: refactoring flags and writeback stuff Minchan Kim
2018-12-03  2:40 ` [PATCH v4 4/7] zram: introduce ZRAM_IDLE flag Minchan Kim
2018-12-03  2:40 ` [PATCH v4 5/7] zram: support idle/huge page writeback Minchan Kim
2018-12-03  2:40 ` [PATCH v4 6/7] zram: add bd_stat statistics Minchan Kim
2018-12-03  2:40 ` [PATCH v4 7/7] zram: writeback throttle Minchan Kim
2018-12-03  5:50   ` Sergey Senozhatsky
2018-12-03  6:02     ` Sergey Senozhatsky [this message]
2018-12-03  6:11       ` Sergey Senozhatsky
2018-12-04  2:08 ` [PATCH v4 0/7] zram idle page writeback Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181203060208.GE427@jagdpanzerIV \
    --to=sergey.senozhatsky.work@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=joeypabalinas@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git