From owner-svn-src-all@freebsd.org Tue Dec 17 00:11:49 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 095031D2A47; Tue, 17 Dec 2019 00:11:49 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47cJTw6PWNz4VSk; Tue, 17 Dec 2019 00:11:48 +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 D699555AD; Tue, 17 Dec 2019 00:11:48 +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 xBH0Bmw1088827; Tue, 17 Dec 2019 00:11:48 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBH0Bm5I088826; Tue, 17 Dec 2019 00:11:48 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201912170011.xBH0Bm5I088826@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Tue, 17 Dec 2019 00:11:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355831 - head/sys/cam/nvme X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/cam/nvme X-SVN-Commit-Revision: 355831 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Dec 2019 00:11:49 -0000 Author: imp Date: Tue Dec 17 00:11:48 2019 New Revision: 355831 URL: https://svnweb.freebsd.org/changeset/base/355831 Log: NVME trim stuff. Add two sysctls to control pacing of nvme trims. kern.cam.nda.X.goal_trim is the number of upper layer BIO_DEELETE requests to try to collecet before sending TRIM down too the nvme drive. trim_ticks is the number of ticks, at mosot, to wait for at least goal_trim BIOS_DELEETE requests to come in. Trim pacing is useful when a large number off disjoint trims are comoing in from the upper layers. Since we have no way to chain toogether trims from the upper layers that are sent down, this acts as a hueristic to group trims into reasonable sized chunks. What's reasonable varies from drive to drive. Sponsored by: Netflix Modified: head/sys/cam/nvme/nvme_da.c Modified: head/sys/cam/nvme/nvme_da.c ============================================================================== --- head/sys/cam/nvme/nvme_da.c Tue Dec 17 00:10:19 2019 (r355830) +++ head/sys/cam/nvme/nvme_da.c Tue Dec 17 00:11:48 2019 (r355831) @@ -177,6 +177,14 @@ static int nda_max_trim_entries = NDA_MAX_TRIM_ENTRIES SYSCTL_INT(_kern_cam_nda, OID_AUTO, max_trim, CTLFLAG_RDTUN, &nda_max_trim_entries, NDA_MAX_TRIM_ENTRIES, "Maximum number of BIO_DELETE to send down as a DSM TRIM."); +static int nda_goal_trim_entries = NDA_MAX_TRIM_ENTRIES / 2; +SYSCTL_INT(_kern_cam_nda, OID_AUTO, goal_trim, CTLFLAG_RDTUN, + &nda_goal_trim_entries, NDA_MAX_TRIM_ENTRIES / 2, + "Number of BIO_DELETE to try to accumulate before sending a DSM TRIM."); +static int nda_trim_ticks = 50; /* 50ms ~ 1000 Hz */ +SYSCTL_INT(_kern_cam_nda, OID_AUTO, trim_ticks, CTLFLAG_RDTUN, + &nda_trim_ticks, 50, + "Number of ticks to hold BIO_DELETEs before sending down a trim"); /* * All NVMe media is non-rotational, so all nvme device instances @@ -741,6 +749,9 @@ ndaregister(struct cam_periph *periph, void *arg) free(softc, M_DEVBUF); return(CAM_REQ_CMP_ERR); } + /* Statically set these for the moment */ + cam_iosched_set_trim_goal(softc->cam_iosched, nda_goal_trim_entries); + cam_iosched_set_trim_ticks(softc->cam_iosched, nda_trim_ticks); /* ident_data parsing */