From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.145 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796109795; b=cDAJsOqKkkCBNV6Kbgo2GcjEIY5RdmvgQVuTD1gtMPcWPodf9snN4SFxDP/OBh2+Ove3 1lbjwCwuumiocYlg8zUGwSPrPq4b91j0J3Zb62Bzr/gjGsAD84r4ZvDsPIyT77DMtkoRH iisxKOyw8M8Dr2eXX59JoO4hEMy7JVaJPZ3FF1UGjUOlv41uas3TIFCW2h2Wtc5A+ZlFR QixN51+8ETCH+U4+axqO7ILZgUKdLnqB/AGgxmXKYSwcHwV7R/Y5Qma0ovR4Wom+fY4Vi fnID1dErr5yoRpy9Vic/QSAGLb6CpzZ5j2DyPrRVaqLMXljeMzdKBEbCban8SUUW7bQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796109795; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=jq20zaiJeI2JiwzIJ5LXvE80Um5Ik75+c3AhWkTx2vs=; b=irNCVKPucqMPlU8S2/gkZeRiIDO2llUa33O5+BhRrWaIuqYy23qx0ENDoOlaMbknnr9U gdPgVRQ48da/+8Z1a6tBhVfOaYcmeVC6/nnX7+QodMuyOTjYATVT+R2e7LtfS5eB9i/7R idc19XOajtX6yCyZk+K3ASG7clrziWWTmVzup8mYGJP3ddiIoCFhakLY5VFX1hUSDorO6 KGcZ12cVpZQlSQy0w9RgrGUsMP5DyMqoyhGxnhsIafFgsWOWzpJWma/X98IXvVkaGQWAP GU4PUh4BjinKuoYlvt/MT6KRiayN+HgIBj2He+h/hrf7Bqc/3bUpDr7VEF6YY3TxXXQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=vNB089BC; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=FRaz6sWN; arc=none smtp.remote-ip=202.12.124.145 Received: from fout-b2-smtp.messagingengine.com (fout-b2-smtp.messagingengine.com [202.12.124.145]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85D13606A68E for ; Tue, 1 Dec 2026 07:23:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 85D13606A68E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=vNB089BC; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=FRaz6sWN Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id C62221D005A4 for ; Tue, 1 Dec 2026 02:23:06 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Tue, 01 Dec 2026 02:23:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1796109786; x=1796196186; bh=jq20zaiJeI 2JiwzIJ5LXvE80Um5Ik75+c3AhWkTx2vs=; b=vNB089BC2cwxH1QMWtCdKhp/g3 cPfZyXgn+jIqzEY2c87efdl8aBvM0Cowo/7YkWAZnWEkkQH0v87pDKxmaR7fd4wh rsROhSfF8iPx7MKuV9AF9UbAg2Hj8PaokqXylxuQWUd/Eix+Irhksv+GQMhgOegV PKNBP1V31J2oV7Wuk2EDqnrUKqGy2F4J28EYNL3xXdMrlLx8Rq/8Nv6mxuElwIaO 5sBjiirLVppyw12SNMxhqbUuzdKJPnN5dum0nn3NVA0fi8G/LuabUi0w6yd5kX8L DLCS0B3QsdCO4uUjB5pImW8ie5gFy2GArTDqhsRxdKTfaavkd0Fa+asMXRhA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1796109786; x=1796196186; bh=jq20zaiJeI2JiwzIJ5LXvE80Um5Ik75+c3A hWkTx2vs=; b=FRaz6sWNkrK8oFz6dTnx3/8ooagU1De21UROzs/yh7Gkrs/UyA9 ijLyDLiSLm8FWPyHxlvXPskHrEnEqk6UDoY59D9m/jQb4A9iA4txkpY5YAvNSqvf CdrxmIKSBh3aYorKbYI1Hds/iy8mZ6IaHqPscAWsTNGJQdbYa6jI+yW5ss1enTuQ WqWDX7+hgfN4JGI00qtK7vu4RlRIt2tOZksJqHZMe/Va6QCMYh0wyvCGG/yds5Pl DJACi3yfSBIpBQC+oqieOPsUUvSnuTyP5qYhaV8ZMvMSZZ7AQAn/b6G3JqQQg/YS ce9kJcMkBc8DTO3hV6tL/7HbekLpORAFmNQ== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pks.im a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796109786; d=pks.im; mf=PHBzQHBrcy5pbT4=; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:uODDGx8zPhT4fmM+t8CHLVpL7Y1MYUmb8AlOEw9uAhvKuOU MR8zP1i++39ogCF4kqKxsd9IpHM/G43YbV5MgEAGgCKKwZANcFgLjmmtkj94L/vp rCu/mdaBgonUyu1yk7zmn+3ye8kQk/sqVBKCeUjLeJNmlgvgmIc1cmvKtRtcAiE8 +smZfX+itWBEMwK5KWbykJDmdzuRkcZDLZXVLfTqIJHFBO+32aW1d83VzA/QqDN7 mXcaPLe9kuiXNjsuYR2OVoxA7fyOrMuHsojcxq0RIzI6MHOs/18gGu3UivvjEya7 zQfXWgQk1k+fUKcxk+JPhyNfitJL6axMvr7VFUQ==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:B8JTImCfvlIjPn5RtqU9j/OdDEeGOb4AKk3axSfXSiU=:OtN0N4vtQZsgHRRFDuhbHk+ePLj7shA3tEP9nEEgF2g=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFmdSh7eOnt/Ynb4hMQ1pBLqV+ds5RMPRXXi0LxpBKhk+5hwNsKUQUnfuzExbTe21 OxiAmwhzOU2Nq+bI8FkCVUx0uGgxe446xlYeeAPanP3lESH+cuZBAetaRVllHeiQ4dhVp5 P4WEK8qPn/zfB9THIxZJI9HYdAfZiZjx6z051sC3Ker2erq9n1p0mdQNN/6FWRM+igO6+N So+1C7ZzliqSL5iT9jHUAJkeEcCj+q0V06TxjwgeysUO9qp5GnrK/U2YTwjZjiVOgwGPou Zba4edOn8MUkgdRvlXmwknpPebsxj3o5uIvb9FHBcc06mcZL2gGKoxHX+QE3XlQhV1GJQ+ 7WClBTXqyXLpyKh4gr8k35f8GGfXpOXjr1kbT/cI6bFse77clrJUTv3SJhid2cnliKLq5S pWUIKXuz8ahEivC2X6QegV/3T/ZEOVhv2sIk+LuBmI7wzElJwfgZkkgLmL0p66L+98T+dW t8l6369cmcQ/fEHMnediEjbGNX5ZTmZr04K6ZAsR8cznM7l9z0cYjILd85tNUp4OvdNnoE vNOZ5SyQJw1BRJDmR0OUs+pJR1h1rOZ3QPh3ETdT7DJnj/1i0nWGtrkVUj4+Yhq7eR77It 1qVD9X6Nvb0eN3jG0vVR7e6bkvMmcYYSGQqZn6P/6KoB4S6Eemofepgl/9Xg X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 1 Dec 2026 02:23:05 -0500 (EST) Received: by mail (OpenSMTPD) with ESMTPSA id 733205c4 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 1 Dec 2026 07:23:02 +0000 (UTC) Date: Tue, 1 Dec 2026 08:22:58 +0100 From: Patrick Steinhardt To: Kaartic Sivaraam Cc: Git mailing list , Harald Nordgren , Junio C Hamano Subject: Re: [PATCH v4 1/2] test-lib: run EXPENSIVE tests one at a time Message-ID: References: <20261128-ks-ci-long-test-hang-fix-v4-0-f117badd2e13@gmail.com> <20261128-ks-ci-long-test-hang-fix-v4-1-f117badd2e13@gmail.com> X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261128-ks-ci-long-test-hang-fix-v4-1-f117badd2e13@gmail.com> On Sat, Nov 28, 2026 at 08:27:59PM +0530, Kaartic Sivaraam wrote: > diff --git a/t/test-lib.sh b/t/test-lib.sh > index c56654b7c5..bfd2fc8374 100644 > --- a/t/test-lib.sh > +++ b/t/test-lib.sh > @@ -1089,6 +1100,71 @@ fail_117 () { > return 117 > } > > +# EXPENSIVE tests may need many gigabytes of memory, so two of them > +# running at the same time can exhaust the machine. > +# > +# Allow only one at a time across all test scripts that share > +# this TEST_OUTPUT_DIRECTORY. > +expensive_lock_="$TEST_RESULTS_DIR/expensive.lock" > +have_expensive_lock_= > + > +expensive_lock_unavailable_ () { > + say >&3 "cannot take the EXPENSIVE lock, running anyway" > + rm -f "$expensive_lock_.$$" > +} > + > +acquire_expensive_lock_ () { > + local owner waited= tmp="$expensive_lock_.$$" misses=0 > + mkdir -p "$TEST_RESULTS_DIR" || > + { expensive_lock_unavailable_; return 0; } > + # The lock is a hard link to a file that already holds our PID, so > + # it never exists without its owner recorded in it. Remove any > + # $tmp left by a dead process with our PID first: it may still be > + # linked to that process's lock, which writing to it would empty. > + rm -f "$tmp" Nit: it is expected that in most cases this won't do anything, so in the expected common case we'll see an error message. Do we want to silence this? > + echo $$ >"$tmp" || > + { expensive_lock_unavailable_; return 0; } Nit: It would have been nice to maybe have empty lines in this function to make it easier to follow. Right now the reader is presented one huge chunk, and they have to figure out by themselves what the logical blocks are. > + while ! ln "$tmp" "$expensive_lock_" 2>/dev/null > + do > + if ! test -f "$expensive_lock_" > + then > + # Nobody holds the lock, yet we cannot create it (no > + # hard links, disk full, ...). Retry in case it was > + # just released, then run anyway rather than wait > + # forever. > + misses=$((misses + 1)) > + test $misses -lt 3 && continue > + expensive_lock_unavailable_ > + return 0 > + fi I was first thinking that this would trigger after three retries unconditionally, so essentially after three seconds. And that would have been overly aggressive, as we should expect that expensive tests run more than 3 seconds. But this is only detecting the case where we fail to create the lock due to whatever reason. So it's a rather uncommon case. > + misses=0 > + owner=$(cat "$expensive_lock_" 2>/dev/null) > + # A lock carrying our own PID was left by a dead holder whose > + # PID we were given again; we know we do not hold it. > + if test -n "$owner" && > + { test "$owner" = $$ || ! kill -0 "$owner" 2>/dev/null; } > + then > + # The holder was killed without releasing the lock. > + # > + # Another waiter may have taken it over since we > + # looked, so only remove it if it is still the same. > + if test "$(cat "$expensive_lock_" 2>/dev/null)" = "$owner" > + then > + rm -f "$expensive_lock_" > + fi I feel like re-checking the lock owner is kind of pointless here. The check doesn't fix the race, but it suggests it to the reader. And that is overall fine, because the intent now is to fail in a way that we prefer to run the test instead of blocking forever. But it raises the question why we even bother to check again. To me it only causes puzzlement. > @@ -1115,6 +1197,7 @@ test_run_ () { > test_eval_ "$test_cleanup" > teardown_malloc_check > fi > + release_expensive_lock_ In the other block where we call this function we have this one: > + release_expensive_lock_ > + test -z "$expensive_lock_" || rm -f "$expensive_lock_.$$" And as far as I can see, `release_expensive_lock_` does not also prune the PID-file. Do we have to do that here? Thanks! Patrick