block: optimize generic_unplug_device()

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git-commits-head@...>
Date: Thursday, May 8, 2008 - 5:59 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=dbaf2c...
Commit:     dbaf2c003e151ad9231778819b0977f95e20e06f
Parent:     2cdf79cafbd11580f5b63cd4993b45c1c4952415
Author:     Jens Axboe <jens.axboe@oracle.com>
AuthorDate: Wed May 7 09:48:17 2008 +0200
Committer:  Jens Axboe <jens.axboe@oracle.com>
CommitDate: Wed May 7 09:48:17 2008 +0200

    block: optimize generic_unplug_device()
    
    Original patch from Mikulas Patocka <mpatocka@redhat.com>
    
    Mike Anderson was doing an OLTP benchmark on a computer with 48 physical
    disks mapped to one logical device via device mapper.
    
    He found that there was a slowdown on request_queue->lock in function
    generic_unplug_device. The slowdown is caused by the fact that when some
    code calls unplug on the device mapper, device mapper calls unplug on all
    physical disks. These unplug calls take the lock, find that the queue is
    already unplugged, release the lock and exit.
    
    With the below patch, performance of the benchmark was increased by 18%
    (the whole OLTP application, not just block layer microbenchmarks).
    
    So I'm submitting this patch for upstream. I think the patch is correct,
    because when more threads call simultaneously plug and unplug, it is
    unspecified, if the queue is or isn't plugged (so the patch can't make
    this worse). And the caller that plugged the queue should unplug it
    anyway. (if it doesn't, there's 3ms timeout).
    
    Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
    Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
---
 block/blk-core.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index b754a4a..1b7dddf 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -253,9 +253,11 @@ EXPORT_SYMBOL(__generic_unplug_device);
  **/
 void generic_unplug_device(struct request_queue *q)
 {
-	spin_lock_irq(q->queue_lock);
-	__generic_unplug_device(q);
-	spin_unlock_irq(q->queue_lock);
+	if (blk_queue_plugged(q)) {
+		spin_lock_irq(q->queue_lock);
+		__generic_unplug_device(q);
+		spin_unlock_irq(q->queue_lock);
+	}
 }
 EXPORT_SYMBOL(generic_unplug_device);
 
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
block: optimize generic_unplug_device(), Linux Kernel Mailing List..., (Thu May 8, 5:59 pm)