[Midnightbsd-cvs] src [9475] trunk/sys/cam: Add the ability to enable / disable sorting of BIO requests
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Mar 5 14:47:59 EST 2017
Revision: 9475
http://svnweb.midnightbsd.org/src/?rev=9475
Author: laffer1
Date: 2017-03-05 14:47:59 -0500 (Sun, 05 Mar 2017)
Log Message:
-----------
Add the ability to enable / disable sorting of BIO requests
Modified Paths:
--------------
trunk/sys/cam/ata/ata_da.c
trunk/sys/cam/cam.c
trunk/sys/cam/cam.h
trunk/sys/cam/scsi/scsi_da.c
Modified: trunk/sys/cam/ata/ata_da.c
===================================================================
--- trunk/sys/cam/ata/ata_da.c 2017-03-05 19:47:35 UTC (rev 9474)
+++ trunk/sys/cam/ata/ata_da.c 2017-03-05 19:47:59 UTC (rev 9475)
@@ -131,6 +131,7 @@
ada_state state;
ada_flags flags;
ada_quirks quirks;
+ int sort_io_queue;
int ordered_tag_count;
int outstanding_cmds;
int trim_max_ranges;
@@ -596,6 +597,8 @@
softc->read_ahead : ada_read_ahead)
#define ADA_WC (softc->write_cache >= 0 ? \
softc->write_cache : ada_write_cache)
+#define ADA_SIO (softc->sort_io_queue >= 0 ? \
+ softc->sort_io_queue : cam_sort_io_queues)
/*
* Most platforms map firmware geometry to actual, but some don't. If
@@ -806,10 +809,17 @@
* Place it in the queue of disk activities for this disk
*/
if (bp->bio_cmd == BIO_DELETE &&
- (softc->flags & ADA_FLAG_CAN_TRIM))
- bioq_disksort(&softc->trim_queue, bp);
- else
- bioq_disksort(&softc->bio_queue, bp);
+ (softc->flags & ADA_FLAG_CAN_TRIM)) {
+ if (ADA_SIO)
+ bioq_disksort(&softc->trim_queue, bp);
+ else
+ bioq_insert_tail(&softc->trim_queue, bp);
+ } else {
+ if (ADA_SIO)
+ bioq_disksort(&softc->bio_queue, bp);
+ else
+ bioq_insert_tail(&softc->bio_queue, bp);
+ }
/*
* Schedule ourselves for performing the work.
@@ -1156,6 +1166,10 @@
SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "write_cache", CTLFLAG_RW | CTLFLAG_MPSAFE,
&softc->write_cache, 0, "Enable disk write cache.");
+ SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
+ OID_AUTO, "sort_io_queue", CTLFLAG_RW | CTLFLAG_MPSAFE,
+ &softc->sort_io_queue, 0,
+ "Sort IO queue to try and optimise disk access patterns");
#ifdef ADA_TEST_FAILURE
/*
* Add a 'door bell' sysctl which allows one to set it from userland
@@ -1291,6 +1305,7 @@
snprintf(announce_buf, sizeof(announce_buf),
"kern.cam.ada.%d.write_cache", periph->unit_number);
TUNABLE_INT_FETCH(announce_buf, &softc->write_cache);
+ softc->sort_io_queue = -1;
adagetparams(periph, cgd);
softc->disk = disk_alloc();
softc->disk->d_devstat = devstat_new_entry(periph->periph_name,
Modified: trunk/sys/cam/cam.c
===================================================================
--- trunk/sys/cam/cam.c 2017-03-05 19:47:35 UTC (rev 9474)
+++ trunk/sys/cam/cam.c 2017-03-05 19:47:59 UTC (rev 9475)
@@ -110,8 +110,17 @@
#ifdef _KERNEL
SYSCTL_NODE(_kern, OID_AUTO, cam, CTLFLAG_RD, 0, "CAM Subsystem");
+
+#ifndef CAM_DEFAULT_SORT_IO_QUEUES
+#define CAM_DEFAULT_SORT_IO_QUEUES 1
#endif
+int cam_sort_io_queues = CAM_DEFAULT_SORT_IO_QUEUES;
+TUNABLE_INT("kern.cam.sort_io_queues", &cam_sort_io_queues);
+SYSCTL_INT(_kern_cam, OID_AUTO, sort_io_queues, CTLFLAG_RWTUN,
+ &cam_sort_io_queues, 0, "Sort IO queues to try and optimise disk access patterns");
+#endif
+
void
cam_strvis(u_int8_t *dst, const u_int8_t *src, int srclen, int dstlen)
{
Modified: trunk/sys/cam/cam.h
===================================================================
--- trunk/sys/cam/cam.h 2017-03-05 19:47:35 UTC (rev 9474)
+++ trunk/sys/cam/cam.h 2017-03-05 19:47:59 UTC (rev 9475)
@@ -228,6 +228,9 @@
extern const struct cam_status_entry cam_status_table[];
extern const int num_cam_status_entries;
+#ifdef _KERNEL
+extern int cam_sort_io_queues;
+#endif
union ccb;
#ifdef SYSCTL_DECL /* from sysctl.h */
Modified: trunk/sys/cam/scsi/scsi_da.c
===================================================================
--- trunk/sys/cam/scsi/scsi_da.c 2017-03-05 19:47:35 UTC (rev 9474)
+++ trunk/sys/cam/scsi/scsi_da.c 2017-03-05 19:47:59 UTC (rev 9475)
@@ -145,6 +145,7 @@
da_state state;
da_flags flags;
da_quirks quirks;
+ int sort_io_queue;
int minimum_cmd_size;
int error_inject;
int ordered_tag_count;
@@ -903,6 +904,8 @@
#define DA_DEFAULT_SEND_ORDERED 1
#endif
+#define DA_SIO (softc->sort_io_queue >= 0 ? \
+ softc->sort_io_queue : cam_sort_io_queues)
static int da_poll_period = DA_DEFAULT_POLL_PERIOD;
static int da_retry_count = DA_DEFAULT_RETRY;
@@ -1129,10 +1132,15 @@
if (bp->bio_cmd == BIO_DELETE) {
if (bp->bio_bcount == 0)
biodone(bp);
+ else if (DA_SIO)
+ bioq_disksort(&softc->delete_queue, bp);
else
- bioq_disksort(&softc->delete_queue, bp);
- } else
+ bioq_insert_tail(&softc->delete_queue, bp);
+ } else if (DA_SIO) {
bioq_disksort(&softc->bio_queue, bp);
+ } else {
+ bioq_insert_tail(&softc->bio_queue, bp);
+ }
/*
* Schedule ourselves for performing the work.
@@ -1487,6 +1495,9 @@
OID_AUTO, "minimum_cmd_size", CTLTYPE_INT | CTLFLAG_RW,
&softc->minimum_cmd_size, 0, dacmdsizesysctl, "I",
"Minimum CDB size");
+ SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
+ OID_AUTO, "sort_io_queue", CTLFLAG_RW, &softc->sort_io_queue, 0,
+ "Sort IO queue to try and optimise disk access patterns");
SYSCTL_ADD_INT(&softc->sysctl_ctx,
SYSCTL_CHILDREN(softc->sysctl_tree),
@@ -1634,6 +1645,7 @@
softc->flags |= DA_FLAG_PACK_REMOVABLE;
softc->unmap_max_ranges = UNMAP_MAX_RANGES;
softc->unmap_max_lba = 1024*1024*2;
+ softc->sort_io_queue = -1;
periph->softc = softc;
@@ -2109,9 +2121,16 @@
dadeletemethodset(softc, DA_DELETE_DISABLE);
} else
dadeletemethodset(softc, DA_DELETE_DISABLE);
- while ((bp = bioq_takefirst(&softc->delete_run_queue))
- != NULL)
- bioq_disksort(&softc->delete_queue, bp);
+
+ if (DA_SIO) {
+ while ((bp = bioq_takefirst(&softc->delete_run_queue))
+ != NULL)
+ bioq_disksort(&softc->delete_queue, bp);
+ } else {
+ while ((bp = bioq_takefirst(&softc->delete_run_queue))
+ != NULL)
+ bioq_insert_tail(&softc->delete_queue, bp);
+ }
bioq_insert_tail(&softc->delete_queue,
(struct bio *)ccb->ccb_h.ccb_bp);
ccb->ccb_h.ccb_bp = NULL;
More information about the Midnightbsd-cvs
mailing list