From nobody Tue Dec 30 03:25:51 2025 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 4dgJQ73lHRz6MlBg for ; Tue, 30 Dec 2025 03:25:51 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dgJQ720Gcz3VJQ for ; Tue, 30 Dec 2025 03:25:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767065151; 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=G8opr1u2aDRz/VRKwLT6SwSGLFfbC2EOoPGxGXD04Oo=; b=UCqa8lgHmZBFZ59LxJYZ5TNejT0PU2ncjfo+UQLwcffnLnXBJVkUa4ZLy5NHuNnKra8un3 KHDZiY6tyRadDaspS/+AknOOKKsHu1ouusenq0jqaxWmfPlxOYEaa9FZDVW+lCu+xqWYd+ MlbLO4Ux64K+lSVdCnLcY8hB/Mq3x1+mUYkgRkQt48hklt3kjfbMGOWxSEiqsQRaTYpRQP cmSyLhE6GoS5G890cIekfCgU6Zf+sRncUkeFhNOEOmFlya0QKhFmuhWcmEyg0ZMaQzNOEN k6x10rOiWghLeGBrHtsMTGl6UUGGY0s3okjiycyRrtLL5XZ2ug2r2BXqkzWvSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1767065151; 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=G8opr1u2aDRz/VRKwLT6SwSGLFfbC2EOoPGxGXD04Oo=; b=cl/diSR4RHN4mlrnXJk9iibMM1Hj8fT1I4CdbqpJabbPFG8bbqCXPT2VZUUqf8M7/ggwuk U0frwg/35mBtKBp9qjxUcuPU1A2aXVOOKJrowt7zCP38r8HxifCmOZpIUmYQPJ2deU2YIm d30v/+iaqBk9yJQl6LfZ7HxwDjQtfYb4CRCqC07vgLcVKhC0Y128jgDTIMrzL9H9UKfkv9 lltuDohEUZ9wQiW0U1jNpGuqoMdDqza7eCMNNzHR/Opdt5v88+f3oDKiD8DOup3mkXcD0R v7ZO36wGFFyw0YHcwkISltyHgkRA1ZY3hTyiTsZOqilquZluaEKr8LVB/mVniQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1767065151; a=rsa-sha256; cv=none; b=Dd+pSl6uB3wVsqxWj0jN/W85Fi+n0zRHKRidj9Ogg0RGuh8ov0ABzMTtYQYiB97KUl0j2o VYwSRv1YEugPIul9u2gYkt4hfQb84VWfCJaqMUDj8+hZZd7oJO/o3cZk+nJjBne3Vvo7Gv jEXQlJbeOlMx8xNJ33ta6UANYa544NQpn2TNWGlXR97nV0twK1z1z/cabs8/+7fY0mh23j rVQe53YrKqZv8GwgfZ6ahHHy87PxM/HRW0yyla4LXqvxVtcNblqZQFTPAU5CdxZ5hmMHle raqLFCHSPcvv+IsY4FgkumhAEUPGLIP50YTZjO/3j1LEy9/fc5cAmPVpNF0DTA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dgJQ71XTnzjvq for ; Tue, 30 Dec 2025 03:25:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id b120 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 30 Dec 2025 03:25:51 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 353ba3bf08fd - main - vm_object_coalesce(): do not account holes twice 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 353ba3bf08fdef69b77e3e565435e50784a51412 Auto-Submitted: auto-generated Date: Tue, 30 Dec 2025 03:25:51 +0000 Message-Id: <6953463f.b120.10e84c41@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=353ba3bf08fdef69b77e3e565435e50784a51412 commit 353ba3bf08fdef69b77e3e565435e50784a51412 Author: Konstantin Belousov AuthorDate: 2025-11-27 21:53:24 +0000 Commit: Konstantin Belousov CommitDate: 2025-12-30 03:25:36 +0000 vm_object_coalesce(): do not account holes twice alc wrote: Suppose that the object is OBJ_ONEMAPPING and that we, in fact, have a single mapping to it. Then, we punch a hole in that mapping. vm_map_entry_delete() only subtracts from the object's charge when we shrink the size of the object. Now, suppose that we perform mmap(MAP_ANON) to reallocate some of the hole. Aren't we going to add to the charge here, even though vm_map_entry_delete() never subtracted from the charge for the hole that was created? Only account the change in the charged object size that was added to it. Noted by: alc Reviewed by: alc, markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D54263 --- sys/vm/vm_object.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 36edb279bbce..c216fdc01af1 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2202,7 +2202,8 @@ vm_object_coalesce(vm_object_t prev_object, vm_ooffset_t prev_offset, /* * Account for the charge. */ - if (prev_object->cred != NULL) { + if (prev_object->cred != NULL && + next_pindex + next_size > prev_object->size) { /* * If prev_object was charged, then this mapping, * although not charged now, may become writable @@ -2213,12 +2214,14 @@ vm_object_coalesce(vm_object_t prev_object, vm_ooffset_t prev_offset, * entry, and swap reservation for this entry is * managed in appropriate time. */ - if (!reserved && !swap_reserve_by_cred(ptoa(next_size), - prev_object->cred)) { + vm_size_t charge = ptoa(next_pindex + next_size - + prev_object->size); + if (!reserved && + !swap_reserve_by_cred(charge, prev_object->cred)) { VM_OBJECT_WUNLOCK(prev_object); return (FALSE); } - prev_object->charge += ptoa(next_size); + prev_object->charge += charge; } /*