From nobody Wed Jan 31 16:23:02 2024 X-Original-To: freebsd-threads@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 4TQ6lq161Zz58pyH for ; Wed, 31 Jan 2024 16:23:19 +0000 (UTC) (envelope-from vini.ipsmaker@gmail.com) Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) (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 "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TQ6ln70Jtz4Cbh; Wed, 31 Jan 2024 16:23:17 +0000 (UTC) (envelope-from vini.ipsmaker@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20230601 header.b=kB0kTnw4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of vini.ipsmaker@gmail.com designates 2a00:1450:4864:20::12f as permitted sender) smtp.mailfrom=vini.ipsmaker@gmail.com Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-5111e5e4e2bso2538452e87.3; Wed, 31 Jan 2024 08:23:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706718196; x=1707322996; 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=oFoAbbGZAW6Z+E/a04r/LVKiTzG1iAKRew4mfzD8CeU=; b=kB0kTnw4jziKAbnskULY28jLbjlojc7Rsvie7weXm85bIFRV7s5NkgfZTz7XtwBpha smoRu5kEA9vvmy3yR1u/fBHcMuC+dRLoacRrcqruiWKJhW9+rUNmxyZXLfaCyU/s7IsT K18TKHBeI9EVZRuzHhJs8eII9i3BN8xlK2MMqf09n2acAqoZGUxa+2lGsDbAceE7md2E UpPLdvIjd+sU0k/Fs9U/rhtdrJ5AJ7d+Diikg2rS7i3Pq7gmjWHpDRlRYWhUK6ctTw2m HlO4c3Uw47xj/DnJrftvFHzDouK0GeKXuhZxWOFpqM0MMpqyc7hnTFu53DGgLNCvgNSf RQFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706718196; x=1707322996; 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=oFoAbbGZAW6Z+E/a04r/LVKiTzG1iAKRew4mfzD8CeU=; b=aWiUHXfi4X6oEcx2CTGiTuHNhgaD/mAy9r+T04JzCQWUzkggSYlbbQP3JUzzp3uyKu 8icBjRJFNseZVzaz4AFSIDliQZErVvKb2OAX0IkFvnvgbf4FQtEKqLNOYNST9tZIWZFg UMgBUzMQRS2hHmT6+jPGP3Q2YNR6YvUbnt1xhWCrq5t82xMWCOye1YfbEF+jpUUTeeAB CwTfr/efH2P6KcsxSji6HRr/0BXeaNIZZMcBFLy7+XpHgLMSbntKxYP38wuAjRfA+RaN LWOQXUKgWP2Wt0UMSQ9Q6YaV4eItf5aUrMhdo4kQvrX7wZOeTa26GqID6ioBTnQ+N4cQ NsDA== X-Gm-Message-State: AOJu0Yxkx2RvsXI9P27gBU8i6ORd7hFqVQWi5FTM9rtPGGP2cHLL7Gca sxYZq3IIOLQhqcpftbZLxgzgLuUjcxUtWzbFiieMb/yDfoxA50sLvPuWq6PUuHED69ffwMIiQR6 qWewnlLTAu5Fna4DEkDWMvQW+RHytbYG/NN0piw== X-Google-Smtp-Source: AGHT+IFb/HdGn7Ypjnf3QkZYfI4H+Wu2l8f8xVxg+/PJWSAlLDDEswIfXEa27+jRyDx1bd+9NukhLW4GOsiiG+WjJhY= X-Received: by 2002:a05:6512:33cb:b0:511:9dc:d8bf with SMTP id d11-20020a05651233cb00b0051109dcd8bfmr1830736lfg.67.1706718195660; Wed, 31 Jan 2024 08:23:15 -0800 (PST) List-Id: Threading List-Archive: https://lists.freebsd.org/archives/freebsd-threads List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-threads@freebsd.org X-BeenThere: freebsd-threads@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?Q?Vin=C3=ADcius_dos_Santos_Oliveira?= Date: Wed, 31 Jan 2024 13:23:02 -0300 Message-ID: Subject: Re: aio_read2() and aio_write2() To: Alan Somers Cc: Konstantin Belousov , freebsd-threads@freebsd.org, Konstantin Belousov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: --- X-Spamd-Result: default: False [-3.44 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.997]; R_MIXED_CHARSET(0.56)[subject]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20230601]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; MIME_GOOD(-0.10)[text/plain]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; TAGGED_FROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; FREEMAIL_CC(0.00)[gmail.com,freebsd.org]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; MISSING_XM_UA(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; MID_RHS_MATCH_FROMTLD(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; MLMMJ_DEST(0.00)[freebsd-threads@freebsd.org]; RCVD_COUNT_ONE(0.00)[1]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::12f:from]; FREEMAIL_ENVFROM(0.00)[gmail.com] X-Rspamd-Queue-Id: 4TQ6ln70Jtz4Cbh Do any objections remain for the patch? The workarounds mentioned previously don't work for me (CAP_SEEK required, but I don't control the file descriptors received through SCM_RIGHTS). Em dom., 14 de jan. de 2024 =C3=A0s 16:06, Vin=C3=ADcius dos Santos Oliveir= a escreveu: > > Em dom., 14 de jan. de 2024 =C3=A0s 15:23, Alan Somers > escreveu: > > I think you're using the term "green threading" too broadly. Golang > > uses green threads, but Rust does not. The difference is that in Rust > > with async/await, the task-switching boundaries are explicit (the > > .await syntax). So Rust uses explicit concurrency, not green > > threading. I can't speak to the other languages you mention. > > Still, we might have async IO if the implementation permits. > > > You propose an extension that would essentially create asynchronous > > (and racy) versions of read, write, readv, and writev . But what > > about copy_file_range and fspacectl? Or for that matter all the > > dozens of control-path syscalls like open, stat, chmod, and truncate? > > They would block the thread, obviously. Look, I've been playing with > async IO for most of my career. I'm not asking for exoteric APIs. I > just want a non-blocking version for read(). What's so hard about > that? From what I understand from FreeBSD source code, I can already > "unofficially" do that (offset is ignored if the concrete type is not > a real file). > > Very very few OSes actually implement async versions for anything > beyond the typical read()/write(). Even open() could block. For > anything beyond read()/write(), you just create a thread and live with > that. From a userspace perspective, it's expected that filesystem > operations such as file-move, directory-listing, etc will block the > thread. It's already expected. However you don't expect that for the > basic read()/write(). > > Again: Linux and Windows already allow that and it works fine on them. > > And again: I ask why FreeBSD is special here. I've been answering your > questions, but you've been avoiding my question every time. Why is > FreeBSD special here? Linux and Windows work just fine with this > design. Why suddenly does it become special for FreeBSD? It's the very > same application. > > > This flag that you propose is not a panacea that will eliminate all > > blocking file operations. There will still be a need for things that > > block. Rust (via the Tokio library) still uses a thread pool for such > > things. It even uses the thread pool for the equivalent of read() and > > write() (but not pread and pwrite). > > Nothing new here. I use thread pools to perform DNS queries. I allow > my user to create threads to perform blocking filesystem operations > (move, directory listing, etc). I know what I'm asking for: a read() > that won't block. I'm not asking for a competitor to io_uring. I'm > just asking for a read() that will never block my thread. > > > My point is that if you want fully asynchronous file I/O that never > > blocks you can't achieve that by adding one additional flag to POSIX > > AIO. > > It's just a read() that won't block the thread. Easy. > > Do you have concrete points for the design? What does it need to > change in the design so it becomes acceptable to you? What are the > criterias? If the implementation fulfills all these points, will it be > acceptable for you? > > > Instead, all operations would > > either specify the offset (as with pwrite, pread) or operate only at > > EoF as if O_APPEND were used. > > I strongly disagree here. Async APIs should just achieve the same > semantics one *already* has when it creates threads and performs > blocking calls. Do *not* create new semantics. The initial patch > follows this principle. Your proposal does not. > > > -- > Vin=C3=ADcius dos Santos Oliveira > https://vinipsmaker.github.io/ --=20 Vin=C3=ADcius dos Santos Oliveira https://vinipsmaker.github.io/