Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Jun 2022 05:50:41 GMT
From:      Doug Moore <dougm@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 975715b78819 - main - iommu_gas: use to first-fit search for lowermatch
Message-ID:  <202206140550.25E5ofSK057355@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by dougm:

URL: https://cgit.FreeBSD.org/src/commit/?id=975715b78819c6de68df15a6dd78157c6dba0fcb

commit 975715b78819c6de68df15a6dd78157c6dba0fcb
Author:     Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2022-06-14 05:47:22 +0000
Commit:     Doug Moore <dougm@FreeBSD.org>
CommitDate: 2022-06-14 05:47:22 +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
---
 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 221b404f2a45..e4f396d97fb7 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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202206140550.25E5ofSK057355>