Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3164425pxm; Mon, 28 Feb 2022 13:29:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4J6BKM855iQ6XGmzF8xtFGUGShlNFutIPFQH5QxXDF8A7NhQfa8XxvAagP7H0KIUgThDv X-Received: by 2002:a05:6402:1e8e:b0:412:cfd8:4d12 with SMTP id f14-20020a0564021e8e00b00412cfd84d12mr21299993edf.343.1646083755584; Mon, 28 Feb 2022 13:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646083755; cv=none; d=google.com; s=arc-20160816; b=htO7u6zEwAkNfR/7dJ7+LRP5Ur583k/TB2N8lzAjPKSj2EbpBQMe+pAZJ3zYYCC0Lx L35awV6iZ/F/qU1qqoHL/1nbyYyCn233sglGTYiRTnR+v2O2TzgS+1knGwumfbRU18of PG8hMYmxjUYG8cY+ITfSxlWEKSFG3ZfTJRndAIo69aWHHp0qIgVzIkTsJfYwQUYBfN3W z8LUBuvDDMYZX9fL3Vb7Jyb2QjhxeAli3fuj7+BlkpTJg8EF7AlopReNEwYMoKmvm5V8 voaNokib+U8We1uwVuKBwMVKNH/M2s0BIgRuhmdEZgy0nnOp5V8Kc7zCZSaJRazDDQg9 8DHw== 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 :user-agent:organization:references:in-reply-to:date:cc:to:from :subject:message-id; bh=nKwB72T9vYU57hukhuG7jP2dTPpWeGasT35QRg2nXSw=; b=ubBqI0ZAHbhDhzUjM8b/TkZv0Z8bqEPiEH4yRJ0iAEaqPtdHD8CDABowiORYF4hjtS LY33LQ3CDjccQ+GHIRjQPC98IFj23qLM5dYnrDSbq2CptPdpQH+hhgggrJlenEUXvXqk IbA7rhSkZ/SzAu5tk8vxl3KmjjETO2I9KsAp2wW/Kbv2S0B4VcixCX8BbDBudWDkEZaz X1M6kR7n11M/YwaJnfrLsw0TIfbiMIWKAhKquWNM3qZkTrgYqS6GEkl6ERhgCgQkJStN wP6FJugWVp3tTE8Anv33w1NZAOOsaL4wyOC7uRaXEHZFJ27Cjq7O/UkONUjDOjtpVrTn UCQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b18-20020aa7cd12000000b00410b91b9f83si7177296edw.450.2022.02.28.13.28.52; Mon, 28 Feb 2022 13:29:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230056AbiB1VU4 (ORCPT + 99 others); Mon, 28 Feb 2022 16:20:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbiB1VUz (ORCPT ); Mon, 28 Feb 2022 16:20:55 -0500 Received: from cloud48395.mywhc.ca (cloud48395.mywhc.ca [173.209.37.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 592D7EF0A4; Mon, 28 Feb 2022 13:20:16 -0800 (PST) Received: from [45.44.224.220] (port=57034 helo=[192.168.1.179]) by cloud48395.mywhc.ca with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nOnRG-0004kq-Up; Mon, 28 Feb 2022 16:20:14 -0500 Message-ID: <1b6439ba29a3725ed041bfb8040c6b667cc4898a.camel@trillion01.com> Subject: Re: [PATCH v1] io_uring: Add support for napi_busy_poll From: Olivier Langlois To: Hao Xu , Jens Axboe Cc: Pavel Begunkov , io-uring , linux-kernel Date: Mon, 28 Feb 2022 16:20:14 -0500 In-Reply-To: <9954b806-c4a0-2448-1eac-c8fc5cf2ca2c@linux.alibaba.com> References: <2cedc9f21a1c89aa9fe1fa4dffc2ebeabeb761f5.camel@trillion01.com> <9954b806-c4a0-2448-1eac-c8fc5cf2ca2c@linux.alibaba.com> Organization: Trillion01 Inc Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.42.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cloud48395.mywhc.ca X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - trillion01.com X-Get-Message-Sender-Via: cloud48395.mywhc.ca: authenticated_id: olivier@trillion01.com X-Authenticated-Sender: cloud48395.mywhc.ca: olivier@trillion01.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2022-03-01 at 02:34 +0800, Hao Xu wrote: > > On 2/25/22 23:32, Olivier Langlois wrote: > > On Fri, 2022-02-25 at 00:32 -0500, Olivier Langlois wrote: > > > > > +#ifdef CONFIG_NET_RX_BUSY_POLL > > > > > +static void io_adjust_busy_loop_timeout(struct timespec64 > > > > > *ts, > > > > > +???????????????????????????????????????struct io_wait_queue > > > > > *iowq) > > > > > +{ > > > > > +???????unsigned busy_poll_to = > > > > > READ_ONCE(sysctl_net_busy_poll); > > > > > +???????struct timespec64 pollto = ns_to_timespec64(1000 * > > > > > (s64)busy_poll_to); > > > > > + > > > > > +???????if (timespec64_compare(ts, &pollto) > 0) { > > > > > +???????????????*ts = timespec64_sub(*ts, pollto); > > > > > +???????????????iowq->busy_poll_to = busy_poll_to; > > > > > +???????} else { > > > > > +???????????????iowq->busy_poll_to = timespec64_to_ns(ts) / > > > > > 1000; > > > > How about timespec64_tons(ts) >> 10, since we don't need > > > > accurate > > > > number. > > > Fantastic suggestion! The kernel test robot did also detect an > > > issue > > > with that statement. I did discover do_div() in the meantime but > > > what > > > you suggest is better, IMHO... > > After having seen Jens patch (io_uring: don't convert to jiffies > > for > > waiting on timeouts), I think that I'll stick with do_div(). > > > > I have a hard time considering removing timing accuracy when effort > > is > > made to make the same function more accurate... > > > I think they are different things. Jens' patch is to resolve the > problem > > that jiffies possibly can not stand for time < 1ms (when HZ is 1000). > > For example, a user assigns 10us, turn out to be 1ms, it's big > difference. > > But divided by 1000 or 1024 is not that quite different in this case. > > > idk... For every 100uSec slice, dividing by 1024 will introduce a ~2.4uSec error. I didn't dig enough the question to figure out if the error was smaller than the used clock accuracy. but even if the error is small, why letting it slip in when 100% accurate value is possible? Beside, making the painfully picky do_div() macro for some platforms happy, I fail to understand the problem with doing a division to get an accurate value. let me reverse the question. Even if the bit shifting is a bit faster than doing the division, would the code be called often enough to make a significant difference?