From patchwork Wed Dec 13 10:42:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongyu Jin X-Patchwork-Id: 13490648 X-Patchwork-Delegate: snitzer@redhat.com Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D140922EF1 for ; Wed, 13 Dec 2023 10:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VlVo5BE8" Received: by mail-io1-f49.google.com with SMTP id ca18e2360f4ac-7b70de199f6so195957539f.2 for ; Wed, 13 Dec 2023 02:42:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702464163; x=1703068963; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kk71sp729csxdUViLno20l6lcdfkMyL/Wdv2yhvpzTA=; b=VlVo5BE8PdxBh1RcQzy57soOOm6+yn/Hd1XYeMOS4GBQKPbKafvpX5tpZW3K1clun4 KRtRADjH15sxX4h8Ps5P6sLQveWAXzZS1ZY7Z4+CVYI3JA+pmkxjZxWNxfPUySIw4+qt uZSFfABE1MKileHYXP2XHFOpq8LgBkWhFSHOheu2tnBg51Q66qtnYAaz4Im5ZXvIcrDF r19U3/LiJoESitunGauL0TSMBiCYY9j32Tqf9MhHM1gpJ8IoSU+6slaxRMTN24bfMOL8 3DhN45ZP5CcRGCUVrXUuSv7cCLEv/5ec1cub+0fp1DqjCQ5MhmF4rcsM+cKjgBk29WYI BXOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702464163; x=1703068963; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kk71sp729csxdUViLno20l6lcdfkMyL/Wdv2yhvpzTA=; b=eP2zAOCQP54couP6LHUMlA6mwB3xEFAQTfqcEO38v96SSm7QShXJ2mLJTpIiZN2DMY 06taa061FtTVzTGh5ibgFLEcJpldBjaqwNF5CWbxTQ2pM1gcWKl+3mye1utxWA1RoiQ/ ge64/TkTQsTNtyRZSGYQeL6ySM0wt5xv5IHktqlX/OUcIcj9tq9r1mNXOI0B3i/zRkDH unRgu4cYImMipQMXJU3yvRxAZ0yhc4AMZ2Kq2X0/cMM4eGg84PbJIyWIVqCh0VUM8i4t DFjRL1eo4eGD7mHanC68iI6K2kYa7/IL/jQWuDdPRbAn4kPZ9aeA4r/IAteN0K1yX82u vdEg== X-Gm-Message-State: AOJu0YxIPgkXuUcyD6SIXKjFYGzQejkgCxAUZQ8ytVCumhZrqaduSQrl ebLoL7QO4arfYxOoq4EuBno= X-Google-Smtp-Source: AGHT+IF8KhM4LKu59z4wp0wI/kfaBUgeyltzCePLtvl91gtiRSE3aEV5k+2UHPjWxXWBRbof2CjeiA== X-Received: by 2002:a5e:d70b:0:b0:7b7:4cd:6b16 with SMTP id v11-20020a5ed70b000000b007b704cd6b16mr7899907iom.31.1702464162859; Wed, 13 Dec 2023 02:42:42 -0800 (PST) Received: from ubuntu.. ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id c11-20020a6b4e0b000000b0078647b08ab0sm3058186iob.6.2023.12.13.02.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 02:42:42 -0800 (PST) From: Hongyu Jin To: agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, axboe@kernel.dk, ebiggers@kernel.org Cc: zhiguo.niu@unisoc.com, ke.wang@unisoc.com, yibin.ding@unisoc.com, hongyu.jin@unisoc.com, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-block@vger.kernel.org Subject: [PATCH v5 1/5] block: Fix bio IO priority setting Date: Wed, 13 Dec 2023 18:42:12 +0800 Message-Id: <20231213104216.27845-2-hongyu.jin.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231213104216.27845-1-hongyu.jin.cn@gmail.com> References: <20231213104216.27845-1-hongyu.jin.cn@gmail.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Hongyu Jin Move bio_set_ioprio() into submit_bio(): 1. Only call bio_set_ioprio() once to set the priority of original bio, the bio that cloned and splited from original bio will auto inherit the priority of original bio in clone process. 2. The IO priority can be passed to module that implement struct gendisk::fops::submit_bio, help resolve some of the IO priority loss issues. This patch depends on commit 82b74cac2849 ("blk-ioprio: Convert from rqos policy to direct call") Fixes: a78418e6a04c ("block: Always initialize bio IO priority on submit") Co-developed-by: Yibin Ding Signed-off-by: Yibin Ding Signed-off-by: Hongyu Jin --- block/blk-core.c | 10 ++++++++++ block/blk-mq.c | 11 ----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index fdf25b8d6e78..68158c327aea 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -49,6 +49,7 @@ #include "blk-pm.h" #include "blk-cgroup.h" #include "blk-throttle.h" +#include "blk-ioprio.h" struct dentry *blk_debugfs_root; @@ -809,6 +810,14 @@ void submit_bio_noacct(struct bio *bio) } EXPORT_SYMBOL(submit_bio_noacct); +static void bio_set_ioprio(struct bio *bio) +{ + /* Nobody set ioprio so far? Initialize it based on task's nice value */ + if (IOPRIO_PRIO_CLASS(bio->bi_ioprio) == IOPRIO_CLASS_NONE) + bio->bi_ioprio = get_current_ioprio(); + blkcg_set_ioprio(bio); +} + /** * submit_bio - submit a bio to the block device layer for I/O * @bio: The &struct bio which describes the I/O @@ -831,6 +840,7 @@ void submit_bio(struct bio *bio) count_vm_events(PGPGOUT, bio_sectors(bio)); } + bio_set_ioprio(bio); submit_bio_noacct(bio); } EXPORT_SYMBOL(submit_bio); diff --git a/block/blk-mq.c b/block/blk-mq.c index e2d11183f62e..a6e2609df9c9 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -40,7 +40,6 @@ #include "blk-stat.h" #include "blk-mq-sched.h" #include "blk-rq-qos.h" -#include "blk-ioprio.h" static DEFINE_PER_CPU(struct llist_head, blk_cpu_done); static DEFINE_PER_CPU(call_single_data_t, blk_cpu_csd); @@ -2922,14 +2921,6 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q, return rq; } -static void bio_set_ioprio(struct bio *bio) -{ - /* Nobody set ioprio so far? Initialize it based on task's nice value */ - if (IOPRIO_PRIO_CLASS(bio->bi_ioprio) == IOPRIO_CLASS_NONE) - bio->bi_ioprio = get_current_ioprio(); - blkcg_set_ioprio(bio); -} - /** * blk_mq_submit_bio - Create and send a request to block device. * @bio: Bio pointer. @@ -2963,8 +2954,6 @@ void blk_mq_submit_bio(struct bio *bio) if (!bio_integrity_prep(bio)) return; - bio_set_ioprio(bio); - rq = blk_mq_get_cached_request(q, plug, &bio, nr_segs); if (!rq) { if (!bio)