Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8480252ybn; Tue, 1 Oct 2019 08:41:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzb5KaGl2gUCBhPFKWBi3xz60Y8ON3MUroULo71izMtDDKm6Pr8fHZKlE4SF4z/D4rbKnyW X-Received: by 2002:a17:906:b298:: with SMTP id q24mr24732366ejz.168.1569944493238; Tue, 01 Oct 2019 08:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569944493; cv=none; d=google.com; s=arc-20160816; b=CfD5Jt1zJxnq6Au5CAlAuy9NRYvlmGkUDLJI2kyDi5dlYm+w8GmiNPPRmntxM8wWSV /nUbIQiXNFk0vFw66UTr+UlYtsNyCclsQoHTZrPz3EPIcKogGCDKI52ZeATpKJGsuSWb rrgC1QaMHhFNdvJjmqxb2YcyjMNklcUpRMhigxmd+UoVPHhTttl5Gc3am3VwSsZh6ek4 SBo6a5WSRjkOUJtr/1Hfgz5chfQs8AHCdPhyKcak8sCdOQDE4Ay8RZAk0kfefEWq5H0W itCIFFgoEaM8WwyFwXF9+iMb0MSz7RuJZ1K6hXX7CI/mxkGoQwCvPWw5qrbrDlAmZ8Rc RoZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=x4oki5zqaQqD9Lw/LHfcoqYFe2cd/ERA90a/rseIBMo=; b=RjtT0IZchxj9TJoCsxpBb3MKrzoBbTVqM4ExYqRmIh2RblCVjsbx69IhESEXXYDgXn S/3eFtD0dr74u2OAWGSFWKZtvTLKfxJLAc142JcsxMUkapHsaTG0pf7v/IZrR2/l8IFK Pa4jCNw3lxgrYlL5yotNC5qS6MugQwDAZN9Aa2J3Ly9sJSF7glOAKq1BvMmCNAyyjiyH AwUXVJR02Rj80WW3ARTwc9d3pzDIRT8m1CZl+5GAn5IbFAliSLzwi+OLFg+WFxvJSM7d btbsqZoqfXziHVaFxZtXcGh/MLcyP6AGYALn2gC4nhGEzytxrCNNchzGwxoRTzv5RcCq IFhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=WiIT9lAW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m33si9518412edc.94.2019.10.01.08.41.08; Tue, 01 Oct 2019 08:41:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=WiIT9lAW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389299AbfJAPio (ORCPT + 99 others); Tue, 1 Oct 2019 11:38:44 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:36176 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388916AbfJAPio (ORCPT ); Tue, 1 Oct 2019 11:38:44 -0400 Received: by mail-io1-f65.google.com with SMTP id b136so49082335iof.3 for ; Tue, 01 Oct 2019 08:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=x4oki5zqaQqD9Lw/LHfcoqYFe2cd/ERA90a/rseIBMo=; b=WiIT9lAWvLNqkJPLDmK3wtxUBnf7YlD0Y/kELsZ+76TlnDPSyvunE5wo0RbyKXRFQa q5XkTSz7HmMAj2RYgO68VYiCeT4dPWF9dFle0DmUC+RRFWbiqODHQKrf6ih1DOQmL6VS 9As5ceqbUSx+qr7H1jLjg1uiMSRImQoyzxisdZcAuM6EPQsnNGcvPq442sxIo4wtMvR4 hEJCIm2A/RAc8xGf197TveBDYPhwudyteTXmi6+ZT4JdJPLzmQvKfMh+wCMgOB/F4ozv dib8PFFKWS0wJQNjaZVYrDfvDvdpjICYt5QmdIxLfh0PELHRPwnfMu2bXy85jgG/ND9Y /2Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=x4oki5zqaQqD9Lw/LHfcoqYFe2cd/ERA90a/rseIBMo=; b=aeQX0T4B6Gq1yaZp1dDrvZbTt/GhyjPli78B7uf7a27elOrGk5PDiegtF1/Aa1enHG bhxxK/9czNsXA7A34tJoXk4CfyZLfAzXp39GG0hFWxUEfngSU0TiFZfmbNBb6Lrwob2b 0x9J/R+zUgqz3NaEDVcoZhjCHnqOuEN8Fo9Gcm7An3fkZiKXzkLJpJfVsLsErCjenJFi aHh5eItw1ticIqSncAVoiqnlUjk22vzP/ruIxpQUuLm6APiMp0S1QrGVJK1yxgSHdDu1 qGeSvzFFXgLAvee2UpURHMTVICXARuxEUns8T1lIWHAb0hsp6dHWwSPOGBLO4s00U3yf XbMA== X-Gm-Message-State: APjAAAX8JGN3358kAI/dmMFV6BZg/FlWP/mardCC0xIk9CTfV4ja2uVf sSdSQ1a54fZhtSx5jm/2cqdeqF/K/mAWpA== X-Received: by 2002:a6b:9107:: with SMTP id t7mr11078862iod.150.1569944322839; Tue, 01 Oct 2019 08:38:42 -0700 (PDT) Received: from [192.168.1.50] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id t24sm7118469ioi.44.2019.10.01.08.38.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Oct 2019 08:38:41 -0700 (PDT) Subject: Re: [PATCH] io_uring: use __kernel_timespec in timeout ABI From: Jens Axboe To: Arnd Bergmann Cc: y2038@lists.linaro.org, linux-api@vger.kernel.org, Alexander Viro , =?UTF-8?Q?Stefan_B=c3=bchler?= , Hannes Reinecke , Jackie Liu , Andrew Morton , Hristo Venev , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190930202055.1748710-1-arnd@arndb.de> <8d5d34da-e1f0-1ab5-461e-f3145e52c48a@kernel.dk> Message-ID: <623e1d27-d3b1-3241-bfd4-eb94ce70da14@kernel.dk> Date: Tue, 1 Oct 2019 09:38:40 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <8d5d34da-e1f0-1ab5-461e-f3145e52c48a@kernel.dk> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/1/19 8:09 AM, Jens Axboe wrote: > On 9/30/19 2:20 PM, Arnd Bergmann wrote: >> All system calls use struct __kernel_timespec instead of the old struct >> timespec, but this one was just added with the old-style ABI. Change it >> now to enforce the use of __kernel_timespec, avoiding ABI confusion and >> the need for compat handlers on 32-bit architectures. >> >> Any user space caller will have to use __kernel_timespec now, but this >> is unambiguous and works for any C library regardless of the time_t >> definition. A nicer way to specify the timeout would have been a less >> ambiguous 64-bit nanosecond value, but I suppose it's too late now to >> change that as this would impact both 32-bit and 64-bit users. > > Thanks for catching that, Arnd. Applied. On second thought - since there appears to be no good 64-bit timespec available to userspace, the alternative here is including on in liburing. That seems kinda crappy in terms of API, so why not just use a 64-bit nsec value as you suggest? There's on released kernel with this feature yet, so there's nothing stopping us from just changing the API to be based on a single 64-bit nanosecond timeout. diff --git a/fs/io_uring.c b/fs/io_uring.c index dd094b387cab..de3d14fe3025 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1892,16 +1892,13 @@ static int io_timeout(struct io_kiocb *req, const struct io_uring_sqe *sqe) unsigned count, req_dist, tail_index; struct io_ring_ctx *ctx = req->ctx; struct list_head *entry; - struct timespec ts; + u64 timeout; if (unlikely(ctx->flags & IORING_SETUP_IOPOLL)) return -EINVAL; if (sqe->flags || sqe->ioprio || sqe->buf_index || sqe->timeout_flags || sqe->len != 1) return -EINVAL; - if (copy_from_user(&ts, (void __user *) (unsigned long) sqe->addr, - sizeof(ts))) - return -EFAULT; /* * sqe->off holds how many events that need to occur for this @@ -1932,9 +1929,10 @@ static int io_timeout(struct io_kiocb *req, const struct io_uring_sqe *sqe) list_add(&req->list, entry); spin_unlock_irq(&ctx->completion_lock); + timeout = READ_ONCE(sqe->addr); hrtimer_init(&req->timeout.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); req->timeout.timer.function = io_timeout_fn; - hrtimer_start(&req->timeout.timer, timespec_to_ktime(ts), + hrtimer_start(&req->timeout.timer, ns_to_ktime(timeout), HRTIMER_MODE_REL); return 0; } -- Jens Axboe