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>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
joaodias@google.com, srnvs@google.com
Subject: Re: [PATCH] zram: idle writeback fixes and cleanup
Date: Thu, 27 Dec 2018 11:26:24 +0900 [thread overview]
Message-ID: <20181227022624.GA30091@jagdpanzerIV> (raw)
In-Reply-To: <20181224033529.19450-1-minchan@kernel.org>
On (12/24/18 12:35), Minchan Kim wrote:
[..]
> @@ -645,10 +680,13 @@ static ssize_t writeback_store(struct device *dev,
> bvec.bv_len = PAGE_SIZE;
> bvec.bv_offset = 0;
>
> - if (zram->stop_writeback) {
> + spin_lock(&zram->wb_limit_lock);
> + if (zram->wb_limit_enable && !zram->bd_wb_limit) {
> + spin_unlock(&zram->wb_limit_lock);
> ret = -EIO;
> break;
> }
> + spin_unlock(&zram->wb_limit_lock);
[..]
> @@ -732,11 +771,10 @@ 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;
> - }
> + spin_lock(&zram->wb_limit_lock);
> + if (zram->wb_limit_enable && zram->bd_wb_limit > 0)
> + zram->bd_wb_limit -= 1UL << (PAGE_SHIFT - 12);
> + spin_unlock(&zram->wb_limit_lock);
Do we really need ->wb_limit_lock spinlock? We kinda punch it twice
in this loop. If someone clears ->wb_limit_enable somewhere in between
then the worst thing to happen is that we will just write extra page
to the backing device; not a very big deal to me. Am I missing
something?
-ss
next prev parent reply other threads:[~2018-12-27 2:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-24 3:35 [PATCH] zram: idle writeback fixes and cleanup Minchan Kim
2018-12-27 2:26 ` Sergey Senozhatsky [this message]
2018-12-28 5:19 ` Minchan Kim
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=20181227022624.GA30091@jagdpanzerIV \
--to=sergey.senozhatsky.work@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=joaodias@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=srnvs@google.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.