From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B929DC5519F for ; Wed, 18 Nov 2020 15:38:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A90E2477C for ; Wed, 18 Nov 2020 15:38:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="u+I4DBKA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727434AbgKRPh6 (ORCPT ); Wed, 18 Nov 2020 10:37:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:47796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726495AbgKRPh5 (ORCPT ); Wed, 18 Nov 2020 10:37:57 -0500 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 99A2024789; Wed, 18 Nov 2020 15:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605713876; bh=UGVJOfZ14mLGsxcq39Gp7kwnfZ1K1WKhEYTJNoHGnlE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=u+I4DBKA43q3z5h1gpDuLMq5eM4QCVt/EH/+MesEVCGTSe7wJFDRVfXKRzlEdAY0C 07NlDaVYOYK6Pfge4Xz4v7rb1NuuVZbEn2q4OGbi4zuiAZQtNp/Gpd0a14/u1bepO3 ZEI0BCm4IuB09He0hf69+Ct0zCLvQbf+3WOyJaeg= Received: by mail-oi1-f178.google.com with SMTP id o25so2628605oie.5; Wed, 18 Nov 2020 07:37:56 -0800 (PST) X-Gm-Message-State: AOAM532zttSqtLp9fdYuvabAKbuAeHQ/3SPgsgE0qKaAivosai5v1imX e8IB4VL1MjWzq3l3SR1sHwC4vBT26ARoU5fl8WI= X-Google-Smtp-Source: ABdhPJw49F5eVt72usPrt335IBS23KcOceM0C5Ck8bvtp2CLmZWf2zjr7GY8+GkQD7jyqTKK0IVtQT/QJoBqS9TQ2qU= X-Received: by 2002:aca:4e42:: with SMTP id c63mr431657oib.67.1605713875694; Wed, 18 Nov 2020 07:37:55 -0800 (PST) MIME-Version: 1.0 References: <20201118144617.986860-1-willemdebruijn.kernel@gmail.com> <20201118144617.986860-2-willemdebruijn.kernel@gmail.com> <20201118150041.GF29991@casper.infradead.org> In-Reply-To: From: Arnd Bergmann Date: Wed, 18 Nov 2020 16:37:39 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/2] epoll: add nsec timeout support with epoll_pwait2 To: Willem de Bruijn Cc: Matthew Wilcox , Linux FS-devel Mailing List , linux-kernel , Al Viro , Andrew Morton , Soheil Hassas Yeganeh , Arnd Bergmann , Shuo Chen , linux-man Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 18, 2020 at 4:10 PM Willem de Bruijn wrote: > On Wed, Nov 18, 2020 at 10:00 AM Matthew Wilcox wrote: > > > > On Wed, Nov 18, 2020 at 09:46:15AM -0500, Willem de Bruijn wrote: > > > -static inline struct timespec64 ep_set_mstimeout(long ms) > > > +static inline struct timespec64 ep_set_nstimeout(s64 timeout) > > > { > > > - struct timespec64 now, ts = { > > > - .tv_sec = ms / MSEC_PER_SEC, > > > - .tv_nsec = NSEC_PER_MSEC * (ms % MSEC_PER_SEC), > > > - }; > > > + struct timespec64 now, ts; > > > > > > + ts = ns_to_timespec64(timeout); > > > ktime_get_ts64(&now); > > > return timespec64_add_safe(now, ts); > > > } > > > > Why do you pass around an s64 for timeout, converting it to and from > > a timespec64 instead of passing around a timespec64? > > I implemented both approaches. The alternative was no simpler. > Conversion in existing epoll_wait, epoll_pwait and epoll_pwait > (compat) becomes a bit more complex and adds a stack variable there if > passing the timespec64 by reference. And in ep_poll the ternary > timeout test > 0, 0, < 0 now requires checking both tv_secs and > tv_nsecs. Based on that, I found this simpler. But no strong > preference. The 64-bit division can be fairly expensive on 32-bit architectures, at least when it doesn't get optimized into a multiply+shift. Arnd