From nobody Mon Sep 22 17:39:02 2025 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 4cVr2J5trhz68BwM; Mon, 22 Sep 2025 17:39:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cVr2J5FvLz3rbt; Mon, 22 Sep 2025 17:39:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758562744; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LnecI+H1+7PmHGYzX2HvB1V8PW2Chf4GH12Vmghuq7A=; b=yYhdFf5b43MNEQ4d1ED/3XHbuOlX6nqlbInzkWkGU2c/AQkhPadGUz7E2zlNu54p1iFXw0 Ai3TOiZj+vBPBWK3HPn8dYgQDnWir5xLUjnis6eQvIT5OkDfY+XEsk2mhfgtWgRS6qCs7W UXhqxr7bsfS+SetIakuLAfoQ0eJOC1b8pMY8NG58QJ9C2cxurqAdKocDlWGxAzkv+J89XK UMrYEpF1sLJ0jDK9Ji+TFTsJCrTzBfVfYXVBh2BoV58jBd7ZCNt3Q7+hyiSo+X3rP3AhoK rUx0IzNIi+srJv14kvas5nc5Z7SuTt+XVVN4TjvmwIZkhCfoIPRNwuVnfARVNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758562744; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LnecI+H1+7PmHGYzX2HvB1V8PW2Chf4GH12Vmghuq7A=; b=rq9/p2x7+aPOAa9KwgxyxBdwBQIGdnRvm7LXBBbLHzNF0Ch8A1v+1yvKhMMdtv6vdW35gh jwl/tFaFiPobcIgZOGhY+LNo1zer9GbN3fGCFOQuRedU2APbGY1KBDe8u0J7dJ6GMJrBYo w5yd/j2/aAP21v0FAjD0EW8T0khJiQGChNPUMEbj5k/BqWsX+nlZniEFCkLs+QD/8xXTYc gC6esnvwpIichVTDSabzyo3ABLY9obD63AYyF5BKwqSE9xjWKqG5ozbqO14L5uDm1+AVSe F9kWzsJZ+N3BNTrzRmTZyDgkrhGJKdy3K4KZ9I8gSl5/hh5xN0Y3uDLW2+acvg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758562744; a=rsa-sha256; cv=none; b=NZqAwE2nqvM3KdpwbdBd2un9Nz2jA8+fPRBINAqGt0F+RkH6qCNeBvUBbWxc+a3yAz7BsD D253hVhR8Htqtk8yVfuVT0dPpwmPXhtXwVj12VkANn0nm5pu/2LSjSNOTVknLfJrNQ+Svb 4vwOccRYwtcyUgH3RrNKOyfddGCuJ7EHx6FUHyGDAetFPpgNnNyvSuqLXNu6ezU7VcNU/S GaGSaw4Yccj1PbLMl46JUxChSN0VlYbURIQ3Qqaw2IZhIoezL09ldATdgqavOtq0ij8yZZ sQOvmoi14M99PF9gJxThz7PWbwqJYqI8urx9LXAeptLNjd6+AhueCounJg+IwA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from [10.103.41.71] (unknown [193.115.216.57]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4cVr2J1DdBzxNg; Mon, 22 Sep 2025 17:39:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Mon, 22 Sep 2025 18:39:02 +0100 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 User-Agent: Mozilla Thunderbird Subject: Re: git: 40a42785dbba - main - fcntl(F_SETFL): only allow one thread to perform F_SETFL Content-Language: en-US To: Mateusz Guzik Cc: Konstantin Belousov , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202509191419.58JEJsvj031867@gitrepo.freebsd.org> <92831372-745d-4612-b38f-aeb235dd8cca@FreeBSD.org> From: John Baldwin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 9/22/25 04:54, Mateusz Guzik wrote: > On Mon, Sep 22, 2025 at 10:41 AM John Baldwin wrote: >> >> On 9/19/25 10:19, Konstantin Belousov wrote: >>> The branch main has been updated by kib: >>> >>> URL: https://cgit.FreeBSD.org/src/commit/?id=40a42785dbba93cc5196178fc49d340c1a89cabe >>> >>> commit 40a42785dbba93cc5196178fc49d340c1a89cabe >>> Author: Konstantin Belousov >>> AuthorDate: 2025-09-11 10:05:04 +0000 >>> Commit: Konstantin Belousov >>> CommitDate: 2025-09-19 14:19:13 +0000 >>> >>> fcntl(F_SETFL): only allow one thread to perform F_SETFL >>> >>> Use f_vflags file locking for this. >>> Allowing more than one thread handling F_SETFL might cause de-sync >>> between real driver state and flags. >>> >>> Reviewed by: markj >>> Tested by: pho >>> Sponsored by: The FreeBSD Foundation >>> MFC after: 2 weeks >>> Differential revision: https://reviews.freebsd.org/D52487 >> >> Thanks for fixing this. I still slightly worry that "home-grown" locks >> aren't visible to WITNESS and it's checking. >> > > Another problem with these is that they don't do adaptive spinning. > > In particular for file offset, it *is* putting threads off cpu in real > workloads when it plausibly could be avoided. > > I think the real thing to do here is to drop the hand-rolled machinery > and use an sx lock. > > Currently struct file is 80 bytes which is a very nasty size from > caching standpoint. > > Locks are 32 bytes in size, which is another problem, but ultimately > one can be added here without growing the struct past 128 bytes. > > The only issue here is that files are marked as NOFREE, so this memory > can *never* be reclaimed. > > One could be tempted to use smr here, but the cost of smr_enter is > prohibitive. There is a lazy variant which does not do atomics, which > perhaps could work, but that 0 users in the tree and was probably > never tested. > > With 32-bit archs going away I don't think it's a big deal though. > > For interested, on Linux the struct is 256 bytes. I had suggested in an earlier review adding an sx-pool similar to our existing mtxpool and using that. That would avoid bloating the structure with a dedicated lock. -- John Baldwin