aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/cam_periph.h
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2021-05-15 10:17:22 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2021-05-15 11:03:49 +0000
commit3394d4239b85b5577845d9e6de4e97b18d3dba58 (patch)
treef1428b46e132876f64621e0f6660e11d188d5495 /sys/cam/cam_periph.h
parent189f8eea138a78b09c9f19114b1362b0df1cf87d (diff)
downloadsrc-3394d4239b85b5577845d9e6de4e97b18d3dba58.tar.gz
src-3394d4239b85b5577845d9e6de4e97b18d3dba58.zip
cam: allocate CCBs from UMA for SCSI and ATA IO
This patch makes it possible for CAM to use small CCBs allocated from an periph-specific UMA zone instead of the usual, huge ones. The end result is that CCBs issued via da(4) take 544B (size of ccb_scsiio) instead of the usual 2kB (size of 'union ccb', ~1.5kB, rounded up by malloc(9)). For ATA it's 272B. We waste less memory, we avoid zeroing the unused 1kB, and it should be easier to allocate those CCBs in low memory conditions. It should also be possible to use uma_zone_reserve(9) to improve behaviour in low memory conditions even further. Note that this does not change the size, or the layout, of CCBs as such. CCBs get allocated in various different ways, in particular on the stack, and I don't want to redo all that. Instead, this provides an opt-in mechanism for the periph to declare "my start() callback is fine with receiving a CCB allocated from this UMA zone". In other words, most of the code works exactly as it used to; the change only happens to IOs issued by xpt_run_allockq(), which is - conveniently - pretty much all that matters for performance. The reason for doing it this way is that it's pretty small, localized change, and can be implemented gradually and iteratively: take a periph, make sure its start() callback only casts the CCBs it takes to a particular type of CCB, for example ccb_scsiio, and that it only casts CCBs returned by cam_periph_getccb() to that type, then add UMA zone for that size, and declare it safe to XPT. This is disabled by default. Set 'kern.cam.ada.enable_uma_ccbs=1' and 'kern.cam.da.enable_uma_ccbs=1' tunables to enable it. Testing is welcome; I will flip the default to enable in two weeks from now. Reviewed By: imp Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D28674
Diffstat (limited to 'sys/cam/cam_periph.h')
-rw-r--r--sys/cam/cam_periph.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/cam/cam_periph.h b/sys/cam/cam_periph.h
index 15a239decf0a..9c323394797c 100644
--- a/sys/cam/cam_periph.h
+++ b/sys/cam/cam_periph.h
@@ -42,6 +42,8 @@
#include <sys/sysctl.h>
#include <sys/taskqueue.h>
+#include <vm/uma.h>
+
#include <cam/cam_xpt.h>
struct devstat;
@@ -147,6 +149,7 @@ struct cam_periph {
ac_callback_t *deferred_callback;
ac_code deferred_ac;
struct task periph_run_task;
+ uma_zone_t ccb_zone;
};
#define CAM_PERIPH_MAXMAPS 2