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=-7.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 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 6A7A1C433E0 for ; Mon, 3 Aug 2020 03:16:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DEAC20738 for ; Mon, 3 Aug 2020 03:16:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726150AbgHCDQT (ORCPT ); Sun, 2 Aug 2020 23:16:19 -0400 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:44814 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725863AbgHCDQT (ORCPT ); Sun, 2 Aug 2020 23:16:19 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07425;MF=jiufei.xue@linux.alibaba.com;NM=1;PH=DS;RN=2;SR=0;TI=SMTPD_---0U4WbRYc_1596424572; Received: from ali-186590e05fa3.local(mailfrom:jiufei.xue@linux.alibaba.com fp:SMTPD_---0U4WbRYc_1596424572) by smtp.aliyun-inc.com(127.0.0.1); Mon, 03 Aug 2020 11:16:13 +0800 Subject: Re: [PATCH liburing 1/2] io_uring_enter: add timeout support To: Jens Axboe Cc: io-uring@vger.kernel.org References: <1596017415-39101-1-git-send-email-jiufei.xue@linux.alibaba.com> <1596017415-39101-2-git-send-email-jiufei.xue@linux.alibaba.com> <0f6cdf31-fbec-d447-989d-969bb936838a@kernel.dk> <0002bd2c-1375-2b95-fe98-41ee0895141e@linux.alibaba.com> <252c29a9-9fb4-a61f-6899-129fd04db4a0@kernel.dk> <253b4df7-a35b-4d49-8cdc-c6fa24446bf9@kernel.dk> From: Jiufei Xue Message-ID: Date: Mon, 3 Aug 2020 11:16:12 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <253b4df7-a35b-4d49-8cdc-c6fa24446bf9@kernel.dk> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: io-uring-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Hi Jens, On 2020/7/31 上午11:57, Jens Axboe wrote: > Then why not just make the sqe-less timeout path flush existing requests, > if it needs to? Seems a lot simpler than adding odd x2 variants, which > won't really be clear. > Flushing the requests will access and modify the head of submit queue, that may race with the submit thread. I think the reap thread should not touch the submit queue when IORING_FEAT_GETEVENTS_TIMEOUT is supported. > Chances are, if it's called with sq entries pending, the caller likely > wants those submitted. Either the caller was aware and relying on that > behavior, or the caller is simply buggy and has a case where it doesn't > submit IO before waiting for completions. > That is not true when the SQ/CQ handling are split in two different threads. The reaping thread is not aware of the submit queue. It should only wait for completion of the requests, such as below: submitting_thread: reaping_thread: io_uring_get_sqe() io_uring_prep_nop() io_uring_wait_cqe_timeout2() io_uring_submit() woken if requests are completed or timeout And if the SQ/CQ handling are in the same thread, applications should use the old API if they do not want to submit the request themselves. io_uring_get_sqe io_uring_prep_nop io_uring_wait_cqe_timeout > Hence I really don't think that's a big deal, and even arguably the right > thing to do.