From nobody Sat Jul 20 02:59:10 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WQrq45ZnXz5QxZ3; Sat, 20 Jul 2024 02:59:12 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WQrq30BFdz4362; Sat, 20 Jul 2024 02:59:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721444351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bHA81zFaHwihW/riNVa8v1JJS1NwN/4BOgZTAq6Vsm4=; b=kqra7vrkEcZOsl87SeFgxY4X4CWscpzTMF23KsJ6a6EpSxk7gj2f34VSpO6Hj0SYsVoKNN 1jc34QcGBkt72K7XCTs4hH2tLaL1bc9+/XElxQgEorbxnz84Pc74aCvDXI6d7RfYr8pjWw MkRG1VVzUA88ci1+Tr9f3Ap2kQLyIt5YOZycBIcpva9IwOHjJMTZinC3LesQWMmJuBQ+iy QkCjWIdEpL9mgtFCiYuOWSqwQk/Se5sRddC02NmIe7KT8VmzclLogjIsVuB+7/Peg1eUE+ UnJ1P22nJi0yN24b1j0kxG4RR37n9zJ37ilQIV5U2LeKZcbUSSpWR1s9Ya4GFA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721444351; a=rsa-sha256; cv=none; b=flEJhVuXS/h7hTLR/HXofL7+tmTgrcv79yhQxwYB5guOx8Q9JfPb2fvcTd0oq744hua47B G7YaKuCGDjzGstSVOMs6QTHzwTMMjGv+vTIg7s/C4smIJT8vGltpnr/1UsUB6Bc14msMjF k3ch7yX85kQh3uU9goPrMyvGQwILcNOM++m+IGE4MKdWtidLnXf0xs58sxLw2jEBWX6TsC PxoV81VOO8Ag02zAYKFpHraeK/PrgRVbSNzrGFT+TaxJix50GeVMXptpGygCNqij9vZh45 aAucDDOH4xO1P/5QtRIe5uC/X6TuGQrlJvbpdYK65nnr8Dn0L6LojAi2e2BliA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721444351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=bHA81zFaHwihW/riNVa8v1JJS1NwN/4BOgZTAq6Vsm4=; b=xHnCub5jWnTFX3hAFt5tiugQ/m5a/7vs3i6IESjAw6IQKRHAcSpcf/jf/B30L80bQnjSH/ llicnyZ0Ky8s+Kocf0or8UcDXxf7u1RIlt5m664x07N3eMLo8SEqrqgtsD8bEkTfVjn2He qhF9jzLZeCzN9Kb29VN8NBX3taZwOUemilp64BW3jJZjB92ycLncmHjQU5lWxY/cp4Io8X HyUXNqd1oXkVID96IZSXH0tvqtcaslw7EALuKAaIQ46i2118OGJdDhoVgCz/9mwpv5eeaS 2q4PRAuWm9aHoV7ijQCMJbG06fbE9OD4XHlhzVPEUYNlEA+Fr3Geg3TkP1Sepg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WQrq26sw9zytQ; Sat, 20 Jul 2024 02:59:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46K2xAej024600; Sat, 20 Jul 2024 02:59:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46K2xAUc024597; Sat, 20 Jul 2024 02:59:10 GMT (envelope-from git) Date: Sat, 20 Jul 2024 02:59:10 GMT Message-Id: <202407200259.46K2xAUc024597@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 9cbf3d618273 - main - cam/iosched: Make each periph driver provide schedule fnp List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9cbf3d618273e09cdc7e18e878b33b9305836ad8 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=9cbf3d618273e09cdc7e18e878b33b9305836ad8 commit 9cbf3d618273e09cdc7e18e878b33b9305836ad8 Author: Warner Losh AuthorDate: 2024-07-20 02:53:17 +0000 Commit: Warner Losh CommitDate: 2024-07-20 02:53:37 +0000 cam/iosched: Make each periph driver provide schedule fnp When we init the iosched instance, require clients to provide a schedule function. We have almost, but not quite everything to know when it is safe to schedule new I/O. The periph drivers, however, have all the information, so make them do it when the I/O Scheduler needs to maybe schedule I/O for rate limiting, etc. and use it to do that. Sponsored by: Netflix Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D46038 --- sys/cam/ata/ata_da.c | 3 ++- sys/cam/cam_iosched.c | 6 ++++-- sys/cam/cam_iosched.h | 3 ++- sys/cam/nvme/nvme_da.c | 3 ++- sys/cam/scsi/scsi_da.c | 3 ++- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c index 2c1183b74c1d..ae7cf14c8f8e 100644 --- a/sys/cam/ata/ata_da.c +++ b/sys/cam/ata/ata_da.c @@ -1913,7 +1913,8 @@ adaregister(struct cam_periph *periph, void *arg) softc->disk->d_drv1 = periph; softc->disk->d_unit = periph->unit_number; - if (cam_iosched_init(&softc->cam_iosched, periph, softc->disk) != 0) { + if (cam_iosched_init(&softc->cam_iosched, periph, softc->disk, + adaschedule) != 0) { printf("adaregister: Unable to probe new device. " "Unable to allocate iosched memory\n"); free(softc, M_DEVBUF); diff --git a/sys/cam/cam_iosched.c b/sys/cam/cam_iosched.c index 28b5375ae246..5f171e402ed2 100644 --- a/sys/cam/cam_iosched.c +++ b/sys/cam/cam_iosched.c @@ -315,6 +315,7 @@ struct cam_iosched_softc { struct bio_queue_head bio_queue; struct bio_queue_head trim_queue; const struct disk *disk; + cam_iosched_schedule_t schedfnc; /* scheduler flags < 16, user flags >= 16 */ uint32_t flags; int sort_io_queue; @@ -619,7 +620,7 @@ cam_iosched_ticker(void *arg) cam_iosched_limiter_tick(&isc->write_stats); cam_iosched_limiter_tick(&isc->trim_stats); - cam_iosched_schedule(isc, isc->periph); + isc->schedfnc(isc->periph); /* * isc->load is an EMA of the pending I/Os at each tick. The number of @@ -1155,13 +1156,14 @@ cam_iosched_cl_sysctl_fini(struct control_loop *clp) */ int cam_iosched_init(struct cam_iosched_softc **iscp, struct cam_periph *periph, - const struct disk *dp) + const struct disk *dp, cam_iosched_schedule_t schedfnc) { *iscp = malloc(sizeof(**iscp), M_CAMSCHED, M_NOWAIT | M_ZERO); if (*iscp == NULL) return ENOMEM; (*iscp)->disk = dp; + (*iscp)->schedfnc = schedfnc; #ifdef CAM_IOSCHED_DYNAMIC if (iosched_debug) printf("CAM IOSCHEDULER Allocating entry at %p\n", *iscp); diff --git a/sys/cam/cam_iosched.h b/sys/cam/cam_iosched.h index e1019c531579..54f9a7c02a25 100644 --- a/sys/cam/cam_iosched.h +++ b/sys/cam/cam_iosched.h @@ -79,9 +79,10 @@ cam_iosched_sbintime_t(uintptr_t delta) } typedef void (*cam_iosched_latfcn_t)(void *, sbintime_t, struct bio *); +typedef void (*cam_iosched_schedule_t)(struct cam_periph *periph); int cam_iosched_init(struct cam_iosched_softc **, struct cam_periph *periph, - const struct disk *dp); + const struct disk *dp, cam_iosched_schedule_t schedfnp); void cam_iosched_fini(struct cam_iosched_softc *); void cam_iosched_sysctl_init(struct cam_iosched_softc *, struct sysctl_ctx_list *, struct sysctl_oid *); struct bio *cam_iosched_next_trim(struct cam_iosched_softc *isc); diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c index 1a93ea71ba77..1c0d5e8381d8 100644 --- a/sys/cam/nvme/nvme_da.c +++ b/sys/cam/nvme/nvme_da.c @@ -946,7 +946,8 @@ ndaregister(struct cam_periph *periph, void *arg) DEVSTAT_TYPE_DIRECT | XPORT_DEVSTAT_TYPE(cpi.transport), DEVSTAT_PRIORITY_DISK); - if (cam_iosched_init(&softc->cam_iosched, periph, disk) != 0) { + if (cam_iosched_init(&softc->cam_iosched, periph, disk, + ndaschedule) != 0) { printf("ndaregister: Unable to probe new device. " "Unable to allocate iosched memory\n"); free(softc, M_DEVBUF); diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 4ecf8c35aca2..1a6df6171b66 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -2973,7 +2973,8 @@ daregister(struct cam_periph *periph, void *arg) snprintf(softc->disk->d_attachment, sizeof(softc->disk->d_attachment), "%s%d", cpi.dev_name, cpi.unit_number); - if (cam_iosched_init(&softc->cam_iosched, periph, softc->disk) != 0) { + if (cam_iosched_init(&softc->cam_iosched, periph, softc->disk, + daschedule) != 0) { printf("daregister: Unable to probe new device. " "Unable to allocate iosched memory\n"); free(softc, M_DEVBUF);