From nobody Sat Oct 22 05:48: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 4MvVkJ0pDMz4fyQY; Sat, 22 Oct 2022 05:48: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 4MvVkH5QSFz47Cv; Sat, 22 Oct 2022 05:48:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666417703; 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=RyA59mRNuQ0U8zZDsYNaX+Oe/EGXyOrf/CAy7aP+RBg=; b=O2KQTOD9pg2d17MpJoMUYcV7FGBOg5FiR1XN6Rf9fc/IOn5DPiFHymiCGVwz2TGxSdQEH/ Xcz8CA+BzRH8X0gqdvHBWM4M17+1lsXHarGo4pDeSN2TvovLPBUoZHQB4SSB+APLu00dXO kTOcNBTEq0qoRO9lsXrmE/J9h2OrINkpa48DMraWQhvEvVWTVOQ1VBQ+3y0XucfL/UBccL ZrL530IS2aUtZjXo3l67G65CNDgsvma/GAPeNyCgsEBw2p5LQLKZjVvAdhs4E9RSenQYfc dh7c0fU9jVpmqW+I9H0fL0fN43q3Acc5vsPEiHTD7R5q+IWqXMyNz7wIQb9rzA== 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 4MvVkH4496zSLc; Sat, 22 Oct 2022 05:48: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 29M5mNqP077219; Sat, 22 Oct 2022 05:48:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29M5mNP3077218; Sat, 22 Oct 2022 05:48:23 GMT (envelope-from git) Date: Sat, 22 Oct 2022 05:48:23 GMT Message-Id: <202210220548.29M5mNP3077218@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: b7761f1f0830 - main - x86/busdma: Limit reserved pages if low nsegs 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: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b7761f1f0830fc4b4bd7a1f9f364cfb39b7f4288 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666417703; 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=RyA59mRNuQ0U8zZDsYNaX+Oe/EGXyOrf/CAy7aP+RBg=; b=Ipo6lroEwmydCYI/YAH/gBaM0YzgzEAaOSohi4v7RxFoSAOprqwHrDCJKXubD6rp9HE3YJ rfVk2NFt1PNskLrr2VueKb0XAX+1m33lDIItu5E67+GKWUehFwK9TjJ1KwN8qfv7y2Kww4 GgbNTEpuEqQYBjUSy8LUCug4CqVormkmJ6hsiKMGYWrziMSwCW9QaUvY/Csn6hbiNOVd8i OBfmu5sH3mPMxN/yP0/VKPeO9kUnwkOyszmRny+DcUil0WMm3y/4waYBYnmvMJqYcH0NKG YG4X8V3tbAtbRrXfEaNKpHFyMGiv8ANzXw+w1utTusHE5JVwZvuE2y4aV1NXYg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666417703; a=rsa-sha256; cv=none; b=B9D/17xXRDqSHar5gv+VYpdBqZGYUAQdTt/BPNonaVKZKXaA5oxfXfoKIukW9dANwOjH9F xCzVgj7c5P0B/ROnJc5Q7/irIzwiar/j9/NaSGDMEyxh5fkGPu1YTyvHzqaH06+XJLBPBY 3lGyiPKr8tz2JFaXf1OETbCnzjxA0ju7K9VX5g4M/5LJwlewsPDRPVxCgKqsa1gCw6Csje Vt3O8kUDTrx81hcmxnSVvCNswmh5u5jEQWrHHq8sw1Xg1OYYbE96bswc4W9RoApWxAxi9X ErvPpykGJViUoV8l4z6Zw6HC/YG4hqiBGXBN8GvPNoDsacc2pUHQeyZwATDo8Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=b7761f1f0830fc4b4bd7a1f9f364cfb39b7f4288 commit b7761f1f0830fc4b4bd7a1f9f364cfb39b7f4288 Author: Colin Percival AuthorDate: 2022-10-21 18:13:36 +0000 Commit: Colin Percival CommitDate: 2022-10-22 05:47:33 +0000 x86/busdma: Limit reserved pages if low nsegs When bus_dmamap_create is called, if bouncing might be required we reserve enough pages for a maximum-length request, subject to the MAX_BPAGES constraint (32 MB on amd64; 32 MB or 2 MB on i386 depending on the amount of RAM). Since pages used for bouncing are typically non-consecutive, each bounced page will typically constitute a busdma segment; as such, we are unlikely to ever successfully use more pages than the nsegments limit. Limit the number of pages reserved to nsegments. On FreeBSD/Firecracker, this reduces bounce page memory consumption from 32 MB to 512 kB, making VMs with 128 MB of RAM usable. Reviewed by: imp, mav Sponsored by: https://www.patreon.com/cperciva Differential Revision: https://reviews.freebsd.org/D37082 --- sys/x86/x86/busdma_bounce.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/x86/x86/busdma_bounce.c b/sys/x86/x86/busdma_bounce.c index faed4b7353cc..cf919c01ca64 100644 --- a/sys/x86/x86/busdma_bounce.c +++ b/sys/x86/x86/busdma_bounce.c @@ -325,6 +325,7 @@ bounce_bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) if ((dmat->bounce_flags & BUS_DMA_MIN_ALLOC_COMP) == 0 || (bz->map_count > 0 && bz->total_bpages < maxpages)) { pages = MAX(atop(dmat->common.maxsize), 1); + pages = MIN(dmat->common.nsegments, pages); pages = MIN(maxpages - bz->total_bpages, pages); pages = MAX(pages, 1); if (alloc_bounce_pages(dmat, pages) < pages)