]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[downloader] Profile receive datapath
authorMichael Brown <mcb30@ipxe.org>
Mon, 28 Apr 2014 11:31:39 +0000 (12:31 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 28 Apr 2014 11:31:39 +0000 (12:31 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/downloader.c

index cec6625ba84d497a76650ba83637a9bac6791a5e..ec69db6b188b2d8a819b6b54a43b54cb202d9a78 100644 (file)
@@ -29,6 +29,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <ipxe/uaccess.h>
 #include <ipxe/umalloc.h>
 #include <ipxe/image.h>
+#include <ipxe/profile.h>
 #include <ipxe/downloader.h>
 
 /** @file
@@ -37,6 +38,14 @@ FILE_LICENCE ( GPL2_OR_LATER );
  *
  */
 
+/** Receive profiler */
+static struct profiler downloader_rx_profiler __profiler =
+       { .name = "downloader.rx" };
+
+/** Data copy profiler */
+static struct profiler downloader_copy_profiler __profiler =
+       { .name = "downloader.copy" };
+
 /** A downloader */
 struct downloader {
        /** Reference count for this object */
@@ -166,6 +175,9 @@ static int downloader_xfer_deliver ( struct downloader *downloader,
        size_t max;
        int rc;
 
+       /* Start profiling */
+       profile_start ( &downloader_rx_profiler );
+
        /* Calculate new buffer position */
        if ( meta->flags & XFER_FL_ABS_OFFSET )
                downloader->pos = 0;
@@ -178,8 +190,10 @@ static int downloader_xfer_deliver ( struct downloader *downloader,
                goto done;
 
        /* Copy data to buffer */
+       profile_start ( &downloader_copy_profiler );
        copy_to_user ( downloader->image->data, downloader->pos,
                       iobuf->data, len );
+       profile_stop ( &downloader_copy_profiler );
 
        /* Update current buffer position */
        downloader->pos += len;
@@ -188,6 +202,7 @@ static int downloader_xfer_deliver ( struct downloader *downloader,
        free_iob ( iobuf );
        if ( rc != 0 )
                downloader_finished ( downloader, rc );
+       profile_stop ( &downloader_rx_profiler );
        return rc;
 }