🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #4186

Re: [PATCH v4 1/2] test-lib: run EXPENSIVE tests one at a time

#4186
From: Kaartic Sivaraam
Date: Tue, 01 Dec 2026 10:14
123 lines
15702 bytes
On 11/30/26 19:43, Christian Couder wrote:
> 
>> +# This function takes care of cleaning up the lock we
>> +# acquire in acquire_expensive_lock_. It is defined
>> +# up here as we refer to it in die().
>> +release_expensive_lock_ () {
>> +       test -n "$have_expensive_lock_" || return 0
>> +       rm -f "$expensive_lock_"
>> +       have_expensive_lock_=
>> +}
> 
> Something like the following would check whose lock it is before releasing it:
> 
> ------------
> 
> # Remove the lock only if it still names $1 as its owner, so that
> # a lock someone else has just taken is left alone.
> remove_expensive_lock_owned_by_ () {
>         test "$(cat "$expensive_lock_" 2>/dev/null)" = "$1" &&
>         rm -f "$expensive_lock_"
> }
> 
> release_expensive_lock_ () {
>         test -n "$have_expensive_lock_" || return 0
>         remove_expensive_lock_owned_by_ $$
>         have_expensive_lock_=
> }
> 
> ------------
> 
> This would limit the damage in the case (mentioned in the commit
> message) where two waiters clearing the same stale lock at once let
> two expensive tests run together:
> 
> - waiters A and B both see a stale lock,
> - A removes it and takes the lock, then B, which re-checked before A
> removed it, removes A's lock and takes it too,
> - both run, and when A finishes it deletes B's lock, so C starts while
> B is still running.
> 
> With the ownership check, A leaves B's lock alone, so the damage stays
> at two tests instead of growing.
> 

Interesting. That seems sensible. Will include this.

>> +               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
> 
> Here we could both reuse the remove_expensive_lock_owned_by_() helper
> and be a bit more verbose, for example:
>

Indeed.

>         # Another waiter may have taken it over since we
>         # looked, so only remove it if it is still the same.
>         if remove_expensive_lock_owned_by_ "$owner"
>         then
>                say >&3 "removing stale EXPENSIVE lock left by PID $owner"
>         fi
> 
> The extra message might help when reading the logs of a run where a
> script was killed.
> 

Makes sense. Will include this too.

>> +                       continue
>> +               fi
>> +               if test -z "$waited"
>> +               then
>> +                       say >&3 "waiting for another EXPENSIVE test to finish"
> 
> This and the message in expensive_lock_unavailable_() use `say >&3`
> which prints to /dev/null when `-v` or `--verbose-log` is not passed.
> 
> This is not an issue for CI runs as `--verbose-log` is used then. But
> someone running tests locally without `-v` might wonder why their
> local run is stuck.
> 

Indeed. But I kind of assumed anyone wanting more diagnostics would run 
with '-v' anyways.

> With Meson, or when running scripts or `prove` directly, nothing
> cleans test-results/. So a lock left behind by SIGKILL (including the
> OOM killer) can still be there days later. The same PID could then be
> reused by a long-running process of the same user. This would result
> in the script silently waiting forever.
> 
> In such a case, printing something even if `-v` or `--verbose-log` is
> not used, would likely make it much easier to understand what's going
> on.
> 
> So I would suggest sending this message, as well as the "running
> anyway" and "removing stale" messages, to stderr instead. There are
> only a few dozen EXPENSIVE tests, so this should not add much output.
> The subtests in 2/2 that go through the stale lock removal would then
> need to expect that message on stderr though.
> 
> The message would also help even more if it included the holder's PID,
> for example like "waiting for EXPENSIVE lock held by PID 1234".
> 

Okay. I guess sending to stderr doesn't do us much harm either. I'll 
prefix it with a '#' to ensure it doesn't interfere with TAP.

-- 
Sivaraam
Technical Details
Message-ID: <8427f816-2d04-460e-8909-f0740724f2a5@gmail.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76759-linux-kernel-git=dewy.ru
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> <CAP8UFD3V8hb+uHzCeEP1Tx8+kPi3rWyrTP7d_4QerJ6XPn+CtQ@mail.gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76759-linux-kernel-git=dewy.ru
From: kaartic.sivaraam@gmail.com (Kaartic Sivaraam)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v4 1/2] test-lib: run EXPENSIVE tests one at a time
Date: Tue, 1 Dec 2026 15:44:39 +0530
Organization: Usenet Network
Message-ID: <8427f816-2d04-460e-8909-f0740724f2a5@gmail.com>
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>
 <CAP8UFD3V8hb+uHzCeEP1Tx8+kPi3rWyrTP7d_4QerJ6XPn+CtQ@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="1682696"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:twAEqxRpIsJRrncgqnyjre+ySao= sha256:HucLLzm2CQpRZsEg8656VpFKXmbhUBHWqIAzY6+ff/8=
	sha1:sEGNTTY6yaeRiI776+Hdw/C1i1g= sha256:sF+up/Sjjl8uLnble+jw3aMzGpxstXN4ZAj/9ZIyG7Y=
