Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3492939pxb; Mon, 16 Nov 2020 16:43:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJydXjz+bsPKNSRqV3rkUzLyvWwq91zWa4wDEUYGyvVtSuwFPSebBkjPsDhAr6aM2rwr06jv X-Received: by 2002:a05:6402:181a:: with SMTP id g26mr19260201edy.8.1605573810155; Mon, 16 Nov 2020 16:43:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605573810; cv=none; d=google.com; s=arc-20160816; b=MBvFuXPEh/viPZAhkb3xT4C5dQ4+pNFTbZAW92PTDNafNXyRH2yQWE1CeJFJ5tm5bn N7+uWqvHwpZpYVFOqcZFXNBnr5mi1itQRT3dwIa6MBMqs/C/XdahY1sDR3TtjrtNyL63 LYcoGLF9g3/EwN6hRqvZjYOiYA7AzA1ljXrH4I5bRDgwrHz6q4ZtaR6c/u+r4IuZf744 HoYRZjhCGiE/e1YPNf+ZIAudrlD1kTVEznGeQkIzZkvMpcz4maeJqjgpiqkMcimH1kq2 SPh0pcbBZ+xzbWXB0LIiwfa+3BWSsoYrz+dfkbg/dMb2VlTW4uzV6Bs1+Hqvk8v2SOI4 0Afg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=n0AHJqLMr8+ugrnNhaen8bNIvXOUhLJnhjUzQxTG940=; b=LXoveQChWyooOkBPHU4XehpohQ6DKxezj+mSZWzZ4xDuBeeq1I22EWkaNbcllZtscI o2hzpOMpcvAwMS7Pd9odNrSeCGaqvy7MzgFcvVMRzsz3xnOZPYotWhq/7qkXx6nl3I8b sVrdl+v/rsaIAhZ142UvIAaz8etOMFyG2lMcdEjrf7Dkq5gM1uQJ8jmfb4huci4bOTAV Qf6aW53U9fSzhpIlG2iiS13GRRzv9ifuVsB9O2XXrAiggW5FcRHrWU60zbYua69qMkMe uRe9s2kufK4DSR0t1ASldXrT+/PQjceRGDLE/LTEckLucYctbJl6ncZKgUk0Z9BcX+z4 TEww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0ElmHFBU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g23si12895144edr.322.2020.11.16.16.43.07; Mon, 16 Nov 2020 16:43:30 -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=@kernel.org header.s=default header.b=0ElmHFBU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731283AbgKQAh4 (ORCPT + 99 others); Mon, 16 Nov 2020 19:37:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:49172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726437AbgKQAh4 (ORCPT ); Mon, 16 Nov 2020 19:37:56 -0500 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D2CFC2463D; Tue, 17 Nov 2020 00:37:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605573475; bh=wk+WwoC6VnrSIsXOBifPoQffU2aM299BwJ0a+IY7U2E=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=0ElmHFBUgX0HuyB23JYp8rUSo+R5t//mtsKa8oJ6La3L7hHybePhh8rktpHgrZdrH ZvOjV5+goIRWzeHg0fzWyD7iaj9T2a8Zdwaze6aSaDnRR0IHjL6VrKkeWegL+CmGRg PonWEtEjg4dngeeQYGmVxMVj8+WtEXBXD1qKASSk= Date: Mon, 16 Nov 2020 16:37:54 -0800 From: Andrew Morton To: Willem de Bruijn Cc: linux-fsdevel@vger.kernel.org, LKML , Al Viro , Soheil Hassas Yeganeh , Arnd Bergmann , Shuo Chen , Willem de Bruijn Subject: Re: [PATCH v2] epoll: add nsec timeout support Message-Id: <20201116163754.ab6ff2ad8f797705db15cc1f@linux-foundation.org> In-Reply-To: References: <20201116161001.1606608-1-willemdebruijn.kernel@gmail.com> <20201116120445.7359b0053778c1a4492d1057@linux-foundation.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 16 Nov 2020 18:51:16 -0500 Willem de Bruijn wrote: > 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. That's OK - it's mainly syscall table patchery. The fs/ changes are what matters. And the interface. > > 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? Adding a syscall is pretty cheap - it's just a table entry. > > > > 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. I don't understand this. You're proposing that the new epoll_pwait2() be able to take either msec or nsec, based on the flags argument? With a longer-term plan to deprecate the old epoll_pwait()? If so, that's not likely to be viable - how can we ever know that the whole world stopped using the old syscall? > Come to think of it, better to convert to timespec to both have actual > typing and consistency with ppoll/pselect. Sure. > > 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). Sure. > A separate RFC patch against manpages/master sent at the same time? That's the common approach - a followup saying "here's what I'll send to the manpages people if this gets merged". And something under tools/testing/sefltests/ would be nice, if only so that the various arch maintainers can verify that their new syscall is working correctly. Perhaps by adding a please-use-epoll_pwait2 arg to the existing tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c, if that looks like a suitable testcase.