From: Minchan Kim <minchan@kernel.org>
To: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] zram: support page-based parallel write
Date: Mon, 24 Oct 2016 14:58:18 +0900 [thread overview]
Message-ID: <20161024055818.GA5703@blaptop> (raw)
In-Reply-To: <20161024052044.GA1855@swordfish>
On Mon, Oct 24, 2016 at 02:20:44PM +0900, Sergey Senozhatsky wrote:
> Hi Minchan,
>
> On (10/24/16 13:47), Minchan Kim wrote:
> > Hi Sergey,
> >
> > > > +static void zram_unplug(struct blk_plug_cb *cb, bool from_schedule)
> > > > +{
> > > > + spin_lock(&workers.req_lock);
> > > > + if (workers.nr_req)
> > > > + worker_wake_up();
> > > > + spin_unlock(&workers.req_lock);
> > > > + kfree(cb);
> > > > +}
> > > > +
> > > > +static int zram_check_plugged(void)
> > > > +{
> > > > + return !!blk_check_plugged(zram_unplug, NULL,
> > > > + sizeof(struct blk_plug_cb));
> > > > +}
> > >
> > > I'm having some troubles understanding the purpose of zram_check_plugged().
> > > it's a global symbol, can you just use it directly? otherwise we are
> > > doing additional kmalloc/kfree, spin_lock/unlock and so on.
> >
> > I don't understnad it. Why does it that use zram_check_plugged directly reduce
> > count things you mentioned?
> > >
> > > what am I missing? current->plug? can it affect us? how?
> >
> > Sorry. I can't understand your point.
>
> I meant that every blk_check_plugged() is
>
> struct blk_plug_cb *blk_check_plugged(blk_plug_cb_fn unplug, void *data,
> int size)
> {
> struct blk_plug *plug = current->plug;
> struct blk_plug_cb *cb;
>
> if (!plug)
> return NULL;
>
> list_for_each_entry(cb, &plug->cb_list, list)
> if (cb->callback == unplug && cb->data == data)
> return cb;
Normally, this routine will check and bail out if it has been plugged
rightly so it would be not too many allocation in there.
Having said that, there is no need to allocate cb in block layer.
drive can allocate one time and reuse it with passing it to the
blk_check_plugged. I was tempted to introduce the API into block layer
but it was just optimization/easy stuff once this patchset settle down
so I didn't consider in this patchset.
>
> /* Not currently on the callback list */
> BUG_ON(size < sizeof(*cb));
> cb = kzalloc(size, GFP_ATOMIC);
> if (cb) {
> cb->data = data;
> cb->callback = unplug;
> list_add(&cb->list, &plug->cb_list);
> }
> return cb;
> }
>
> which is extra kzalloc/kfree/etc. do we really need to do it all the time?
> thus my question -- what am I missing (aka educate me)?
>
> > > hm... no real objection, but exporing this sysfs attr can be very hacky
> > > and difficult for people...
> >
> > We have been used sysfs for tune the zram for a long time.
> > Please suggest ideas if you have better. :)
>
> yeah, but this one feels like a super-hacky knob. basically
>
> "enable when you can't tweak your usage patterns. this will tweak the driver".
>
> so I'd probably prefer to keep it hidden for now (may be eventually
> we will come to some "out-of-zram" solution. but the opposition may
> be "fix your usage pattern").
Frankly speaking, I tend to agree.
As I mentioned in cover-letter or somethine, I don't want to make this knob.
A option is we admit it's trade-off. So, if someone enables this config,
he will lost random/direct IO performance at this moment while he can get much
benefit buffered sequential read/write.
What do you think?
>
> besides, you make this sysfs attr .config dependent
>
> > +#ifdef CONFIG_ZRAM_ASYNC_IO
> > +static DEVICE_ATTR_RW(use_aio);
> > +#endif
> >
> > static struct attribute *zram_disk_attrs[] = {
> > &dev_attr_disksize.attr,
> > @@ -1231,6 +1666,9 @@ static struct attribute *zram_disk_attrs[] = {
> > &dev_attr_mem_used_max.attr,
> > &dev_attr_max_comp_streams.attr,
> > &dev_attr_comp_algorithm.attr,
> > +#ifdef CONFIG_ZRAM_ASYNC_IO
> > + &dev_attr_use_aio.attr,
> > +#endif
>
> so this knob is not even guaranteed to be there all the time.
>
> I wish I could suggest any sound alternative, but I don't have one
> at the moment. May be I'll have a chance to speak to block-dev people
> next week.
Okay. But I think it's not a good idea to hurt wb context you mentioned.
IOW, IO queuing could be parallelized by multiple wb context but
servicing(i.e., compression) should be done in zram contexts, not
wb context.
Thanks.
next prev parent reply other threads:[~2016-10-24 5:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-22 6:42 [PATCH 1/3] zram: rename IO processing functions Minchan Kim
2016-09-22 6:42 ` [PATCH 2/3] zram: support page-based parallel write Minchan Kim
2016-09-29 3:18 ` Sergey Senozhatsky
2016-09-30 5:52 ` Minchan Kim
2016-10-04 4:43 ` Sergey Senozhatsky
2016-10-04 7:35 ` Minchan Kim
2016-10-05 2:01 ` Minchan Kim
2016-10-06 8:29 ` Sergey Senozhatsky
2016-10-07 6:33 ` Minchan Kim
2016-10-07 18:08 ` Sergey Senozhatsky
2016-10-17 5:04 ` Minchan Kim
2016-10-21 6:08 ` Sergey Senozhatsky
2016-10-24 4:51 ` Minchan Kim
2016-10-21 6:03 ` Sergey Senozhatsky
2016-10-24 4:47 ` Minchan Kim
2016-10-24 5:20 ` Sergey Senozhatsky
2016-10-24 5:58 ` Minchan Kim [this message]
2016-10-24 7:23 ` Sergey Senozhatsky
2016-09-22 6:42 ` [PATCH 3/3] zram: adjust the number of zram thread Minchan Kim
2016-10-21 6:23 ` Sergey Senozhatsky
2016-10-24 4:54 ` Minchan Kim
2016-10-24 5:29 ` 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=20161024055818.GA5703@blaptop \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sergey.senozhatsky.work@gmail.com \
--cc=sergey.senozhatsky@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).