From patchwork Wed Jun 15 16:16:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 12882715 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4349C43334 for ; Wed, 15 Jun 2022 16:19:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354872AbiFOQTN (ORCPT ); Wed, 15 Jun 2022 12:19:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353677AbiFOQSP (ORCPT ); Wed, 15 Jun 2022 12:18:15 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 536A149B4A for ; Wed, 15 Jun 2022 09:16:39 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 8B6AC1F96C; Wed, 15 Jun 2022 16:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zdHGHI4Ev58b/pl0dNaAGHgKtCtHQQd4DQ4+opUALT0=; b=ZKIFAaa9x20cf8eb21YT708pM1jiWkTdZoKbW208/bLgFz9Rk04mC5+/UpxuazpxSCS5a6 oYID15OgKRn1jG2d6V9+2jI5vuYEE63pIi/28G5RaI2s1Dtl7YSxeV1SIn7DMkRaccRLPV E3VCBTalsIm1M9Oy9dJYovuTFMqp3Q0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zdHGHI4Ev58b/pl0dNaAGHgKtCtHQQd4DQ4+opUALT0=; b=p/R3wstH9a+z6T8c68t4eyyEFpUouQiOHJorvtFFst78o4zMl4lv2imxOzKyrku0ALIJ8j ZvTEvKjvNwBBraAA== Received: from quack3.suse.cz (unknown [10.163.28.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 2C18F2C142; Wed, 15 Jun 2022 16:16:17 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id C7876A058D; Wed, 15 Jun 2022 18:16:16 +0200 (CEST) From: Jan Kara To: Jens Axboe Cc: , Damien Le Moal , Niklas Cassel , Bart Van Assche , Jan Kara Subject: [PATCH 1/8] block: Fix handling of tasks without ioprio in ioprio_get(2) Date: Wed, 15 Jun 2022 18:16:04 +0200 Message-Id: <20220615161616.5055-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220615160437.5478-1-jack@suse.cz> References: <20220615160437.5478-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1501; h=from:subject; bh=9KD3aySqtPBkLpNodH9xvh4U02ybJw2mmf5dcbjI88g=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBiqgXEYfqwMx2mXUc/W3d23Pk3TGBQcOIl9EQiNkKN 4Wc0ZKaJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYqoFxAAKCRCcnaoHP2RA2fk7B/ 9UkES+O6bz4btxCgvDAETpvsgq2JS3VKJHuxfz1765SK1gCrblXh1UCs6PTj+BpWT3UjTr/GXIUZZV N95np4nenzfb0ZHuzG69LmTCv1HAI+vrdW3I8WjOuRvieiRKKzfZj2JhKkNrau1qjPkoL9GzxXCYFo jXMVZsZIXfhP9D+eRxgPNaoetVNx7x/zWxbcCY0bmF37L39l7Vq0zk4cGaLNZNBspRRozahNT/R07q 9J0Nr5Ped8c3oZo7tPLZnlH/eeVQW/9kBE+tCqLb6DXxTfGSgxjR3MWZ4LJG2xMjCadMsY2OCGJlIw 8J93rHVTwKO4HyG1lmG/Fgmmy6+sjp X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org ioprio_get(2) can be asked to return the best IO priority from several tasks (IOPRIO_WHO_PGRP, IOPRIO_WHO_USER). Currently the call treats tasks without set IO priority as having priority IOPRIO_CLASS_BE/IOPRIO_BE_NORM however this does not really reflect the IO priority the task will get (which depends on task's nice value) and with the following fix it will not even match returned IO priority for a single task. Fix IO priority comparison to treat unset IO priority as the lowest possible one. This way we will return IOPRIO_CLASS_NONE priority only if none of the considered tasks has explicitely set IO priority, otherwise we return the highest set IO priority. This changes userspace visible behavior but this way the caller really gets back the highest set IO priority without contaminating the result with IOPRIO_CLASS_BE/IOPRIO_BE_NORM from tasks which have IO priority unset. Signed-off-by: Jan Kara --- block/ioprio.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/block/ioprio.c b/block/ioprio.c index 2fe068fcaad5..62890391fc80 100644 --- a/block/ioprio.c +++ b/block/ioprio.c @@ -157,10 +157,9 @@ static int get_task_ioprio(struct task_struct *p) int ioprio_best(unsigned short aprio, unsigned short bprio) { if (!ioprio_valid(aprio)) - aprio = IOPRIO_DEFAULT; + return bprio; if (!ioprio_valid(bprio)) - bprio = IOPRIO_DEFAULT; - + return aprio; return min(aprio, bprio); } From patchwork Wed Jun 15 16:16:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 12882718 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5759AC43334 for ; Wed, 15 Jun 2022 16:19:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354930AbiFOQTW (ORCPT ); Wed, 15 Jun 2022 12:19:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355270AbiFOQSO (ORCPT ); Wed, 15 Jun 2022 12:18:14 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F271A45526 for ; Wed, 15 Jun 2022 09:16:38 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 8CAA41F974; Wed, 15 Jun 2022 16:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DTz8ZVve7ICu7ezzDrVXZ+LmahVFfCLd1uVrOnwq32w=; b=Z52xnl8JQ+IflGRFzIFjDSi9Q4IvTDAgAJGQ8+dYhICPrJj6tPfE5vEDdgdHNDleJBIRck SV7+4XFldTnpRvIMFVpo/RPJcyIXyPgKYuFZ1ZMP00h5LHXv8ZqQb8MBVe8BoLLp8GzRfq 7axvnEQUnYbUCap1/rCkK3zxYEevJek= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DTz8ZVve7ICu7ezzDrVXZ+LmahVFfCLd1uVrOnwq32w=; b=867JSihYk8Zk1gpO/ZczPpxpT+bz/LT/h04RlwzxitutCoh0qvnyk4IAw6YyshPTV2jK6t HNLkAQAZOy94gtBQ== Received: from quack3.suse.cz (unknown [10.163.28.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 2FB352C143; Wed, 15 Jun 2022 16:16:17 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id CF859A0635; Wed, 15 Jun 2022 18:16:16 +0200 (CEST) From: Jan Kara To: Jens Axboe Cc: , Damien Le Moal , Niklas Cassel , Bart Van Assche , Jan Kara Subject: [PATCH 2/8] block: Make ioprio_best() static Date: Wed, 15 Jun 2022 18:16:05 +0200 Message-Id: <20220615161616.5055-2-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220615160437.5478-1-jack@suse.cz> References: <20220615160437.5478-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1133; h=from:subject; bh=rPhukKpylibo4V7blrFwToaoTXpiIOZKaKcKjvnBkH8=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBiqgXFL3CrP+llnmWK8hvTtjpQrXA8t+2r7TnX2j/R XDlm+QKJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYqoFxQAKCRCcnaoHP2RA2V5iCA C77nKCaoxw4vNiMOJQI3XPj8lauAzSJX9lxSUcjaY7+3bIZZbKYL3EtlcepSuytKFPS3wLdt2pm4P/ BqnbLh9MnEXE5Fj8L09bLZcuEt4qGkfSo2aYUHnhe6tGhhI0V3BjyfJVcjLFBaSeZEsZ+hqSEogw0X PuG/p49Qs5yOa4BGSHaIYKSxabj8BPGvCmlg0xqoNzslWH5kiWIvYfLVX21JcRxLbAunM7Kyda4NTz E9O1YmeQ7C4CAnQJPiOvmVa2hzFTYm6VZOQOdCl8l7g0e7WneyEo3PZmojNjJyd2teY3XQR/c1sJhc vcW+QncQ0uD2cgl8kJSiV760pLG1LQ X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Nobody outside of block/ioprio.c uses it. Signed-off-by: Jan Kara --- block/ioprio.c | 2 +- include/linux/ioprio.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/block/ioprio.c b/block/ioprio.c index 62890391fc80..18f7e16882fe 100644 --- a/block/ioprio.c +++ b/block/ioprio.c @@ -154,7 +154,7 @@ static int get_task_ioprio(struct task_struct *p) return ret; } -int ioprio_best(unsigned short aprio, unsigned short bprio) +static int ioprio_best(unsigned short aprio, unsigned short bprio) { if (!ioprio_valid(aprio)) return bprio; diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h index 3f53bc27a19b..774bb90ad668 100644 --- a/include/linux/ioprio.h +++ b/include/linux/ioprio.h @@ -59,11 +59,6 @@ static inline int get_current_ioprio(void) return IOPRIO_DEFAULT; } -/* - * For inheritance, return the highest of the two given priorities - */ -extern int ioprio_best(unsigned short aprio, unsigned short bprio); - extern int set_task_ioprio(struct task_struct *task, int ioprio); #ifdef CONFIG_BLOCK From patchwork Wed Jun 15 16:16:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 12882711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD496CCA47E for ; Wed, 15 Jun 2022 16:19:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353928AbiFOQTC (ORCPT ); Wed, 15 Jun 2022 12:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355504AbiFOQSQ (ORCPT ); Wed, 15 Jun 2022 12:18:16 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 580604754A for ; Wed, 15 Jun 2022 09:16:41 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 8BE6C21C21; Wed, 15 Jun 2022 16:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8cTgyUe8U9yS5g+cIa5MjDMZW0aOXcrwLKNlSHMFKPg=; b=PtHa/9Xhba9eHgL4zHehfjJ16Mg77/D1DL2lBMyouahX2vZEgOkuCtIv838PE55jcgnk8c /fc2Xa4CEBWOQ3N6t10YI96njgKwDx3/7srcKz1+NbMJAsR3fNOIqupiBMC9bbFQ2QhGng ef6SIOj3RpDSKMHSuzAmRGCI02gtPYc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8cTgyUe8U9yS5g+cIa5MjDMZW0aOXcrwLKNlSHMFKPg=; b=aMCQJS3GR1Tyq9nXG2Cetr2Aiiu5yrmD3d1/QFaVWI9LFaYyRs/ZN4RgGUsBXkH7dcOpdP aLDPH65gNb5vPaAQ== Received: from quack3.suse.cz (unknown [10.163.28.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 35FB92C145; Wed, 15 Jun 2022 16:16:17 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id D67C1A0637; Wed, 15 Jun 2022 18:16:16 +0200 (CEST) From: Jan Kara To: Jens Axboe Cc: , Damien Le Moal , Niklas Cassel , Bart Van Assche , Jan Kara Subject: [PATCH 3/8] block: fix default IO priority handling again Date: Wed, 15 Jun 2022 18:16:06 +0200 Message-Id: <20220615161616.5055-3-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220615160437.5478-1-jack@suse.cz> References: <20220615160437.5478-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2544; h=from:subject; bh=6xC6IMuAoBDLjO+1hSyfaMEJHwTJVPxPrWFG2SqXOs4=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBiqgXGYxINOnFb5NP98EmQl5ef90xq9gRepbX7c3Sy xeeCj7OJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYqoFxgAKCRCcnaoHP2RA2Sn3CA DbL9KZByZmAbaLWdX8PCjGvnJAZ0vJJhbiuDa3sk4I/E2TKL7s48vp0JgDux7uq6jSDhfKC861pD4d X3cqnaiy1A6eC3cfR2eq4KK9yeH4yYuU44tF+22P4SwgjYAFv+Jhazt1TmZy/q+cPKHc7ivu+s+w3J uR7UmeMIA3V67QoDQ6KSSxQUUCSwOrNPBW7W8LRJfekh6L7l/2hGM/MjAxqbJotfYC7iy2gJ1B7gqB MYsK/NALqDeipbJ/pkRMsCWfV423S1dcZDYrljurMJNN8xx01VCvhnadC/XxuvdJ6oAF6sX6a0Aq14 nv7JlB6wydSX4ScDVDWQ1fFPoNr6Hj X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Commit e70344c05995 ("block: fix default IO priority handling") introduced an inconsistency in get_current_ioprio() that tasks without IO context return IOPRIO_DEFAULT priority while tasks with freshly allocated IO context will return 0 (IOPRIO_CLASS_NONE/0) IO priority. Tasks without IO context used to be rare before 5a9d041ba2f6 ("block: move io_context creation into where it's needed") but after this commit they became common because now only BFQ IO scheduler setups task's IO context. Similar inconsistency is there for get_task_ioprio() so this inconsistency is now exposed to userspace and userspace will see different IO priority for tasks operating on devices with BFQ compared to devices without BFQ. Furthemore the changes done by commit e70344c05995 change the behavior when no IO priority is set for BFQ IO scheduler which is also documented in ioprio_set(2) manpage: "If no I/O scheduler has been set for a thread, then by default the I/O priority will follow the CPU nice value (setpriority(2)). In Linux kernels before version 2.6.24, once an I/O priority had been set using ioprio_set(), there was no way to reset the I/O scheduling behavior to the default. Since Linux 2.6.24, specifying ioprio as 0 can be used to reset to the default I/O scheduling behavior." So make sure we default to IOPRIO_CLASS_NONE as used to be the case before commit e70344c05995. Also cleanup alloc_io_context() to explicitely set this IO priority for the allocated IO context. Fixes: e70344c05995 ("block: fix default IO priority handling") Signed-off-by: Jan Kara --- block/blk-ioc.c | 2 ++ include/linux/ioprio.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/block/blk-ioc.c b/block/blk-ioc.c index df9cfe4ca532..63fc02042408 100644 --- a/block/blk-ioc.c +++ b/block/blk-ioc.c @@ -247,6 +247,8 @@ static struct io_context *alloc_io_context(gfp_t gfp_flags, int node) INIT_HLIST_HEAD(&ioc->icq_list); INIT_WORK(&ioc->release_work, ioc_release_fn); #endif + ioc->ioprio = IOPRIO_DEFAULT; + return ioc; } diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h index 774bb90ad668..d9dc78a15301 100644 --- a/include/linux/ioprio.h +++ b/include/linux/ioprio.h @@ -11,7 +11,7 @@ /* * Default IO priority. */ -#define IOPRIO_DEFAULT IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_BE_NORM) +#define IOPRIO_DEFAULT IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0) /* * Check that a priority value has a valid class. From patchwork Wed Jun 15 16:16:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 12882710 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77E60C433EF for ; Wed, 15 Jun 2022 16:19:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237508AbiFOQTA (ORCPT ); Wed, 15 Jun 2022 12:19:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355309AbiFOQSQ (ORCPT ); Wed, 15 Jun 2022 12:18:16 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA87055378 for ; Wed, 15 Jun 2022 09:16:41 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 91FCC21C37; Wed, 15 Jun 2022 16:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cKKCMNR572e3ji6tuUccfiNuQr0/7Utivo3oPFSORRs=; b=apTlQqRqu7SxwS0SfmBv/hmr+mwdDGLh66mjnzQiceL3+AEKV8eFo2vm++zLDIwMtxOWQk efxs3qXr/08q5+0Q7YVgO0LX1x61CEkxTgfhBEtekMOar+APUGHuMUXKUysJyS1HJdUlXw u8v6a1FiXedjgiAZDlTMmkSk4RAJFKs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cKKCMNR572e3ji6tuUccfiNuQr0/7Utivo3oPFSORRs=; b=v1K38U2z0q+Vmruuu75QtATBeQVfwBlASqZDOUNn2aRBXMqNf3BMYlVdpnz25LuJ9jSg+z +MpUCb6TEUfYr7BQ== Received: from quack3.suse.cz (unknown [10.163.28.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 3D9EF2C146; Wed, 15 Jun 2022 16:16:17 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id DD273A0638; Wed, 15 Jun 2022 18:16:16 +0200 (CEST) From: Jan Kara To: Jens Axboe Cc: , Damien Le Moal , Niklas Cassel , Bart Van Assche , Jan Kara Subject: [PATCH 4/8] block: Return effective IO priority from get_current_ioprio() Date: Wed, 15 Jun 2022 18:16:07 +0200 Message-Id: <20220615161616.5055-4-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220615160437.5478-1-jack@suse.cz> References: <20220615160437.5478-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1173; h=from:subject; bh=9bNkPVfvA56IJLEMsD6DpNxGU5tqEWJT3J3e95Phzjc=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBiqgXHvbqzTRIJLGRa6GUCcQe1x/QU/2iOdz0YYIxL crH7ylSJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYqoFxwAKCRCcnaoHP2RA2QIaB/ 9fDcBRjhXqOltkouU8J66mMijEZBuhyPnp3hyB2Pc9OB560PsxHuS6jz6OR3Tx3QfS3cmPiBAPbAMU OToolwS8GJ8KG5TiuM1XrZX56OMK+iE7cHsDuxXnHaIuIUNX0daosQyQW0YovWTf3RAiMJ6EChY8mL MtEiqgfci/ulS3MPdAYHrMoOw2Q5pXoqpoFmNhm1rkzsY6bzedLupXKecTKfz695VoEjcCYMq37dUe HuNw7eZA+VSFnUOdXmXtIrn1YoKg9Mf+pwvYCdxCBIT7LWPVXogpWoeH23Mdtjk5zEoUrGi5w92Pbo TubPcACadwa1v+pVo0wcYyv+H6V+4X X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org get_current_ioprio() is used to initialize IO priority of various requests. As such it should be returning the effective IO priority of the task (i.e., reflecting the fact that unset IO priority should get set based on task's CPU priority) so that the conversion is concentrated in one place. Signed-off-by: Jan Kara --- include/linux/ioprio.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h index d9dc78a15301..519d51fc8902 100644 --- a/include/linux/ioprio.h +++ b/include/linux/ioprio.h @@ -53,10 +53,17 @@ static inline int task_nice_ioclass(struct task_struct *task) static inline int get_current_ioprio(void) { struct io_context *ioc = current->io_context; + int prio; if (ioc) - return ioc->ioprio; - return IOPRIO_DEFAULT; + prio = ioc->ioprio; + else + prio = IOPRIO_DEFAULT; + + if (IOPRIO_PRIO_CLASS(prio) == IOPRIO_CLASS_NONE) + prio = IOPRIO_PRIO_VALUE(task_nice_ioclass(current), + task_nice_ioprio(current)); + return prio; } extern int set_task_ioprio(struct task_struct *task, int ioprio); From patchwork Wed Jun 15 16:16:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 12882712 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0B42C433EF for ; Wed, 15 Jun 2022 16:19:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354702AbiFOQTI (ORCPT ); Wed, 15 Jun 2022 12:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348905AbiFOQSS (ORCPT ); Wed, 15 Jun 2022 12:18:18 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA92755379 for ; Wed, 15 Jun 2022 09:16:41 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id D2F1E1F97E; Wed, 15 Jun 2022 16:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DqpItv11q9RFz4JOFsyAcCZ02pSGUPVwPnv55+p1+qw=; b=REa5iSpbS1FAxzwUVoxuo6vCNIt1i60JXhhKVbO8UO74xqL1chteFyQeT7GFAER8yvJV/2 FoymVNnG/cDZirArtWxkNNMy1Bp7I/YoXCI5eak7yfLG1ABk+I6+u3q0YyDNSyBgVQLWjp OAfPBUDOHqEYaf7ivl+u6x64EQkGk9U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DqpItv11q9RFz4JOFsyAcCZ02pSGUPVwPnv55+p1+qw=; b=eskKPzttw6e7hx5thiclXeGwfk170kyMvOU/Y7z5xRE4gHisfWmH/L3NQymIEpyFXnTPS+ oOIITXeZOMzSMxBA== Received: from quack3.suse.cz (unknown [10.163.28.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id C56D22C149; Wed, 15 Jun 2022 16:16:18 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id E3778A0639; Wed, 15 Jun 2022 18:16:16 +0200 (CEST) From: Jan Kara To: Jens Axboe Cc: , Damien Le Moal , Niklas Cassel , Bart Van Assche , Jan Kara Subject: [PATCH 5/8] blk-ioprio: Remove unneeded field Date: Wed, 15 Jun 2022 18:16:08 +0200 Message-Id: <20220615161616.5055-5-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220615160437.5478-1-jack@suse.cz> References: <20220615160437.5478-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1907; h=from:subject; bh=aeKHE3LvhJoWaFM7YpJcwiDk+5O0mTw/oPPCBn0n9AM=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBiqgXIzGQLNJUmPklWz6HkDZPusSIiVep4XVNpKKnw dxcwcHeJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYqoFyAAKCRCcnaoHP2RA2Z+ZCA CUn1Q1FxxhIsM14y0uZKzZX8IJ3nlJ4QSMjrMqPaTFHYwzPjA09LcxR4B3P8X42FPv5OyKUSLVl38k hqlFz9LTvcrX+Dx/b1J4H2tGNYDOjNIEezngScnId+dlw9ZGaXLmF8eJnM77412FlLKiFQIozy7qf4 nY+eZDRc2L0swc1336MmYfucN7+H9jeBFSCEBTVzhKzJV8O5nXp4W3qvurJ9hJ1lzFdxmA/u660ON1 Aunzg7wpUtqhMQEa8rNqjMC9KoP29j3JsvGvwENQ4uQNw+0fbs7Xic4N6jGxRzXAz9oE+dIVz4kkhm qRFvs9sWBM/wePjmmifkzW2ZJ9U+2S X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org blkcg->ioprio_set field is not really useful except for avoiding possibly more expensive checks inside blkcg_ioprio_track(). The check for blkcg->prio_policy being equal to POLICY_NO_CHANGE does the same service so just remove the ioprio_set field and replace the check. Signed-off-by: Jan Kara --- block/blk-ioprio.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/block/blk-ioprio.c b/block/blk-ioprio.c index 79e797f5d194..3f605583598b 100644 --- a/block/blk-ioprio.c +++ b/block/blk-ioprio.c @@ -62,7 +62,6 @@ struct ioprio_blkg { struct ioprio_blkcg { struct blkcg_policy_data cpd; enum prio_policy prio_policy; - bool prio_set; }; static inline struct ioprio_blkg *pd_to_ioprio(struct blkg_policy_data *pd) @@ -113,7 +112,6 @@ static ssize_t ioprio_set_prio_policy(struct kernfs_open_file *of, char *buf, if (ret < 0) return ret; blkcg->prio_policy = ret; - blkcg->prio_set = true; return nbytes; } @@ -193,16 +191,15 @@ static void blkcg_ioprio_track(struct rq_qos *rqos, struct request *rq, struct ioprio_blkcg *blkcg = ioprio_blkcg_from_bio(bio); u16 prio; - if (!blkcg->prio_set) + if (blkcg->prio_policy == POLICY_NO_CHANGE) return; /* * Except for IOPRIO_CLASS_NONE, higher I/O priority numbers * correspond to a lower priority. Hence, the max_t() below selects * the lower priority of bi_ioprio and the cgroup I/O priority class. - * If the cgroup policy has been set to POLICY_NO_CHANGE == 0, the - * bio I/O priority is not modified. If the bio I/O priority equals - * IOPRIO_CLASS_NONE, the cgroup I/O priority is assigned to the bio. + * If the bio I/O priority equals IOPRIO_CLASS_NONE, the cgroup I/O + * priority is assigned to the bio. */ prio = max_t(u16, bio->bi_ioprio, IOPRIO_PRIO_VALUE(blkcg->prio_policy, 0)); From patchwork Wed Jun 15 16:16:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 12882716 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11AB2CCA47E for ; Wed, 15 Jun 2022 16:19:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345676AbiFOQTO (ORCPT ); Wed, 15 Jun 2022 12:19:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354888AbiFOQSR (ORCPT ); Wed, 15 Jun 2022 12:18:17 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 840AE55485 for ; Wed, 15 Jun 2022 09:16:42 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id DD8721F981; Wed, 15 Jun 2022 16:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gEBpPJCz8/bsKbGbLSHxdhAcO0Jh7iiRRT/PkSSqJ5Q=; b=tPVDlTIIi/CpVRDKJkQBkQCPUV07HVFaknZvwbyQsUy7py+09SYsFpjw+0Tvkd+y7aiWi+ YkqYH+eL14B8puwKCx+2OFYA8tKKYyBfMusgIz4Es+RFLWC3q5k0RBYzMQVtxcwVUNU4mt zAjFJWfEyKiALciUXlTHcjAEyxzorBM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gEBpPJCz8/bsKbGbLSHxdhAcO0Jh7iiRRT/PkSSqJ5Q=; b=qCLBmcaZ0RF+c/QYr6qwbgiBWyHcd1+UqUT1/NxH/YWxcsaFav+DLv+sIRyRWQ2rTOFAac QsDxKfRbAjSxxTAg== Received: from quack3.suse.cz (unknown [10.163.28.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id CA2622C14F; Wed, 15 Jun 2022 16:16:18 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id EA636A063A; Wed, 15 Jun 2022 18:16:16 +0200 (CEST) From: Jan Kara To: Jens Axboe Cc: , Damien Le Moal , Niklas Cassel , Bart Van Assche , Jan Kara Subject: [PATCH 6/8] blk-ioprio: Convert from rqos policy to direct call Date: Wed, 15 Jun 2022 18:16:09 +0200 Message-Id: <20220615161616.5055-6-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220615160437.5478-1-jack@suse.cz> References: <20220615160437.5478-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4547; h=from:subject; bh=ECoFLx4eh//cI4rGpxOBBAOY0ZfPr9sTKA2GSSz6C54=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBiqgXJf6HOw5oGkoLu+DfDyVmCr1VTk4ceCf2I3wLl aQKq96qJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYqoFyQAKCRCcnaoHP2RA2XWXCA CnUKxaWxIdHhG4B7TP5VjICQtSrFY/1UKDAfMkdqNDOL1d3bySVzhO/r0u2ij5YE2rO+0Lmrc3vFHB aOzoexGxTJxEGxph2oKr4x7WIfODfvQDd2/Ji4SPGGuUM+uQiB0Y4LGNDPh9ZcIr0VavyjuEzqXUv/ NUZYJ7aMlE5L6IKbCCaL9v7GzZ38cYncwtI91xlGyCNd2pa4ywFCrrimE4jBXGUQRTQMB7rN+FWcra 4fpK+rdO+Gp5svChe7lwUDTKqTusm7hmVyzf+JWcmL3S3LE5Fr2vDXKDEJ243a8ncKwu8UIpVAuMqq IbDMDH9KPX9HVIWt52cE56cqTnR3F1 X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Convert blk-ioprio handling from a rqos policy to a direct call from blk_mq_submit_bio(). Firstly, blk-ioprio is not a much of a rqos policy anyway, it just needs a hook in bio submission path to set the bio's IO priority. Secondly, the rqos .track hook gets actually called too late for blk-ioprio purposes and introducing a special rqos hook just for blk-ioprio looks even weirder. Signed-off-by: Jan Kara --- block/blk-cgroup.c | 1 + block/blk-ioprio.c | 50 +++++----------------------------------------- block/blk-ioprio.h | 9 +++++++++ block/blk-mq.c | 8 ++++++++ 4 files changed, 23 insertions(+), 45 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 764e740b0c0f..6906981563f8 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1299,6 +1299,7 @@ int blkcg_init_queue(struct request_queue *q) ret = blk_iolatency_init(q); if (ret) { blk_throtl_exit(q); + blk_ioprio_exit(q); goto err_destroy_all; } diff --git a/block/blk-ioprio.c b/block/blk-ioprio.c index 3f605583598b..c00060a02c6e 100644 --- a/block/blk-ioprio.c +++ b/block/blk-ioprio.c @@ -181,17 +181,12 @@ static struct blkcg_policy ioprio_policy = { .pd_free_fn = ioprio_free_pd, }; -struct blk_ioprio { - struct rq_qos rqos; -}; - -static void blkcg_ioprio_track(struct rq_qos *rqos, struct request *rq, - struct bio *bio) +void blkcg_set_ioprio(struct bio *bio) { struct ioprio_blkcg *blkcg = ioprio_blkcg_from_bio(bio); u16 prio; - if (blkcg->prio_policy == POLICY_NO_CHANGE) + if (!blkcg || blkcg->prio_policy == POLICY_NO_CHANGE) return; /* @@ -207,49 +202,14 @@ static void blkcg_ioprio_track(struct rq_qos *rqos, struct request *rq, bio->bi_ioprio = prio; } -static void blkcg_ioprio_exit(struct rq_qos *rqos) +void blk_ioprio_exit(struct request_queue *q) { - struct blk_ioprio *blkioprio_blkg = - container_of(rqos, typeof(*blkioprio_blkg), rqos); - - blkcg_deactivate_policy(rqos->q, &ioprio_policy); - kfree(blkioprio_blkg); + blkcg_deactivate_policy(q, &ioprio_policy); } -static struct rq_qos_ops blkcg_ioprio_ops = { - .track = blkcg_ioprio_track, - .exit = blkcg_ioprio_exit, -}; - int blk_ioprio_init(struct request_queue *q) { - struct blk_ioprio *blkioprio_blkg; - struct rq_qos *rqos; - int ret; - - blkioprio_blkg = kzalloc(sizeof(*blkioprio_blkg), GFP_KERNEL); - if (!blkioprio_blkg) - return -ENOMEM; - - ret = blkcg_activate_policy(q, &ioprio_policy); - if (ret) { - kfree(blkioprio_blkg); - return ret; - } - - rqos = &blkioprio_blkg->rqos; - rqos->id = RQ_QOS_IOPRIO; - rqos->ops = &blkcg_ioprio_ops; - rqos->q = q; - - /* - * Registering the rq-qos policy after activating the blk-cgroup - * policy guarantees that ioprio_blkcg_from_bio(bio) != NULL in the - * rq-qos callbacks. - */ - rq_qos_add(q, rqos); - - return 0; + return blkcg_activate_policy(q, &ioprio_policy); } static int __init ioprio_init(void) diff --git a/block/blk-ioprio.h b/block/blk-ioprio.h index a7785c2f1aea..5a1eb550e178 100644 --- a/block/blk-ioprio.h +++ b/block/blk-ioprio.h @@ -6,14 +6,23 @@ #include struct request_queue; +struct bio; #ifdef CONFIG_BLK_CGROUP_IOPRIO int blk_ioprio_init(struct request_queue *q); +void blk_ioprio_exit(struct request_queue *q); +void blkcg_set_ioprio(struct bio *bio); #else static inline int blk_ioprio_init(struct request_queue *q) { return 0; } +static inline void blk_ioprio_exit(struct request_queue *q) +{ +} +static inline void blkcg_set_ioprio(struct bio *bio) +{ +} #endif #endif /* _BLK_IOPRIO_H_ */ diff --git a/block/blk-mq.c b/block/blk-mq.c index e9bf950983c7..67a7bfa58b7c 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -42,6 +42,7 @@ #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); @@ -2790,6 +2791,11 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q, return rq; } +static void bio_set_ioprio(struct bio *bio) +{ + blkcg_set_ioprio(bio); +} + /** * blk_mq_submit_bio - Create and send a request to block device. * @bio: Bio pointer. @@ -2830,6 +2836,8 @@ void blk_mq_submit_bio(struct bio *bio) trace_block_getrq(bio); + bio_set_ioprio(bio); + rq_qos_track(q, rq, bio); blk_mq_bio_to_request(rq, bio, nr_segs); From patchwork Wed Jun 15 16:16:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 12882714 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD3A5CCA473 for ; Wed, 15 Jun 2022 16:19:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354495AbiFOQTM (ORCPT ); Wed, 15 Jun 2022 12:19:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354872AbiFOQSQ (ORCPT ); Wed, 15 Jun 2022 12:18:16 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8DBC55206 for ; Wed, 15 Jun 2022 09:16:39 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D872E21C47; Wed, 15 Jun 2022 16:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j+EeqhSguiL/f3al2niBNE1UPdRtw82hjLXb6sHZejg=; b=EiqW3n3Vqbg3pIPHD9QFyoEirRKQDdc7AxYt4BS4rcRv/Y8WHztx1ftsBhnVcNQcPtZsmk Fb61VbDe1k6xNlhE8ROwxepfyZIN686Zoeo8aJMDrdZ7jWAG3IkzAMQlipU4T/jpneh/52 Hon5Ftu9amrJ5OozNol1r7bQJfWsqjs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j+EeqhSguiL/f3al2niBNE1UPdRtw82hjLXb6sHZejg=; b=EYn3I50TKUdZ8Kej01JPunnh1Oc5hbf4O5GrFjtMDxUw24HfAhic108+i3Mss7v4+Jzd2u jFTiFsWEAUBT2WCg== Received: from quack3.suse.cz (unknown [10.163.28.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id CA0CE2C14E; Wed, 15 Jun 2022 16:16:18 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id F137BA063B; Wed, 15 Jun 2022 18:16:16 +0200 (CEST) From: Jan Kara To: Jens Axboe Cc: , Damien Le Moal , Niklas Cassel , Bart Van Assche , Jan Kara Subject: [PATCH 7/8] block: Initialize bio priority earlier Date: Wed, 15 Jun 2022 18:16:10 +0200 Message-Id: <20220615161616.5055-7-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220615160437.5478-1-jack@suse.cz> References: <20220615160437.5478-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=902; h=from:subject; bh=rGyU+5zciSS3AScSd4SNeEGsxv246Ub1JBy28bN6W3M=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBiqgXKxwClY9U8vYvn2qq0rBlvaWqphh7dAHT9ZZtf PVXXROWJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYqoFygAKCRCcnaoHP2RA2ac8CA DjA4K/cehTVACAcVUXlurJ8mGMJ+Wg6Hz57ae85hhIqYBEk3VN9RnO/3nMC96Og9HaeorlZrQanu0r W0k26DjSgg0/R9UtqGycogDxAyd4RGqBX5s0zOHItvtqqaZdVyJByRxrHaAiwAv7wOZ51sL7u74MNx sc56b1dPln5uEoiaQmccpVcPMzWoPwL2YW7mwhVrUwrnmcu3Krpl+8cMUh7q8ZbL2nu2aWrBWIN0Nz jf5sYEYmeyb/SxvrpQiDJ/2lDDUcFU7Hsv1wcsfpYGVpSLM5+410JZ+6SXLRTlIn0Zu5/QaF2l5rXl YOsXldG9F+jr57rGJIuFTybC5m9Fgf X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Bio's IO priority needs to be initialized before we try to merge the bio with other bios. Otherwise we could merge bios which would otherwise receive different IO priorities leading to possible QoS issues. Signed-off-by: Jan Kara --- block/blk-mq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 67a7bfa58b7c..e17d822e6051 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2825,6 +2825,8 @@ 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) @@ -2836,8 +2838,6 @@ void blk_mq_submit_bio(struct bio *bio) trace_block_getrq(bio); - bio_set_ioprio(bio); - rq_qos_track(q, rq, bio); blk_mq_bio_to_request(rq, bio, nr_segs); From patchwork Wed Jun 15 16:16:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 12882717 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2B1BC433EF for ; Wed, 15 Jun 2022 16:19:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349414AbiFOQTP (ORCPT ); Wed, 15 Jun 2022 12:19:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355555AbiFOQSS (ORCPT ); Wed, 15 Jun 2022 12:18:18 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA08A48387 for ; Wed, 15 Jun 2022 09:16:41 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D8A6E21C53; Wed, 15 Jun 2022 16:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vTBV4GVJAyuQOnq7Eqd7AQEyBKr2b9T1PTHtj8WIfgs=; b=Ej03qcuyjOIrR3YiDk6zf+JIiyFUYC9G45VsAyngUP8HRXkLocPlcasElRuyWRGS7XWKFS 02BzT0XzTHz3TL1P8CaFdiqLBlAhJ0Y3v+grqlfDk8oLIAOfux0VEOOzqwdR34/8iTELdN VGnriq5hVAv6JjGLcRyc6PGk+po+w98= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1655309778; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vTBV4GVJAyuQOnq7Eqd7AQEyBKr2b9T1PTHtj8WIfgs=; b=Fr0sxROVC5BHwqjjexPnWvBzfRguHNAbZdUi81bl8RxY2E3OzSws8WNY6Uj/zJYKewwp48 nYJeIOEU6LLpVfCQ== Received: from quack3.suse.cz (unknown [10.163.28.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id C9FE22C14B; Wed, 15 Jun 2022 16:16:18 +0000 (UTC) Received: by quack3.suse.cz (Postfix, from userid 1000) id 040DBA063C; Wed, 15 Jun 2022 18:16:17 +0200 (CEST) From: Jan Kara To: Jens Axboe Cc: , Damien Le Moal , Niklas Cassel , Bart Van Assche , Jan Kara Subject: [PATCH 8/8] block: Always initialize bio IO priority on submit Date: Wed, 15 Jun 2022 18:16:11 +0200 Message-Id: <20220615161616.5055-8-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220615160437.5478-1-jack@suse.cz> References: <20220615160437.5478-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1090; h=from:subject; bh=294Oi1TS0R+sTtvAWIrlNByf+vKBwPZJ3GDBJ8IBplU=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBiqgXLlPdqbWvvzQGioc3zcit8ZN/sDhbTEpIOQJjs XJ5ngECJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCYqoFywAKCRCcnaoHP2RA2WsOB/ 4sWcBtp2toW6eEGKFbcTPF0ZXam0cwn+aKd/9H+jlbRGJurJ1ZlbUdscETIWqvRQAssH/zP+r7OWv+ iZ2gMSnir1Bo5JsLA0XNHyBx176ltB3fOIzH5FHG1Ol5ECygLhBDwMZ0QjH3Gvr6FwaNvcJJ/cGbRo SLn6A6CywG/wd2hZz05AXz7o/eP3gj8Yf/VJZHYKLGwkMaXeywzCpg5VpNuou6TXXtGELlNITZvU4m BJIw5wBwKPOTMiatt5yiiNuvEdJC72wnaRzUw9b19kczzT54WJHPmZStviMCIr1g6VaFJ8K6sxFh4x mm7WKb+nhGq1KmR+42o0M69rQUr5P2 X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Currently, IO priority set in task's IO context is not reflected in the bio->bi_ioprio for most IO (only io_uring and direct IO set it). This results in odd results where process is submitting some bios with one priority and other bios with a different (unset) priority and due to differing priorities bios cannot be merged. Make sure bio->bi_ioprio is always set on bio submission. Signed-off-by: Jan Kara --- block/blk-mq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/blk-mq.c b/block/blk-mq.c index e17d822e6051..e976f696babc 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2793,7 +2793,13 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q, static void bio_set_ioprio(struct bio *bio) { + unsigned short ioprio_class; + blkcg_set_ioprio(bio); + ioprio_class = IOPRIO_PRIO_CLASS(bio->bi_ioprio); + /* Nobody set ioprio so far? Initialize it based on task's nice value */ + if (ioprio_class == IOPRIO_CLASS_NONE) + bio->bi_ioprio = get_current_ioprio(); } /**