Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3468681pxb; Mon, 16 Nov 2020 15:56:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0Omj7usyGQ0WZMJ8PyvSl5cWmmszZ71td4CQahaLeNhRGhRGiEvL26wWTWFt3SEpxn4+p X-Received: by 2002:a17:906:d7a3:: with SMTP id pk3mr16381354ejb.208.1605570967237; Mon, 16 Nov 2020 15:56:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605570967; cv=none; d=google.com; s=arc-20160816; b=bq1kgXTM7O5MwdqlbqRMqla2yAjZ+w+ywf0yqy/oQXg6U9yiTQCP+/6bYS32zUHKjP x2bD4pQ57mc3sNgvBksIhaEOvS+lY1hTUPBVLQ9PUjg76nsSDyquFf4JUPfOxKd2UrIJ I0s5xbQ+MGkGtN7z9vHb+0FGqbK2Bwl8Wsr/f7Qayvx0UF5Kr9oG4HuciFnlSG4QeW/N dF9uY8BfeZHAFbloV1HPLb3/fsoqqThQ/coSg5sEn6rXAT5DLRrxug03mXGOj9GCo6vA WpBqm2h7RSHWNjSw6Gxm1RTH4gYGdCJYqeOa4CGtPaKDKpigRQZK84JCs6k3CqDfyJCj iXMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=l35Fp/NoyrjrpcxM04CYLD1c4g2zMDwnAd4FtQOuoEw=; b=mBhyx2aUJp/FtFf4t/TbHUCzZDBNFxGp6hTtGuR5dQEigkpOmjTLQNDlBvcZecZy/V LlceSAgqw16bpRQrkBsvmr7/ZEUZ5oYNuFKMq71btNNLUHMecJljVr9Xzo8Y0x5HhMcv OnVFMOga2R1Sq51/BkfB3zHXY4lWEouuX54PrrAvtLY2QMxVRQq7uEtZP6cbLDlqwSGG 4zh5cKLkUa+vfeB1ltWzPgL3HRLr+ra/rolOjcy7v89fJxLAeVw6+H3BPEvx43gSnaYG 8X/fuPM1Rf/OHtbZtKd8Yn7xPVdO6Y0US8wVHba28CJhVwCpCMxlQNhOpBAEjRJhvo75 hXjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=arNLsBPl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c2si12706007edu.115.2020.11.16.15.55.44; Mon, 16 Nov 2020 15:56:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=arNLsBPl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730945AbgKPXvz (ORCPT + 99 others); Mon, 16 Nov 2020 18:51:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730522AbgKPXvz (ORCPT ); Mon, 16 Nov 2020 18:51:55 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB6E6C0613CF; Mon, 16 Nov 2020 15:51:54 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id a15so20580022edy.1; Mon, 16 Nov 2020 15:51:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=l35Fp/NoyrjrpcxM04CYLD1c4g2zMDwnAd4FtQOuoEw=; b=arNLsBPleBUAJwg+AQszd/ytpsK7EVx1O9iFSfZx7MOizrFaARqpLaxvRiQAxA1qDp O90I0mk5qAjRcqh9BHqwZS0X00qj4hPAMdPRCgxLRxEhyZSsSN7XBmz8jiJWtE4aNoCO fQeXycLMsdf+U9rKjLzDvHzXm9qbg2+Wkx1S3JUVwCeuEZf/qUgbgEcPZr34/vUwGSEB lJU8my3DDuAiTRiwMAbhPhigHa+lLa2bumcmdwUcdtBpq/yXg7ytOGhNDH0xF/NOR9yu GxnlbQJpPpjfDoAEvkB6hcoQu95Qo6c6676t+qneID8/NL6sOO8HYhlncDdj+JauTky7 417w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=l35Fp/NoyrjrpcxM04CYLD1c4g2zMDwnAd4FtQOuoEw=; b=GN3nSgkjvn6ttXYhrMK7qTQDcBrEm3S1J2x7cvLjNrB/Y5gRF6lQw2bIxzAnNb4yCx SNFz7AUgu1OShPbc8BQyJXJucYXYm1xTrhkDkOMbrqWaEna4EF9Ca4CNI55tFWeMW1K+ aOLWAq34RJ4fUUMXqZl4lfO1ObZsGg5anRXhF6NIDfaBBz2GTxB0UzmS6BScrc9fC5/J ChJYBN7KHNDfPrwe23p/1DmVyS7odeuo45O202Gfgvd3E1IZ25rlSblC+ObYpipRtpWq hR42bQJl7qDrAG+/k5aQ9hv1xWyCdplILtfX3mgE20v7Zui9lPPxoq8TRIVoRiWvYfZP QxnQ== X-Gm-Message-State: AOAM532E9CmS7+D8r49Ga35XncIxbramEY2RXz0eYsiJClQOGzkx6U5i qJXFNm7rbj+CA5U+oDwaNW8lnCFj9QoaGEB9jxE= X-Received: by 2002:aa7:d34e:: with SMTP id m14mr17544278edr.42.1605570713432; Mon, 16 Nov 2020 15:51:53 -0800 (PST) MIME-Version: 1.0 References: <20201116161001.1606608-1-willemdebruijn.kernel@gmail.com> <20201116120445.7359b0053778c1a4492d1057@linux-foundation.org> In-Reply-To: From: Willem de Bruijn Date: Mon, 16 Nov 2020 18:51:16 -0500 Message-ID: Subject: Re: [PATCH v2] epoll: add nsec timeout support To: Andrew Morton Cc: linux-fsdevel@vger.kernel.org, LKML , Al Viro , Soheil Hassas Yeganeh , Arnd Bergmann , Shuo Chen , Willem de Bruijn Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 16, 2020 at 6:36 PM Willem de Bruijn wrote: > > On Mon, Nov 16, 2020 at 3:04 PM Andrew Morton wrote: > > > > On Mon, 16 Nov 2020 11:10:01 -0500 Willem de Bruijn wrote: > > > > > From: Willem de Bruijn > > > > > > Add epoll_create1 flag EPOLL_NSTIMEO. When passed, this changes the > > > interpretation of argument timeout in epoll_wait from msec to nsec. > > > > > > Use cases such as datacenter networking operate on timescales well > > > below milliseconds. Shorter timeouts bounds their tail latency. > > > The underlying hrtimer is already programmed with nsec resolution. > > > > hm, maybe. It's not very nice to be using one syscall to alter the > > interpretation of another syscall's argument in this fashion. For > > example, one wonders how strace(1) is to properly interpret & display > > this argument? > > > > Did you consider adding epoll_wait2()/epoll_pwait2() syscalls which > > take a nsec timeout? Seems simpler. > > I took a first stab. The patch does become quite a bit more complex. Not complex in terms of timeout logic. Just a bigger patch, taking as example the recent commit ecb8ac8b1f14 that added process_madvise. > I was not aware of how uncommon syscall argument interpretation > contingent on internal object state really is. Yes, that can > complicate inspection with strace, seccomp, ... This particular case > seems benign to me. But perhaps it sets a precedent. > > A new nsec resolution epoll syscall would be analogous to pselect and > ppoll, both of which switched to nsec resolution timespec. > > Since creating new syscalls is rare, add a flags argument at the same time? > > Then I would split the change in two: (1) add the new syscall with > extra flags argument, (2) define flag EPOLL_WAIT_NSTIMEO to explicitly > change the time scale of the timeout argument. To avoid easy mistakes > by callers in absence of stronger typing. Come to think of it, better to convert to timespec to both have actual typing and consistency with ppoll/pselect. > epoll_wait is missing from include/uapi/asm-generic/unistd.h as it is > superseded by epoll_pwait. Following the same rationale, add > epoll_pwait2 (only).