Content-Language: en-US
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id CA9DC1172D9; Tue,  1 Dec 2026 13:14:58 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.949
X-Spam-Status: No, score=-1.949 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id rc1AWQxIIkGZ;
	Tue,  1 Dec 2026 13:14:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76759-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 88D0D11731C; Tue,  1 Dec 2026 13:14:47 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 80C0331213; Tue,  1 Dec 2026 10:14:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796120085;
	b=CdwJgpfPhtbV12heszgHh4lFss2n085fkjJkJ74z2SzbgIOsNfUKl2tzw8Wq3gjMUjea
	 DVyCxNJZw8N+zSPriGs6kMu+7k0ZeuTTjF9KyvsXxVWy1nB0zzsVZnxPG+wmk+KCyvzxw
	 /w1eCKMN2k1efhmoJhTf8lE6DV9r12yfq13w26RkoCs4Ywbc8z6uKq4KXfYTi3r7A9tfK
	 H9/Y+7bJ3mbvGDWEINFqHMqcfr3LpTfOizpyXGFyU0TF+xhcDp5nRjhMXzZtWNb6C+Mfx
	 zJt3+XIRyHP5BRiMc3xI1td2xPc0nz77QDtL8/7L95hC/Obl43VgEL3r/1lS5/EBE2g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796120085;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:Message-ID:Date:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To:
	 Content-Type:Content-Transfer-Encoding;
	bh=m+PeuH+9WXisNlsGIeS2DAAOHw6/CQZV/CLoAFcU9/U=;
	b=G08+ImbX8VfMlvzerwEdcz8OQlgAdxd5XCPOMgS4PONtlm/z5MUYv0P5SHvn1rNCPE8C
	 Lxj7JvVRBvlIZCsfJnQh0WJebuq5xvJNG0STx05Sp8ADWHaTedA2q5Em6VhVNH6YkPVm+
	 YZrZzs/S13DL8Bou8a+enBSiTfo77Pgk023iMIw8p5O42Np+TtmrVfFhpP4uCtBtvlxNI
	 mc4FBHuDewVV58m8nYhvueqaAYrKfFG4uLJO5OX1opKwHrSx6sHA+K4oYWjp1/sJikOQ6
	 2XVPHj6tvUZQV65/qpjPicBHYYKC1qSoHGgAf2aCstM5/W2PVlyB0IAfFWI5biQobMw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qKZqg7TV;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 47DDC606A332;
	Tue,  1 Dec 2026 10:14:45 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qKZqg7TV
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.52
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796120084;
	b=Tq1pJE4/AF2EP/3jvW1RjAq1wR+88Kaxbzxpgl21UcoSoENh1kTi1OQSOawQovxHfq7V
	 gZyN6s2Lw4KtLyAAYpXfYz2qkL2HawU+jH3EK+OheyKtseIA8ni4OcKy/rGmVH5LM6CHn
	 2oTzGzfFarv4fZs9RrGrQ2qTQwfb64KgRA8jELQmFguKvbkYQCZXqe1VRtsIEN5kRPX/R
	 9PXfQ3Sn82apUECE8Vztr+BRKEDBSniljJdFP/kVKK1e4d8Ti5C3/agSFiS05zA0DU0dY
	 7dfFfwhZ1UqLQl8warbszFM6BzFQI1p1YeTLJJ4ZKjM6ou+hh0C0RqijOR1Qm+epc5w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796120084;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-ID:Date:
	 MIME-Version:User-Agent:Subject:To:Cc:References:Content-Language:
	 From:In-Reply-To:Content-Type:Content-Transfer-Encoding;
	bh=m+PeuH+9WXisNlsGIeS2DAAOHw6/CQZV/CLoAFcU9/U=;
	b=X00V0GVDMJKyF8CgOSUvWKk3nFh4GEMK2R82ps6UvETEM8YXW+LoaBWExmPojhPpaQ1Y
	 zHi0CfMPuky7f+VTCQ472I+HG3jsrnazxb0pPTM/F2rGr3uWIg3omjsS1cXfSr8Gx1h7d
	 sNA3ZgMh+fKBvtLsR0XuaCdaxxfpXBeIMBMhUoEKZGuwWZ5Sh4FTvM4bpjRFSZQ2RxCje
	 vhurFbgDm1i9Bj8tVQizm8NhH9QA5k7ZxqV5OjkhNr2QnH0yw4iuqVokDy9nNXUzFw+AB
	 39PpG0POgIHE1TLOqusLHY60QDePc6i2taxNwMzpqQ4Yo0uE0Ert7lcJ1UiB5FO0Mfg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qKZqg7TV;
	arc=none smtp.remote-ip=74.125.82.52
