Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp371543pxm; Tue, 1 Mar 2022 23:30:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyGs9zAAyZBFTcSHyEqSIP5cGYYwDljNiQSaLWCzHUcPvEqh3Ue/68LHv71GJA+zN8+kpm1 X-Received: by 2002:a17:906:a398:b0:6ce:71b:deff with SMTP id k24-20020a170906a39800b006ce071bdeffmr21611242ejz.204.1646206238838; Tue, 01 Mar 2022 23:30:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646206238; cv=none; d=google.com; s=arc-20160816; b=r/1WkgXcl5y+Pk1AkyL2yiKObqjsFK7LwoLHoBZ/VH3IpIwemtwag5Hzc2N9i30w01 WQpcb4UgdmQm2AmLmKEfmB+guDfN6qImut2dV9L43Kbn5QH6XwY8kta+hhjN7Yn6tq0j UlSaWhRKza6m4FjyFjw9FGwtX+QG1nAnpQGeJ4xrnERBOC+QUM1RuUZ3fqm3EVe5Xpza N2YVL3rGqHUSf19GqYIqtwcEtiZqJE82CHaMEKx+aDSsvwQOUUXGYdB1OmJEyUhLZphC 8FSx02b1FYrb6zkbfrzVFI7hG4WKFvMoej+2GJ9tGd+9PnD3sX8YgBlLz7HFGQRTuwT8 Y8Jg== 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=b5ELX0qEwFLhVR9SM1QXVEmE98S7GmnG3i5DlfPh/I8=; b=zXzjVyeIiHeF0Tc8Pc7fVOKPopsZ2B33yk5/cDNKOht6AaeWUnsc0fZqZRDBTNkusm xUeZbWgylySAFpWycGQgTzg7oDauJvxq6Th9Jpi1BphrcMxk3Mg6XL75r5exIs5OPZ8D KO8xWuvgsipQ7n9j0Ikxg8olBw7Ub9tDdGMTgmYVx6AQc+YxWYMWlbJbKTu4ohfYxRZi rosn7ciC9KjyBg2Z4P+cvPkvT1mooRG9kUhiwis84G86Egn8thA1dZ0BEhJ+Sv1vdrWn sw31sFmx8aiM0qir0femsIFEyoyc0GDx2ftLiVCJ1q5lM8iAx+lX1xcxBqu0XapjkuG6 KQgA== 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 z4-20020a17090674c400b006b910421fa3si9449080ejl.372.2022.03.01.23.30.14; Tue, 01 Mar 2022 23:30:38 -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 S237725AbiCBFNU (ORCPT + 99 others); Wed, 2 Mar 2022 00:13:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237334AbiCBFNT (ORCPT ); Wed, 2 Mar 2022 00:13:19 -0500 Received: from cloud48395.mywhc.ca (cloud48395.mywhc.ca [173.209.37.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73B98E5C; Tue, 1 Mar 2022 21:12:34 -0800 (PST) Received: from [45.44.224.220] (port=57058 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 1nPHHt-0004WT-2C; Wed, 02 Mar 2022 00:12:33 -0500 Message-ID: Subject: Re: [PATCH v4 2/2] io_uring: Add support for napi_busy_poll From: Olivier Langlois To: Hao Xu , Jens Axboe , Pavel Begunkov Cc: io-uring , linux-kernel Date: Wed, 02 Mar 2022 00:12:32 -0500 In-Reply-To: <29bad95d-06f8-ea7c-29fe-81e52823c90a@linux.alibaba.com> References: <29bad95d-06f8-ea7c-29fe-81e52823c90a@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 Wed, 2022-03-02 at 02:31 +0800, Hao Xu wrote: > > +static void io_blocking_napi_busy_loop(struct list_head > > *napi_list, > > +????????????????????????????????????? struct io_wait_queue *iowq) > > +{ > > +???????unsigned long start_time = > > +???????????????list_is_singular(napi_list) ? 0 : > > +???????????????busy_loop_current_time(); > > + > > +???????do { > > +???????????????if (list_is_singular(napi_list)) { > > +???????????????????????struct napi_entry *ne = > > +???????????????????????????????list_first_entry(napi_list, > > +??????????????????????????????????????????????? struct napi_entry, > > list); > > + > > +???????????????????????napi_busy_loop(ne->napi_id, > > io_busy_loop_end, iowq, > > +????????????????????????????????????? true, BUSY_POLL_BUDGET); > > +???????????????????????io_check_napi_entry_timeout(ne); > > +???????????????????????break; > > +???????????????} > > +???????} while (io_napi_busy_loop(napi_list) && > > +??????????????? !io_busy_loop_end(iowq, start_time)); > > +} > > + > > How about: > > if (list is singular) { > > ???? do something; > > ???? return; > > } > > while (!io_busy_loop_end() && io_napi_busy_loop()) > > ???? ; > > > Btw, start_time seems not used in singular branch. Hao, it takes me few readings before being able to figure out the idea behind your suggestions. Sorry about that! So, if I get it correctly, you are proposing extract out the singular block out of the while loop... IMHO, this is not a good idea because you could start iterating the do/while loop with a multiple entries list that ends up becoming a singular list after one or few iterations. Check what io_napi_busy_loop() is doing... It does not look like that but a lot thoughts have been put into writing io_blocking_napi_busy_loop()...