aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/cam_queue.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2013-10-21 12:00:26 +0000
committerAlexander Motin <mav@FreeBSD.org>2013-10-21 12:00:26 +0000
commit227d67aa5469398eb77e5eca2e525e6aae7b3a61 (patch)
tree2241bb08977b8fb8347e216b1dd8011b6627f617 /sys/cam/cam_queue.c
parente45e2255e88f6ce44bae133e7e59910ac4e1177d (diff)
downloadsrc-227d67aa5469398eb77e5eca2e525e6aae7b3a61.tar.gz
src-227d67aa5469398eb77e5eca2e525e6aae7b3a61.zip
Merge CAM locking changes from the projects/camlock branch to radically
reduce lock congestion and improve SMP scalability of the SCSI/ATA stack, preparing the ground for the coming next GEOM direct dispatch support. Replace big per-SIM locks with bunch of smaller ones: - per-LUN locks to protect device and peripheral drivers state; - per-target locks to protect list of LUNs on target; - per-bus locks to protect reference counting; - per-send queue locks to protect queue of CCBs to be sent; - per-done queue locks to protect queue of completed CCBs; - remaining per-SIM locks now protect only HBA driver internals. While holding LUN lock it is allowed (while not recommended for performance reasons) to take SIM lock. The opposite acquisition order is forbidden. All the other locks are leaf locks, that can be taken anywhere, but should not be cascaded. Many functions, such as: xpt_action(), xpt_done(), xpt_async(), xpt_create_path(), etc. are no longer require (but allow) SIM lock to be held. To keep compatibility and solve cases where SIM lock can't be dropped, all xpt_async() calls in addition to xpt_done() calls are queued to completion threads for async processing in clean environment without SIM lock held. Instead of single CAM SWI thread, used for commands completion processing before, use multiple (depending on number of CPUs) threads. Load balanced between them using "hash" of the device B:T:L address. HBA drivers that can drop SIM lock during completion processing and have sufficient number of completion threads to efficiently scale to multiple CPUs can use new function xpt_done_direct() to avoid extra context switch. Make ahci(4) driver to use this mechanism depending on hardware setup. Sponsored by: iXsystems, Inc. MFC after: 2 months
Notes
Notes: svn path=/head/; revision=256843
Diffstat (limited to 'sys/cam/cam_queue.c')
-rw-r--r--sys/cam/cam_queue.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/sys/cam/cam_queue.c b/sys/cam/cam_queue.c
index daaa9b3f7e9f..f6624f30f068 100644
--- a/sys/cam/cam_queue.c
+++ b/sys/cam/cam_queue.c
@@ -220,27 +220,30 @@ cam_devq_alloc(int devices, int openings)
}
if (cam_devq_init(devq, devices, openings) != 0) {
free(devq, M_CAMDEVQ);
- return (NULL);
+ return (NULL);
}
-
return (devq);
}
int
cam_devq_init(struct cam_devq *devq, int devices, int openings)
{
+
bzero(devq, sizeof(*devq));
+ mtx_init(&devq->send_mtx, "CAM queue lock", NULL, MTX_DEF);
if (camq_init(&devq->send_queue, devices) != 0)
return (1);
devq->send_openings = openings;
- devq->send_active = 0;
- return (0);
+ devq->send_active = 0;
+ return (0);
}
void
cam_devq_free(struct cam_devq *devq)
{
+
camq_fini(&devq->send_queue);
+ mtx_destroy(&devq->send_mtx);
free(devq, M_CAMDEVQ);
}
@@ -286,6 +289,7 @@ cam_ccbq_resize(struct cam_ccbq *ccbq, int new_size)
int delta;
delta = new_size - (ccbq->dev_active + ccbq->dev_openings);
+ ccbq->total_openings += delta;
ccbq->devq_openings += delta;
ccbq->dev_openings += delta;
@@ -303,6 +307,7 @@ cam_ccbq_init(struct cam_ccbq *ccbq, int openings)
if (camq_init(&ccbq->queue,
imax(64, 1 << fls(openings + openings / 2))) != 0)
return (1);
+ ccbq->total_openings = openings;
ccbq->devq_openings = openings;
ccbq->dev_openings = openings;
return (0);