From owner-svn-src-head@freebsd.org Fri Oct 26 16:23:53 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 665AA10EAFC8; Fri, 26 Oct 2018 16:23:53 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1C3737D629; Fri, 26 Oct 2018 16:23:53 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F145423648; Fri, 26 Oct 2018 16:23:52 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9QGNq8Q047427; Fri, 26 Oct 2018 16:23:52 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9QGNqwu047424; Fri, 26 Oct 2018 16:23:52 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201810261623.w9QGNqwu047424@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 26 Oct 2018 16:23:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r339777 - in head/sys/cam: ata nvme scsi X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: in head/sys/cam: ata nvme scsi X-SVN-Commit-Revision: 339777 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Oct 2018 16:23:53 -0000 Author: imp Date: Fri Oct 26 16:23:51 2018 New Revision: 339777 URL: https://svnweb.freebsd.org/changeset/base/339777 Log: Add statistics for TRIM comands Add a counter for the LBAs, Ranges and hardware commands so that we can provide additional color to the statistics we provide to vendors. Sponsored by: Netflix, Inc Modified: head/sys/cam/ata/ata_da.c head/sys/cam/nvme/nvme_da.c head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/ata/ata_da.c ============================================================================== --- head/sys/cam/ata/ata_da.c Fri Oct 26 16:03:30 2018 (r339776) +++ head/sys/cam/ata/ata_da.c Fri Oct 26 16:23:51 2018 (r339777) @@ -251,6 +251,9 @@ struct ada_softc { struct sysctl_oid *sysctl_tree; struct callout sendordered_c; struct trim_request trim_req; + uint64_t trim_count; + uint64_t trim_ranges; + uint64_t trim_lbas; #ifdef CAM_IO_STATS struct sysctl_ctx_list sysctl_stats_ctx; struct sysctl_oid *sysctl_stats_tree; @@ -1440,6 +1443,18 @@ adasysctlinit(void *context, int pending) OID_AUTO, "delete_method", CTLTYPE_STRING | CTLFLAG_RW, softc, 0, adadeletemethodsysctl, "A", "BIO_DELETE execution method"); + SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, + SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, + "trim_count", CTLFLAG_RD, &softc->trim_count, + "Total number of dsm commands sent"); + SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, + SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, + "trim_ranges", CTLFLAG_RD, &softc->trim_ranges, + "Total number of ranges in dsm commands"); + SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, + SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, + "trim_lbas", CTLFLAG_RD, &softc->trim_lbas, + "Total lbas in the dsm commands sent"); SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "read_ahead", CTLFLAG_RW | CTLFLAG_MPSAFE, &softc->read_ahead, 0, "Enable disk read ahead."); @@ -1918,7 +1933,7 @@ adaregister(struct cam_periph *periph, void *arg) static int ada_dsmtrim_req_create(struct ada_softc *softc, struct bio *bp, struct trim_request *req) { - uint64_t lastlba = (uint64_t)-1; + uint64_t lastlba = (uint64_t)-1, lbas = 0; int c, lastcount = 0, off, ranges = 0; bzero(req, sizeof(*req)); @@ -1937,6 +1952,7 @@ ada_dsmtrim_req_create(struct ada_softc *softc, struct (lastcount >> 8) & 0xff; count -= c; lba += c; + lbas += c; } while (count > 0) { @@ -1951,6 +1967,7 @@ ada_dsmtrim_req_create(struct ada_softc *softc, struct req->data[off + 6] = c & 0xff; req->data[off + 7] = (c >> 8) & 0xff; lba += c; + lbas += c; count -= c; lastcount = c; ranges++; @@ -1972,6 +1989,9 @@ ada_dsmtrim_req_create(struct ada_softc *softc, struct break; } } while (1); + softc->trim_count++; + softc->trim_ranges += ranges; + softc->trim_lbas += lbas; return (ranges); } Modified: head/sys/cam/nvme/nvme_da.c ============================================================================== --- head/sys/cam/nvme/nvme_da.c Fri Oct 26 16:03:30 2018 (r339776) +++ head/sys/cam/nvme/nvme_da.c Fri Oct 26 16:23:51 2018 (r339777) @@ -105,12 +105,14 @@ struct nda_softc { nda_quirks quirks; int unmappedio; quad_t deletes; - quad_t dsm_req; uint32_t nsid; /* Namespace ID for this nda device */ struct disk *disk; struct task sysctl_task; struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; + uint64_t trim_count; + uint64_t trim_ranges; + uint64_t trim_lbas; #ifdef CAM_TEST_FAILURE int force_read_error; int force_write_error; @@ -637,9 +639,18 @@ ndasysctlinit(void *context, int pending) OID_AUTO, "deletes", CTLFLAG_RD, &softc->deletes, "Number of BIO_DELETE requests"); - SYSCTL_ADD_QUAD(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), - OID_AUTO, "dsm_req", CTLFLAG_RD, - &softc->dsm_req, "Number of DSM requests sent to SIM"); + SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, + SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, + "trim_count", CTLFLAG_RD, &softc->trim_count, + "Total number of unmap/dsm commands sent"); + SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, + SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, + "trim_ranges", CTLFLAG_RD, &softc->trim_ranges, + "Total number of ranges in unmap/dsm commands"); + SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, + SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, + "trim_lbas", CTLFLAG_RD, &softc->trim_lbas, + "Total lbas in the unmap/dsm commands sent"); SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "rotating", CTLFLAG_RD, &nda_rotating_media, 1, @@ -939,6 +950,7 @@ ndastart(struct cam_periph *periph, union ccb *start_c struct nda_trim_request *trim; struct bio *bp1; int ents; + uint32_t totalcount = 0, ranges = 0; trim = malloc(sizeof(*trim), M_NVMEDA, M_ZERO | M_NOWAIT); if (trim == NULL) { @@ -959,6 +971,8 @@ ndastart(struct cam_periph *periph, union ccb *start_c htole32(bp1->bio_bcount / softc->disk->d_sectorsize); dsm_range->starting_lba = htole64(bp1->bio_offset / softc->disk->d_sectorsize); + ranges++; + totalcount += dsm_range->length; dsm_range++; if (dsm_range >= dsm_end) break; @@ -967,10 +981,12 @@ ndastart(struct cam_periph *periph, union ccb *start_c /* XXX -- Could limit based on total payload size */ } while (bp1 != NULL); start_ccb->ccb_trim = trim; - softc->dsm_req++; nda_nvme_trim(softc, &start_ccb->nvmeio, &trim->dsm, dsm_range - &trim->dsm); start_ccb->ccb_state = NDA_CCB_TRIM; + softc->trim_count++; + softc->trim_ranges += ranges; + softc->trim_lbas += totalcount; /* * Note: We can have multiple TRIMs in flight, so we don't call * cam_iosched_submit_trim(softc->cam_iosched); Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Fri Oct 26 16:03:30 2018 (r339776) +++ head/sys/cam/scsi/scsi_da.c Fri Oct 26 16:23:51 2018 (r339777) @@ -334,6 +334,9 @@ struct da_softc { uint32_t unmap_gran; uint32_t unmap_gran_align; uint64_t ws_max_blks; + uint64_t trim_count; + uint64_t trim_ranges; + uint64_t trim_lbas; da_delete_methods delete_method_pref; da_delete_methods delete_method; da_delete_func_t *delete_func; @@ -2182,6 +2185,18 @@ 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_UQUAD(&softc->sysctl_ctx, + SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, + "trim_count", CTLFLAG_RD, &softc->trim_count, + "Total number of unmap/dsm commands sent"); + SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, + SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, + "trim_ranges", CTLFLAG_RD, &softc->trim_ranges, + "Total number of ranges in unmap/dsm commands"); + SYSCTL_ADD_UQUAD(&softc->sysctl_ctx, + SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, + "trim_lbas", CTLFLAG_RD, &softc->trim_lbas, + "Total lbas in the unmap/dsm commands sent"); SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "zone_mode", CTLTYPE_STRING | CTLFLAG_RD, @@ -3934,6 +3949,9 @@ da_delete_unmap(struct cam_periph *periph, union ccb * da_default_timeout * 1000); ccb->ccb_h.ccb_state = DA_CCB_DELETE; ccb->ccb_h.flags |= CAM_UNLOCKED; + softc->trim_count++; + softc->trim_ranges += ranges; + softc->trim_lbas += totalcount; cam_iosched_submit_trim(softc->cam_iosched); }