From nobody Mon Sep 22 17:40:42 2025 X-Original-To: dev-commits-src-all@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 4cVr4b2XrCz68CCY for ; Mon, 22 Sep 2025 17:41:03 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) (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 4cVr4b0kgkz3s79 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-x633.google.com with SMTP id a640c23a62f3a-b07c28f390eso862596366b.2 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=wppss1/8bzFR9a3jnFbx09PXtoCbKhHYFdMGeij26QHAS59IZ4or4N+lIMlx1apAK4 svquuOiXejNRaik4F+pNTBMjTHQAUJmAf+IWfr2F2xtxLOE7u0+W5ZC7Ix74aYeuwwe9 eKG9Qjsd/PuUHtHB4iLsVamj+ZsAuqI3rojpTFJWJXH0MeTTAKiCS3UcP4myCA9spBPQ TKJ8FKmiUUf81vOhP1CDYE6M5t0utyinSN+77pn7GJSeCrePkVTwRPLkDlv++gv5n4AF UHKm7S7g1fomBsqTrUfIuUtzwifycxhK4D3rL5UCGR5dN/0BeOcnRLQxpepOPXIGL3wH 0yIQ== X-Forwarded-Encrypted: i=1; AJvYcCWSVPdhVz+yB5kwZ8eXBEUBYIi3CMO8NNWjGbLmFyIncp0MHb+NRInUOCnRM9tBiKyUZvH2McpMlsatBkaAic2PlYCV@freebsd.org X-Gm-Message-State: AOJu0YwQl+SbLahI5x6m5Cf0Vw/cEx9if6ab+bOV+cBdPBhGExI66ZQu Sa0j1JI9PALMFfC/47lyrH9QJX4bi+cAp5XPTGdreMOCi4CO9GxYUfgtZpBptfXuSRphB+wBtTd wWj7UfYoDPdtt1okXxAdHOkS/wWEi+sI= X-Gm-Gg: ASbGncvnLDw2Ug8oXEmLcJVsyTHWi1ZbYWO4wdPCRU7vanF5eGHePIWmnpE5IyvGNac 534Av4OUi7gPUqGY1Dgy31ifg981Ea8zGUFXww/DKPtCLV8Fef9CYtOihAHzcv+WzfLVbKp65go spfebNr8IIx1RDZBgJMG368V41BN2uATkCCtSAKrJcXvZxTaKsI8fuLLSGaACZLSAyFY3+gC6vz UC6vj7tNC+1DXIMaFRoQCFTjdlCNs2LBJS0YQ== 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 all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: 4cVr4b0kgkz3s79 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.