From nobody Wed Aug 17 16:04:02 2022 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 4M7CW82tqmz4ZnF8; Wed, 17 Aug 2022 16:04: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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M7CW82LDCz3f17; Wed, 17 Aug 2022 16:04:04 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660752244; 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=YY919bzMaK7vyJD/+msogMEl5Ak6U1zavHdlNLpAZQo=; b=LjAbEC5UNnlxB2qXczuRfOQptnProkwyb2H4pmY5kYYZnO85Qchj1zmm0SiwPw9R3Gg/Ji amvfZCEtnABs6ATOUyM0FWP5IOwefbtemGfuQgvnaWHOpgiIbR/tdUvpt69H2l/+m1ZdNJ dsGBeF2QDZgMGYQkQVx7ueZ6lX3Hj+dDmEri72LH/KUbO22JGalIJ0fVBeGQP+iZ+phxt9 aDluW/peNOj7Np1CGf8v/10K6sebsLy7YO13WcwSRqLG0KKJ0XS8XK4TcJjx1GyJgyT0Cf 2NulYeFypuboNRuR0W2wfqdvYbsmikN/zHr97c5q6N0La7ZfAVAmMjs04YncIg== Received: from [10.0.1.4] (ralph.baldwin.cx [66.234.199.215]) (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 4M7CW74VxZz1Qtr; Wed, 17 Aug 2022 16:04:03 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <05eb9b32-d466-57c2-a01f-d34955873ac8@FreeBSD.org> Date: Wed, 17 Aug 2022 09:04:02 -0700 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: git: 9ac6eda6c6a3 - main - pipe: try to skip locking the pipe if a non-blocking fd is used Content-Language: en-US To: Gleb Smirnoff , Mateusz Guzik Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org References: <202208171423.27HENpvp024623@gitrepo.freebsd.org> From: John Baldwin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660752244; 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=YY919bzMaK7vyJD/+msogMEl5Ak6U1zavHdlNLpAZQo=; b=RUxMg8n7t0iqkFkeu0HdHWC4F2x+usEIfyd1Uir9CqQrnk90Q2rVfWIqDpCLT9vaNFy4zs vjK0zmtNdlDYSHQ2G6+nb98hqo1xZiUx5I5XLKKEpCQRLlZsdnHtRDn5g1sTovediTRtax cv7xGkHFYYFe1HUX+6Cf7kwntUiQzV2F+HTj11MquW9nBKhkByB66inXQsWtIMbG3/TCER Ycbp5zA7Jl0Ojnws+zlnRfEe2HQlsAaxGJ60rLZNxcYfYItf1XgzUMlRFPK0HI7midbmXi vjBMWNrsR7ipMh0neZvXfJF7P4y9iAV9XUWLa9yd+7vbSj/iV7ixkWk2Gh+rDw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660752244; a=rsa-sha256; cv=none; b=IQfFNSy81vHLol5Vedjmmnvf+2XquVINtpDJAZdzMAFssNySRyQGAbGKjbnWvjbTDXTN7r leTb9eTayb7E6Yu8GnvVYLFsFfytZGHYp3toGJyj560sWGMiuOiQ5QfpUhXC1J+E39SDsD n5+K8CYkupFDSDs9UlZiCabkun3/2Pri9I7kyHfovcHkiJ6QTh7iMwtXrhSusa+HRfk3ch 7DO/KQnkP9tYF5Ph8UK/ZztIh3ce05waQledNwX9myXm1vkGq4MYz2olJgzQvS40aRPcyq mmHqSbPclEl8cMV9NeoJ/UfjAHRmsLUfQDNq9wRL1fXIVaet40HhZ66g/Lq24w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N On 8/17/22 8:39 AM, Gleb Smirnoff wrote: > On Wed, Aug 17, 2022 at 08:34:22AM -0700, Gleb Smirnoff wrote: > T> This also breaks API. Although not explicitly narrated by POSIX or our > T> documentation, but there is a strong contract that, if application had > T> received a non-blocking fd from event dispatcher (kevent, poll, select) > T> as writable, then it is possible to write thre non-zero bytes with next > T> syscall. > > Actually for poll(2) and kevent(2) you can almost read this contract between > the lines: > > POLLWRNORM Normal data may be written without blocking. > > EVFILT_WRITE Takes a descriptor as the identifier, and returns > whenever it is possible to write to the descriptor. > For sockets, pipes and fifos, data will contain the > amount of space remaining in the write buffer. The > filter will set EV_EOF when the reader disconnects, > and for the fifo case, this will be cleared when a > new reader connects. Note that this filter is not > supported for vnodes. > > So with this change it may happen that previous return of poll or kevent > returned incorrect information. While I largely agree with your sentiment, I think the actual contract is a bit weaker than you stated and something more like: "If a non-blocking fd becomes writable and the event is published, at least one thread will be able to write without blocking." That is, the contract you stated is true when there is a single writer, but with multiple writers it is not true. You might get a kevent back that says you have X bytes of room to write, yet be able to write less than X because of concurrent writes in other threads. -- John Baldwin