Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp590715pxm; Wed, 2 Mar 2022 04:59:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWYPfyiziZQ9GJ+VKwFGjCnu5ylffldvISr/tu/cfsqQl3X4b9dhAmtesBUb+KrSmofCf/ X-Received: by 2002:a17:907:1b20:b0:6da:649b:d99e with SMTP id mp32-20020a1709071b2000b006da649bd99emr1715560ejc.712.1646225950376; Wed, 02 Mar 2022 04:59:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646225950; cv=none; d=google.com; s=arc-20160816; b=g2zCVvlyXnVJLJ++GaOG+7bKtzjv6qOmTOhB3KDIvvhOVUV2PuQQWcRX2whTaYgpS2 rboCNCk8EcRJPR+QFpbIyk0mIzS4xiELrPJBLxP1bqYLs+dHgagbvKDmlV2tVT8XP1SY rBLeRgCy5Z97VpV658b2DOAP7+Yyk3+AlO2+tEvJu88zQ2zQh209Y0L7vr4bYTm/I7Y+ vEc+H4hGO+3LS0Caeqnx3ruBv+A7vHa+14NFc4lI0UbL3gAhaimzmfNLzuNYb0E+2lP0 f4hUsIkZs6t1pQOLfYB4SzM/wyCdhQRCHqcTLz1QDhWqXb6VUxCjoZr++QQB3q+Ne0cN yY6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=LGc3IUxHo1Ccrzkrx2UvGG6egraNwys6L8l9vWHirZ8=; b=tU4eJuzq1Et+JPCgIbXENxtbY7Xb9aQUFlGVvILi2OiWCcKS1wk+2y9MP+dlaJQKE0 k5F4kV0TQ6FVfA738NUKRa+zlpra6JtgG2HSGrjZp4IVlaKCwm/n7Mz0E77Sl6JCNuta STVfjo5L1Rk+7XBA4KyQzTi+xEknkta2lJRzpmXLA4WmdzfdyP8jQlycmp64paT4Fk2Q HZ1L+bSnpc2E+AnLt1J4BgTue/W7TUr8wqZ4cEwn1SfT8U1sx3Y+ITdgiC83jD97qALF xp0qiDoeYt6hjna/PhkBDakzq6FLtJU/ZmvrsItgOGwiVjnpgpfGFM3pTbmz5jzQqXVG zmPQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z8-20020a170906814800b006d6e100c3c0si3466737ejw.14.2022.03.02.04.58.47; Wed, 02 Mar 2022 04:59:10 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239713AbiCBGgW (ORCPT + 99 others); Wed, 2 Mar 2022 01:36:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231644AbiCBGgV (ORCPT ); Wed, 2 Mar 2022 01:36:21 -0500 Received: from out199-10.us.a.mail.aliyun.com (out199-10.us.a.mail.aliyun.com [47.90.199.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 560645F8C4; Tue, 1 Mar 2022 22:35:38 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R991e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=haoxu@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0V61Jf3z_1646202933; Received: from 30.226.12.26(mailfrom:haoxu@linux.alibaba.com fp:SMTPD_---0V61Jf3z_1646202933) by smtp.aliyun-inc.com(127.0.0.1); Wed, 02 Mar 2022 14:35:34 +0800 Message-ID: <970e752b-aa75-8f66-ae7a-65ab509bea10@linux.alibaba.com> Date: Wed, 2 Mar 2022 14:35:33 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v4 2/2] io_uring: Add support for napi_busy_poll Content-Language: en-US To: Olivier Langlois , Jens Axboe , Pavel Begunkov Cc: io-uring , linux-kernel References: <29bad95d-06f8-ea7c-29fe-81e52823c90a@linux.alibaba.com> From: Hao Xu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 3/2/22 13:12, Olivier Langlois wrote: > 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. My bad, I get your point now. > > 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()... True.