All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@suse.de>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, jgarzik@pobox.com
Subject: Re: [PATCH] bsg, block layer sg
Date: Mon, 6 Mar 2006 10:19:59 +0100	[thread overview]
Message-ID: <20060306091959.GZ4329@suse.de> (raw)
In-Reply-To: <20060306011355.4df811f6.akpm@osdl.org>

On Mon, Mar 06 2006, Andrew Morton wrote:
> Jens Axboe <axboe@suse.de> wrote:
> >
> > ...
> > > 
> > > If you expand the two above statements you get:
> > > 
> > > 	spin_lock_irqsave(q->queue_lock, flags);
> > > 	__elv_add_request(q, rq, where, plug);
> > > 	spin_unlock_irqrestore(q->queue_lock, flags);
> > > 	spin_lock_irq(q->queue_lock);
> > > 	__generic_unplug_device(q);
> > > 	spin_unlock_irq(q->queue_lock);
> > > 
> > > which is a bit sad.
> > 
> > Indeed, I'll do the locking manually and use the __ functions.
> 
> blk_execute_rq_nowait() and pkt_generic_packet() also do the above two
> calls.   It might be worth creating a new library function.

Yes it might, there are other call sites like this in the kernel. But
it's basically blk_execute_rq_nowait(). I'll make that change.

> > > > +static int bsg_complete_all_commands(struct bsg_device *bd)
> > > > +{
> > > > +	struct bsg_command *bc;
> > > > +	int ret, tret;
> > > > +
> > > > +	dprintk("%s: entered\n", bd->name);
> > > > +
> > > > +	set_bit(BSG_F_BLOCK, &bd->flags);
> > > > +
> > > > +	/*
> > > > +	 * wait for all commands to complete
> > > > +	 */
> > > > +	ret = 0;
> > > > +	do {
> > > > +		ret = bsg_io_schedule(bd, TASK_UNINTERRUPTIBLE);
> > > > +		/*
> > > > +		 * look for -ENODATA specifically -- we'll sometimes get
> > > > +		 * -ERESTARTSYS when we've taken a signal, but we can't
> > > > +		 * return until we're done freeing the queue, so ignore
> > > > +		 * it.  The signal will get handled when we're done freeing
> > > > +		 * the bsg_device.
> > > > +		 */
> > > > +	} while (ret != -ENODATA);
> > > > +
> > > > +	/*
> > > > +	 * discard done commands
> > > > +	 */
> > > 
> > > Would it be useful to reap the completed commands earlier?  While their
> > > predecessors are still in flight?
> > 
> > Not sure I follow... You mean if someone attempts to queue and fails
> > because we are out of commands, then try and reap some done commands?
> 
> Rather than waiting for all commands to complete then freeing them all
> up, it might be possible to free some of them earlier, while the rest
> are still in flight.  Pipeline the reaping with the I/O completion.  A
> minor saving in cycles and memory, perhaps.   Probably it's not worth
> the complexity - I was just asking ;)

For the example above, it's the final shutdown case just waiting for all
commands to complete. So definitely not worth extra complexity :-)

-- 
Jens Axboe


  reply	other threads:[~2006-03-06  9:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-02 11:19 [PATCH] bsg, block layer sg Jens Axboe
2006-03-02 11:22 ` Jeff Garzik
2006-03-05  2:08 ` Andrew Morton
2006-03-06  8:57   ` Jens Axboe
2006-03-06  9:13     ` Andrew Morton
2006-03-06  9:19       ` Jens Axboe [this message]
2006-03-06  9:25         ` Jens Axboe
2006-03-06 18:30 ` Erik Andersen
2006-03-06 18:57   ` Jens Axboe

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=20060306091959.GZ4329@suse.de \
    --to=axboe@suse.de \
    --cc=akpm@osdl.org \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    /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.