Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1642181

Re: [PATCH 2/2] zram: do not count duplicated pages as compressed

From Minchan Kim <minchan@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] zram: do not count duplicated pages as compressed
Date 2017-05-16 04:00 +0200
Message-ID <tHzWh-7wv-3@gated-at.bofh.it> (permalink)
References <tHiVr-57h-3@gated-at.bofh.it> <tHiVr-57h-1@gated-at.bofh.it> <tHzCV-7pz-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Sergey,

On Tue, May 16, 2017 at 10:30:22AM +0900, Sergey Senozhatsky wrote:
> On (05/15/17 16:41), Minchan Kim wrote:
> [..]
> > diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> > index b885356551e9..8152e405117b 100644
> > --- a/drivers/block/zram/zram_drv.c
> > +++ b/drivers/block/zram/zram_drv.c
> > @@ -624,15 +624,22 @@ static void zram_free_page(struct zram *zram, size_t index)
> >  		return;
> >  	}
> >  
> > +	if (zram_dedup_enabled(zram) &&
> > +			zram_test_flag(zram, index, ZRAM_DUP)) {
> > +		zram_clear_flag(zram, index, ZRAM_DUP);
> > +		atomic64_sub(entry->len, &zram->stats.dup_data_size);
> > +		goto out;
> > +	}
> 
> so that `goto' there is to just jump over ->stats.compr_data_size?

Yub.

> can you sub ->stats.compr_data_size before the `if' and avoid labels?


> 
> >  	if (!entry)
> >  		return;
> 
> shouldn't this `if' be moved before `if (zram_dedup_enabled(zram)`?

You mean this?

static void zram_free_page(..) {
        if (zram_test_flag(zram, index, ZRAM_SAME))
                ...

        if (!entry)
                return;

        if (zram_dedup_enabled(zram) && xxxx)) {
                zram_clear_flag(ZRAM_DUP);
                atomic64_sub(entry->len, &zram->stats.dup_data_size);
        } else {
                atomic64_sub(zram_get_obj_size(zram, index),
                                        &zram->stats.compr_dat_size);
        }

        zram_entry_free
        zram_set_entry
        zram_set_obj_size
}

> 
> 
> [..]
> > @@ -794,7 +801,15 @@ static int __zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index)
> >  	entry = zram_dedup_find(zram, page, &checksum);
> >  	if (entry) {
> >  		comp_len = entry->len;
> > -		goto found_dup;
> > +		zram_slot_lock(zram, index);
> > +		zram_free_page(zram, index);
> > +		zram_set_flag(zram, index, ZRAM_DUP);
> > +		zram_set_entry(zram, index, entry);
> > +		zram_set_obj_size(zram, index, comp_len);
> > +		zram_slot_unlock(zram, index);
> > +		atomic64_add(comp_len, &zram->stats.dup_data_size);
> > +		atomic64_inc(&zram->stats.pages_stored);
> > +		return 0;
> 
> hm. that's a somewhat big code duplication. isn't it?

Yub. 3 parts. above part,  zram_same_page_write and tail of __zram_bvec_write.

Do you have any idea? Feel free to suggest. :)
Thanks.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 2/2] zram: do not count duplicated pages as compressed Minchan Kim <minchan@kernel.org> - 2017-05-15 09:50 +0200
  Re: [PATCH 2/2] zram: do not count duplicated pages as compressed Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-05-16 03:40 +0200
    Re: [PATCH 2/2] zram: do not count duplicated pages as compressed Minchan Kim <minchan@kernel.org> - 2017-05-16 04:00 +0200
      Re: [PATCH 2/2] zram: do not count duplicated pages as compressed Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-05-16 04:40 +0200
        Re: [PATCH 2/2] zram: do not count duplicated pages as compressed Minchan Kim <minchan@kernel.org> - 2017-05-16 07:30 +0200
          Re: [PATCH 2/2] zram: do not count duplicated pages as compressed Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-05-16 07:50 +0200
            Re: [PATCH 2/2] zram: do not count duplicated pages as compressed Minchan Kim <minchan@kernel.org> - 2017-05-16 09:20 +0200
              Re: [PATCH 2/2] zram: do not count duplicated pages as compressed Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-05-16 09:40 +0200
                Re: [PATCH 2/2] zram: do not count duplicated pages as compressed Minchan Kim <minchan@kernel.org> - 2017-05-17 11:00 +0200
                Re: [PATCH 2/2] zram: do not count duplicated pages as compressed Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-05-17 11:20 +0200
                Re: [PATCH 2/2] zram: do not count duplicated pages as compressed Minchan Kim <minchan@kernel.org> - 2017-05-18 07:00 +0200
                Re: [PATCH 2/2] zram: do not count duplicated pages as compressed Christoph Hellwig <hch@infradead.org> - 2017-05-21 09:10 +0200
                Re: [PATCH 2/2] zram: do not count duplicated pages as compressed Minchan Kim <minchan@kernel.org> - 2017-05-21 09:20 +0200

csiph-web