Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4866488ybe; Mon, 9 Sep 2019 16:17:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYuEoXYZfIF3up33rd3Wi9ooST6ENDQQSd67VAnMnQ/8rqMyXVXoZkAb9c8MrO6MVsd4vc X-Received: by 2002:a50:e40a:: with SMTP id d10mr28053172edm.194.1568071063114; Mon, 09 Sep 2019 16:17:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568071063; cv=none; d=google.com; s=arc-20160816; b=ecyqf3G4TI8SpePo7w7MzSQp99cxECKXqi/3aiRNw3Nl57a9CJ+bCAbDSIlLYwvzQ+ vmQYkeHLJf6GXlose8XcQQd8Zhwftab79UioyZLjN+AuIyYBCZ8AV000mdYGVArBNQ05 TiSkFoUcL5jK5o3fMOuccj7+YovWp3nA7JMouutoUM7hwz1qf+RgR/Gfa9mTxAZ/Xji6 d9AXZPZVtHujCKQ6WOwwHMolQiadwXw24bpX35r/HgT9+scul6mrpoPNYanhB7XhfD9Z BjDHss7TOykfTFdLoA+5bJ0kC2IaLVX7sZQVOgRg9/wgZeX/q6WVXu1LET/c5LtQYNZD Gxtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=YU5F/Heic/wQrryXNlwp20GNT69t9CUbHvlrLA5dbAc=; b=Eq341xlbplRhYEaG5Jdt6FIFYgUoG3dfi+5+2XMUHgHU4EBX3GzZ1rIAEflpXyE9OQ qRsz29E9EpxV9xpH40lOTzZN00yGSP6MO/2QwlkyFgpD+rUFyl5OQ1S9l1ag31kmrbVG 3jTg5TDyx37bxTC6o0pq0akyhRDORL9wFHa1cC1seRIdND4Pj7Ca7ITn3d8VKaBOKU32 eyV7gwgBwdMk3wbtPE79mjFZ+2hqOUu6JYLRr/Ep54bE0P7m38cT9YpA9973LBEEaYLx 3qN2FLSEg3C4JUCExFIdRSxMF00rEilXQzSeyFeNpQybRb/Dmm3+NJ5YJ9cj0rBMW4By 4Bkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=J5Qdkebk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si1049100ede.268.2019.09.09.16.17.18; Mon, 09 Sep 2019 16:17:43 -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=@gmail.com header.s=20161025 header.b=J5Qdkebk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390949AbfIILSS (ORCPT + 99 others); Mon, 9 Sep 2019 07:18:18 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:42865 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731115AbfIILSR (ORCPT ); Mon, 9 Sep 2019 07:18:17 -0400 Received: by mail-lj1-f193.google.com with SMTP id y23so12301601lje.9; Mon, 09 Sep 2019 04:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YU5F/Heic/wQrryXNlwp20GNT69t9CUbHvlrLA5dbAc=; b=J5QdkebkgJNQn7971ElrZEaGBPIM9nw8WPDH2K2qw4xfiHukTeYSoQdmX7B/ypiaXY GQYNVMuyIAdfUivwq2/K2N7pj0GAw3omgFOR7/McV2iqAWvKJVP7rvUyTXHIURI4Tfsj 1knS7eWtPGtcVs5GMLzHPsvmq4nBSmbCs1rfUud6xQRLalNMxGqljJz1AvuTS5Izm87p DofkeNkPakDGfxsyj5eZwiIAsZRTU96tdUB9DkyhTnefjzctGDe9grPOgsAnZaRmMTok tbAzTJsC5jyuciG9V9tXybp2xt6LZBn5MvfRy1JchesEv0FPABA7k9NWl/8f5xrFaOUd C89g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YU5F/Heic/wQrryXNlwp20GNT69t9CUbHvlrLA5dbAc=; b=lekWKFT6bgFzdDNd824FtSBymfHrYOPQUvQx6wAQ0dIntTo/bD0bCzXWq0T+kReK5F QzwEX7WZjQZa13g5EVkjdxBsSZNh3AlrQ8CxebajZ0yljfjSTVEhx3k7qAwiMLsTLXSv Q6qfnb2uWMajVKt9qVHzYjtgs2oZaHO/+++PXboYy8Coval1BwR0/IMZcHVI2PVrFJzb 2cVUjLFsuFDGrPMNi/CnV3MfYntVqzU36wOtBVfGxY8eql5spIE+PduuYSdoggeiDAuB wykrMn6UFg6qyuimhRqE9GuWI5+vdXrfUPHsrMuWmz29VtEDhJ3c9G055x2u60Wqrmvx gylA== X-Gm-Message-State: APjAAAV9OVLZHQnbB/DSOQ+pMsrqgZQMJyGj+zQrft4Z/eM1nL9yY6Kl Hz9u9S175F24coQA03hvbj8= X-Received: by 2002:a2e:8691:: with SMTP id l17mr15421306lji.20.1568027895520; Mon, 09 Sep 2019 04:18:15 -0700 (PDT) Received: from uranus.localdomain ([5.18.103.226]) by smtp.gmail.com with ESMTPSA id p12sm2916453ljn.15.2019.09.09.04.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 04:18:14 -0700 (PDT) Received: by uranus.localdomain (Postfix, from userid 1000) id 0CE07460667; Mon, 9 Sep 2019 14:18:12 +0300 (MSK) Date: Mon, 9 Sep 2019 14:18:12 +0300 From: Cyrill Gorcunov To: Dmitry Safonov Cc: linux-kernel@vger.kernel.org, Dmitry Safonov <0x7f454c46@gmail.com>, Adrian Reber , Alexander Viro , Andrei Vagin , Andy Lutomirski , Ingo Molnar , Oleg Nesterov , Pavel Emelyanov , Thomas Gleixner , containers@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 4/9] select: Micro-optimise __estimate_accuracy() Message-ID: <20190909111812.GB1508@uranus> References: <20190909102340.8592-1-dima@arista.com> <20190909102340.8592-5-dima@arista.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190909102340.8592-5-dima@arista.com> User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 09, 2019 at 11:23:35AM +0100, Dmitry Safonov wrote: > Shift on s64 is faster than division, use it instead. > > As the result of the patch there is a hardly user-visible effect: > poll(), select(), etc syscalls will be a bit more precise on ~2.3% > than before because 1000 != 1024 :) > > Signed-off-by: Dmitry Safonov > --- > fs/select.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/fs/select.c b/fs/select.c > index 12cdefd3be2d..2477c202631e 100644 > --- a/fs/select.c > +++ b/fs/select.c > @@ -51,15 +51,14 @@ > > static long __estimate_accuracy(ktime_t slack) > { > - int divfactor = 1000; > - > if (slack < 0) > return 0; > > - if (task_nice(current) > 0) > - divfactor = divfactor / 5; > + /* A bit more precise than 0.1% */ > + slack = slack >> 10; > > - slack = ktime_divns(slack, divfactor); > + if (task_nice(current) > 0) > + slack = slack * 5; > > if (slack > MAX_SLACK) > return MAX_SLACK; Compiler precompute constants so it doesn't do division here. But I didn't read the series yet so I might be missing something obvious.