summaryrefslogtreecommitdiffstats
path: root/sys/dev/ata/ata-queue.c
diff options
context:
space:
mode:
authorsos <sos@FreeBSD.org>2004-01-14 21:26:35 +0000
committersos <sos@FreeBSD.org>2004-01-14 21:26:35 +0000
commit894449cd93a70b82e4c6349b4a39db9744f1d10c (patch)
treeab783629baab236719afb9f4d2d98f0bd972552f /sys/dev/ata/ata-queue.c
parent8eb3bce2502df28a9ecaba98f09cdee00ec60ad0 (diff)
downloadFreeBSD-src-894449cd93a70b82e4c6349b4a39db9744f1d10c.zip
FreeBSD-src-894449cd93a70b82e4c6349b4a39db9744f1d10c.tar.gz
Use UMA instead of plain malloc for getting ATA request storage.
This gives +10% performance on simple tests, so definitly worth it. A few percent more could be had by not using M_ZERO'd alloc's, but we then need to clear fields all over the place to be safe, and that was deemed not worth the trouble (and it makes life dangerous).
Diffstat (limited to 'sys/dev/ata/ata-queue.c')
-rw-r--r--sys/dev/ata/ata-queue.c33
1 files changed, 6 insertions, 27 deletions
diff --git a/sys/dev/ata/ata-queue.c b/sys/dev/ata/ata-queue.c
index aa47437..ca43afd 100644
--- a/sys/dev/ata/ata-queue.c
+++ b/sys/dev/ata/ata-queue.c
@@ -34,11 +34,11 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/ata.h>
#include <sys/kernel.h>
-#include <sys/malloc.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/sema.h>
#include <sys/taskqueue.h>
+#include <vm/uma.h>
#include <machine/bus.h>
#include <sys/rman.h>
#include <dev/ata/ata-all.h>
@@ -48,36 +48,13 @@ static void ata_completed(void *, int);
static void ata_timeout(struct ata_request *);
static char *ata_skey2str(u_int8_t);
-/* local vars */
-static MALLOC_DEFINE(M_ATA_REQ, "ATA request", "ATA request");
-
-/*
- * ATA request related functions
- */
-struct ata_request *
-ata_alloc_request(void)
-{
- struct ata_request *request;
-
- request = malloc(sizeof(struct ata_request), M_ATA_REQ, M_NOWAIT | M_ZERO);
- if (!request)
- printf("FAILURE - malloc ATA request failed\n");
- sema_init(&request->done, 0, "ATA request done");
- return request;
-}
-
-void
-ata_free_request(struct ata_request *request)
-{
- sema_destroy(&request->done);
- free(request, M_ATA_REQ);
-}
-
void
ata_queue_request(struct ata_request *request)
{
- /* mark request as virgin (it might be a retry) */
+ /* mark request as virgin */
request->result = request->status = request->error = 0;
+ if (!request->callback)
+ sema_init(&request->done, 0, "ATA request done");
if (request->device->channel->flags & ATA_IMMEDIATE_MODE) {
@@ -122,6 +99,8 @@ ata_queue_request(struct ata_request *request)
sema_wait(&request->done);
}
}
+ if (!request->callback)
+ sema_destroy(&request->done);
}
int
OpenPOWER on IntegriCloud