mirror of https://github.com/ipxe/ipxe.git
[downloader] Profile receive datapath
Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/17/head
parent
e825a96a25
commit
4e78733094
|
@ -29,6 +29,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
#include <ipxe/uaccess.h>
|
#include <ipxe/uaccess.h>
|
||||||
#include <ipxe/umalloc.h>
|
#include <ipxe/umalloc.h>
|
||||||
#include <ipxe/image.h>
|
#include <ipxe/image.h>
|
||||||
|
#include <ipxe/profile.h>
|
||||||
#include <ipxe/downloader.h>
|
#include <ipxe/downloader.h>
|
||||||
|
|
||||||
/** @file
|
/** @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 */
|
/** A downloader */
|
||||||
struct downloader {
|
struct downloader {
|
||||||
/** Reference count for this object */
|
/** Reference count for this object */
|
||||||
|
@ -166,6 +175,9 @@ static int downloader_xfer_deliver ( struct downloader *downloader,
|
||||||
size_t max;
|
size_t max;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
/* Start profiling */
|
||||||
|
profile_start ( &downloader_rx_profiler );
|
||||||
|
|
||||||
/* Calculate new buffer position */
|
/* Calculate new buffer position */
|
||||||
if ( meta->flags & XFER_FL_ABS_OFFSET )
|
if ( meta->flags & XFER_FL_ABS_OFFSET )
|
||||||
downloader->pos = 0;
|
downloader->pos = 0;
|
||||||
|
@ -178,8 +190,10 @@ static int downloader_xfer_deliver ( struct downloader *downloader,
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* Copy data to buffer */
|
/* Copy data to buffer */
|
||||||
|
profile_start ( &downloader_copy_profiler );
|
||||||
copy_to_user ( downloader->image->data, downloader->pos,
|
copy_to_user ( downloader->image->data, downloader->pos,
|
||||||
iobuf->data, len );
|
iobuf->data, len );
|
||||||
|
profile_stop ( &downloader_copy_profiler );
|
||||||
|
|
||||||
/* Update current buffer position */
|
/* Update current buffer position */
|
||||||
downloader->pos += len;
|
downloader->pos += len;
|
||||||
|
@ -188,6 +202,7 @@ static int downloader_xfer_deliver ( struct downloader *downloader,
|
||||||
free_iob ( iobuf );
|
free_iob ( iobuf );
|
||||||
if ( rc != 0 )
|
if ( rc != 0 )
|
||||||
downloader_finished ( downloader, rc );
|
downloader_finished ( downloader, rc );
|
||||||
|
profile_stop ( &downloader_rx_profiler );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue