From nobody Sun Jun 16 17:14:10 2024 X-Original-To: dev-commits-src-main@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 4W2KPP2l2Hz5P8dD; Sun, 16 Jun 2024 17:14:17 +0000 (UTC) (envelope-from peter@holm.cc) Received: from kaskal.pair.com (kaskal.pair.com [209.68.5.173]) (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 4W2KPN60Mxz4bhR; Sun, 16 Jun 2024 17:14:16 +0000 (UTC) (envelope-from peter@holm.cc) Authentication-Results: mx1.freebsd.org; none Received: from kaskal.pair.com (localhost [127.0.0.1]) by kaskal.pair.com (Postfix) with ESMTP id 7A370D656AF; Sun, 16 Jun 2024 13:14:15 -0400 (EDT) Received: from Peters-Air (c-x5996a268.customers.hiper-net.dk [89.150.162.104]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by kaskal.pair.com (Postfix) with ESMTPSA id AFDEED8D1AA; Sun, 16 Jun 2024 13:14:14 -0400 (EDT) Date: Sun, 16 Jun 2024 19:14:10 +0200 From: Peter Holm To: Doug Moore Cc: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: Re: git: dd0e5c02ab13 - main - swap_pager: small improvement to find_least Message-ID: References: <202406111638.45BGcnhX099470@gitrepo.freebsd.org> <29240b1e-6a8a-0bd5-f16f-322623d4b778@freebsd.org> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <29240b1e-6a8a-0bd5-f16f-322623d4b778@freebsd.org> X-Scanned-By: mailmunge 3.11 on 209.68.5.173 X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:7859, ipnet:209.68.0.0/18, country:US] X-Rspamd-Queue-Id: 4W2KPN60Mxz4bhR On Sun, Jun 16, 2024 at 11:55:48AM -0500, Doug Moore wrote: > Thank you, Peter.  That was a stupid mistake and I have now undone it. > > Doug > Happy to help. It was a KASAN build that found the issue. - Peter > On 6/16/24 07:13, Peter Holm wrote: > > On Tue, Jun 11, 2024 at 04:38:49PM +0000, Doug Moore wrote: > > > The branch main has been updated by dougm: > > > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=dd0e5c02ab13b9eb240d42a71a8f41a8b036bd33 > > > > > > commit dd0e5c02ab13b9eb240d42a71a8f41a8b036bd33 > > > Author: Doug Moore > > > AuthorDate: 2024-06-11 16:36:23 +0000 > > > Commit: Doug Moore > > > CommitDate: 2024-06-11 16:36:23 +0000 > > > > > > swap_pager: small improvement to find_least > > > Drop an unneeded test, a branch and a needless computation to save a > > > few instructions. > > > Reviewed by: kib > > > Differential Revision: https://reviews.freebsd.org/D45558 > > > --- > > > sys/vm/swap_pager.c | 19 +++++++------------ > > > 1 file changed, 7 insertions(+), 12 deletions(-) > > > > > > diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c > > > index a07a38481490..15f227457bba 100644 > > > --- a/sys/vm/swap_pager.c > > Doug, > > > > Here's an easy way to reproduce the issue: > > > > 12:43 ~ $ sort /dev/zero & > > [1] 3650 > > 12:43 ~ $ sort /dev/zero & > > [2] 3651 > > 12:43 ~ $ sort /dev/zero & > > [3] 3652 > > 12:43 ~ $ panic: Negative index: -16 > > cpuid = 8 > > time = 1718534645 > > KDB: stack backtrace: > > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe010855fa50 > > vpanic() at vpanic+0x13f/frame 0xfffffe010855fb80 > > panic() at panic+0x43/frame 0xfffffe010855fbe0 > > swap_pager_find_least() at swap_pager_find_least+0x105/frame 0xfffffe010855fc20 > > vm_object_collapse() at vm_object_collapse+0x68b/frame 0xfffffe010855fca0 > > vmspace_fork() at vmspace_fork+0xb68/frame 0xfffffe010855fd30 > > fork1() at fork1+0x4f8/frame 0xfffffe010855fda0 > > sys_fork() at sys_fork+0x54/frame 0xfffffe010855fe00 > > amd64_syscall() at amd64_syscall+0x158/frame 0xfffffe010855ff30 > > fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe010855ff30 > > --- syscall (2, FreeBSD ELF64, fork), rip = 0xaba1c31565a, rsp = 0xaba1b0cecb8, rbp = 0xaba1b0cf220 --- > > KDB: enter: panic > > [ thread pid 3653 tid 100349 ] > > Stopped at $0,0x104d5c2(%rip) > > db> x/s version > > version: FreeBSD 15.0-CURRENT #2 main-n270778-d26c565597b8-dirty: Sun Jun 16 12:32:39 CEST 2024\012 pho@mercat1.netperf.freebsd.org:/usr/src/sys/amd64/compile/PHO\012 > > db> > > > > --- a/sys/vm/swap_pager.c > > +++ b/sys/vm/swap_pager.c > > @@ -2303,6 +2303,7 @@ swap_pager_find_least(vm_object_t object, vm_pindex_t pindex) > > if (sb == NULL) > > return (object->size); > > for (i = pindex - sb->p; i < SWAP_META_PAGES; i++) { > > + KASSERT((i >= 0), ("Negative index: %d", i)); > > if (sb->d[i] != SWAPBLK_NONE) > > return (sb->p + i); > > } > > > > - Peter