All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Jaegeuk Kim <jaegeuk@kernel.org>,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	Martijn Coenen <maco@android.com>
Subject: Re: [PATCH v2 2/3] loop: Select I/O scheduler 'none' from inside add_disk()
Date: Thu, 5 Aug 2021 11:26:19 +0800	[thread overview]
Message-ID: <YQtaWz7EtkNAtIkY@T590> (raw)
In-Reply-To: <bbecb701-48d6-bdfa-2d41-afb6c48a8254@acm.org>

On Wed, Aug 04, 2021 at 10:43:05AM -0700, Bart Van Assche wrote:
> On 8/3/21 7:39 PM, Ming Lei wrote:
> > On Tue, Aug 03, 2021 at 11:23:03AM -0700, Bart Van Assche wrote:
> > > We noticed that the user interface of Android devices becomes very slow
> > > under memory pressure. This is because Android uses the zram driver on top
> > > of the loop driver for swapping, because under memory pressure the swap
> > > code alternates reads and writes quickly, because mq-deadline is the
> > > default scheduler for loop devices and because mq-deadline delays writes by
> > 
> > Maybe we can bypass io scheduler always for request with REQ_SWAP, such as:
> > 
> > diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
> > index 0f006cabfd91..d86709ac9d1f 100644
> > --- a/block/blk-mq-sched.c
> > +++ b/block/blk-mq-sched.c
> > @@ -420,7 +420,8 @@ static bool blk_mq_sched_bypass_insert(struct blk_mq_hw_ctx *hctx,
> >   	 * passthrough request is added to scheduler queue, there isn't any
> >   	 * chance to dispatch it given we prioritize requests in hctx->dispatch.
> >   	 */
> > -	if ((rq->rq_flags & RQF_FLUSH_SEQ) || blk_rq_is_passthrough(rq))
> > +	if ((rq->rq_flags & RQF_FLUSH_SEQ) || blk_rq_is_passthrough(rq) ||
> > +			blk_rq_is_swap(rq))
> >   		return true;
> >   	return false;
> > diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> > index d3afea47ade6..71aaa99614ab 100644
> > --- a/include/linux/blkdev.h
> > +++ b/include/linux/blkdev.h
> > @@ -251,6 +251,11 @@ static inline bool blk_rq_is_passthrough(struct request *rq)
> >   	return blk_op_is_passthrough(req_op(rq));
> >   }
> > +static inline bool blk_rq_is_swap(struct request *rq)
> > +{
> > +	return rq->cmd_flags & REQ_SWAP;
> > +}
> > +
> >   static inline unsigned short req_get_ioprio(struct request *req)
> >   {
> >   	return req->ioprio;
> 
> Hi Ming,
> 
> Thanks for having suggested an alternative. However, isn't the above a
> policy? Shouldn't a kernel provide mechanisms instead of policies?

REQ_SWAP means it is one IO written to swap device/file, so the system
is suffering memory pressure, then isn't it reasonable to bypass io
scheduler for all SWAP IOs?

The issue you described in comment log is neither loop specific, nor
mq-deadline, I think it isn't good to just workaround the issue for loop.

> 
> Additionally, the above patch does not address all Android loop driver use
> cases. Reading APEX files is regular I/O and hence REQ_SWAP is not set while
> reading from APEX files.

Is APEX file one swap file? If not, can you explain it a bit why you want to
switch to none when reading APEX file?


Thanks,
Ming


  reply	other threads:[~2021-08-05  3:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-03 18:23 [PATCH v2 0/3] Improve loop driver I/O scheduler and QD selection Bart Van Assche
2021-08-03 18:23 ` [PATCH v2 1/3] blk-mq: Introduce the BLK_MQ_F_NO_SCHED_BY_DEFAULT flag Bart Van Assche
2021-08-03 18:23 ` [PATCH v2 2/3] loop: Select I/O scheduler 'none' from inside add_disk() Bart Van Assche
2021-08-04  2:39   ` Ming Lei
2021-08-04 17:43     ` Bart Van Assche
2021-08-05  3:26       ` Ming Lei [this message]
2021-08-05 16:49         ` Bart Van Assche
2021-08-04 17:58     ` Jens Axboe
2021-08-04  5:35   ` Christoph Hellwig
2021-08-04 17:58     ` Bart Van Assche
2021-08-04 18:04       ` Jens Axboe
2021-08-05  6:39       ` Christoph Hellwig
2021-08-03 18:23 ` [PATCH v2 3/3] loop: Add the default_queue_depth kernel module parameter Bart Van Assche
2021-08-04  6:07   ` Greg KH
2021-08-04 17:38     ` Bart Van Assche
2021-08-04 19:33       ` Greg KH
2021-08-05  6:14     ` Chaitanya Kulkarni

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=YQtaWz7EtkNAtIkY@T590 \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=jaegeuk@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=maco@android.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    /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.