Message ID | 20230716195007.731909670@linuxfoundation.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp778826vqt; Sun, 16 Jul 2023 14:17:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlH5ssX6LbTeqfKVsxCNfsyjFdmejwqOHwmLBXSVOc24bM3Htw1DJATD4XWrt9lbTNEbXI4w X-Received: by 2002:a05:6a00:18a5:b0:64c:c5f9:1533 with SMTP id x37-20020a056a0018a500b0064cc5f91533mr13489229pfh.33.1689542237535; Sun, 16 Jul 2023 14:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689542237; cv=none; d=google.com; s=arc-20160816; b=x7+sDJH8dsocbCEgy3DYzXGEQf1eUV8bX5CLUJESwGUc9OAWPt1yD59hS8DPuMxz7k nPnBDeQoRfAN1XnqptQxRTUnhQpJTwiyDl0MyhQSvnYUETQbXoSqUQWvA4tzTMoG7lW0 jrQ62rorc2fJHIGAgENOkYRJ+NfNJI4TktYBTay9W1xdofBu3yLUHnRybTRDzyTY6SBy 5ZQ3XUY/z7ZbQU1fEnm1kIeUX5sgwUeV2ySVqO2eIJFWnBKGKIKGhetTE5W9SF1axOJS RETo6VWd2P3PPG0Sb2KL0OKIlgyJP8f8jPiti96WsXrhOZclM1Y7gFHYwjntEiuI56G1 3ADA== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RX/5bqHMA2m9Fh1KpdGCTx1cOE1oh+wjNfE/B2xqakU=; fh=lP7xFG8LMCk6E4eEHoDhWf7pUSclif8yeIbxz4oRH8Y=; b=m5ga0lEmiB/fBsBNwGKSS5WFUPD11Jh5XdKWho7xt5flch8pIJqtYznvypxd5S/pjA wvI/PZlGvw9pOe/gqq/CSAt+6jbLToAZ+D8amLF1nhCxo8hR6VRmkApI/FaIreEv7GtH d+nNwtMx16t1X5XKdFgimCIxw7orHosayZycMCII9/VATOKHWQU9uuJNhsE9p+nTfp7W /hN0Rry6Sv3sFIoWRP5ixw5UMfbj/G8tgtptmXn+IAZ9RWUHhHuvPaywqTP6Pk/3ng00 WVt2j6+fYQa9zMdXN7uMZRK38yWhBps6TVAvknA52K75gMi+9JgCvqljePqy31y6P1IX dF2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UANksxT4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay5-20020a056a00300500b0068270404171si10472458pfb.208.2023.07.16.14.17.04; Sun, 16 Jul 2023 14:17:17 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UANksxT4; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232140AbjGPUaV (ORCPT <rfc822;assdfgzxcv4@gmail.com> + 99 others); Sun, 16 Jul 2023 16:30:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232120AbjGPUaT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 16 Jul 2023 16:30:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E7D4E46; Sun, 16 Jul 2023 13:30:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A12AC60EAE; Sun, 16 Jul 2023 20:30:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF745C433C7; Sun, 16 Jul 2023 20:30:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1689539414; bh=ExzEbA/RIzTxjKUcd5Ih5Si564HbUIS8oZ/FuVczb5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UANksxT4i2gk58mCdpEjB/JIRdD+KqDeUfEMyEsliBgk+GGhzyYYrPRTuBannQ6VV +bqW/b8oWQ8nh2Mbs0ue0SJTtyX+z1Rl/i6ucvIU2woSmCL4FGmLNgQBIcbkl+X+4r vepNY1w8q8m0LkFIZDFiLWtx2ACnkIuOVVRgdOS0= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: stable@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, patches@lists.linux.dev, Pavel Begunkov <asml.silence@gmail.com>, io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, Andres Freund <andres@anarazel.de>, Jens Axboe <axboe@kernel.dk> Subject: [PATCH 6.4 800/800] io_uring: Use io_schedule* in cqring wait Date: Sun, 16 Jul 2023 21:50:53 +0200 Message-ID: <20230716195007.731909670@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230716194949.099592437@linuxfoundation.org> References: <20230716194949.099592437@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771613441136389140 X-GMAIL-MSGID: 1771613441136389140 |
Series |
None
|
|
Commit Message
Greg KH
July 16, 2023, 7:50 p.m. UTC
From: Andres Freund <andres@anarazel.de> commit 8a796565cec3601071cbbd27d6304e202019d014 upstream. I observed poor performance of io_uring compared to synchronous IO. That turns out to be caused by deeper CPU idle states entered with io_uring, due to io_uring using plain schedule(), whereas synchronous IO uses io_schedule(). The losses due to this are substantial. On my cascade lake workstation, t/io_uring from the fio repository e.g. yields regressions between 20% and 40% with the following command: ./t/io_uring -r 5 -X0 -d 1 -s 1 -c 1 -p 0 -S$use_sync -R 0 /mnt/t2/fio/write.0.0 This is repeatable with different filesystems, using raw block devices and using different block devices. Use io_schedule_prepare() / io_schedule_finish() in io_cqring_wait_schedule() to address the difference. After that using io_uring is on par or surpassing synchronous IO (using registered files etc makes it reliably win, but arguably is a less fair comparison). There are other calls to schedule() in io_uring/, but none immediately jump out to be similarly situated, so I did not touch them. Similarly, it's possible that mutex_lock_io() should be used, but it's not clear if there are cases where that matters. Cc: stable@vger.kernel.org # 5.10+ Cc: Pavel Begunkov <asml.silence@gmail.com> Cc: io-uring@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Andres Freund <andres@anarazel.de> Link: https://lore.kernel.org/r/20230707162007.194068-1-andres@anarazel.de [axboe: minor style fixup] Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- io_uring/io_uring.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
Comments
Hello. On neděle 16. července 2023 21:50:53 CEST Greg Kroah-Hartman wrote: > From: Andres Freund <andres@anarazel.de> > > commit 8a796565cec3601071cbbd27d6304e202019d014 upstream. > > I observed poor performance of io_uring compared to synchronous IO. That > turns out to be caused by deeper CPU idle states entered with io_uring, > due to io_uring using plain schedule(), whereas synchronous IO uses > io_schedule(). > > The losses due to this are substantial. On my cascade lake workstation, > t/io_uring from the fio repository e.g. yields regressions between 20% > and 40% with the following command: > ./t/io_uring -r 5 -X0 -d 1 -s 1 -c 1 -p 0 -S$use_sync -R 0 /mnt/t2/fio/write.0.0 > > This is repeatable with different filesystems, using raw block devices > and using different block devices. > > Use io_schedule_prepare() / io_schedule_finish() in > io_cqring_wait_schedule() to address the difference. > > After that using io_uring is on par or surpassing synchronous IO (using > registered files etc makes it reliably win, but arguably is a less fair > comparison). > > There are other calls to schedule() in io_uring/, but none immediately > jump out to be similarly situated, so I did not touch them. Similarly, > it's possible that mutex_lock_io() should be used, but it's not clear if > there are cases where that matters. > > Cc: stable@vger.kernel.org # 5.10+ > Cc: Pavel Begunkov <asml.silence@gmail.com> > Cc: io-uring@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Signed-off-by: Andres Freund <andres@anarazel.de> > Link: https://lore.kernel.org/r/20230707162007.194068-1-andres@anarazel.de > [axboe: minor style fixup] > Signed-off-by: Jens Axboe <axboe@kernel.dk> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > --- > io_uring/io_uring.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > --- a/io_uring/io_uring.c > +++ b/io_uring/io_uring.c > @@ -2575,6 +2575,8 @@ int io_run_task_work_sig(struct io_ring_ > static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx, > struct io_wait_queue *iowq) > { > + int token, ret; > + > if (unlikely(READ_ONCE(ctx->check_cq))) > return 1; > if (unlikely(!llist_empty(&ctx->work_llist))) > @@ -2585,11 +2587,20 @@ static inline int io_cqring_wait_schedul > return -EINTR; > if (unlikely(io_should_wake(iowq))) > return 0; > + > + /* > + * Use io_schedule_prepare/finish, so cpufreq can take into account > + * that the task is waiting for IO - turns out to be important for low > + * QD IO. > + */ > + token = io_schedule_prepare(); > + ret = 0; > if (iowq->timeout == KTIME_MAX) > schedule(); > else if (!schedule_hrtimeout(&iowq->timeout, HRTIMER_MODE_ABS)) > - return -ETIME; > - return 0; > + ret = -ETIME; > + io_schedule_finish(token); > + return ret; > } > > /* Reportedly, this caused a regression as reported in [1] [2] [3]. Not only v6.4.4 is affected, v6.1.39 is affected too. Reverting this commit fixes the issue. Please check. Thanks. [1] https://bbs.archlinux.org/viewtopic.php?id=287343 [2] https://bugzilla.kernel.org/show_bug.cgi?id=217700 [3] https://bugzilla.kernel.org/show_bug.cgi?id=217699
On Sun, Jul 23, 2023 at 11:39:42AM +0200, Oleksandr Natalenko wrote: > Hello. > > On neděle 16. července 2023 21:50:53 CEST Greg Kroah-Hartman wrote: > > From: Andres Freund <andres@anarazel.de> > > > > commit 8a796565cec3601071cbbd27d6304e202019d014 upstream. > > > > I observed poor performance of io_uring compared to synchronous IO. That > > turns out to be caused by deeper CPU idle states entered with io_uring, > > due to io_uring using plain schedule(), whereas synchronous IO uses > > io_schedule(). > > > > The losses due to this are substantial. On my cascade lake workstation, > > t/io_uring from the fio repository e.g. yields regressions between 20% > > and 40% with the following command: > > ./t/io_uring -r 5 -X0 -d 1 -s 1 -c 1 -p 0 -S$use_sync -R 0 /mnt/t2/fio/write.0.0 > > > > This is repeatable with different filesystems, using raw block devices > > and using different block devices. > > > > Use io_schedule_prepare() / io_schedule_finish() in > > io_cqring_wait_schedule() to address the difference. > > > > After that using io_uring is on par or surpassing synchronous IO (using > > registered files etc makes it reliably win, but arguably is a less fair > > comparison). > > > > There are other calls to schedule() in io_uring/, but none immediately > > jump out to be similarly situated, so I did not touch them. Similarly, > > it's possible that mutex_lock_io() should be used, but it's not clear if > > there are cases where that matters. > > > > Cc: stable@vger.kernel.org # 5.10+ > > Cc: Pavel Begunkov <asml.silence@gmail.com> > > Cc: io-uring@vger.kernel.org > > Cc: linux-kernel@vger.kernel.org > > Signed-off-by: Andres Freund <andres@anarazel.de> > > Link: https://lore.kernel.org/r/20230707162007.194068-1-andres@anarazel.de > > [axboe: minor style fixup] > > Signed-off-by: Jens Axboe <axboe@kernel.dk> > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > --- > > io_uring/io_uring.c | 15 +++++++++++++-- > > 1 file changed, 13 insertions(+), 2 deletions(-) > > > > --- a/io_uring/io_uring.c > > +++ b/io_uring/io_uring.c > > @@ -2575,6 +2575,8 @@ int io_run_task_work_sig(struct io_ring_ > > static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx, > > struct io_wait_queue *iowq) > > { > > + int token, ret; > > + > > if (unlikely(READ_ONCE(ctx->check_cq))) > > return 1; > > if (unlikely(!llist_empty(&ctx->work_llist))) > > @@ -2585,11 +2587,20 @@ static inline int io_cqring_wait_schedul > > return -EINTR; > > if (unlikely(io_should_wake(iowq))) > > return 0; > > + > > + /* > > + * Use io_schedule_prepare/finish, so cpufreq can take into account > > + * that the task is waiting for IO - turns out to be important for low > > + * QD IO. > > + */ > > + token = io_schedule_prepare(); > > + ret = 0; > > if (iowq->timeout == KTIME_MAX) > > schedule(); > > else if (!schedule_hrtimeout(&iowq->timeout, HRTIMER_MODE_ABS)) > > - return -ETIME; > > - return 0; > > + ret = -ETIME; > > + io_schedule_finish(token); > > + return ret; > > } > > > > /* > > Reportedly, this caused a regression as reported in [1] [2] [3]. Not only v6.4.4 is affected, v6.1.39 is affected too. > > Reverting this commit fixes the issue. > > Please check. Is this also an issue in 6.5-rc2? thanks, greg k-h
On 7/23/23 06:50, Greg Kroah-Hartman wrote: > On Sun, Jul 23, 2023 at 11:39:42AM +0200, Oleksandr Natalenko wrote: >> Hello. >> >> On neděle 16. července 2023 21:50:53 CEST Greg Kroah-Hartman wrote: >>> From: Andres Freund <andres@anarazel.de> >>> >>> commit 8a796565cec3601071cbbd27d6304e202019d014 upstream. >>> >>> I observed poor performance of io_uring compared to synchronous IO. That ... >> >> Reportedly, this caused a regression as reported in [1] [2] [3]. Not only v6.4.4 is affected, v6.1.39 is affected too. >> >> Reverting this commit fixes the issue. >> >> Please check. > > Is this also an issue in 6.5-rc2? > > thanks, > > greg k-h Yes - I can confirm this issue is in 6.5-rc2 and with Linus' commit c2782531397f5cb19ca3f8f9c17727f1cdf5bee8. gene
On neděle 23. července 2023 12:50:30 CEST Greg Kroah-Hartman wrote: > On Sun, Jul 23, 2023 at 11:39:42AM +0200, Oleksandr Natalenko wrote: > > Hello. > > > > On neděle 16. července 2023 21:50:53 CEST Greg Kroah-Hartman wrote: > > > From: Andres Freund <andres@anarazel.de> > > > > > > commit 8a796565cec3601071cbbd27d6304e202019d014 upstream. > > > > > > I observed poor performance of io_uring compared to synchronous IO. That > > > turns out to be caused by deeper CPU idle states entered with io_uring, > > > due to io_uring using plain schedule(), whereas synchronous IO uses > > > io_schedule(). > > > > > > The losses due to this are substantial. On my cascade lake workstation, > > > t/io_uring from the fio repository e.g. yields regressions between 20% > > > and 40% with the following command: > > > ./t/io_uring -r 5 -X0 -d 1 -s 1 -c 1 -p 0 -S$use_sync -R 0 /mnt/t2/fio/write.0.0 > > > > > > This is repeatable with different filesystems, using raw block devices > > > and using different block devices. > > > > > > Use io_schedule_prepare() / io_schedule_finish() in > > > io_cqring_wait_schedule() to address the difference. > > > > > > After that using io_uring is on par or surpassing synchronous IO (using > > > registered files etc makes it reliably win, but arguably is a less fair > > > comparison). > > > > > > There are other calls to schedule() in io_uring/, but none immediately > > > jump out to be similarly situated, so I did not touch them. Similarly, > > > it's possible that mutex_lock_io() should be used, but it's not clear if > > > there are cases where that matters. > > > > > > Cc: stable@vger.kernel.org # 5.10+ > > > Cc: Pavel Begunkov <asml.silence@gmail.com> > > > Cc: io-uring@vger.kernel.org > > > Cc: linux-kernel@vger.kernel.org > > > Signed-off-by: Andres Freund <andres@anarazel.de> > > > Link: https://lore.kernel.org/r/20230707162007.194068-1-andres@anarazel.de > > > [axboe: minor style fixup] > > > Signed-off-by: Jens Axboe <axboe@kernel.dk> > > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > > > --- > > > io_uring/io_uring.c | 15 +++++++++++++-- > > > 1 file changed, 13 insertions(+), 2 deletions(-) > > > > > > --- a/io_uring/io_uring.c > > > +++ b/io_uring/io_uring.c > > > @@ -2575,6 +2575,8 @@ int io_run_task_work_sig(struct io_ring_ > > > static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx, > > > struct io_wait_queue *iowq) > > > { > > > + int token, ret; > > > + > > > if (unlikely(READ_ONCE(ctx->check_cq))) > > > return 1; > > > if (unlikely(!llist_empty(&ctx->work_llist))) > > > @@ -2585,11 +2587,20 @@ static inline int io_cqring_wait_schedul > > > return -EINTR; > > > if (unlikely(io_should_wake(iowq))) > > > return 0; > > > + > > > + /* > > > + * Use io_schedule_prepare/finish, so cpufreq can take into account > > > + * that the task is waiting for IO - turns out to be important for low > > > + * QD IO. > > > + */ > > > + token = io_schedule_prepare(); > > > + ret = 0; > > > if (iowq->timeout == KTIME_MAX) > > > schedule(); > > > else if (!schedule_hrtimeout(&iowq->timeout, HRTIMER_MODE_ABS)) > > > - return -ETIME; > > > - return 0; > > > + ret = -ETIME; > > > + io_schedule_finish(token); > > > + return ret; > > > } > > > > > > /* > > > > Reportedly, this caused a regression as reported in [1] [2] [3]. Not only v6.4.4 is affected, v6.1.39 is affected too. > > > > Reverting this commit fixes the issue. > > > > Please check. > > Is this also an issue in 6.5-rc2? As per [1], yes. [1] https://bugzilla.kernel.org/show_bug.cgi?id=217699#c4 > > thanks, > > greg k-h >
Linux regression tracking (Thorsten Leemhuis)
July 23, 2023, 12:11 p.m. UTC |
#5
Addressed
Unaddressed
[CCing the regression list, as it should be in the loop for regressions: https://docs.kernel.org/admin-guide/reporting-regressions.html] [TLDR: I'm adding this report to the list of tracked Linux kernel regressions; the text you find below is based on a few templates paragraphs you might have encountered already in similar form. See link in footer if these mails annoy you.] On 23.07.23 11:39, Oleksandr Natalenko wrote: > On neděle 16. července 2023 21:50:53 CEST Greg Kroah-Hartman wrote: >> From: Andres Freund <andres@anarazel.de> >> >> commit 8a796565cec3601071cbbd27d6304e202019d014 upstream. >> >> I observed poor performance of io_uring compared to synchronous IO. That >> turns out to be caused by deeper CPU idle states entered with io_uring, >> due to io_uring using plain schedule(), whereas synchronous IO uses >> io_schedule(). >> >> The losses due to this are substantial. On my cascade lake workstation, >> t/io_uring from the fio repository e.g. yields regressions between 20% >> and 40% with the following command: >> ./t/io_uring -r 5 -X0 -d 1 -s 1 -c 1 -p 0 -S$use_sync -R 0 /mnt/t2/fio/write.0.0 >> > > Reportedly, this caused a regression as reported in [1] [2] [3]. Not only v6.4.4 is affected, v6.1.39 is affected too. > > Reverting this commit fixes the issue. > > Please check. > > Thanks. > > [1] https://bbs.archlinux.org/viewtopic.php?id=287343 > [2] https://bugzilla.kernel.org/show_bug.cgi?id=217700 > [3] https://bugzilla.kernel.org/show_bug.cgi?id=217699 Thanks for the report. To be sure the issue doesn't fall through the cracks unnoticed, I'm adding it to regzbot, the Linux kernel regression tracking bot: #regzbot introduced 8a796565cec360107 ^ https://bbs.archlinux.org/viewtopic.php?id=287343 https://bugzilla.kernel.org/show_bug.cgi?id=217700 https://bugzilla.kernel.org/show_bug.cgi?id=217699 #regzbot title block: io_uring: high iowait rates and stalls #regzbot ignore-activity This isn't a regression? This issue or a fix for it are already discussed somewhere else? It was fixed already? You want to clarify when the regression started to happen? Or point out I got the title or something else totally wrong? Then just reply and tell me -- ideally while also telling regzbot about it, as explained by the page listed in the footer of this mail. Developers: When fixing the issue, remember to add 'Link:' tags pointing to the report (the parent of this mail). See page linked in footer for details. Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) -- Everything you wanna know about Linux kernel regression tracking: https://linux-regtracking.leemhuis.info/about/#tldr That page also explains what to do if mails like this annoy you.
On 7/23/23 3:39?AM, Oleksandr Natalenko wrote: > Hello. > > On ned?le 16. ?ervence 2023 21:50:53 CEST Greg Kroah-Hartman wrote: >> From: Andres Freund <andres@anarazel.de> >> >> commit 8a796565cec3601071cbbd27d6304e202019d014 upstream. >> >> I observed poor performance of io_uring compared to synchronous IO. That >> turns out to be caused by deeper CPU idle states entered with io_uring, >> due to io_uring using plain schedule(), whereas synchronous IO uses >> io_schedule(). >> >> The losses due to this are substantial. On my cascade lake workstation, >> t/io_uring from the fio repository e.g. yields regressions between 20% >> and 40% with the following command: >> ./t/io_uring -r 5 -X0 -d 1 -s 1 -c 1 -p 0 -S$use_sync -R 0 /mnt/t2/fio/write.0.0 >> >> This is repeatable with different filesystems, using raw block devices >> and using different block devices. >> >> Use io_schedule_prepare() / io_schedule_finish() in >> io_cqring_wait_schedule() to address the difference. >> >> After that using io_uring is on par or surpassing synchronous IO (using >> registered files etc makes it reliably win, but arguably is a less fair >> comparison). >> >> There are other calls to schedule() in io_uring/, but none immediately >> jump out to be similarly situated, so I did not touch them. Similarly, >> it's possible that mutex_lock_io() should be used, but it's not clear if >> there are cases where that matters. >> >> Cc: stable@vger.kernel.org # 5.10+ >> Cc: Pavel Begunkov <asml.silence@gmail.com> >> Cc: io-uring@vger.kernel.org >> Cc: linux-kernel@vger.kernel.org >> Signed-off-by: Andres Freund <andres@anarazel.de> >> Link: https://lore.kernel.org/r/20230707162007.194068-1-andres@anarazel.de >> [axboe: minor style fixup] >> Signed-off-by: Jens Axboe <axboe@kernel.dk> >> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> >> --- >> io_uring/io_uring.c | 15 +++++++++++++-- >> 1 file changed, 13 insertions(+), 2 deletions(-) >> >> --- a/io_uring/io_uring.c >> +++ b/io_uring/io_uring.c >> @@ -2575,6 +2575,8 @@ int io_run_task_work_sig(struct io_ring_ >> static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx, >> struct io_wait_queue *iowq) >> { >> + int token, ret; >> + >> if (unlikely(READ_ONCE(ctx->check_cq))) >> return 1; >> if (unlikely(!llist_empty(&ctx->work_llist))) >> @@ -2585,11 +2587,20 @@ static inline int io_cqring_wait_schedul >> return -EINTR; >> if (unlikely(io_should_wake(iowq))) >> return 0; >> + >> + /* >> + * Use io_schedule_prepare/finish, so cpufreq can take into account >> + * that the task is waiting for IO - turns out to be important for low >> + * QD IO. >> + */ >> + token = io_schedule_prepare(); >> + ret = 0; >> if (iowq->timeout == KTIME_MAX) >> schedule(); >> else if (!schedule_hrtimeout(&iowq->timeout, HRTIMER_MODE_ABS)) >> - return -ETIME; >> - return 0; >> + ret = -ETIME; >> + io_schedule_finish(token); >> + return ret; >> } >> >> /* > > Reportedly, this caused a regression as reported in [1] [2] [3]. Not only v6.4.4 is affected, v6.1.39 is affected too. > > Reverting this commit fixes the issue. > > Please check. > > Thanks. > > [1] https://bbs.archlinux.org/viewtopic.php?id=287343 > [2] https://bugzilla.kernel.org/show_bug.cgi?id=217700 > [3] https://bugzilla.kernel.org/show_bug.cgi?id=217699 Just read the first one, but this is very much expected. It's now just correctly reflecting that one thread is waiting on IO. IO wait being 100% doesn't mean that one core is running 100% of the time, it just means it's WAITING on IO 100% of the time.
Linux regression tracking (Thorsten Leemhuis)
July 23, 2023, 5:35 p.m. UTC |
#7
Addressed
Unaddressed
On 23.07.23 14:11, Linux regression tracking #adding (Thorsten Leemhuis) wrote: > On 23.07.23 11:39, Oleksandr Natalenko wrote: >> On neděle 16. července 2023 21:50:53 CEST Greg Kroah-Hartman wrote: >>> From: Andres Freund <andres@anarazel.de> >>> >>> commit 8a796565cec3601071cbbd27d6304e202019d014 upstream. >>> >>> I observed poor performance of io_uring compared to synchronous IO. That >>> turns out to be caused by deeper CPU idle states entered with io_uring, >>> due to io_uring using plain schedule(), whereas synchronous IO uses >>> io_schedule(). > #regzbot introduced 8a796565cec360107 ^ > https://bbs.archlinux.org/viewtopic.php?id=287343 > https://bugzilla.kernel.org/show_bug.cgi?id=217700 > https://bugzilla.kernel.org/show_bug.cgi?id=217699 > #regzbot title block: io_uring: high iowait rates and stalls > #regzbot ignore-activity Apparently expected behavior: https://lore.kernel.org/lkml/538065ee-4130-6a00-dcc8-f69fbc7d7ba0@kernel.dk/ #regzbot resolve: notabug: on a closer look it turned out that's expected behavior Ciao, Thorsten (wearing his 'the Linux kernel's regression tracker' hat) -- Everything you wanna know about Linux kernel regression tracking: https://linux-regtracking.leemhuis.info/about/#tldr That page also explains what to do if mails like this annoy you. #regzbot ignore-activity
On 7/23/23 11:31, Jens Axboe wrote: ... > Just read the first one, but this is very much expected. It's now just > correctly reflecting that one thread is waiting on IO. IO wait being > 100% doesn't mean that one core is running 100% of the time, it just > means it's WAITING on IO 100% of the time. > Seems reasonable thank you. Question - do you expect the iowait to stay high for a freshly created mariadb doing nothing (as far as I can tell anyway) until process exited? Or Would you think it would drop in this case prior to the process exiting. For example I tried the following - is the output what you expect? Create a fresh mariab with no databases - monitor the core showing the iowaits with: mpstat -P ALL 2 100 # rm -f /var/lib/mysql/* # mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql # systemctl start mariadb (iowaits -> 100%) # iotop -bo |grep maria (shows no output, iowait stays 100%) (this persists until mariadb process exits) # systemctl stop mariadb (iowait drops to 0%)
Hello. On neděle 23. července 2023 19:43:50 CEST Genes Lists wrote: > On 7/23/23 11:31, Jens Axboe wrote: > ... > > Just read the first one, but this is very much expected. It's now just > > correctly reflecting that one thread is waiting on IO. IO wait being > > 100% doesn't mean that one core is running 100% of the time, it just > > means it's WAITING on IO 100% of the time. > > > > Seems reasonable thank you. > > Question - do you expect the iowait to stay high for a freshly created > mariadb doing nothing (as far as I can tell anyway) until process > exited? Or Would you think it would drop in this case prior to the > process exiting. > > For example I tried the following - is the output what you expect? > > Create a fresh mariab with no databases - monitor the core showing the > iowaits with: > > mpstat -P ALL 2 100 > > # rm -f /var/lib/mysql/* > # mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql > > # systemctl start mariadb (iowaits -> 100%) > > > # iotop -bo |grep maria (shows no output, iowait stays 100%) > > (this persists until mariadb process exits) > > > # systemctl stop mariadb (iowait drops to 0%) This is a visible userspace behaviour change with no changes in the userspace itself, so we cannot just ignore it. If for some reason this is how it should be now, how do we explain it to MariaDB devs to get this fixed? Thanks.
Hi, On 2023-07-23 20:06:19 +0200, Oleksandr Natalenko wrote: > On neděle 23. července 2023 19:43:50 CEST Genes Lists wrote: > > On 7/23/23 11:31, Jens Axboe wrote: > > ... > > > Just read the first one, but this is very much expected. It's now just > > > correctly reflecting that one thread is waiting on IO. IO wait being > > > 100% doesn't mean that one core is running 100% of the time, it just > > > means it's WAITING on IO 100% of the time. > > > > > > > Seems reasonable thank you. > > > > Question - do you expect the iowait to stay high for a freshly created > > mariadb doing nothing (as far as I can tell anyway) until process > > exited? Or Would you think it would drop in this case prior to the > > process exiting. > > > > For example I tried the following - is the output what you expect? > > > > Create a fresh mariab with no databases - monitor the core showing the > > iowaits with: > > > > mpstat -P ALL 2 100 > > > > # rm -f /var/lib/mysql/* > > # mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql > > > > # systemctl start mariadb (iowaits -> 100%) > > > > > > # iotop -bo |grep maria (shows no output, iowait stays 100%) > > > > (this persists until mariadb process exits) > > > > > > # systemctl stop mariadb (iowait drops to 0%) > > This is a visible userspace behaviour change with no changes in the > userspace itself, so we cannot just ignore it. If for some reason this is > how it should be now, how do we explain it to MariaDB devs to get this > fixed? Just to confirm I understand: Your concern is how it looks in mpstat, not performance or anything like that? As far as I can tell, mariadb submits a bunch of IOs, which all have completed: ... mariadbd 438034 [000] 67593.094595: io_uring:io_uring_submit_req: ring 0xffff8887878ac800, req 0xffff888929df2400, user_data 0x55d5eaf29488, opcode READV, flags 0x0, sq_thread 0 mariadbd 438034 [000] 67593.094604: io_uring:io_uring_submit_req: ring 0xffff8887878ac800, req 0xffff888929df2500, user_data 0x55d5eaf29520, opcode READV, flags 0x0, sq_thread 0 mariadbd 438034 [000] 67593.094690: io_uring:io_uring_complete: ring 0xffff8887878ac800, req 0xffff888929df2400, user_data 0x55d5eaf29488, result 16384, cflags 0x0 extra1 0 extra2 0 mariadbd 438034 [000] 67593.094699: io_uring:io_uring_complete: ring 0xffff8887878ac800, req 0xffff888929df2500, user_data 0x55d5eaf29520, result 16384, cflags 0x0 extra1 0 extra2 0 Then waits for io_uring events: mariadbd 438032 [003] 67593.095282: io_uring:io_uring_cqring_wait: ring 0xffff8887878ac800, min_events 1 There won't be any completions without further IO being submitted. io_uring could have logic to somehow report a different state in such a case (where there'll not be any completions before new IOs being submitted), but that'd likely not be free. Greetings, Andres Freund
On 7/23/23 14:58, Andres Freund wrote: > Just to confirm I understand: Your concern is how it looks in mpstat, not > performance or anything like that? Right - there is no performance issue or any other issue to my knowledge and cores are idle. So, as you said, its just a small reporting item - which is now quite clear. thank you. gene
On 7/23/23 12:06?PM, Oleksandr Natalenko wrote: > Hello. > > On ned?le 23. ?ervence 2023 19:43:50 CEST Genes Lists wrote: >> On 7/23/23 11:31, Jens Axboe wrote: >> ... >>> Just read the first one, but this is very much expected. It's now just >>> correctly reflecting that one thread is waiting on IO. IO wait being >>> 100% doesn't mean that one core is running 100% of the time, it just >>> means it's WAITING on IO 100% of the time. >>> >> >> Seems reasonable thank you. >> >> Question - do you expect the iowait to stay high for a freshly created >> mariadb doing nothing (as far as I can tell anyway) until process >> exited? Or Would you think it would drop in this case prior to the >> process exiting. >> >> For example I tried the following - is the output what you expect? >> >> Create a fresh mariab with no databases - monitor the core showing the >> iowaits with: >> >> mpstat -P ALL 2 100 >> >> # rm -f /var/lib/mysql/* >> # mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql >> >> # systemctl start mariadb (iowaits -> 100%) >> >> >> # iotop -bo |grep maria (shows no output, iowait stays 100%) >> >> (this persists until mariadb process exits) >> >> >> # systemctl stop mariadb (iowait drops to 0%) > > This is a visible userspace behaviour change with no changes in the > userspace itself, so we cannot just ignore it. If for some reason this > is how it should be now, how do we explain it to MariaDB devs to get > this fixed? It's not a behavioural change, it's a reporting change. There's no functionality changing here. That said, I do think we should narrow it a bit so we're only marked as in iowait if the task waiting has pending IO. That should still satisfy the initial problem, and it won't flag iowait on mariadb like cases where they have someone else just perpetually waiting on requests. As a side effect, this also removes the flush that wasn't at all necessary on io_uring. If folks are able to test the below, that would be appreciated. diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 89a611541bc4..f4591b912ea8 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -2493,11 +2493,20 @@ int io_run_task_work_sig(struct io_ring_ctx *ctx) return 0; } +static bool current_pending_io(void) +{ + struct io_uring_task *tctx = current->io_uring; + + if (!tctx) + return false; + return percpu_counter_read_positive(&tctx->inflight); +} + /* when returns >0, the caller should retry */ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx, struct io_wait_queue *iowq) { - int token, ret; + int io_wait, ret; if (unlikely(READ_ONCE(ctx->check_cq))) return 1; @@ -2511,17 +2520,19 @@ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx, return 0; /* - * Use io_schedule_prepare/finish, so cpufreq can take into account - * that the task is waiting for IO - turns out to be important for low - * QD IO. + * Mark us as being in io_wait if we have pending requests, so cpufreq + * can take into account that the task is waiting for IO - turns out + * to be important for low QD IO. */ - token = io_schedule_prepare(); + io_wait = current->in_iowait; + if (current_pending_io()) + current->in_iowait = 1; ret = 0; if (iowq->timeout == KTIME_MAX) schedule(); else if (!schedule_hrtimeout(&iowq->timeout, HRTIMER_MODE_ABS)) ret = -ETIME; - io_schedule_finish(token); + current->in_iowait = io_wait; return ret; }
On 7/24/23 11:47, Jens Axboe wrote: > It's not a behavioural change, it's a reporting change. There's no > functionality changing here. That said, I do think we should narrow it a > bit so we're only marked as in iowait if the task waiting has pending > IO. That should still satisfy the initial problem, and it won't flag > iowait on mariadb like cases where they have someone else just > perpetually waiting on requests. > > As a side effect, this also removes the flush that wasn't at all > necessary on io_uring. > > If folks are able to test the below, that would be appreciated. > > > diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c > index 89a611541bc4..f4591b912ea8 100644 > --- a/io_uring/io_uring.c > +++ b/io_uring/io_uring.c > @@ -2493,11 +2493,20 @@ int io_run_task_work_sig(struct io_ring_ctx *ctx) > return 0; > } > > +static bool current_pending_io(void) > +{ > + struct io_uring_task *tctx = current->io_uring; > + > + if (!tctx) > + return false; > + return percpu_counter_read_positive(&tctx->inflight); > +} > + > /* when returns >0, the caller should retry */ > static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx, > struct io_wait_queue *iowq) > { > - int token, ret; > + int io_wait, ret; > > if (unlikely(READ_ONCE(ctx->check_cq))) > return 1; > @@ -2511,17 +2520,19 @@ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx, > return 0; > > /* > - * Use io_schedule_prepare/finish, so cpufreq can take into account > - * that the task is waiting for IO - turns out to be important for low > - * QD IO. > + * Mark us as being in io_wait if we have pending requests, so cpufreq > + * can take into account that the task is waiting for IO - turns out > + * to be important for low QD IO. > */ > - token = io_schedule_prepare(); > + io_wait = current->in_iowait; > + if (current_pending_io()) > + current->in_iowait = 1; > ret = 0; > if (iowq->timeout == KTIME_MAX) > schedule(); > else if (!schedule_hrtimeout(&iowq->timeout, HRTIMER_MODE_ABS)) > ret = -ETIME; > - io_schedule_finish(token); > + current->in_iowait = io_wait; > return ret; > } > > Tested on top of 6.4.6 stable - and working great - iowait stats now look like they always did. thank you gene
--- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -2575,6 +2575,8 @@ int io_run_task_work_sig(struct io_ring_ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx, struct io_wait_queue *iowq) { + int token, ret; + if (unlikely(READ_ONCE(ctx->check_cq))) return 1; if (unlikely(!llist_empty(&ctx->work_llist))) @@ -2585,11 +2587,20 @@ static inline int io_cqring_wait_schedul return -EINTR; if (unlikely(io_should_wake(iowq))) return 0; + + /* + * Use io_schedule_prepare/finish, so cpufreq can take into account + * that the task is waiting for IO - turns out to be important for low + * QD IO. + */ + token = io_schedule_prepare(); + ret = 0; if (iowq->timeout == KTIME_MAX) schedule(); else if (!schedule_hrtimeout(&iowq->timeout, HRTIMER_MODE_ABS)) - return -ETIME; - return 0; + ret = -ETIME; + io_schedule_finish(token); + return ret; } /*