lkml.org 
[lkml]   [2018]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/6] zram: introduce ZRAM_IDLE flag
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.

\
 
 \ /
  Last update: 2018-11-22 06:12    [W:0.059 / U:0.668 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site