From nobody Mon Jun 27 05:37:23 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 270CA8A370C; Mon, 27 Jun 2022 05:37:24 +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 4LWc1b3bV9z3p5d; Mon, 27 Jun 2022 05:37:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656308243; 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=EL+R8Nq/m8Wa/5fYOgXU71cmB115ajOnB/3hV8uqL1Y=; b=tiIS62VSTgR8dWi/OtrLCTJaSZnuKbKPwmfX8jNwKXa6NhBCgmLeqUUZ9ileMfA9AohhR3 ma1/R+NfJmqh+i77TT4QGgN9HlAQRekFwyJTdTV0ymt9XaSnJLZnT2yqnLraag1mgCCO19 GWrhlMqEmnf75FL+KBWMv+dTaAq9GhEdJmFhKMUBReMlwfDcpvbJxf5jUSS9ZFTe9WAYVp GD8kasUGL6J06VC+SiBWuWbPtVCyRbBJfdDehqPbujhIk1dajOGkhCUGaKQDJeOwmChMI3 bkOQOraENZZApe6cveb8PncycS1pWmyAPNJ88tQq0naUbHAQGvWMC6b+5n+SsQ== 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 56F35220F9; Mon, 27 Jun 2022 05:37:23 +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 25R5bNuS074603; Mon, 27 Jun 2022 05:37:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25R5bNl8074602; Mon, 27 Jun 2022 05:37:23 GMT (envelope-from git) Date: Mon, 27 Jun 2022 05:37:23 GMT Message-Id: <202206270537.25R5bNl8074602@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: c253ae9fe423 - stable/13 - iommu_gas: restrict tree search to promising paths 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: c253ae9fe423daab996724cb58bc1be7e59212b9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656308243; 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=EL+R8Nq/m8Wa/5fYOgXU71cmB115ajOnB/3hV8uqL1Y=; b=IL4hSNdYLvwJgL6Y2DGZltSzXYApYp2dBrhWcZvoX+oIRiqBT0ds8hQUtqfcHtuToQPUFg bgaXg/vliBNwV0Ac+L1fiJg9QyuH47vjFo3qt7pN7/YfKvh0UixWPx6U05BG7yNb5D8kRb iKZCSznJaXei+a0aahy/BjO2hw4/oOpwtyN6oj6RvyrlzqKxp/iue9YNc4RY03l44+eaJv C8Sif7SEYQ/W1Vnb9RkzQJbjE2Yr6L32LIXmPTMiE/jZXXr2XO0iVUdLUR2lNQqy7uS0ak 3msptmw1H/jo4vkgIpy4TVlS4bE3uQvDgCP6fTTY8f1bbDozaXzSOTWJ7hHfbQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656308243; a=rsa-sha256; cv=none; b=Tg0R7wwDhiNZFUxpYPArCFxS5QFIyAI20iURcyoerjEeVM6QlRXMAeSfGpvmU+I6UCpFOq IONRtVooCkI9r6JenrtJbQb85XdavbCqCmdgezYoJoERHbHIZ05VNiDYXe8joO3RaPjiH2 tIw9Su1qInsF8b45W+lPmMTByyYi3Ljy5H2SNlukeSdaHMNB9t3clD1owOdBFAgWO5d8/X S1veSVC+dkpeJ/Z26Gn3XrEgC+mD8R9svFNqkM42cilc9cMBWFXLcSJIvfOAHFheV+un96 qWkFzeb17ISyZZG4p4MVPk95IccrEBwIFQ9DGLF8rOh7EC3sZCdvKZ9XvOayVg== 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=c253ae9fe423daab996724cb58bc1be7e59212b9 commit c253ae9fe423daab996724cb58bc1be7e59212b9 Author: Doug Moore AuthorDate: 2022-06-06 21:26:01 +0000 Commit: Doug Moore CommitDate: 2022-06-27 05:36:42 +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 (cherry picked from commit b831865fe3b8f66281b39a9cb567c92dc285a1da) --- 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 c4faebec9d08..b8bbcf0de7fb 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);