X-Received: from mail-dl1-f52.google.com (mail-dl1-f52.google.com [74.125.82.52])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 104E7606A31A
	for <git@vger.kernel.org>; Tue,  1 Dec 2026 10:14:43 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 104E7606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dl1-f52.google.com with SMTP id a92af1059eb24-14394530ec6so7013936c88.1
        for <git@vger.kernel.org>; Tue, 01 Dec 2026 02:14:43 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796120083; x=1796724883; darn=vger.kernel.org;
        h=content-transfer-encoding:content-type:in-reply-to:from
         :content-language:references:cc:to:subject:user-agent:mime-version
         :date:message-id:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=m+PeuH+9WXisNlsGIeS2DAAOHw6/CQZV/CLoAFcU9/U=;
        b=qKZqg7TVSxOUdH7kLmD9O0rQ6lZtZTVAuHUs3W5+lRYPoDuoRJAy/4KY+SUITLbHWX
         5dejpDhUp2hNCqcp9MWBHrh5nxy+pddVUKRq5duoxfVbw5SnBC0Flpav6H7SWgQzkE8n
         jNxO5AolZP5K0EPEl/fhzEEkHvcxd6kiIqnn4obax4jq/EMfNuMMzKCfpB+sMmToJjSl
         aXyg2yVt7h+W3i8qrnARNd3+uGJDx7xQTbrnJMbEyzXtcDY4EvqmKy0avJLwHu7BjR/8
         waAfBGTSzm/IgkQ9XrGqCL0b/1iiSNrAO1o0KATnnVWD/CEdyeVSXwo1cc2RS25bq+o9
         d35g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796120083; x=1796724883;
        h=content-transfer-encoding:content-type:in-reply-to:from
         :content-language:references:cc:to:subject:user-agent:mime-version
         :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=m+PeuH+9WXisNlsGIeS2DAAOHw6/CQZV/CLoAFcU9/U=;
        b=pqujr3nSraASCFpBNyE2ygqdr/RjMUyR3z2qF40v33V1P3DkVoribpU+hi/F+Ah5o9
         4VW/HRce2AtmP9ZorYHkNX4elMn4w6ShAugzVLIA83sNbQhWw+yHieicAyQDS9pL2Y8c
         DqQrTjPBquU3PF9lY+y/2R9Bd6Ued+vRX7B1lQy2g6FC8/iZC7MrzRSHUOer5dm5JB4+
         jY0sirQ+e/BNjrDup7vsa9T7cEjJWwFY0UW2n0PFU4Ywp+G6nH14U0QCqGmwa86j+hxs
         W3LWh4oXWpD6Evjdm8jZ+ntdrtBhfSjXNkXQFJglSM1s+7k9i72fmRtGt6dvt6ZObrGy
         oLEg==
X-Gm-Message-State: APuU4Z9YsO1Q0Z6OjpWkW0cgSvGzg9t8UiyodoWL2FTK478wTFrNQbP3
	W4dItcQAO7cN7B2xMUoXDdp/AGcRyEqmrmU8KAuC+/oEpzadIC8Vtr6mfVduoA==
X-Gm-Gg: AZFdTZdsX3eYTUzJI0rbWtwZxseNOZr8rWJuZJ3OK/UqCYbKKljakw7L76Waokkvkef
	PpkjW/cQdlWK7PfCrGKaRl22Gr4PCr09gTMzgZEJqasV5ECOtSxUiuMecipftdAgiTwr9Wu9EE9
	2og4fL0F6GNhUyy490XSsz/EH49Eb2aqZdGKcVbkFpUWFyAP/ezbUmAILeW/Pumwc3YhFmgEalA
	i/etex1VeHn78xEriO63m3Ryweo5UL9CeJWoLooym3KrC0WlY7NstjhcSUroRoLpjPzkQjfdz22
	q1fksVE1NT8yxE6pjfC/rE2Aod+289h81fwGYQ+5es9URxkFIa5tdw4kUjYATBRqx3/dh4KuvyD
	bTqew5bt2UdFPOOqvL+IiJCL5Em58vKfwOJDhjUyHChg1ZzCBxuPQr1nsXXhIHYi7l8+7GQV3gw
	s2ozpKqAc1P/kfXfLOCUyj55z6EW0nUEnhO1u/v8UYXihJNec+wNVcbq7b1VyuStdwNKy2YJiUC
	ZL2h4cZ7YU3a7svsh9fBSz/J9NMCvMPKhVME5YpyiYYr8i8fso2qC8I9QJYy4qM8J+h5TVxnpvR
	JT0WOgfhLT+gv/M77KEKIxaQQ/kbsjmyjLGzixmmEQ==
X-Received: by 2002:a05:7300:881a:b0:385:8aea:11bf with SMTP id 5a478bee46e88-3858aea13eamr41593085eec.41.1796120082980;
        Tue, 01 Dec 2026 02:14:42 -0800 (PST)
X-Received: from [192.168.1.34] ([103.215.237.185])
        by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385646633d0sm184245608eec.3.2026.12.01.02.14.40
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Tue, 01 Dec 2026 02:14:42 -0800 (PST)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-User-Agent: Mozilla Thunderbird
X-Cc: Git mailing list <git@vger.kernel.org>,
 Harald Nordgren <haraldnordgren@gmail.com>,
 Junio C Hamano <gitster@pobox.com>, Patrick Steinhardt <ps@pks.im>
X-In-Reply-To: <CAP8UFD3V8hb+uHzCeEP1Tx8+kPi3rWyrTP7d_4QerJ6XPn+CtQ@mail.gmail.com>