From nobody Mon Nov 13 14:24:14 2023 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 4STWrv0YMRz50tXc; Mon, 13 Nov 2023 14:24:15 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4STWrv06QJz3Kj6; Mon, 13 Nov 2023 14:24:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699885455; 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=3Q+LxIdUmcw0BIdXXKt3BnGmvRwbAfKUd3z1CEXgfTM=; b=Wm8irjLlItHAGOxjBQYfArWPqZqtUHGKTel9ycJD138ImtK/EisZ075H4KKMxdyCvKQ4t8 Omkg3xkTaUi+qKjcjG1gcD2ssKhi6w1dIeJ32owpAtqz8IvicAu6elsf6OpxHOXKQk7pSj N3juLmkvWDeI9ScxCYzDlUWNRXwUSuUVQ1csD8LpcG7PBae111pQ+jkxixA0RFhZmAsuMq G/KEoIYGFBRzhU4i507dwoLqxlq9PDQr8MUU3F4D8yUWgfCnM3q80r8uAz6iceCGI7BsYi 8QvSJZQRrSC4SGgo0evUjujPAEzzDCy8vQOy5AO1cQSQZoz6//t6VPDq/F0eTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699885455; 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=3Q+LxIdUmcw0BIdXXKt3BnGmvRwbAfKUd3z1CEXgfTM=; b=SHvH6jt57gbne2b4brT7n8uUrfyLo19Yk6Y2t11Rnb08yQEKuOkr0VyX/RUpbn3Z2H4Skq 62AoxoTzm2TNofRmVR8wGx1oOaOPdKlnqZamSakwKIS4ghTGVctprm1SNxE7NqUy0rsR4r RvkTzxBIfAgEkOxVAzvc17/HsOc+2Wp0ND13zjKjMAqQZ/fDvWDctEZBG/r+lHk1RxdYlR 6C7hRmmtuejU2USMNLer7MO9Zr5me6xEczRyj/6dHzlwinu3OsjGFAU99z6I/X7r6QeWEN lioQiTRu4kRl8yxUjFoQkf/gy4sBYUMIrMrDxxX8wqw6yioC845zvnXWZ1z64w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699885455; a=rsa-sha256; cv=none; b=Y2/xro54zyBj6LgizkN61lDKIJVcVVynLX7e9ED4E+DVvC2EkJxqWixPzdd8t3n9P6p/52 1X+U3KyP7gotE35+b86ro/3bKXtto9VvzJPYv47LKI3mTaS5/OCHMis7K6WtuUBRnAu71r ZF68JMtT75G1vn2H1xCY2KeKMFpGQgTtF//hFIRqJ6cg5rqYK87XgpXmphox8mtFTUXynT Na6UBAwE/UsEFTBXxCHMzOVDZo+Mle7iKBWi9OhKk5XMBmJavDzAAqnjI34a0QG+rpIeoD aWOAN3Qk2eLu1o3gekglu+WQFxsvuWmDzFwYiqic9MS3WgMcy37BxGuFwaWxJA== 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 4STWrt6Gbwz17jk; Mon, 13 Nov 2023 14:24:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3ADEOEXI059640; Mon, 13 Nov 2023 14:24:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3ADEOEcp059637; Mon, 13 Nov 2023 14:24:14 GMT (envelope-from git) Date: Mon, 13 Nov 2023 14:24:14 GMT Message-Id: <202311131424.3ADEOEcp059637@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: 20f8814cd3fa - main - busdma: On systmes that use subr_busdma_bounce, measure deferred time 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: 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: 20f8814cd3fa6b7cda704e07dec4da6cb9647e37 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=20f8814cd3fa6b7cda704e07dec4da6cb9647e37 commit 20f8814cd3fa6b7cda704e07dec4da6cb9647e37 Author: Warner Losh AuthorDate: 2023-11-13 14:23:53 +0000 Commit: Warner Losh CommitDate: 2023-11-13 14:23:53 +0000 busdma: On systmes that use subr_busdma_bounce, measure deferred time Measure the total deferred time (from the time we decide to defer until we try again) for busdma_load requests. On systems that don't ever defer, there is no performnce change. Add new sysctl hw.busdma.zoneX.total_deferred_time to report this (in microseconds). Normally, deferrals don't happen in modern hardware... Except there's a lot of buggy hardware that can't cope with memory > 4GB or that can't cross a 4GB boundary (or even more restrictive values), necessitating bouncing. This will measure the effect on the I/Os of this deferral. Sponsored by: Netflix Reviewed by: gallatin, mav Differential Revision: https://reviews.freebsd.org/D42550 --- sys/arm64/arm64/busdma_bounce.c | 1 + sys/kern/subr_busdma_bounce.c | 10 +++++++++- sys/riscv/riscv/busdma_bounce.c | 1 + sys/x86/x86/busdma_bounce.c | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/arm64/arm64/busdma_bounce.c b/sys/arm64/arm64/busdma_bounce.c index c1028f35ba7f..ee84d03a44d4 100644 --- a/sys/arm64/arm64/busdma_bounce.c +++ b/sys/arm64/arm64/busdma_bounce.c @@ -98,6 +98,7 @@ struct bus_dmamap { struct memdesc mem; bus_dmamap_callback_t *callback; void *callback_arg; + __sbintime_t queued_time; STAILQ_ENTRY(bus_dmamap) links; u_int flags; #define DMAMAP_COHERENT (1 << 0) diff --git a/sys/kern/subr_busdma_bounce.c b/sys/kern/subr_busdma_bounce.c index f5f27dae9b05..76f50b2abf38 100644 --- a/sys/kern/subr_busdma_bounce.c +++ b/sys/kern/subr_busdma_bounce.c @@ -76,6 +76,7 @@ struct bounce_zone { #ifdef dmat_domain int domain; #endif + sbintime_t total_deferred_time; bus_size_t alignment; bus_addr_t lowaddr; char zoneid[8]; @@ -119,6 +120,7 @@ _bus_dmamap_reserve_pages(bus_dma_tag_t dmat, bus_dmamap_t map, int flags) bz = dmat->bounce_zone; STAILQ_INSERT_TAIL(&bz->bounce_map_waitinglist, map, links); + map->queued_time = sbinuptime(); mtx_unlock(&bounce_lock); return (EINPROGRESS); } @@ -239,7 +241,10 @@ alloc_bounce_zone(bus_dma_tag_t dmat) "domain", CTLFLAG_RD, &bz->domain, 0, "memory domain"); #endif - + SYSCTL_ADD_SBINTIME_USEC(busdma_sysctl_tree(bz), + SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO, + "total_deferred_time", CTLFLAG_RD, &bz->total_deferred_time, + "Cumulative time busdma requests are deferred (us)"); if (start_thread) { if (kproc_create(busdma_thread, NULL, NULL, 0, 0, "busdma") != 0) @@ -436,6 +441,7 @@ busdma_thread(void *dummy __unused) STAILQ_HEAD(, bus_dmamap) callbacklist; bus_dma_tag_t dmat; struct bus_dmamap *map, *nmap; + struct bounce_zone *bz; thread_lock(curthread); sched_class(curthread, PRI_ITHD); @@ -452,8 +458,10 @@ busdma_thread(void *dummy __unused) STAILQ_FOREACH_SAFE(map, &callbacklist, links, nmap) { dmat = map->dmat; + bz = dmat->bounce_zone; dmat_lockfunc(dmat)(dmat_lockfuncarg(dmat), BUS_DMA_LOCK); + bz->total_deferred_time += (sbinuptime() - map->queued_time); bus_dmamap_load_mem(map->dmat, map, &map->mem, map->callback, map->callback_arg, BUS_DMA_WAITOK); dmat_lockfunc(dmat)(dmat_lockfuncarg(dmat), diff --git a/sys/riscv/riscv/busdma_bounce.c b/sys/riscv/riscv/busdma_bounce.c index 6b50dc527b66..2aa6c0d0b371 100644 --- a/sys/riscv/riscv/busdma_bounce.c +++ b/sys/riscv/riscv/busdma_bounce.c @@ -95,6 +95,7 @@ struct bus_dmamap { struct memdesc mem; bus_dmamap_callback_t *callback; void *callback_arg; + __sbintime_t queued_time; STAILQ_ENTRY(bus_dmamap) links; u_int flags; #define DMAMAP_COULD_BOUNCE (1 << 0) diff --git a/sys/x86/x86/busdma_bounce.c b/sys/x86/x86/busdma_bounce.c index b9943ad3792e..6ae02752a805 100644 --- a/sys/x86/x86/busdma_bounce.c +++ b/sys/x86/x86/busdma_bounce.c @@ -90,6 +90,7 @@ struct bus_dmamap { struct memdesc mem; bus_dmamap_callback_t *callback; void *callback_arg; + __sbintime_t queued_time; STAILQ_ENTRY(bus_dmamap) links; #ifdef KMSAN struct memdesc kmsan_mem;