From nobody Fri Jun 18 19:19:08 2021 X-Original-To: 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 83F5C11CD9DF for ; Fri, 18 Jun 2021 19:19:17 +0000 (UTC) (envelope-from nc@FreeBSD.org) Received: from rainpuddle.neelc.org (locks.neelc.org [IPv6:2602:fed2:7106:25ff::1]) (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 mx1.freebsd.org (Postfix) with ESMTPS id 4G67yY2wMkz3BtZ; Fri, 18 Jun 2021 19:19:16 +0000 (UTC) (envelope-from nc@FreeBSD.org) Received: from mail.neelc.org (locks.neelc.org [IPv6:2602:fed2:7106:25ff::1]) by rainpuddle.neelc.org (Postfix) with ESMTPSA id 1AC4B89290; Fri, 18 Jun 2021 12:19:08 -0700 (PDT) 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 Date: Fri, 18 Jun 2021 12:19:08 -0700 From: Neel Chauhan To: Mark Johnston Cc: current@freebsd.org Subject: Re: Kernel/driver hacking: panic: Assertion vm_object_busied((m->object)) failed at /usr/src/sys/vm/vm_page.c:5455 In-Reply-To: References: <8bd27c2a72ebfa9299bca7d930297faf@FreeBSD.org> User-Agent: Roundcube Webmail/1.4.11 Message-ID: <389e4560afdc211e9915746b11a0d0d0@FreeBSD.org> X-Sender: nc@FreeBSD.org Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4G67yY2wMkz3BtZ X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N Hi Mark, On 2021-06-18 06:57, Mark Johnston wrote: > That seems surprising, since the vm_page_grab() call should return the > page at pidx if one exists. I believe that's not the case. I did pringfs >> Any hints on where the physical address is? Should we have an >> FreeBSD-specific "pa" argument for the physical address if it's >> needed? > > I'm not sure. I'll just note that the Linux code appears to be trying > to map a set of pages belonging to a scatter-gather list. Taking the > physical address of the first page and assuming that all subsequent > pages are physically contiguous doesn't seem correct, but this is what > is happening in that loop, since each iteration simply increments pa by > PAGE_SIZE. Based on this email and our private one, and prior debugging it seems this panic comes on the first iteration. Something must be vm_page_grab() returns NULL, and then we run: if (!vm_page_busy_acquire(m, VM_ALLOC_WAITFAIL)) goto retry; if (vm_page_insert(m, vm_obj, pidx)) { vm_page_xunbusy(m); VM_OBJECT_WUNLOCK(vm_obj); vm_wait(NULL); VM_OBJECT_WLOCK(vm_obj); goto retry; } Source: https://github.com/neelchauhan/drm-kmod/blob/d0eee96973ee0772e977b813678f92c5becf0507/drivers/gpu/drm/i915/intel_freebsd.c#L245 The first if() doesn't panic, but we panic at the second one, it doesn't go into or jumo over the statement. I could use for() or for_each_sg_page() and they both panic. I am almost feeling I'd have to hire a FreeBSD kernel consultant and/or sell my TigerLake laptop for an AMD Ryzen-based laptop. -Neel (nc@)