From: Minchan Kim <minchan@kernel.org>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/6] zram: introduce ZRAM_IDLE flag
Date: Thu, 22 Nov 2018 14:11:56 +0900 [thread overview]
Message-ID: <20181122051156.GB182024@google.com> (raw)
In-Reply-To: <20181120024659.GC4231@jagdpanzerIV>
On Tue, Nov 20, 2018 at 11:46:59AM +0900, Sergey Senozhatsky wrote:
> Hello,
>
> On (11/16/18 16:20), Minchan Kim wrote:
> [..]
> > +static ssize_t idle_store(struct device *dev,
> > + struct device_attribute *attr, const char *buf, size_t len)
> > +{
> > + struct zram *zram = dev_to_zram(dev);
> > + unsigned long nr_pages = zram->disksize >> PAGE_SHIFT;
> > + int index;
> > +
> > + down_read(&zram->init_lock);
> > + if (!init_done(zram)) {
> > + up_read(&zram->init_lock);
> > + return -EINVAL;
> > + }
> > +
> > + for (index = 0; index < nr_pages; index++) {
> > + zram_slot_lock(zram, index);
> > + if (!zram_allocated(zram, index))
> > + goto next;
> > +
> > + zram_set_flag(zram, index, ZRAM_IDLE);
> > +next:
> > + zram_slot_unlock(zram, index);
> > + }
> > +
> > + up_read(&zram->init_lock);
> > +
> > + return len;
> > +}
>
> This is one way of doing it.
>
> The other one could, probabaly, be a bit more friendly to the cache
> lines and CPU cycles. Basically, have a static timestamp variable,
> which would keep the timestamp of last idle_store().
>
> static idle_snapshot_ts;
>
> static ssize_t idle_store(struct device *dev,
> struct device_attribute *attr,
> const char *buf, size_t len)
> {
> idle_snapshot_ts = ktime();
> }
>
> And then in read_block_state() compare handle access time and
> idle_snapshot_ts (if it's not 0). If the page was not modified/access
> since the last idle_snapshot_ts (handle access time <= idle_snapshot_ts),
> then it's idle, otherwise (handle access time > idle_snapshot_ts) it's
> not idle.
>
> Would this do the trick?
It was a option when I imagined this idea first but problem from product
division was memory waste of ac_time for every zram table.
next prev parent reply other threads:[~2018-11-22 5:12 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-16 7:20 [PATCH 0/6] zram idle page writeback Minchan Kim
2018-11-16 7:20 ` [PATCH 1/6] zram: fix lockdep warning of free block handling Minchan Kim
2018-11-16 7:20 ` [PATCH 2/6] zram: refactoring flags and writeback stuff Minchan Kim
2018-11-16 7:20 ` [PATCH 3/6] zram: introduce ZRAM_IDLE flag Minchan Kim
2018-11-20 2:46 ` Sergey Senozhatsky
2018-11-22 5:11 ` Minchan Kim [this message]
2018-11-22 5:45 ` Sergey Senozhatsky
2018-11-16 7:20 ` [PATCH 4/6] zram: support idle page writeback Minchan Kim
2018-11-21 4:55 ` Sergey Senozhatsky
2018-11-21 13:34 ` Minchan Kim
2018-11-22 2:14 ` Sergey Senozhatsky
2018-11-22 5:04 ` Minchan Kim
2018-11-22 5:40 ` Sergey Senozhatsky
2018-11-22 6:15 ` Minchan Kim
2018-11-22 6:31 ` Minchan Kim
2018-11-22 6:59 ` Sergey Senozhatsky
2018-11-23 6:23 ` Minchan Kim
2018-11-16 7:20 ` [PATCH 5/6] zram: add bd_stat statistics Minchan Kim
2018-11-16 7:20 ` [PATCH 6/6] zram: writeback throttle 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=20181122051156.GB182024@google.com \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sergey.senozhatsky.work@gmail.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 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).