From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796114872; b=Z4QyqQ0CjceG+iqp75B4f6UPAeKiFZVcg8d6GoVP3n3Ojdfd070VoRLV1d57Z/Lb5sk6 RsNfmT4tbdzb5KlMFBSvJgslo3ALB2TyJZv6CNFGeIIqNhToweyIHvSpRUXnmLY3ywt93 yFKr7dWVBBL42PxgRAnLPN8JteFEv2LV8LJkcJPPh6MkVTcva0CJ521qejiTNEwpuH950 PwzaubWhb37foZGO9dN6yGB8qywKSni5VlIZrT83DLRIu27P2VvHfLVYJhrRn5ofDetvW 7BUgNuRBfxKjMuHTEJZ2ZMoUMwQlRPUyEZSb5wRoQ6B4Yx4+TeC2QuO8AxnAcFPf8gQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796114872; 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=UuEhFmJ3Gtl8Sf0ao/PAhx6Luox7aQsF8U/X+ZaWg7M=; b=nDxnU+gWB1PBtQH6sBmyPbOIv+7+Yqq2T2EeYJsok9L/IAx5P4NSXI9vNrHGAfy4b/HS 3QCpaW5d5AIYpe60TZ5hlvs1fE9yZTRQngMP7l+/m3u8fQRUJF1eM+1IhfKy3mNNSn7aG wxIb3ZMZRJAcrlC9JdYymD7Nt3CnXB2qCvdmZ6qoLZxCRNaE1RxyYq1n+mDA+8DKylz4d dge7JLtLog6ikf41V2k/EQfrF6IaATch5Ttfo8X5+WbNDGWN7+r/WnvmorfpKJYC4BPuS N2Ce5E3BDc9Br/l7DK3Kf2UFfPCl/2QbM+mShvMQKC3d4tCiaEAO76J4D9KQdYxmImw== 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=rk4k8ZwV; arc=none smtp.remote-ip=209.85.214.170 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.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 0BAC5606A32A for ; Tue, 1 Dec 2026 08:47:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0BAC5606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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=rk4k8ZwV Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2f03920c4a0so70127375ad.3 for ; Tue, 01 Dec 2026 00:47:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796114871; x=1796719671; 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=UuEhFmJ3Gtl8Sf0ao/PAhx6Luox7aQsF8U/X+ZaWg7M=; b=rk4k8ZwVGunEoJpPk4maT0LurSXMUbhwEgPe9p3U+6ntXc2KeTETSZbnuURcF28P4O HWz512XTqC/BLKj1w9ta6jthZIpYQzavzH0T2EMuFgezl27SPLFHQGZ/LgLeObw+3oi3 hm66jcriO/Taxh17iBh7I4J6PAUSTr+dfxJK2taZImtL9KU9+xBvfhxWdATbDAYkSuED E6zsltj1cgfrLblS+Ajw7H+xIxFRb3tcWH+KF6yYwJpDaZNKv1RgO/Oi+/mk28EUfitd YA+zYLx0OQms8AsNsU/85Cry2veYhbaJj5kKJqMtDu2002Drg7YeGrTqqZKaKtIp8nb+ FekA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796114871; x=1796719671; 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=UuEhFmJ3Gtl8Sf0ao/PAhx6Luox7aQsF8U/X+ZaWg7M=; b=NHZsfhFZjBsXZoMrBFh4bJtPMKy2i0rB6BKShQGqnqVyDqkGMUNcnbzYSDCKhwnafS 5LFhAZ2YG+qpeMAvQ7HIF26Hb7XRiCHoO9+eDeRFpwwNZy2ZFJetrJ9FULCuNxGGnLGC Wg3lll4uVmvZyOC9xludVmMY63Wl+0VSGgW8dWuLBQlnC40KdY7ooSCHvDkLez94PVsV DdAvku+NGugpmN8uQJTh7zci6OkVwhB/SfgbXghwktWlOGudQiYI69VMuBzhUBGYSfMQ QlM7K7NQ7uE7qI6PcPcP+lUYA/SDP7rpruayvP3bEv/4CBCkirj4Bwzzng1zQ5I3ObKQ f/2g== X-Gm-Message-State: APuU4Z+wjLdruClOpxyAcGAgU3dbZmCSQeym1woKozJLKSkwrubuCKU1 JfIQeUP3oT8tEhWRDNbLANOyaBUa5rVOafMIwUT4SgarDvEK4Mq9G0ET9BgY6A== X-Gm-Gg: AZFdTZeeqJaqYP3XtKne14Bmd2Vw5s2I+OSjJq9JtvTAV7QwpZofc5bwrYnnJiwrj5W 2DKpd1JVIZI87T1aqQchaqAIl/q9M/pPaNhFeo/k34mCHHcKVBq/zFQ/qSUTJ6Hou9c9QAxu7o/ fThul7JgT0/DOBimDqlikSkLaSeiJGYmY3ts6AEqCzk+dH19fs395oAhG0Rwlvy62BYBN0zWE8n ZkaLS0FuVLsqaOWXh+5aiRgsbPI/dHViWFmFuQSHT60h+/dwzRsKcDqESu32Kr/CU2VTxBMedvt YbAQDhh5EWwSaBI12E/of9IgRkr5zz4dS6MDW0K96PtEPfC9hCTppQk3F3LNCEI1HbfGUP/eeRP Bq+SsfjemvPSgqTnEEsBPBwsdAajF7y4EuBSbxB66W2SfMzp37bF5j0+MgcUvI2dwln9U3PSxX0 h+OlQeWuDa9rYE0MmJGxDMWDVkL9DF6nejejyrjP5qGarMI/gDwSK3hw8A/W/6m8Qm6b0M8R4xI CW0y0OvfAxa8eU3LjjZvQ2qIYvmYvDy3YZ38ktjNgAyJfsLSIQ//CPufrqY8ADZJc/vuQk5O5l/ zVSal4K3khah3zt+ztRmHYRep8NqCfDTqnrQFVjjBrxhBcczQwHPKdTRoKMWznA= X-Received: by 2002:a17:903:98b:b0:2ed:1df2:8b35 with SMTP id d9443c01a7336-2f03f1b8105mr425399715ad.37.1796114871037; Tue, 01 Dec 2026 00:47:51 -0800 (PST) Received: from [192.168.1.34] ([103.215.237.185]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f03f147a9esm177991915ad.72.2026.12.01.00.47.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2026 00:47:50 -0800 (PST) Message-ID: <17e17015-53a8-4887-9891-7a7f2f16ea6c@gmail.com> Date: Tue, 1 Dec 2026 14:17:48 +0530 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 1/2] test-lib: run EXPENSIVE tests one at a time To: Patrick Steinhardt Cc: Git mailing list , Harald Nordgren , Junio C Hamano 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> Content-Language: en-US From: Kaartic Sivaraam In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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. >> + 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. > Indeed. This is a good one. I've tried to improve things by throwing newlines in places where it seemed logically better to place them. >> + 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. > Yep. We won't be retrying when the lock already exists. The comment should've conveyed this. If you think we could improve it in someway, do let me know. >> + 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. > 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. >> @@ -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? > We ideally reach this only after a normal flow of acquire_expensive_lock_. We do have 'rm -r "$tmp"' at the end of it which is intended to do exactly that. So, I think it is not necessary here. -- Sivaraam