🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #4191

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

#4191
From: Kaartic Sivaraam
Date: Tue, 01 Dec 2026 12:50
81 lines
14276 bytes
On 12/1/26 16:37, Patrick Steinhardt wrote:
> On Tue, Dec 01, 2026 at 02:17:48PM +0530, Kaartic Sivaraam wrote:
>> On 12/1/26 12:52, Patrick Steinhardt wrote:
>>>> +
>>>> +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?
>>>
>>
>> I guess that was mostly done to keep things consistent as we pretty much
>> silence everything in this function. So, I tend to prefer keeping the '-f'
>> on this one too.
> 
> Oh, the "-f" should be kept indeed. But shouldn't it be `2>/dev/null`?
> 
> Ah, no, rm(1) doesn't actually complain in case the target path does not
> exist. I thought it did. One week off and I've already forgotten
> everything.
>

I guess you're just warming up from the time off ;-)

>>> 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.
>>>
>>
>> The re-check is present in order to prevent a specific race scenario pointed
>> out by Junio:
>>
>>>   * T1 holds $expensive_lock_, finishes its last EXPENSIVE test,
>>>     calls release_expensive_lock_ (rm -rf "$expensive_lock_"), and
>>>     exits.
>>>
>>>   * Waiter T2 read owner=$(cat "$expensive_lock_/pid" 2>/dev/null)
>>>     (obtaining T1's PID) just before T1 removed the directory.
>>>
>>>   * Waiter T3 runs mkdir "$expensive_lock_", succeeds, writes T3's
>>>     PID to pid, and begins its EXPENSIVE test.
>>>
>>>   * T2 now checks test -n "$owner" && ! kill -0 "$owner" 2>/dev/null
>>>     against T1's exited PID, finds that T1 is gone, runs rm -rf
>>>     "$expensive_lock_", which deletes T3's active lock.  It loops,
>>>     succeeds on mkdir "$expensive_lock_", and runs its EXPENSIVE test
>>>     concurrently with T3.
>>
>>
>> It talks about the variant that created directories but it applies for the
>> current linking variant also.
>>
>> If we could improve the comment above the relevant code in someway, do let
>> me know. It tries to convey it but I unfortunately couldn't get what detail
>> it is missing.
> 
> But the race isn't fully fixed, is it? You have simply narrowed the race
> window, but the race itself still exists between `test $(cat
> "$expensive_lock_" = "$owner")` and the `rm -f`, doesn't it?
>

Ah. That is true indeed. Though, without the re-check, makes overlaps 
after a SIGKILL more common: in a small stress test they went from about 
3 per run to about 15. So, I kind of lean towards keeping it since it 
doesn't cost us much.

-- 
Sivaraam
Technical Details
Message-ID: <3fba9f96-47e3-47c0-b540-92af0190fdc3@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-76776-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> <aw51wkqQQ8kgXkzI@pks.im> <17e17015-53a8-4887-9891-7a7f2f16ea6c@gmail.com> <aw6qhTYmIMTdid8U@pks.im>

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-76776-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 18:20:52 +0530
Organization: Usenet Network
Message-ID: <3fba9f96-47e3-47c0-b540-92af0190fdc3@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>
 <aw51wkqQQ8kgXkzI@pks.im> <17e17015-53a8-4887-9891-7a7f2f16ea6c@gmail.com>
 <aw6qhTYmIMTdid8U@pks.im>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="1713440"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:WhI6G0XqDBW7Lmq3KFPRERFdu4U= sha256:j7tzjebwhFl4iRyw1Y72CrcDHhIr253Wxn6iZ9q/aHY=
	sha1:vZNJ8dD3liJ8kh84fpJifIY5MHU= sha256:mKbroU2gJwsxn+nZlgUQtUQGYK+kMbLO0cXq45MX1DI=
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 912F911739D; Tue,  1 Dec 2026 15:51:24 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
	tests=[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 MZmLARbubsti;
	Tue,  1 Dec 2026 15:51:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-76776-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id E45E911737D; Tue,  1 Dec 2026 15:51:11 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 2EBAB27849; Tue,  1 Dec 2026 12:51:01 +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=1796129458;
	b=R59WPab8KUF6fsg89EcQ3hnXUxTFrHvpc+d/Jz9fKuTM3j/rBQSeUmS+ujLu8fvO5w3l
	 eKgKCmU+6xwQtn1h4wFDAIZAqNqfjyfOJhmnF/0jCQIUCTK/DlD4AprdOL1bn3eiyMBHv
	 SBCYvPhCKceedd6Ay3647Oq709oXHVFYe8hJJlIOoKUFUncufu4KBwfv0cZSmSYuFkcFI
	 pUEHxKIkQYLnxWUDEcgaJwX4olez2qWWA+AHG8wl7ZcqRdXCjLoeZOrCOuGd2Fun8EyMq
	 JCr/YGcyoTvER5pHvky7eEO/7sdO+h9Z0Mf0QDh5rkEWA2fq3nyH1PM8hVhZnguHRHA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796129458;
	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=VzRZkrKfBbSa72u1vONDu8DNher5d6SusJoNxo+00d8=;
	b=FLaP6L68BtRRDA+eFDOa8mauviPVo+vn9cGIIb/EKmnMDZIiSeOncnlra50iexL+nqs1
	 Q+jEI2VfXcXjHUb+pNaVbrQCMZ/pY/SGSryVEJcMly54RSm5piDlrdqUfJowBJqlPJLFA
	 4QWbTE9o9HhtgDDAwU1pXjEoBVpi8Oq2YarFftn4MtpkLY1/vQeVL7IKkLEJhyrfC5QOV
	 8fjF745MtnjI6/eJdqQfhR9t1Fm0TQVNvQgy+y8BzqIdwJ+0N1mV0Kd8txWvqh6raLXFs
	 hxw3MEdYnNFz7srGS/KV99DKtfCOtGWWDA1OWETAmK1e0AI6AnajSTRxPBpi3S2ii+w==
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=XJT0uck8;
	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 5A8E1606A32F;
	Tue,  1 Dec 2026 12:50:58 +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=XJT0uck8
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.215.170
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796129457;
	b=tDOb3qCoF6GAxzSDIg1FKL2/Gz9MROfGVv5G9jy/afj947hehgb5hxyfJEorUtt/qXUx
	 EHiBQFytjaccNz4jML2LG9WAJ8GzCTJEO+HSzuywNrxKGCkeUZV3EblGzo4gD+gxCfj/y
	 wRN+/cYnKPtOzVGdyDne1jJn26pEE8uf92YBi20UloLqKNPDakIhu9FMKrG5QMK7JnvGB
	 /2pOQhXuiRFgsayS+d51RuVdlzGS0Z3YA42dtuCCDHya0kUcOzBYw2jrhSWhkjulIhj+W
	 a9HzE+r3c4x0GbCqs0jk7auEjECbZUrlNy3AWtA+TE0OpvbW3qT1XuvlgYnsFBE3Yjw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796129457;
	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=VzRZkrKfBbSa72u1vONDu8DNher5d6SusJoNxo+00d8=;
	b=2vVcAbBh5+zimr7l0102a9ehvb4Xwm55sv0tcPBBHBEZwAkkktVpguZ83PjLBE77lg9k
	 Gy+/qE1ilCz40Gf2sJL6hpV/35njZcbtzKMhPZitt5CaE7QpOOJlkbMyPgWI/pjsuQ+Jq
	 QPOwvDrlxLNqS6vapTciAaQ9ZrSdt7u5u6K0NejARsgHO7RP0Nx11lInNK+16GkDNkM6D
	 bt7qOj+DWhDOrlxmhb6zhmXlwgTe8wy4Xn91UVuMqlSH18mFVzYqCsD6eSOWFOShcq7qt
	 Y1KUsqYXZMgHA+Lk/k1vI9HScxWOE04m3JqkjwO49fQeDzlQ7Gh0uB6q+xP9DQsFuMQ==
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=XJT0uck8;
	arc=none smtp.remote-ip=209.85.215.170
X-Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170])
	(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 1FF3C606A325
	for <git@vger.kernel.org>; Tue,  1 Dec 2026 12:50:56 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1FF3C606A325
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-pg1-f170.google.com with SMTP id 41be03b00d2f7-cdb2dfcca94so5015045a12.1
        for <git@vger.kernel.org>; Tue, 01 Dec 2026 04:50:56 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1796129456; x=1796734256; 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=VzRZkrKfBbSa72u1vONDu8DNher5d6SusJoNxo+00d8=;
        b=XJT0uck84Y31pp4p899XrG/OdhHaC6Ok9F0gNhdzz+OGYYd4yYsGyH9Wm15Qm/x6DP
         58RS9vU4f2ZkSW3Iy3Q2h5QiqALl6i+f+Pz2e4YpvcsRzUZlquvpbxuXzosPtMIxRK94
         rbBaAhPIP6KsSi3eBmdM50+d6fSa/Q1jWndFpC9SX4fKUmB6aGDnBJUw5WpIWPuw9Xsy
         RL2aUd/Q9Djg05A/E5kXH4yvMjSatq/UaUcj7MygNoHPKtFLrP1uYr7tKIZCP283Q4Y/
         hZu0AtHOpu0Ud1VFJS0W90ev3u6dvf5wcO0hPpokiTlcFkh5TNbkMIA0prKginXJ3pjM
         tUXg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1796129456; x=1796734256;
        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=VzRZkrKfBbSa72u1vONDu8DNher5d6SusJoNxo+00d8=;
        b=ntxsnJK76AwB9FluuyBkr9f2KXMW8yXepwSkHzivRNUK6Q3pg29QdzYKZSH3t1Ryiy
         aOH+m8C/++NQNSzTjucSfloxDPkjfJucvkYFYi7sFDIzKIlK+RArp0XPOBg0p8XWckSB
         FyQH984pKJ+o8lm8YxDAnyG6h3XEvtQLQfrmlrNVDkEQ/D7zup78NseTgpxQEvgyITQ4
         lQ8SBUQW152Vo3TWfU7UHLpjSLuZjW2kurD3Py/n8ykwjmyRhGTtIqip3J+DiSi0WN9S
         CSE/j125ZTkTxjr5WgNhiYTqvLVTlAfbuSbOpqv7hQeOBlKTp6WY5FAJc/W6/10K/T/q
         K8xA==
X-Gm-Message-State: APuU4Z+H0LAlsUuXIqvDAPf8MeEw3KRnzdszT4G0YAqpxWnDHI2JAFSu
	c5c9L0Wz0EC0aaiA/wjHcwSu2cfQzac8Sq/EgBxJJIr81rpYu69Or884
X-Gm-Gg: AZFdTZcaehh2P1LhdWBsA4OHVPuGZ6D/BvmIG/BqbjQ3de0BTaxSjPloQ50ZABM7vCn
	CZys7YlhJ42iw/qE00xNcJx5rD+arhk13HxWYJy/OQDb/ikJCHDCqY97nDYigmrD4rkfiFoC+z3
	6I+1aa1P3ekMCJfSg+UScxILbfEQGCy+yfJj0JcDclXQqO6LXbA1ILAKRZ52nUc1dtAbEroSOrj
	Yms9+d2lm0ftEbH0LMjYkHGAK6hmLB7SUDKqYnHTx+RIAYOTLB2hqr4o2gU+GOMYk7T2eLn4KDI
	Gn3OpiwZKeAx15TmdNtI594KmRsFVILhkn7qCztq7D/qBYN4ZbnXT3lvrHJNMZ7ITeZ3ZCc64TK
	0cFbfUUALs1PN3Hm0sKTDP/QbpfyX8cOilu5+KB22BOEiLE9xBANQUk3cTs0LOvHSV3Q+GC7WGm
	xc4s8qfKTEWoXxoycwBOBjSvbAB1P/5q0iODC9/c86UetVQ0xL+s51+4xPRLx3TIsVpZTwmZ7hI
	6L4Vez4kvfhB4TXAcVpgt4ltvhwZXZv3Lc+f8pSWvaEz96jh2hahZonDRcyRnw9WrFynwhxgSp3
	AEX4e9xjQSKlBGE/CZk7b755OAPsh4rb8nWTVyvZyg==
X-Received: by 2002:a05:6300:8095:b0:3f8:f792:2373 with SMTP id adf61e73a8af0-4014c2573b2mr33757063637.48.1796129456002;
        Tue, 01 Dec 2026 04:50:56 -0800 (PST)
X-Received: from [192.168.1.34] ([103.215.237.185])
        by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8d329855224sm8004593b3a.38.2026.12.01.04.50.54
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Tue, 01 Dec 2026 04:50:55 -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>
X-In-Reply-To: <aw6qhTYmIMTdid8U@pks.im>