From owner-svn-src-stable@FreeBSD.ORG Thu Jun 6 10:06:33 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8230A4EA; Thu, 6 Jun 2013 10:06:33 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7217516A8; Thu, 6 Jun 2013 10:06:33 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r56A6X8V090904; Thu, 6 Jun 2013 10:06:33 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r56A6WcB090896; Thu, 6 Jun 2013 10:06:32 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306061006.r56A6WcB090896@svn.freebsd.org> From: Steven Hartland Date: Thu, 6 Jun 2013 10:06:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r251462 - in stable/8/sys/cam: . ata scsi X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2013 10:06:33 -0000 Author: smh Date: Thu Jun 6 10:06:32 2013 New Revision: 251462 URL: http://svnweb.freebsd.org/changeset/base/251462 Log: MFC r248922: Adds the ability to enable / disable sorting of BIO requests Modified: stable/8/sys/cam/ata/ata_da.c stable/8/sys/cam/cam.c stable/8/sys/cam/cam.h stable/8/sys/cam/scsi/scsi_da.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/cam/ (props changed) Modified: stable/8/sys/cam/ata/ata_da.c ============================================================================== --- stable/8/sys/cam/ata/ata_da.c Thu Jun 6 10:00:22 2013 (r251461) +++ stable/8/sys/cam/ata/ata_da.c Thu Jun 6 10:06:32 2013 (r251462) @@ -130,6 +130,7 @@ struct ada_softc { ada_state state; ada_flags flags; ada_quirks quirks; + int sort_io_queue; int ordered_tag_count; int outstanding_cmds; int trim_max_ranges; @@ -443,6 +444,8 @@ static void adashutdown(void *arg, int 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 @@ -660,10 +663,17 @@ adastrategy(struct bio *bp) * 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. @@ -967,6 +977,10 @@ adasysctlinit(void *context, int pending 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 @@ -1088,6 +1102,7 @@ adaregister(struct cam_periph *periph, v 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: stable/8/sys/cam/cam.c ============================================================================== --- stable/8/sys/cam/cam.c Thu Jun 6 10:00:22 2013 (r251461) +++ stable/8/sys/cam/cam.c Thu Jun 6 10:06:32 2013 (r251462) @@ -103,6 +103,15 @@ const int num_cam_status_entries = #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 Modified: stable/8/sys/cam/cam.h ============================================================================== --- stable/8/sys/cam/cam.h Thu Jun 6 10:00:22 2013 (r251461) +++ stable/8/sys/cam/cam.h Thu Jun 6 10:06:32 2013 (r251462) @@ -212,6 +212,9 @@ struct cam_status_entry 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: stable/8/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/8/sys/cam/scsi/scsi_da.c Thu Jun 6 10:00:22 2013 (r251461) +++ stable/8/sys/cam/scsi/scsi_da.c Thu Jun 6 10:06:32 2013 (r251462) @@ -141,6 +141,7 @@ struct da_softc { da_state state; da_flags flags; da_quirks quirks; + int sort_io_queue; int minimum_cmd_size; int error_inject; int ordered_tag_count; @@ -885,6 +886,8 @@ static void dashutdown(void *arg, int h #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_retry_count = DA_DEFAULT_RETRY; static int da_default_timeout = DA_DEFAULT_TIMEOUT; @@ -1137,10 +1140,15 @@ dastrategy(struct bio *bp) if (bp->bio_cmd == BIO_DELETE) { if (bp->bio_bcount == 0) biodone(bp); - else + else if (DA_SIO) bioq_disksort(&softc->delete_queue, bp); - } else + 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. @@ -1428,6 +1436,9 @@ dasysctlinit(void *context, int pending) 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"); /* * Add some addressing info. @@ -1567,6 +1578,7 @@ daregister(struct cam_periph *periph, vo 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; @@ -1985,9 +1997,16 @@ cmd6workaround(union ccb *ccb) 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;