From nobody Sat Nov 22 22:07:41 2025 X-Original-To: freebsd-current@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 4dDR671Cpnz6HgXs for ; Sat, 22 Nov 2025 22:07:43 +0000 (UTC) (envelope-from mmel@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dDR670Zv1z4Ltq; Sat, 22 Nov 2025 22:07:43 +0000 (UTC) (envelope-from mmel@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763849263; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8BGa64wfT2bvXUoPhcys6VRPnD9Wu1e3irNHnb+nnYA=; b=PBhVqcM6DZF2kGAMUJEJvRI9pLrQBAn9vAtAL8krHR87vBBv9TYzd+0uqC3Cpl8A2w2thK MlnhidGp+vficFbSTe+QOjzFBac2zNazG7QQFwGTzTsXHr6Ku34A+Sfze9BZ49/Sxyomdp Tg0koOEWNXuCQ1NsomchdfQtdPhX/QhEAlEX5Xdt3wmEscO6i5Z0Av+uq7b/Sa30zAVd4B EXuTC1PeMXVLZV8OcSd8FIwg/6yjaRqD2OZFH64TVvuyIq7IcLlCGhyqTiGRwvdJXc6TUC qW/0xjm91Loj9dt0+4HNA5Gq0hT42oVhJRtGIjh24+4Iyrg2mmYb7+gjNraOmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763849263; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8BGa64wfT2bvXUoPhcys6VRPnD9Wu1e3irNHnb+nnYA=; b=iumareIKyHGES0UDE3kqsEKO/ToRVuUYQ0ln4Xhu3C6ncMHtLnseXbm8VjbNm8oSyszKE9 5N6KqY82aiIeTlbisPy8i45jQNS+mAzHgoBXXZcmvuIh03z4M/pqme/9eCbz7qVYRrs36c 6t4jgr2iP9WZC/vGvCjjyHxuv6eM9n8cYDbfZuouG32Q7QvWXNNT2lqB57QGbXDZveuqWj 1Q+KSYSA27Hosflnp9ey1iJID7qvgyjstNk0qmUjmA7aJgWBrVuvDqg8T7D0gVvJ+DwNlo ZRCrzAj9rWopTrkHoqEpUnCcxZQRitLAPBgeAKoKEGZXH7va5WWsJxs4xZixxA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1763849263; a=rsa-sha256; cv=none; b=YbU25ATtiMgqOs5GxAU9zAZXtHFj0eoEHx31skk/wm8dBWMI0cwZZc0RBhJ/sBBTheaC4m uWakXYW8/560JAW10jxqIgNCtJHECcJYxPkW/3CtpHfN5T+PkCSllfWHyqaqv5CTzuGcDZ J/o9DPB1riTf37F+axgExkob1GAJQS2q4+E3hFW49ULNDAj1OBtQF6U6x1qEzprPpXue37 tvKRLtBbeV/5DJh/2/O8FM3hkcBm0p0fPxX7qscPKrDwMfXG0cPCYZEsxJ4WzLOLDum4yX xffMrtsdngyYPWSo7+401HcgRQ6vSd9jWJJ+h3b72DTFit3BoBKYRsBSyVFQeQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from [192.168.168.195] (lety.radiolinkplus.cz [109.205.241.143]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: mmel/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4dDR664fDBzysC; Sat, 22 Nov 2025 22:07:42 +0000 (UTC) (envelope-from mmel@freebsd.org) Message-ID: <9ef6253b-0f3a-4178-bfb2-65cc847ce652@freebsd.org> Date: Sat, 22 Nov 2025 23:07:41 +0100 List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Michal Meloun Reply-To: mmel@FreeBSD.org Subject: Re: mmap( MAP_ANON) is broken on current. (was Still seeing Failed assertion: "p[i] == 0" on armv7 buildworld) To: Konstantin Belousov Cc: FreeBSD Current References: <603e75f8-7064-4fca-8520-282331c20ec0@freebsd.org> <9a864c53-0033-46d1-ad07-6b528115789f@freebsd.org> Content-Language: cs, en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 22.11.2025 21:41, Konstantin Belousov wrote: > On Sat, Nov 22, 2025 at 10:19:38PM +0200, Konstantin Belousov wrote: >> Please in addition to the patch, enable debug.vm_check_pg_zero. > > And use the following patch (one more hunk for vm_object_page_remove()): > > diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c > index 6b09552c5fee..76808b5ad7f1 100644 > --- a/sys/vm/vm_map.c > +++ b/sys/vm/vm_map.c > @@ -1743,6 +1743,27 @@ vm_map_insert1(vm_map_t map, vm_object_t object, vm_ooffset_t offset, > (vm_size_t)(prev_entry->end - prev_entry->start), > (vm_size_t)(end - prev_entry->end), cred != NULL && > (protoeflags & MAP_ENTRY_NEEDS_COPY) == 0)) { > + vm_object_t obj = prev_entry->object.vm_object; > + if (obj != NULL) { > + struct pctrie_iter pages; > + vm_page_t p; > + > + vm_page_iter_init(&pages, obj); > + p = vm_radix_iter_lookup_ge(&pages, > + OFF_TO_IDX(prev_entry->offset + > + prev_entry->end - prev_entry->start)); > + if (p != NULL) { > + KASSERT(p->pindex >= OFF_TO_IDX(prev_entry->offset + > + prev_entry->end - prev_entry->start + > + end - start), > + ("FOUND page %p pindex %#jx " > + "e %#jx %#jx %#jx %#jx", > + p, p->pindex, (uintmax_t)prev_entry->offset, > + (uintmax_t)prev_entry->end, > + (uintmax_t)prev_entry->start, > + (uintmax_t)(end - start))); > + } > + } > /* > * We were able to extend the object. Determine if we > * can extend the previous map entry to include the > diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c > index 5b4517d2bf0c..e87047f9a380 100644 > --- a/sys/vm/vm_object.c > +++ b/sys/vm/vm_object.c > @@ -1988,7 +1988,7 @@ vm_object_page_remove(vm_object_t object, vm_pindex_t start, vm_pindex_t end, > (options & (OBJPR_CLEANONLY | OBJPR_NOTMAPPED)) == OBJPR_NOTMAPPED, > ("vm_object_page_remove: illegal options for object %p", object)); > if (object->resident_page_count == 0) > - return; > + goto remove_pager; > vm_object_pip_add(object, 1); > vm_page_iter_limit_init(&pages, object, end); > again: > @@ -2061,6 +2061,7 @@ vm_object_page_remove(vm_object_t object, vm_pindex_t start, vm_pindex_t end, > } > vm_object_pip_wakeup(object); > > +remove_pager: > vm_pager_freespace(object, start, (end == 0 ? object->size : end) - > start); > } > @@ -2189,13 +2190,19 @@ vm_object_coalesce(vm_object_t prev_object, vm_ooffset_t prev_offset, > next_size >>= PAGE_SHIFT; > next_pindex = OFF_TO_IDX(prev_offset) + prev_size; > > - if (prev_object->ref_count > 1 && > - prev_object->size != next_pindex && > + if (prev_object->ref_count > 1 || > + prev_object->size != next_pindex || > (prev_object->flags & OBJ_ONEMAPPING) == 0) { > VM_OBJECT_WUNLOCK(prev_object); > return (FALSE); > } > > + KASSERT(next_pindex + next_size > prev_object->size, > + ("vm_object_coalesce: " > + "obj %p next_pindex %#jx next_size %#jx obj_size %#jx", > + prev_object, (uintmax_t)next_pindex, (uintmax_t)next_size, > + (uintmax_t)prev_object->size)); > + > /* > * Account for the charge. > */ > @@ -2222,26 +2229,13 @@ vm_object_coalesce(vm_object_t prev_object, vm_ooffset_t prev_offset, > * Remove any pages that may still be in the object from a previous > * deallocation. > */ > - if (next_pindex < prev_object->size) { > - vm_object_page_remove(prev_object, next_pindex, next_pindex + > - next_size, 0); > -#if 0 > - if (prev_object->cred != NULL) { > - KASSERT(prev_object->charge >= > - ptoa(prev_object->size - next_pindex), > - ("object %p overcharged 1 %jx %jx", prev_object, > - (uintmax_t)next_pindex, (uintmax_t)next_size)); > - prev_object->charge -= ptoa(prev_object->size - > - next_pindex); > - } > -#endif > - } > + vm_object_page_remove(prev_object, next_pindex, next_pindex + > + next_size, 0); > > /* > * Extend the object if necessary. > */ > - if (next_pindex + next_size > prev_object->size) > - prev_object->size = next_pindex + next_size; > + prev_object->size = next_pindex + next_size; > > VM_OBJECT_WUNLOCK(prev_object); > return (TRUE); uff, we have winner. All check passed.