From nobody Tue Jun 14 05:50:41 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 51E32844E94; Tue, 14 Jun 2022 05:50:41 +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 4LMcwx1tT8z4sDQ; Tue, 14 Jun 2022 05:50:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655185841; 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=zCPbFCDvY8STNQq9HonAPxfmnNpkkh0uk/s13ypXxyo=; b=vV274L/kQTcKwxZgF6nf7vsnY4oYoUiNYHnaStIIq8/cT8QjHIqcsMDhM9OBmMXAUS/EV+ u23ZO3koveM8sokuk9lERCPX8C5GzeTWi2d1HPepI/N1bfWnsKv2prkQf0EN+eVUfLJTu6 x+PqxvaIlqoPdfNdgLbvQYymZ0giNRTXg6kQk/CE+e6M1+9U48lpUziJZUNhYm0KLc1eTZ wXgJ2TSrRfJ2dm5ABEZaU9eSMgjcOX/U+xFEH/B0aaqUyIWuYQDeq+UEPEIvbAQ1rlcjh9 SBlhD3cNs24RYyClVHLXjKiu5DvHd8ALQhbgE5svCDflg9r5uQq+HpRtnOuPmg== 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 2173A24A84; Tue, 14 Jun 2022 05:50:41 +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 25E5ofM4057357; Tue, 14 Jun 2022 05:50:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25E5ofSK057355; Tue, 14 Jun 2022 05:50:41 GMT (envelope-from git) Date: Tue, 14 Jun 2022 05:50:41 GMT Message-Id: <202206140550.25E5ofSK057355@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: 975715b78819 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 975715b78819c6de68df15a6dd78157c6dba0fcb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655185841; 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=zCPbFCDvY8STNQq9HonAPxfmnNpkkh0uk/s13ypXxyo=; b=FiZSlmLwuPYH4JiEOs74tEzA8tUaruFDt3i83vK+8f+QP/TMS4daiGaeekU9htkTEJgdpQ FP5rmwZL+NHWY9tu3nM+fVvNyjSdOnptQmpKsL9kCb3jXCTq4WRD4fLqDqZ3F4dAx5vVXj vpsc66dt2B5Qk819o5D0JxOQpvwmeATwCcj3uw2OGACb7XvBLS69A117L97TcGVDWRr7XH w6/qgGP5yCwAHCD2D21O4a+USkWJQk2+H58J0oLN8aH5q0FKyz25uNCmBYRyRWKy6EFWTB PNCl7ek3sq9PKVNke/bryCDtOUl9oonxpja+oCA2Z1nEDXfF5vJ4d2YSjSmpsA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655185841; a=rsa-sha256; cv=none; b=YzD++b/wRvHyGQB7txnBqkhAlGZLOVrB6iMeavh2XIZYI7DFXFILQJ6yLm3xQxGAvFrjwc r0VIKoq9uly29wXiMduUrRV+kAs4cMSicJ2v42UmKALFI4ijy+32PxINfiPMlufa+NWkWL kWP+CpUpmJaB2RCUfnGs4czha7gnPoUXTdr6b4e12C4gMGPxRZHiEYBPeS4mpM/hg/O83s nJcBvxJN9pVXBIHAOzyzO450yvcOVgAjSbIypEasCMoDXbmL8P2FQqPehsGBJUh7rvkzwk V7ZHMXIUzi017AnAVD2zGYXP5jeSQ+zrjmuoBPoz4u8s8IokfPbywy/tv4rRkQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=975715b78819c6de68df15a6dd78157c6dba0fcb commit 975715b78819c6de68df15a6dd78157c6dba0fcb Author: Doug Moore AuthorDate: 2022-06-14 05:47:22 +0000 Commit: Doug Moore 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);