Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5743065imw; Wed, 20 Jul 2022 11:34:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1txo0DtEGjRkuwZ/O/b4zyQINLHd5kRZ3CJfolaUGvRsRFgQSq72psmEp3F6LQ8iJ3eThHZ X-Received: by 2002:a17:907:2cd4:b0:72b:7fa8:eafc with SMTP id hg20-20020a1709072cd400b0072b7fa8eafcmr36619170ejc.438.1658342050534; Wed, 20 Jul 2022 11:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658342050; cv=none; d=google.com; s=arc-20160816; b=BZ22zYDbGx9c39yGqJencQLCqK5cFrbYWPbVgMjWQVfogMyCEHL2FnocgSkwik4O00 pMDaNR7QZABTX4qSVoV0/4yx5Ox0vT29a90ovXMjF4gnxcQVMUhBxpitbcAsfblaQm7m 2l1iKoc7MGStafuOxFNgq47J1KL+X9KViXO8bUM94ea5Z5pvkwL7MHQ79MC+ijiYpC1q Id65QCOma/X9e5wRhczWUMNeQJrJq0gg1h8v37dlrEW3DzuWgKZ3M8CXo7xx4aeFdnH3 peQ3kwPE4EohF8+cLHY6YBPF5Yry/kv/b7iaQJ0DE2Smgjl3CGRjIc5Z1ZiCEBIq/V2J FgvQ== 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:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=S+VXSDukK/OTHYC9Ft1p/BhMJLNvQaxCO1/JBdZMGJs=; b=FhUsYlLcXFk2L0zRSQwgK503ub8Bf+Kr4kdFjy/vpQJ6KfpfQh5VZ9jqpMfQVCjraO ajLAqi9WSQlh1m+qA3a59OPZIOAZZ0PInXQwhfLJT4afCbM7xO+gtSanTaXOMpN/pHhd NEoKk8s9Rux4aCcm4veDypSui7gjLwkgP1VdkNAbffXP3Urox+hSup20TyYtPDchk8cd AH0lG5uQUfth9ka1x0K2+FR8JQqUfzZMGy7b8F6YNk3InhjJ/lJoVQ1rNfwiH4k4ypsD p5qLBlu0i6cel+PCodA8EJShE9eGxMLO79vWETM7b48TW2IWZeyktVTSKSO0j5noFzVq Wi2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=hYQeNc+o; 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 k3-20020a1709062a4300b0072b85a5c27bsi21320276eje.871.2022.07.20.11.33.45; Wed, 20 Jul 2022 11:34:10 -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=@kernel-dk.20210112.gappssmtp.com header.s=20210112 header.b=hYQeNc+o; 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 S235597AbiGTSNc (ORCPT + 99 others); Wed, 20 Jul 2022 14:13:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234284AbiGTSNb (ORCPT ); Wed, 20 Jul 2022 14:13:31 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A739643C2 for ; Wed, 20 Jul 2022 11:13:29 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id v1so6072649ilg.4 for ; Wed, 20 Jul 2022 11:13:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language :from:to:cc:references:in-reply-to:content-transfer-encoding; bh=S+VXSDukK/OTHYC9Ft1p/BhMJLNvQaxCO1/JBdZMGJs=; b=hYQeNc+oyCrGVU4f9RAI8Nn50VyYg4YpCSGf7qKSdKgOQUDa+FnT43nLvhTSSWz8AA M85+Q0y+QcgIiM8soJhZUTxkB+M8asRc6yYzV62rRye0c/TGTveat0r2cMg4k2VYPkVa 2wsqFiC9mSm8XnUpWpfHhFUXgJL51CX5k7hvzZ4jKSg0+kRG0zDscIy+IVUJtJveNs+E XahYG609Djq33GFdY+zC3sUCOa3N9ZbZ0lFXp2xMUfvdVeRi529XGfeZAZITF6vx5Sje mRwU239C/ilIokBmvZtFMEakGmJoeIu9hGjUVQdgAwrtryY4bKLtiB+JjLM5YhbdnH2E 4A1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=S+VXSDukK/OTHYC9Ft1p/BhMJLNvQaxCO1/JBdZMGJs=; b=I9GRSzvTLAxxQzs6mfBTirqNfRYMjNsFuMUNvxmDGYx+QONtXHG2uGhTj+kJrl75VQ coWFEgNLG43CbVKcmVWkO5yx9Spsg2ZhrIswfgX53aph2c8V4/74fHVkddB4RQA2LeDR MMps7tl4c5dSCm1vAmJWN/2Ljq4tJoosF2O3D3K1R/7hLMeamWLnX6wbIAhQ6Z3+oO/L T2ZeoE6L8Rl576/XqNjRE3H6R3ND4fH3fzYrBqIsk8u+FvL1etiPalDwDrFlL+/Su91C MiwIRu/A85zFR5F6V+w3maJFI0kOhldnU2s9g9MWWFWC1B5Xig88WtOco8KrPoLQmXNl WVzQ== X-Gm-Message-State: AJIora+0Z7wRL8tLfGqVknMnbXtZfhfoG4o1vKcbfC08s1z3sbe7sksT HuVohZiYWuEMfhXYp6inFZAUYA== X-Received: by 2002:a05:6e02:16c7:b0:2dd:d67:f39d with SMTP id 7-20020a056e0216c700b002dd0d67f39dmr1293394ilx.316.1658340808839; Wed, 20 Jul 2022 11:13:28 -0700 (PDT) Received: from [192.168.1.172] ([207.135.234.126]) by smtp.gmail.com with ESMTPSA id d6-20020a92d5c6000000b002dc0ddef9cfsm7126181ilq.73.2022.07.20.11.13.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Jul 2022 11:13:28 -0700 (PDT) Message-ID: <299889df-db40-e0e2-6bc6-d9eb784ebe89@kernel.dk> Date: Wed, 20 Jul 2022 12:13:27 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [LKP] Re: [io_uring] 584b0180f0: phoronix-test-suite.fio.SequentialWrite.IO_uring.Yes.Yes.1MB.DefaultTestDirectory.mb_s -10.2% regression Content-Language: en-US From: Jens Axboe To: Yin Fengwei , kernel test robot Cc: LKML , io-uring@vger.kernel.org, lkp@lists.01.org, lkp@intel.com References: <20220527092432.GE11731@xsang-OptiPlex-9020> <2085bfef-a91c-8adb-402b-242e8c5d5c55@kernel.dk> <0d60aa42-a519-12ad-3c69-72ed12398865@intel.com> <26d913ea-7aa0-467d-4caf-a93f8ca5b3ff@kernel.dk> <9df150bb-f4fd-7857-aea8-b2c7a06a8791@intel.com> <7146c853-0ff8-3c92-c872-ce6615baab40@kernel.dk> <81af5cdf-1a13-db2c-7b7b-cfd86f1271e6@intel.com> <74d1f308-de03-fd5e-b7f0-0e17980f988e@kernel.dk> <2ec953da-78fd-df01-44cf-6f33a5e40864@intel.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 7/20/22 11:24 AM, Jens Axboe wrote: > On 7/19/22 2:58 AM, Yin Fengwei wrote: >> Hi Jens, >> >> On 7/19/2022 10:29 AM, Jens Axboe wrote: >>> I'll poke at this tomorrow. >> >> Just FYI. Another finding (test is based on commit 584b0180f0): >> If the code block is put to different function, the fio performance result is >> different: > > I think this turned out to be a little bit of a goose chase. What's > happening here is that later kernels defer the file assignment, which > means it isn't set if a request is queued with IOSQE_ASYNC. That in > turn, for writes, means that we don't hash it on io-wq insertion, and > then it doesn't get serialized with other writes to that file. > > I'll come up with a patch for this that you can test. Can you try this? It's against 5.19-rc7. diff --git a/fs/io_uring.c b/fs/io_uring.c index a01ea49f3017..34758e95990a 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2015,6 +2015,64 @@ static inline void io_arm_ltimeout(struct io_kiocb *req) __io_arm_ltimeout(req); } +static bool io_bdev_nowait(struct block_device *bdev) +{ + return !bdev || blk_queue_nowait(bdev_get_queue(bdev)); +} + +/* + * If we tracked the file through the SCM inflight mechanism, we could support + * any file. For now, just ensure that anything potentially problematic is done + * inline. + */ +static bool __io_file_supports_nowait(struct file *file, umode_t mode) +{ + if (S_ISBLK(mode)) { + if (IS_ENABLED(CONFIG_BLOCK) && + io_bdev_nowait(I_BDEV(file->f_mapping->host))) + return true; + return false; + } + if (S_ISSOCK(mode)) + return true; + if (S_ISREG(mode)) { + if (IS_ENABLED(CONFIG_BLOCK) && + io_bdev_nowait(file->f_inode->i_sb->s_bdev) && + file->f_op != &io_uring_fops) + return true; + return false; + } + + /* any ->read/write should understand O_NONBLOCK */ + if (file->f_flags & O_NONBLOCK) + return true; + return file->f_mode & FMODE_NOWAIT; +} + +static inline bool io_file_supports_nowait(struct io_kiocb *req) +{ + return req->flags & REQ_F_SUPPORT_NOWAIT; +} + +/* + * If we tracked the file through the SCM inflight mechanism, we could support + * any file. For now, just ensure that anything potentially problematic is done + * inline. + */ +static unsigned int io_file_get_flags(struct file *file) +{ + umode_t mode = file_inode(file)->i_mode; + unsigned int res = 0; + + if (S_ISREG(mode)) + res |= FFS_ISREG; + if (__io_file_supports_nowait(file, mode)) + res |= FFS_NOWAIT; + if (io_file_need_scm(file)) + res |= FFS_SCM; + return res; +} + static void io_prep_async_work(struct io_kiocb *req) { const struct io_op_def *def = &io_op_defs[req->opcode]; @@ -2031,6 +2089,9 @@ static void io_prep_async_work(struct io_kiocb *req) if (req->flags & REQ_F_FORCE_ASYNC) req->work.flags |= IO_WQ_WORK_CONCURRENT; + if (req->file && !io_req_ffs_set(req)) + req->flags |= io_file_get_flags(req->file) << REQ_F_SUPPORT_NOWAIT_BIT; + if (req->flags & REQ_F_ISREG) { if (def->hash_reg_file || (ctx->flags & IORING_SETUP_IOPOLL)) io_wq_hash_work(&req->work, file_inode(req->file)); @@ -3556,64 +3617,6 @@ static void io_iopoll_req_issued(struct io_kiocb *req, unsigned int issue_flags) } } -static bool io_bdev_nowait(struct block_device *bdev) -{ - return !bdev || blk_queue_nowait(bdev_get_queue(bdev)); -} - -/* - * If we tracked the file through the SCM inflight mechanism, we could support - * any file. For now, just ensure that anything potentially problematic is done - * inline. - */ -static bool __io_file_supports_nowait(struct file *file, umode_t mode) -{ - if (S_ISBLK(mode)) { - if (IS_ENABLED(CONFIG_BLOCK) && - io_bdev_nowait(I_BDEV(file->f_mapping->host))) - return true; - return false; - } - if (S_ISSOCK(mode)) - return true; - if (S_ISREG(mode)) { - if (IS_ENABLED(CONFIG_BLOCK) && - io_bdev_nowait(file->f_inode->i_sb->s_bdev) && - file->f_op != &io_uring_fops) - return true; - return false; - } - - /* any ->read/write should understand O_NONBLOCK */ - if (file->f_flags & O_NONBLOCK) - return true; - return file->f_mode & FMODE_NOWAIT; -} - -/* - * If we tracked the file through the SCM inflight mechanism, we could support - * any file. For now, just ensure that anything potentially problematic is done - * inline. - */ -static unsigned int io_file_get_flags(struct file *file) -{ - umode_t mode = file_inode(file)->i_mode; - unsigned int res = 0; - - if (S_ISREG(mode)) - res |= FFS_ISREG; - if (__io_file_supports_nowait(file, mode)) - res |= FFS_NOWAIT; - if (io_file_need_scm(file)) - res |= FFS_SCM; - return res; -} - -static inline bool io_file_supports_nowait(struct io_kiocb *req) -{ - return req->flags & REQ_F_SUPPORT_NOWAIT; -} - static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe) { struct kiocb *kiocb = &req->rw.kiocb; -- Jens Axboe