From nobody Mon Jun 06 21:29:29 2022 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 1D3801BE657B; Mon, 6 Jun 2022 21:29:30 +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 4LH67s5mvMz3hHR; Mon, 6 Jun 2022 21:29:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654550969; 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=3p7w1FRZCn3gnOiUwqu2Bkzw07M9ljVdjBxS82J7bBg=; b=sH1bdELKdrJHW9RS+zohUsc5fti5UKDSnoJpq4SNsm2R0+RSbjufRD280gw3z0b77PnxG6 +H/vCTpB9yYvAEOyIhQdnfLWsDFe1grtpUHZmFdFFhWRDPSjflUeKwNyHbPHI/dZIFvo4f x65ERunBTVUepUCQLp9qUOoS291dPUOvyc0hI4JyX1nEoAAC+C/2swC3xY7OkRXUm6Iz+q n1HnyVS3ncdEfsowFxxcG31qyDoR115CUwsHpBXy1hl0pxNzvVVbsH65W73Lj2gYcXUBZV yjtoHDPltU+sr38fd/zCBWMSlPAFtsNE35OyytlvVm23SiQPxuMSBC8oWuHqmg== 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 9A2E95CCB; Mon, 6 Jun 2022 21:29:29 +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 256LTT8D040650; Mon, 6 Jun 2022 21:29:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 256LTTGH040649; Mon, 6 Jun 2022 21:29:29 GMT (envelope-from git) Date: Mon, 6 Jun 2022 21:29:29 GMT Message-Id: <202206062129.256LTTGH040649@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: b831865fe3b8 - main - iommu_gas: restrict tree search to promising paths 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: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b831865fe3b8f66281b39a9cb567c92dc285a1da Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654550969; 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=3p7w1FRZCn3gnOiUwqu2Bkzw07M9ljVdjBxS82J7bBg=; b=jaT1M3+NpmbbB28htl3Ms7o+WmQ2oi35u894YWSKvOVhS9922HJ7QrPkdjK4PNJXuwiimc pao3py2/0VIQpyUQ5F4YwEyCybhZbUeWuoNHo3ArSatnKdPamRNsifX7og7zoDGN7DPpJq Qf64f38l9jfHggNlKhFVhDhpuINuhXzgIoIHExxI5lpxaNJB38kECyMmXsXj1haFqhR5nn j7S2at2dg+MAOUxZsuQbFAggHNK/y4KmLFvnaOHiFGU8IsGJBWoe54p1X0Tmh3yDqYki1+ ZcHMSubMcJHyZDKSN4q/R4vUpBj1vM7KGHUNZUAoueGMMVXGE5MPp/PD8SeeyQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654550969; a=rsa-sha256; cv=none; b=EXPJj9AQQXokJy1gHpZy+OXhwplsKQ46CT9+IoPBysvDcrUfpCgA3VHOanwDcZB9Kxfht7 Pq0vu26uhTkIrWY6cva5vlij8OJGZdZQjYPTq/a5gbyfsqCKE6XjlVRLoqaCZcguW6WsVv aTaZ346HFhH1ny2eAOPdsK1h7lqVEEFuCkkWZnAGDrXOq32eMQWbE2scrWCq/eHUwYn5Wb 22PbxBVdNn5pXrs+qkpqLeiGUIhRteRS9jrg5sRZqNhmZGHeA8RMpiXrVfHgCk1K6dvFzW saojPSLHkASiV8SYxzPyixXvngfHZF1tKmDT8hjyix84Yi/wikQLteLvxRPAMA== 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=b831865fe3b8f66281b39a9cb567c92dc285a1da commit b831865fe3b8f66281b39a9cb567c92dc285a1da Author: Doug Moore AuthorDate: 2022-06-06 21:26:01 +0000 Commit: Doug Moore CommitDate: 2022-06-06 21:26:01 +0000 iommu_gas: restrict tree search to promising paths In iommu_gas_lowermatch and iommu_gas_uppermatch, a subtree search is quickly terminated if the largest available free space in the subtree is below a limit, where that limit is related to the size of the allocation request. However, that limit is too small; it does not account for both of the guard pages that will surround the allocated space, but only for one of them. Consequently, it permits the search to proceed through nodes that cannot produce a successful allocation for all the requested space. Fix that limit to improve search performance. Reviewed by: alc, kib Submitted by: Weixi Zhu (wxzhu@rice.edu) MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D35414 --- sys/dev/iommu/iommu_gas.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c index c0d4f84a3f1c..78dd86c1f255 100644 --- a/sys/dev/iommu/iommu_gas.c +++ b/sys/dev/iommu/iommu_gas.c @@ -384,7 +384,12 @@ iommu_gas_lowermatch(struct iommu_gas_match_args *a, struct iommu_map_entry *ent iommu_gas_match_insert(a); return (0); } - if (entry->free_down < a->size + a->offset + IOMMU_PAGE_SIZE) + + /* + * If the subtree doesn't have free space for the requested allocation + * plus two guard pages, give up. + */ + if (entry->free_down < a->size + a->offset + 2 * IOMMU_PAGE_SIZE) return (ENOMEM); if (entry->first >= a->common->lowaddr) return (ENOMEM); @@ -408,7 +413,11 @@ iommu_gas_uppermatch(struct iommu_gas_match_args *a, struct iommu_map_entry *ent { struct iommu_map_entry *child; - if (entry->free_down < a->size + a->offset + IOMMU_PAGE_SIZE) + /* + * If the subtree doesn't have free space for the requested allocation + * plus two guard pages, give up. + */ + if (entry->free_down < a->size + a->offset + 2 * IOMMU_PAGE_SIZE) return (ENOMEM); if (entry->last < a->common->highaddr) return (ENOMEM);