From nobody Wed Jul 06 17:05:02 2022 X-Original-To: dev-commits-src-all@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 4F91B1D0C6FF; Wed, 6 Jul 2022 17:05:04 +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 4LdQrv27Vbz3CRn; Wed, 6 Jul 2022 17:05:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657127103; 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=XPsWWWjbk476DR31NDOMWy+xFF2MSVzlUVo7oVqDFnU=; b=MZEIGHDXfw8yXWqWvpfCuTxRfCKCHbI6+rSJmaADtKUwQuqCG4z0K9gjW6alC9h72nvknv k733t5oKwD19ECgWAGITEIY4YyqgTikaoaGjItIa2/MD3v9jFZpj45xtNL/MXgYSJAwZTS tLyxqIQbhNAQ9PDlwGJVlokGKkG1Xt+WRLN/bhFe9k2l0NV8e8encxHzjk5YuJbMct6jYB BVn+Xegjdcurlw9BTvCvGLt9GtUgOtALokLvXeEvSADW5/NfX3rW4VcBXwgN/hFUrBXXRQ SvpUlv404DWFN3Q1xpD8Z29ObYdup7UA9UaDUdue4aCBq8kRTbvWl+X6R+Rvrg== 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 D43FE1E4CB; Wed, 6 Jul 2022 17:05:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 266H52dn083691; Wed, 6 Jul 2022 17:05:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 266H52od083689; Wed, 6 Jul 2022 17:05:02 GMT (envelope-from git) Date: Wed, 6 Jul 2022 17:05:02 GMT Message-Id: <202207061705.266H52od083689@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Doug Moore Subject: git: 9b12e43d1f80 - stable/13 - iommu_gas: use to first-fit search for lowermatch List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9b12e43d1f80923fd5f6e9b6a137938830a6165a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657127103; 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=XPsWWWjbk476DR31NDOMWy+xFF2MSVzlUVo7oVqDFnU=; b=B+0Y25dOKiZHoNhs6oqaYXrFb0/nQNu4mCj7kHvjAeHG3qiqgeSG1Hiu20dmpQ6WcgpnU7 WZunFUtrmNNbyyxhCCoFOyB6Pqz0Knj+5uBB8BxvzjCRG7h/ojae0cxIkOtPLPMvkPSG8x XiR/xHqXSQkUTocVhsWkZUsQ1JmKUxZC/D/YPPLjI8N7ucCvsWkGPsLMDy0Hx0RoQky66v 8QiCkE274xj8nfkknfV17y3t3f70jlAp5gedbEfIQgqTKSOLLEdvkxIHpIhglDSJp9HCew a4oM2QaHsJj1l56pft0nREsRn+JrHhKm6O7CVPoimv4lnoJWzBD9HUNYM19J4w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657127103; a=rsa-sha256; cv=none; b=SWmv6p9PvnTDSIUa52vaZ9pOnB5zxDN+vm/kP+VvLDyJxJVQ4zWSph3IC6xhiTg5nvftde 3dpXEVLqmVVfnmFbrsH1T5fMTO1x4KblXm1N1N6ss4YcDAO8byXzkLVKsF0zMBNBwvFXSv jYy1Fku8HLspX2VrsC8/w6nq2LJEz0HPH2U+AZLQTMqhbBvp5prJTvM+mhFuQcUSS773PB XcLSzp64b/6WlmUWBaTMNYAeW5m7dORahSUuNCPX2QezldK3BgIrillYpUYQzwFRjhxAht sC0n6ti8BvbFhIEJTUD+sJTluyqpGBqBWu2ucAvWJBUgVBhnJZyzFzVonepwBQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=9b12e43d1f80923fd5f6e9b6a137938830a6165a commit 9b12e43d1f80923fd5f6e9b6a137938830a6165a Author: Doug Moore AuthorDate: 2022-06-14 05:47:22 +0000 Commit: Doug Moore CommitDate: 2022-07-06 16:42:48 +0000 iommu_gas: use to first-fit search for lowermatch Reverse the order of the search for a free space in lowermatch, to make it a first-fit search. Iommu_gas_match_one always allocates from the beginning of the free gap discovered from searching the tree, so the current code isn't really allocating in a reverse first-fit anyway, and making the search first-fit reduces the number of iommu page table pages that are used. Reported by: alc Reviewed by: alc, kib MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D35458 (cherry picked from commit 975715b78819c6de68df15a6dd78157c6dba0fcb) --- sys/dev/iommu/iommu_gas.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c index f7c38e8d65e8..11a3e9ab695e 100644 --- a/sys/dev/iommu/iommu_gas.c +++ b/sys/dev/iommu/iommu_gas.c @@ -387,18 +387,18 @@ iommu_gas_lowermatch(struct iommu_gas_match_args *a, struct iommu_map_entry *ent return (ENOMEM); if (entry->first >= a->common->lowaddr) return (ENOMEM); - child = RB_RIGHT(entry, rb_entry); + child = RB_LEFT(entry, rb_entry); if (child != NULL && 0 == iommu_gas_lowermatch(a, child)) return (0); - if (child != NULL && entry->end < a->common->lowaddr && - iommu_gas_match_one(a, entry->end, child->first, + if (child != NULL && child->last < a->common->lowaddr && + iommu_gas_match_one(a, child->last, entry->start, a->common->lowaddr)) { iommu_gas_match_insert(a); return (0); } - child = RB_LEFT(entry, rb_entry); - if (child != NULL && child->last < a->common->lowaddr && - iommu_gas_match_one(a, child->last, entry->start, + child = RB_RIGHT(entry, rb_entry); + if (child != NULL && entry->end < a->common->lowaddr && + iommu_gas_match_one(a, entry->end, child->first, a->common->lowaddr)) { iommu_gas_match_insert(a); return (0);