From: Anton Ivanov <antiv...@cisco.com>

Obvious performance optimization - it is not necessary
to read the requests one at a time in the IRQ handler

Signed-off-by: Anton Ivanov <antiv...@cisco.com>
---
 arch/um/drivers/ubd_kern.c |   29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 35ba00b..8568290 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -443,6 +443,8 @@ static void do_ubd_request(struct request_queue * q);
 static int thread_fd = -1;
 static LIST_HEAD(restart);
 
+static struct io_thread_req  * ubd_request_list[MAX_SG];
+
 /* XXX - move this inside ubd_intr. */
 /* Called without dev->lock held, and only in interrupt context. */
 static void ubd_handler(void)
@@ -451,21 +453,34 @@ static void ubd_handler(void)
        struct ubd *ubd;
        struct list_head *list, *next_ele;
        unsigned long flags;
-       int n;
+       int n, i;
+
+       /*
+        * obvious optimization - we do not need to read the reqs one at a time
+        * we can read all pending reqs in one interrupt and handle them in bulk
+        */
 
        while(1){
-               n = os_read_file(thread_fd, &req,
-                                sizeof(struct io_thread_req *));
-               if(n != sizeof(req)){
+        do {
+               n = os_read_file(thread_fd, &ubd_request_list,
+                                sizeof(struct io_thread_req *) * MAX_SG);
+        } while (n == -EINTR);
+               if(n < 0){
                        if(n == -EAGAIN)
                                break;
                        printk(KERN_ERR "spurious interrupt in ubd_handler, "
                               "err = %d\n", -n);
                        return;
+               } else if (n % sizeof(struct io_thread_req *) != 0)  {
+                       printk(KERN_ERR "spurious interrupt in ubd_handler, "
+                              "err = %d\n", -n);
+                       return;
+               }
+               for (i = 0; i < n / sizeof(struct io_thread_req *); i++) {
+                       req = ubd_request_list[i];
+                       blk_end_request(req->req, 0, req->length);
+                       kfree(req);
                }
-
-               blk_end_request(req->req, 0, req->length);
-               kfree(req);
        }
 
        list_for_each_safe(list, next_ele, &restart){
-- 
1.7.10.4


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

Reply via email to