From nobody Mon Sep 22 17:40:42 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 4cVr4b3CfJz68CBb for ; Mon, 22 Sep 2025 17:41:03 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (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-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cVr4b0g7Fz3s78 for ; Mon, 22 Sep 2025 17:41:03 +0000 (UTC) (envelope-from mjguzik@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-b07883a5feeso936758566b.1 for ; Mon, 22 Sep 2025 10:41:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758562856; x=1759167656; darn=freebsd.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OlePrsfVGeoL5VltgpCewFfLmZKXwnZFN10HP8x32vA=; b=eDMrsdOSN8Wvrd3P7z9iQB04REIxRtNCjhJeP3+k+53scO7qdfkm60dOwIhwqu9DKF ZlYC3vOCPVyS2IB1Y7qpaLPL2ECcdBOWNHcx7TLbieV+C3eUaL1TFLgwaeEml6Q0k7p7 c70kBrAVkdeNskpWTl5plbmBtcuNpWIcMbASPUdlQ/3vtbS5gfY5WyaKTMWEGH8f2Mvb ferR7uOX+zAc9n3Wd7Klv2FCa600NGFUiuX+H4Kx6VwMQFpNvM/cZU1FOWbaJrSdMtHW 0djzLCUXAsSCXb/G5mmbkUoFWtZ6bzDWKIICBMScAOyXKrganKmHw0YVQAx4JbiUmfOw 54Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758562856; x=1759167656; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OlePrsfVGeoL5VltgpCewFfLmZKXwnZFN10HP8x32vA=; b=UroGQ7ifKBc4FdPb9Pok82O8d74e8freW4hAjuwTYjcpi1VtPt9qvQY3JEuAZXpSP1 oFN87Weq84zHWYhuWzlSJzgD46ydiiOyER3LLq0dNgPM5A69ZKrxVqApYDOtuRfFNX7e YkFvfZq7sge22ezynmhujdkWkq6Y2gt2RwiseIi59/r9fznjF7rfKIyRkbEThcqID/4N oTiQ8Bd0sXJy95Yvs6IGsCTUOvgIG6nVcg1uME59t7hv85+lnNQtuaLcTpf8P6INqPvX rkREhNEBtN9XX1fW6aiI5YPTsW1H9fIfOnn7He6xm8Af9mdBAZ+jpEaUogzwU4wm+0p5 8fAw== X-Forwarded-Encrypted: i=1; AJvYcCUAv+Fkqlzo0t7Iy68MphaD/Gsg9tTVlZhMTqFJLvyyBbbc0e5mX5MiolFnH0AWLNb55bPDShQ6zKNzRKwEDBbMc2QKxQ==@freebsd.org X-Gm-Message-State: AOJu0Yy+EUe4I/8UzPx98eETaf2wwFSlVkTazEpRQ5G9dlUodVN0DGc6 TdoULIKNRjkxbre29dHXI2deCheMdurv4v2wGi3reyTgfJTVFF0Hcvb3tjQHvC9wWxPofk51i4x YLCj/60efKufZpTi4gZPjmD+SRXXRc+w= X-Gm-Gg: ASbGnctdc81mA9bUIVRsmUid5GX9VHqLsuK+bdB88C2/11fY134UXYb53uGGgVjCc4l xUpL8NCLX+NIqmRnrz2T7IBoFBn0v1hvp6WW7khG81omSeQQB3OuwLeZ4MbExLvdDmIlG712OxL rbgLqD2tUxgWsEsC+tQUN+v3JN/82so4yGEZxOl7NSXo0D5aeDFoebmsgNDM7IzTutqVF2gSTPR t99g99RkZkmr5bTNANcqA8hfUTu+a89Ear3BQ== X-Google-Smtp-Source: AGHT+IEIhCKsdj0PUsTIVPRKFi1iQx+oNm7Q/YrAKLsI7TsWrgkIhw2ZEkPgz+mfmK8m37P+ZUkEn0nioGPqP3WRjhE= X-Received: by 2002:a17:907:3fa7:b0:b04:a1a4:4bec with SMTP id a640c23a62f3a-b24f6120ff6mr1397440566b.58.1758562855762; Mon, 22 Sep 2025 10:40:55 -0700 (PDT) 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 References: <202509191419.58JEJsvj031867@gitrepo.freebsd.org> <92831372-745d-4612-b38f-aeb235dd8cca@FreeBSD.org> In-Reply-To: From: Mateusz Guzik Date: Mon, 22 Sep 2025 19:40:42 +0200 X-Gm-Features: AS18NWBiCSyd8QewrF__8dE4g78HSKSI2mCPnt6Z70iSetUONTUsYZDPTEKfX2A Message-ID: Subject: Re: git: 40a42785dbba - main - fcntl(F_SETFL): only allow one thread to perform F_SETFL To: John Baldwin Cc: Konstantin Belousov , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: 4cVr4b0g7Fz3s78 On Mon, Sep 22, 2025 at 7:39=E2=80=AFPM John Baldwin wrot= e: > > On 9/22/25 04:54, Mateusz Guzik wrote: > > On Mon, Sep 22, 2025 at 10:41=E2=80=AFAM 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=3D40a42785dbba93cc519617= 8fc49d340c1a89cabe > >>> > >>> 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-s= ync > >>> 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" lock= s > >> 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. > Per my previous e-mail the offset lock is already contested. Using a pool over a lock embedded into the struct would hinder performance. I explained why I don't consider embedding sx into struct file to be a prob= lem.