From nobody Sun Jan 14 17:13:43 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 4TChh64GFgz56hg8 for ; Sun, 14 Jan 2024 17:13:58 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com [209.85.222.43]) (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 4TChh53f3xz4T8d; Sun, 14 Jan 2024 17:13:57 +0000 (UTC) (envelope-from asomers@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=freebsd.org (policy=none); spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.222.43 as permitted sender) smtp.mailfrom=asomers@gmail.com Received: by mail-ua1-f43.google.com with SMTP id a1e0cc1a2514c-7cedcea89a0so373413241.1; Sun, 14 Jan 2024 09:13:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705252435; x=1705857235; 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=8KtLxuXtJLa6q5hOOU3znGvv8eiYgnYhTPDMOOf+8Ug=; b=lSGhAKlGkaxl6ahTl2OOKKwFGYIXcQL/Zm66Tvg2qZYj6mynNazFVUAWECq34ILhRR N5lozOvgFYO86sszdD4YOHDTpxfzwzytV/O3qStjftTKUXO8b76RJakvoV7ciG6+W2oh GXqcWCSfEJjaiHL3gnOQdrX1ZYhDaWsn1O45vWDv/O54NJi3+w1JbJ5E3wg0NX8/luya 5d9YrWTNj1xKKl27HQjaBlyZJOn5Ggz9JHIYYccybGIFFZ1MDkYQe8Eh/pcROXmY8sAb IhZ+ZHOjAMt/arsq/HOCPZVe8f1J8aKHPNjFCydooZ7+GkQl937EZWJ4zr34twnfHoTG 1igA== X-Gm-Message-State: AOJu0YyvYhMgmSza1/J3ijNsVtgo4bDaf9Iq09kEitM64RMmSw1JFpAw EgEyKmXRojaCvgAxyAJsCQyrljqgPKNuGTGmc0A= X-Google-Smtp-Source: AGHT+IGu7ciQzRAfSv6ehTIw9it7Pq+YjIy+m2zJ6XjYBJ2IPVNy4rH28GXTlpVweCBK1scLyPzmYD9dEMvIdoq6chk= X-Received: by 2002:a67:ee04:0:b0:467:e9a2:ee0d with SMTP id f4-20020a67ee04000000b00467e9a2ee0dmr2130975vsp.34.1705252435413; Sun, 14 Jan 2024 09:13:55 -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: Alan Somers Date: Sun, 14 Jan 2024 10:13:43 -0700 Message-ID: Subject: Re: aio_read2() and aio_write2() To: =?UTF-8?Q?Vin=C3=ADcius_dos_Santos_Oliveira?= 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 [-2.90 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-0.999]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; DMARC_POLICY_SOFTFAIL(0.10)[freebsd.org : SPF not aligned (relaxed), No valid DKIM,none]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; FREEMAIL_CC(0.00)[gmail.com,freebsd.org]; MIME_TRACE(0.00)[0:+]; FREEMAIL_TO(0.00)[gmail.com]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_ONE(0.00)[1]; FREEMAIL_ENVFROM(0.00)[gmail.com]; MLMMJ_DEST(0.00)[freebsd-threads@freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; MISSING_XM_UA(0.00)[]; R_DKIM_NA(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.222.43:from]; TAGGED_RCPT(0.00)[]; FREEFALL_USER(0.00)[asomers]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; RCVD_IN_DNSWL_NONE(0.00)[209.85.222.43:from] X-Rspamd-Queue-Id: 4TChh53f3xz4T8d On Sun, Jan 14, 2024 at 10:07=E2=80=AFAM Vin=C3=ADcius dos Santos Oliveira wrote: > > Em dom., 14 de jan. de 2024 =C3=A0s 13:30, Alan Somers > escreveu: > > I don't understand. What are you worried about that would block? > > lseek never does. It never actually goes to disk; it just retrieves a > > variable from within the kernel. So while the expense of a syscall is > > non-zero, you don't have to worry about lseek blocking. > > Sorry, that was a lot of condensed information that I dumped together. > > We can use lseek to get the offset and use AIO specifying the offset > we just queried. However the untrusted sandboxed process might > actually send as a socket file descriptor (we don't control what we > get from the untrusted sandboxed process), and lseek is then > inappropriate. In that case, I believe lseek should return ESPIPE. >From what I've read from the source code, we can pass > these bogus offsets to AIO, and it'll just work. However we're still > paying an extra syscall (and code doesn't feel right anyway). > > Anyway, the kernel *already* has this thread pool (AIO daemons), and > the only change required here is a flag that controls whether > FOF_OFFSET is passed along. That's a pretty non-invasive change. What > is the problem? Again, the model already works fine on Windows and > Linux. The problem is that this flag would be almost impossible to use correctly for the intended use cases of POSIX AIO. Your application is actually pretty unusual in that it only has one operation in-flight at a time. I think it would be better to use the lseek solution rather than add a footgun to POSIX AIO. -Alan