From nobody Sun Jan 14 16:30:07 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 4TCgjn6F86z56ZhQ for ; Sun, 14 Jan 2024 16:30:21 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (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 4TCgjm6WRPz4Gqm; Sun, 14 Jan 2024 16:30:20 +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.160.172 as permitted sender) smtp.mailfrom=asomers@gmail.com Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-42987bc95ffso55648311cf.1; Sun, 14 Jan 2024 08:30:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705249820; x=1705854620; 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=NH1uTUwj65F53Kf2zl5PxXmnPGMW43a73jqqd/UgO34=; b=GCB3Yv+V3oTyAo1ppzGdO4tYx7cLfh+4p+qFcVoEZVvRBdudQL8FV6oiyT9cA0hhEr qPyRzPlwlWkKQxkxLGeX/p/4+XjnLtUljQllxvwm0Z3JCNgQeDoPkBrmsnx7eNOrwa/j 18Jg60mwwC2R1BWG7zmTSoMadwtA7BUs3qi3S/cBUPobyyy7cxQorewdS4UR4KbkqoKq Awp727lqWhZvfiLWp6YNNpE2sHAySj6Kgf6LRkhtc3J+gwkbN46W778bm0Ueg5sqloaZ g0Y3vAj4mL6fVCziAboRSyAShRBQewDFahNQ+DpLadrZjDSTfYc7GQerlisrbG8q0A7X h+Xw== X-Gm-Message-State: AOJu0YxctySqJfF9rZ1ENV16DqipRZdA86pMwtBZ83MA4eOuSEey8932 saNZ1Aq2pHvUusGB3cncRaxoPGUGKeZi3QwyAko= X-Google-Smtp-Source: AGHT+IGqOAggR2qaakOeoj8JzXGNm3bw+ZuRb/9OfeNz1ilusubZGkDHsvdFcJW1Z9+OYfO6WNfaUFsZ4o8TGNNsf30= X-Received: by 2002:a05:622a:1991:b0:429:c8ba:34ea with SMTP id u17-20020a05622a199100b00429c8ba34eamr202763qtc.53.1705249819806; Sun, 14 Jan 2024 08:30:19 -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 09:30:07 -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.87 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.97)[-0.968]; 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.160.172: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.160.172:from] X-Rspamd-Queue-Id: 4TCgjm6WRPz4Gqm On Sat, Jan 13, 2024 at 5:51=E2=80=AFPM Vin=C3=ADcius dos Santos Oliveira wrote: > > Em s=C3=A1b., 13 de jan. de 2024 =C3=A0s 21:35, Konstantin Belousov > escreveu: > > In principle the function of the new flag could be done like > > aio.aio_offset =3D lseek(fd, 0, SEEK_CUR); > > aio_read(&aio); > > with the dis-advantage of requiring two syscalls instead of one. > > There are more disadvantages besides the extra syscall. > > I've built a green threading framework for Lua on top of Boost.Asio. > However I also added support for sandboxed actors (capsicum and jails > on FreeBSD). For file descriptors received through SCM_RIGHTS from > sandboxed processes, I really don't want to risk blocking the thread > (DoS) going through O_NONBLOCK (file IO is always ready, and that's > why AIO exists). So, for these file descriptors (one can never know > their "type"... whether they refer to pipes and O_NONBLOCK is enough, > or they refer to files and AIO should be used), I'll use AIO as well. > On Linux I can get away by just using io_uring for everything. 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.