From patchwork Wed Aug 11 03:36:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12429965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C552C4338F for ; Wed, 11 Aug 2021 03:37:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F81260F11 for ; Wed, 11 Aug 2021 03:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233397AbhHKDhd (ORCPT ); Tue, 10 Aug 2021 23:37:33 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:34651 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233301AbhHKDha (ORCPT ); Tue, 10 Aug 2021 23:37:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1628653027; x=1660189027; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=RGO3k7Im0/zmf/Hv3HDGjqGVpHrOQ5t3E9jTrtJYPo4=; b=AVk75kGGjONvtEstWZPS4JQgUNvMQLNWbjlMCgV4VCgfz8sMeKl/Jna9 IfASHjhhicy/DoKinCQc6hyx19XMVoaWLVo5zjNputvxX+DKj00mwEkc6 hfSJhc8hgdHMtCQ44kBN0na6I5hFIbUoFxpciUI2oIyEjWZ1iOeJgx06Z FW3wifr6tBjSrmGFKFl9f8YzH3bRjPiYsgghqaRTr18su6dYBrkshGUPV EkfsfyNUbcpILrHHNipvAyuur5153yLU3oD1McqJ9LJ2g4gyMMnIv/D+L 44aRdmovYw+94IOy+lTBUdmkljY7vsoW2t+tE4CBuQfXQcQ+qe4HI1fAh Q==; X-IronPort-AV: E=Sophos;i="5.84,311,1620662400"; d="scan'208";a="177454813" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 Aug 2021 11:37:06 +0800 IronPort-SDR: 9fkimOHJDdRTgmQUiAQGXu+jTLU/NiNBeMwl92uuNSuwg292yjiZQGna3NuyI3/3rIg7Ya7YKV zWAEQrYQcCuRR6b8hOZutK1AVhPEjhtLJ5JkGOZMakL2mynaqsrfXCCv9/UjXhe/JpxKcgg1cd s3TCV9krb5nR06MJkYdjhkwRg6aWfD6Silh6Ot5MWJyoZq2uXvHctjFer234hU5wiBCxz79KtL pjvByF+yxFF2jeUvqUQPoiq4cLdEzEAWPERSaDlIZZCqE7svUKBCPzmWGK6bVej9SC/CNpXyuw ulcyqSLy1tPK/OHWn/L7rusS Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2021 20:14:26 -0700 IronPort-SDR: trfAXxLIff8ymscFRb/l6NN/HkytkwfYfAw417EtaTEXyemhSBWjvjNC8ki0XCnK4sIwPxfn7k Abmk4qG4Py4oSPrzhMTJ8hjxLYp18VB//UY4PolxdCzCaNGkpt5x1ayHXZak3TPz+dMw3tQ3zh 0xPwojW92rU0BS4DXETNoZJT7r4e2GQmj6Pn+06g8VMiSUCVNotZJjyXMX+kOZZUKPFr0OOVL2 /e+b2/phSfkkHuzahvspJ7SV5uk+P9t3GLtkD3uT6gwqMLwRGrveyJuwzidx1JUrm6q3UVWdAU QwQ= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 10 Aug 2021 20:37:05 -0700 From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, Paolo Valente , linux-f2fs-devel@lists.sourceforge.net, Jaegeuk Kim , Chao Yu Subject: [PATCH v4 1/6] block: bfq: fix bfq_set_next_ioprio_data() Date: Wed, 11 Aug 2021 12:36:57 +0900 Message-Id: <20210811033702.368488-2-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811033702.368488-1-damien.lemoal@wdc.com> References: <20210811033702.368488-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org For a request that has a priority level equal to or larger than IOPRIO_BE_NR, bfq_set_next_ioprio_data() prints a critical warning but defaults to setting the request new_ioprio field to IOPRIO_BE_NR. This is not consistent with the warning and the allowed values for priority levels. Fix this by setting the request new_ioprio field to IOPRIO_BE_NR - 1, the lowest priority level allowed. Cc: Fixes: aee69d78dec0 ("block, bfq: introduce the BFQ-v0 I/O scheduler as an extra scheduler") Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke --- block/bfq-iosched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index e4a61eda2d0f..e546a5f4bff9 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -5296,7 +5296,7 @@ bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic) if (bfqq->new_ioprio >= IOPRIO_BE_NR) { pr_crit("bfq_set_next_ioprio_data: new_ioprio %d\n", bfqq->new_ioprio); - bfqq->new_ioprio = IOPRIO_BE_NR; + bfqq->new_ioprio = IOPRIO_BE_NR - 1; } bfqq->entity.new_weight = bfq_ioprio_to_weight(bfqq->new_ioprio); From patchwork Wed Aug 11 03:36:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12429969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49B27C4338F for ; Wed, 11 Aug 2021 03:37:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B65D60F22 for ; Wed, 11 Aug 2021 03:37:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233066AbhHKDhg (ORCPT ); Tue, 10 Aug 2021 23:37:36 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:34652 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233331AbhHKDha (ORCPT ); Tue, 10 Aug 2021 23:37:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1628653027; x=1660189027; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=tda/wI1ZwrYqH4umND8+Og63Ye/tFaSza1oypzr1bnw=; b=ZoXfBHZG5tim3Zuc62cMSqvo5BSxlb7Eutnxy+JqraBcXlnuyLO7zR9F BjHVcAx7i17ChIzTz5smGOsmdi1yWtRZKRguQO5AbfoUxY2/XV0TwMSwE eVHQLqrXw9Xsl6IZbc3h2SvgyyrI2JcjwdTbVuh70hlVrwG7wl7d/BWvR DUKMnAVuDcHWdOJi3lAhyI1ncpEP9Y1QFthgx6i0w2VLhfB9q5ial8w2f Tn3QBrvZhHV6oHLKF2q4/NeU6/SZU7BQ+PioIvvEb84aZpbJLM/KB7iNq bCV0ISEBM3823e2Ho07148t8ddHWurEPNDfrihYQlo6BU5X51xW4TRVeb A==; X-IronPort-AV: E=Sophos;i="5.84,311,1620662400"; d="scan'208";a="177454815" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 Aug 2021 11:37:07 +0800 IronPort-SDR: HJeqTwh7r4Iq7C/NpQHtefspQmHCw9z5VxrwhPAQbcrUPzraXIg4x8rdQvf/JuErg3klyHNOP3 f5N32B2GOQ6axg8QDF3zJDJTolEUY/NfCc8zTDsvsDg9wE5HxntXdcdpxvDrmJxcsqQTbQHnq1 oxhytpKyE9gXO3eoEjUQhayv0rGqFxrT9GRpYtKM8rCUf7ASCelKGHcMkAWpsIlV8UCERW3JtS dPC6l28IBocEW1FWoa+8fTzOQArkNiIAsaISLMnPWhVE62qnpWmU5Rbd6eh+k+ZQNC+r7HZtS6 Ikque6d2f59VHKVdFfm9D5c5 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2021 20:14:27 -0700 IronPort-SDR: FEZpBFus5K4fWMAEN+mHd0TgFuIveatp72Uyh2x27MEW0zq4qojs02FF9Dxp3k7YSsNwfmtUkb LiYzfuXUFhBfjFGA77x1/YdMOkmVf2QTq3DXgVTMr3u5g6Im2G5lGNZMxOxkAZQvydmmhJOxY3 cgbyqTsQTKluBApb9vli7rxpTAHQt4aLK0LEaFVlxn3o+6dpXxWkTqjlqx7dk1W/E+gNtFLwcS p9UY0rh+tKoLKXMAa9+IRCWk7+YVWTSQs9L1klQ4TzgGpkYCKz9g7QbcV2yurdj6ZWOW9icMNS GMo= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 10 Aug 2021 20:37:06 -0700 From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, Paolo Valente , linux-f2fs-devel@lists.sourceforge.net, Jaegeuk Kim , Chao Yu Subject: [PATCH v4 2/6] block: improve ioprio class description comment Date: Wed, 11 Aug 2021 12:36:58 +0900 Message-Id: <20210811033702.368488-3-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811033702.368488-1-damien.lemoal@wdc.com> References: <20210811033702.368488-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org In include/usapi/linux/ioprio.h, change the ioprio class enum comment to remove the outdated reference to CFQ and mention BFQ and mq-deadline instead. Also document the high priority NCQ command use for RT class IOs directed at ATA drives that support NCQ priority. Signed-off-by: Damien Le Moal --- include/uapi/linux/ioprio.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h index 77b17e08b0da..6b735854aebd 100644 --- a/include/uapi/linux/ioprio.h +++ b/include/uapi/linux/ioprio.h @@ -13,10 +13,12 @@ #define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data) /* - * These are the io priority groups as implemented by CFQ. RT is the realtime - * class, it always gets premium service. BE is the best-effort scheduling - * class, the default for any process. IDLE is the idle scheduling class, it - * is only served when no one else is using the disk. + * These are the io priority groups as implemented by the BFQ and mq-deadline + * schedulers. RT is the realtime class, it always gets premium service. For + * ATA disks supporting NCQ IO priority, RT class IOs will be processed using + * high priority NCQ commands. BE is the best-effort scheduling class, the + * default for any process. IDLE is the idle scheduling class, it is only + * served when no one else is using the disk. */ enum { IOPRIO_CLASS_NONE, From patchwork Wed Aug 11 03:36:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12429971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 952A9C4338F for ; Wed, 11 Aug 2021 03:37:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C9A060F13 for ; Wed, 11 Aug 2021 03:37:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232772AbhHKDhi (ORCPT ); Tue, 10 Aug 2021 23:37:38 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:34651 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232994AbhHKDhc (ORCPT ); Tue, 10 Aug 2021 23:37:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1628653030; x=1660189030; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=j0s33+d09cJLd2qYDmoWRU5cJ5eobt/aSkEuXaJrC6o=; b=K1c30+dsvxSxLq4Yc9sB1E/YvDa6P4FZD1A2FOpjEs+aZ/ow+waCoUxc fkAlpT/tVeBj95Q9CCrMgsBXDfVIrAaF/ATx+SmMIxXJGyGmRipqOA7tO iuSF0cvsU1vHyevqcQ4m3wPORZIVKagy8U4TS0k7chSAgrNSpy+66lReF eurO7quGyFnN3iE1a7baQm3kjPyBAtRHddrH8D9lf1mtUKOMFzfz6uo+c VyeHAkvWaxvsH7crzPc2rNUTNONdn71sITRsrxwqKff7mnLYPvZ1SezRl zAb85oqwcbMiC+CRGgC05n/m4IXrAnqzG8GEZk1oWo4e9gRsueYgQOXri g==; X-IronPort-AV: E=Sophos;i="5.84,311,1620662400"; d="scan'208";a="177454816" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 Aug 2021 11:37:09 +0800 IronPort-SDR: O924dDbu7HD8iR8zm07rBT29zKjYrKkiDxGlYdtfqEPv/lFwMZXc7VRhgzBADBpejRAqUoELzC 5GIMZiWcQ1LJogOaUm2w7OtZbbucus+Ah0Vh/b5WlMqkymDKy2vW+3xr7wfZAzHAMdNsHVMFJl 3PA6d7RQpaRbPfHMCoEK+dHP/3o6FAsHiMwlQ0dtAYc+bwiIDe9+e55RNaFWhM4GtnI79975bI 2zluDp5V5Wq/dndGLzXI09ZqNsfmaQiZnIrclokEmkyKXFkiGG/Rd9JpQH5i2dlVfIHOpAVJ6t +wkxJebbcLLiDhlLfLMlSX1L Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2021 20:14:29 -0700 IronPort-SDR: QeCHXqY/a+FukCgR81BdGDYdIyE+0w1AzjKJpMCShWexbiAx90FnRJ+V+isIko4lu+mbaplzmz oA7DjAgMs62UPnzMYSmnsht6YtMeZ2iBp/bI6NSwVuKuft8oiKSX2vTV7/bPGz5Tf3mypEolOq +89DW0cpmueqKaxItD2d2DjFQDT6woxqHugcdKRmNKtYqSPKPRNkYP52qlFEUDoh1V1GDCW0OW I7gNI5Zk1cE8IpvSwlaBfNTxuw/emiu2I25LFYlOK2SU2crMvZYnPkjrgmIjmDS4+WiKBVWuRe wzo= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 10 Aug 2021 20:37:07 -0700 From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, Paolo Valente , linux-f2fs-devel@lists.sourceforge.net, Jaegeuk Kim , Chao Yu Subject: [PATCH v4 3/6] block: change ioprio_valid() to an inline function Date: Wed, 11 Aug 2021 12:36:59 +0900 Message-Id: <20210811033702.368488-4-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811033702.368488-1-damien.lemoal@wdc.com> References: <20210811033702.368488-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Change the ioprio_valid() macro in include/usapi/linux/ioprio.h to an inline function declared on the kernel side in include/linux/ioprio.h. Also improve checks on the class value by checking the upper bound value. Signed-off-by: Damien Le Moal --- include/linux/ioprio.h | 10 ++++++++++ include/uapi/linux/ioprio.h | 2 -- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h index ef9ad4fb245f..2ee3373684b1 100644 --- a/include/linux/ioprio.h +++ b/include/linux/ioprio.h @@ -8,6 +8,16 @@ #include +/* + * Check that a priority value has a valid class. + */ +static inline bool ioprio_valid(unsigned short ioprio) +{ + unsigned short class = IOPRIO_PRIO_CLASS(ioprio); + + return class > IOPRIO_CLASS_NONE && class <= IOPRIO_CLASS_IDLE; +} + /* * if process has set io priority explicitly, use that. if not, convert * the cpu scheduler nice value to an io priority diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h index 6b735854aebd..5064e230374c 100644 --- a/include/uapi/linux/ioprio.h +++ b/include/uapi/linux/ioprio.h @@ -27,8 +27,6 @@ enum { IOPRIO_CLASS_IDLE, }; -#define ioprio_valid(mask) (IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE) - /* * 8 best effort priority levels are supported */ From patchwork Wed Aug 11 03:37:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12429973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0E0CC4320A for ; Wed, 11 Aug 2021 03:37:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E65760F11 for ; Wed, 11 Aug 2021 03:37:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232994AbhHKDhs (ORCPT ); Tue, 10 Aug 2021 23:37:48 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:34657 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233152AbhHKDhd (ORCPT ); Tue, 10 Aug 2021 23:37:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1628653030; x=1660189030; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=TLB12hws/We5+bFUS7lZWqDMzP/Axao9rVRwnxqY1E4=; b=KKkt789oNdkvhNApEuZBQFegoPo32klJuLBDLyqaJNjGd102B0tVLGV4 KONOBLDYJ5u+KeJ6xMpJsWLOZhySIuisRVy5hq1LGF5gXbezUQY04UEGl uAKzPdeQ+2vEKhtjZOP+YR/K9dGmyjyy/LCT7IBaEWnb8ucYUGicT468N KbzQYPU8fknifCljXj5ic5QjrNh8uP2UdmGx52mgLhAKsorgWOeVJKcNk kQYctAdJkO4A7wcHSQWlXNqLYBOVVf2pcs1eg8+lBdi9k31NaeSnHa2fT Afh21StX3o+6yaN7rqdRF2Q4OxiujzwG++ylYx3AuUcCUrIQEfkel+49y Q==; X-IronPort-AV: E=Sophos;i="5.84,311,1620662400"; d="scan'208";a="177454817" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 Aug 2021 11:37:10 +0800 IronPort-SDR: ZqWnGexNqaWCg/W4kKxmFtE2/4dOXzOeYb9IPAtY96awotkDp6JDeqLKuQhq7TeN859na5Btvt 0pnyTFH5WWt30AQAMlvoKWFei1U3GQX+Hd8Dp2ej//vcZb4zC4HphD9/0HX+nI6WAOz+I/s+ka yAqXW0+Q9aE03ezYT1WqkiQ7x8CI0k/83eDycA01SZYUG/NTclD0hTXrOctUMX65qXQIyEKR4Y NTndsep9D/IPrXlXzA8je8Fq5OZlZE/TI1CpQ2YNA/EoHbICKY8PJwKb9H2CaMMV1HIqhSiFQ4 aVEowrtb8K5kEQhXOnxSnEJr Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2021 20:14:30 -0700 IronPort-SDR: poaSQOX8guMoDEMVP4Z35+CJM/Vx+6J1kh3uYqQdi7arVOzPoixAfVoXto8nOL5jKzf6dOUlD3 uKvdzRIRCCV6m99xWYt+NLKotFSP5I5FlIbRDr88E7OP3XLWs29WP+yApBy9+IXhJZFkxrpMXj lcL8951untx1ZeZIE3qTn1Kh4gc9OjWcqDtlRGCA3d50OB0xFs+4RGoi7YB64BN1N39Bi8Kott ri1LAmJ29wNRO1sqNEwPP9IbUzr62hZlYdXMoYpH1fn0UfGr80aMGsZMVC+9lzVQ9M/7+3TOix t58= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 10 Aug 2021 20:37:08 -0700 From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, Paolo Valente , linux-f2fs-devel@lists.sourceforge.net, Jaegeuk Kim , Chao Yu Subject: [PATCH v4 4/6] block: fix IOPRIO_PRIO_CLASS() and IOPRIO_PRIO_VALUE() macros Date: Wed, 11 Aug 2021 12:37:00 +0900 Message-Id: <20210811033702.368488-5-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811033702.368488-1-damien.lemoal@wdc.com> References: <20210811033702.368488-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The ki_ioprio field of struct kiocb is 16-bits (u16) but often handled as an int in the block layer. E.g. ioprio_check_cap() takes an int as argument. With such implicit int casting function calls, the upper 16-bits of the int argument may be left uninitialized by the compiler, resulting in invalid values for the IOPRIO_PRIO_CLASS() macro (garbage upper bits) and in an error return for functions such as ioprio_check_cap(). Fix this by masking the result of the shift by IOPRIO_CLASS_SHIFT bits in the IOPRIO_PRIO_CLASS() macro. The new macro IOPRIO_CLASS_MASK defines the 3-bits mask for the priority class. Similarly, apply the IOPRIO_PRIO_MASK mask to the data argument of the IOPRIO_PRIO_VALUE() macro to ignore the upper bits of the data value. The IOPRIO_CLASS_MASK mask is also applied to the class argument of this macro before shifting the result by IOPRIO_CLASS_SHIFT bits. While at it, also change the argument name of the IOPRIO_PRIO_CLASS() and IOPRIO_PRIO_DATA() macros from "mask" to "ioprio" to reflect the fact that a priority value should be passed rather than a mask. Signed-off-by: Damien Le Moal --- include/uapi/linux/ioprio.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h index 5064e230374c..936f0d8f30e1 100644 --- a/include/uapi/linux/ioprio.h +++ b/include/uapi/linux/ioprio.h @@ -5,12 +5,16 @@ /* * Gives us 8 prio classes with 13-bits of data for each class */ -#define IOPRIO_CLASS_SHIFT (13) +#define IOPRIO_CLASS_SHIFT 13 +#define IOPRIO_CLASS_MASK 0x07 #define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1) -#define IOPRIO_PRIO_CLASS(mask) ((mask) >> IOPRIO_CLASS_SHIFT) -#define IOPRIO_PRIO_DATA(mask) ((mask) & IOPRIO_PRIO_MASK) -#define IOPRIO_PRIO_VALUE(class, data) (((class) << IOPRIO_CLASS_SHIFT) | data) +#define IOPRIO_PRIO_CLASS(ioprio) \ + (((ioprio) >> IOPRIO_CLASS_SHIFT) & IOPRIO_CLASS_MASK) +#define IOPRIO_PRIO_DATA(ioprio) ((ioprio) & IOPRIO_PRIO_MASK) +#define IOPRIO_PRIO_VALUE(class, data) \ + ((((class) & IOPRIO_CLASS_MASK) << IOPRIO_CLASS_SHIFT) | \ + ((data) & IOPRIO_PRIO_MASK)) /* * These are the io priority groups as implemented by the BFQ and mq-deadline From patchwork Wed Aug 11 03:37:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12429977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F706C4320E for ; Wed, 11 Aug 2021 03:37:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5902860F22 for ; Wed, 11 Aug 2021 03:37:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233349AbhHKDhu (ORCPT ); Tue, 10 Aug 2021 23:37:50 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:34665 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233301AbhHKDhe (ORCPT ); Tue, 10 Aug 2021 23:37:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1628653031; x=1660189031; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=+YKFJGf1DXtdTGWfV/bu2IJ+KfNBXvFKm3zTlEpFKjU=; b=m1KQcYh/c8Fna1t8Lzuda09QAwg4bnaM9bWXwpeU7PXOKsUx5qqc4Bru UkC9IKCnQgjeCpWMpQpGvb7fc8usYIrJ7May+Jr6l6IO6jCEg8LvXFMdZ UWDVdnBuSEuvuveVjlIVTInI5QXihGc8T+GpM+Ho3ZK3cdxYpbaG5xqxp gNmk/rbtu/8JrTHn6yYKF8lYMCAriJ/u/CVNQ+cnjWY/NwgVJm0+HL/M2 WffMZgPmjdHk4TdHF9nzj+g3KyhJ7FQYa7Og9/VYzYgAfJPrC1VqDpUSS Wmkhv8as4BG9a0qUcUG87d7uFdqBA+PEAHX2eututNGX8No+iKBPmhq3R A==; X-IronPort-AV: E=Sophos;i="5.84,311,1620662400"; d="scan'208";a="177454818" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 Aug 2021 11:37:11 +0800 IronPort-SDR: pwBmJ12pFdJQUuebDPiIRv/5H2fGQSQslHTrOpfS0/wWPvBtXBno1f6azhseORm4fMKZZxnJkc nUb9NA0U/rgf1IZ+uDnaZMDWwBlYmUd9VN3Y05vVrLvfrxlinpkeQh7yRAfQEqNs7dVrPrwaVv 0Q0EtqG6FjO3ftgl1NXqErbpspT1BkSbvdCZ1SCf9DAIF5xWS9ey+UAeWIYz6RECqVzvWZhhk7 UtpPKWWYHgTwzPY3hsTpjum9Sj+rwHPmajUpATYVm5wr6hlDn9qd+cUv3YvWvfvDVmWhfNY6VH NJ/QRW5VaoRX7yTSDXpTEl5R Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2021 20:14:31 -0700 IronPort-SDR: xNep8P0pzuh2eZT9WzcRvVAjSIspnFg1trw1UROtsdqh7v5PrbS+mSpP745Hl9b4WfPVtlOf1A kWtPfZHmO2iRVKMUMTPJ7BIiS1rR6tdxVaUAx0LiKeHRPaQbuxBj0aIa1O4+IS5knSWeLDHKwO GzYc3Kb+dvqicIs3Nnj0+6Oly/WiCKL6BsCva9pCbCOrA6ivGxp05d71oaz9rNOXDSE39/dPdy LV11YjlEMk4Bn2h+IvvY4QFIn7GYBe7XkEhEgt6ssT7iZF4Q/u0gl0w/mpnOO1bckq/32EbdwQ 1ZA= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 10 Aug 2021 20:37:10 -0700 From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, Paolo Valente , linux-f2fs-devel@lists.sourceforge.net, Jaegeuk Kim , Chao Yu Subject: [PATCH v4 5/6] block: Introduce IOPRIO_NR_LEVELS Date: Wed, 11 Aug 2021 12:37:01 +0900 Message-Id: <20210811033702.368488-6-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811033702.368488-1-damien.lemoal@wdc.com> References: <20210811033702.368488-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The BFQ scheduler and ioprio_check_cap() both assume that the RT priority class (IOPRIO_CLASS_RT) can have up to 8 different priority levels, similarly to the BE class (IOPRIO_CLASS_iBE). This is controlled using the IOPRIO_BE_NR macro , which is badly named as the number of levels also applies to the RT class. Introduce the class independent IOPRIO_NR_LEVELS macro, defined to 8, to make things clear. Keep the old IOPRIO_BE_NR macro definition as an alias for IOPRIO_NR_LEVELS. Signed-off-by: Damien Le Moal --- block/bfq-iosched.c | 8 ++++---- block/bfq-iosched.h | 4 ++-- block/bfq-wf2q.c | 6 +++--- block/ioprio.c | 3 +-- fs/f2fs/sysfs.c | 2 +- include/uapi/linux/ioprio.h | 5 +++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index e546a5f4bff9..4b434369e411 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -2508,7 +2508,7 @@ void bfq_end_wr_async_queues(struct bfq_data *bfqd, int i, j; for (i = 0; i < 2; i++) - for (j = 0; j < IOPRIO_BE_NR; j++) + for (j = 0; j < IOPRIO_NR_LEVELS; j++) if (bfqg->async_bfqq[i][j]) bfq_bfqq_end_wr(bfqg->async_bfqq[i][j]); if (bfqg->async_idle_bfqq) @@ -5293,10 +5293,10 @@ bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic) break; } - if (bfqq->new_ioprio >= IOPRIO_BE_NR) { + if (bfqq->new_ioprio >= IOPRIO_NR_LEVELS) { pr_crit("bfq_set_next_ioprio_data: new_ioprio %d\n", bfqq->new_ioprio); - bfqq->new_ioprio = IOPRIO_BE_NR - 1; + bfqq->new_ioprio = IOPRIO_NR_LEVELS - 1; } bfqq->entity.new_weight = bfq_ioprio_to_weight(bfqq->new_ioprio); @@ -6825,7 +6825,7 @@ void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg) int i, j; for (i = 0; i < 2; i++) - for (j = 0; j < IOPRIO_BE_NR; j++) + for (j = 0; j < IOPRIO_NR_LEVELS; j++) __bfq_put_async_bfqq(bfqd, &bfqg->async_bfqq[i][j]); __bfq_put_async_bfqq(bfqd, &bfqg->async_idle_bfqq); diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 99c2a3cb081e..385e28a843d1 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -931,7 +931,7 @@ struct bfq_group { void *bfqd; - struct bfq_queue *async_bfqq[2][IOPRIO_BE_NR]; + struct bfq_queue *async_bfqq[2][IOPRIO_NR_LEVELS]; struct bfq_queue *async_idle_bfqq; struct bfq_entity *my_entity; @@ -948,7 +948,7 @@ struct bfq_group { struct bfq_entity entity; struct bfq_sched_data sched_data; - struct bfq_queue *async_bfqq[2][IOPRIO_BE_NR]; + struct bfq_queue *async_bfqq[2][IOPRIO_NR_LEVELS]; struct bfq_queue *async_idle_bfqq; struct rb_root rq_pos_tree; diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c index 7a462df71f68..b74cc0da118e 100644 --- a/block/bfq-wf2q.c +++ b/block/bfq-wf2q.c @@ -505,7 +505,7 @@ static void bfq_active_insert(struct bfq_service_tree *st, */ unsigned short bfq_ioprio_to_weight(int ioprio) { - return (IOPRIO_BE_NR - ioprio) * BFQ_WEIGHT_CONVERSION_COEFF; + return (IOPRIO_NR_LEVELS - ioprio) * BFQ_WEIGHT_CONVERSION_COEFF; } /** @@ -514,12 +514,12 @@ unsigned short bfq_ioprio_to_weight(int ioprio) * * To preserve as much as possible the old only-ioprio user interface, * 0 is used as an escape ioprio value for weights (numerically) equal or - * larger than IOPRIO_BE_NR * BFQ_WEIGHT_CONVERSION_COEFF. + * larger than IOPRIO_NR_LEVELS * BFQ_WEIGHT_CONVERSION_COEFF. */ static unsigned short bfq_weight_to_ioprio(int weight) { return max_t(int, 0, - IOPRIO_BE_NR * BFQ_WEIGHT_CONVERSION_COEFF - weight); + IOPRIO_NR_LEVELS * BFQ_WEIGHT_CONVERSION_COEFF - weight); } static void bfq_get_entity(struct bfq_entity *entity) diff --git a/block/ioprio.c b/block/ioprio.c index bee628f9f1b2..ca6b136c5586 100644 --- a/block/ioprio.c +++ b/block/ioprio.c @@ -74,9 +74,8 @@ int ioprio_check_cap(int ioprio) fallthrough; /* rt has prio field too */ case IOPRIO_CLASS_BE: - if (data >= IOPRIO_BE_NR || data < 0) + if (data >= IOPRIO_NR_LEVELS || data < 0) return -EINVAL; - break; case IOPRIO_CLASS_IDLE: break; diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 6642246206bd..daad532a4e2b 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -378,7 +378,7 @@ static ssize_t __sbi_store(struct f2fs_attr *a, ret = kstrtol(name, 10, &data); if (ret) return ret; - if (data >= IOPRIO_BE_NR || data < 0) + if (data >= IOPRIO_NR_LEVELS || data < 0) return -EINVAL; cprc->ckpt_thread_ioprio = IOPRIO_PRIO_VALUE(class, data); diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h index 936f0d8f30e1..aac39338d02c 100644 --- a/include/uapi/linux/ioprio.h +++ b/include/uapi/linux/ioprio.h @@ -32,9 +32,10 @@ enum { }; /* - * 8 best effort priority levels are supported + * The RT and BE priority classes both support up to 8 priority levels. */ -#define IOPRIO_BE_NR (8) +#define IOPRIO_NR_LEVELS 8 +#define IOPRIO_BE_NR IOPRIO_NR_LEVELS enum { IOPRIO_WHO_PROCESS = 1, From patchwork Wed Aug 11 03:37:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 12429975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E21AC43214 for ; Wed, 11 Aug 2021 03:37:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E466460F22 for ; Wed, 11 Aug 2021 03:37:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233301AbhHKDhv (ORCPT ); Tue, 10 Aug 2021 23:37:51 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:34666 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233441AbhHKDhf (ORCPT ); Tue, 10 Aug 2021 23:37:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1628653033; x=1660189033; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=aIY39d4hgoXJ5yC909GBcv4Zo1XR4CYUFpg6offLqg4=; b=mkUytbje80TaCIAMY1x8mnNXFSkG959PhuCkkg0H9IvEWpxXAFl+nG5y 8fNOLfMnC+jie0dwGY5ZszNxYC6YhRW7I4fxim6TlPXk+iVzufI3XDZJc 9FEH8/wc+l97mtQR6K5RTMahnrdu2fBIlpA6aIyDy/8P6rqMmAgKITGdi Wmu3qTopd4Ol1vqZIwTXfZNc/lpI17bX87Tql/vId57QBR7Zq/yBrybUX UvzjfOnkK6aha6P+teG4bdRyKLZoHgqGYjNA9Il3Vu1x6UJ7ouw12dgz9 n/HqGxI/khgKzhWoEdNflx9vuRjSDFAn2eTq1qEAEmA1R6Bj2WDeBrl9L Q==; X-IronPort-AV: E=Sophos;i="5.84,311,1620662400"; d="scan'208";a="177454820" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 11 Aug 2021 11:37:13 +0800 IronPort-SDR: +OrEXQfJqgiy6LbfaF5wDr8J6ZvnjnZFb6Davwx7xbjSPTvRqZZJr3FcMXCF1w6bCvQnW+6vSm k4IPrWzW2Zh5YG9H+bDXk7NIyrkn6+TY+TSn2S6nRN/J1wGRdrnY0wCMMhfPd+PWtPL/XCmNGx 52rrxxnxQUSI8rznDpcOW1sm9m6Eng3GSMvyLoT+hjzbzH2DTx8KBLPAxcjwhso9xJsaxheVAl rjCHP2VmzozOmHzbsjolbcHQMevetz6rXbSCbV7/qhb3rPaWChTJfAVY10U/Usafd8wr+qutJw 6/ZL61eJMmE9Raf2KYkHL4nF Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2021 20:14:33 -0700 IronPort-SDR: Xb3/7ZlwUG+JnG3iXyej6Y9GLbcebGNIfPJy6Y8FRbvgl69fAikHEiz4PTscm0LpsRymbEL1M9 YBnLe88i40M7lEwfZSYnJZKTIf1T9bN4cyxi7cYb4aqEOiLTy8dbisxhryK4ErmqWwTyfKy4hm A5LhpCiaYghAo2RB2Hs5jbkSF0+hw8AxP04tIZ8olrXMvGF9hzbP2zi1i03O1QPD6UllLz1nzJ XeEcq0aFesgKtspnyc6Qae6mQC4uMddcX/niF19d8OlOydIhjzGC+I4d6ahrUZx/iIeZcU/G20 i/0= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 10 Aug 2021 20:37:11 -0700 From: Damien Le Moal To: Jens Axboe , linux-block@vger.kernel.org, Paolo Valente , linux-f2fs-devel@lists.sourceforge.net, Jaegeuk Kim , Chao Yu Subject: [PATCH v4 6/6] block: fix default IO priority handling Date: Wed, 11 Aug 2021 12:37:02 +0900 Message-Id: <20210811033702.368488-7-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811033702.368488-1-damien.lemoal@wdc.com> References: <20210811033702.368488-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The default IO priority is the best effort (BE) class with the normal priority level IOPRIO_NORM (4). However, get_task_ioprio() returns IOPRIO_CLASS_NONE/IOPRIO_NORM as the default priority and get_current_ioprio() returns IOPRIO_CLASS_NONE/0. Let's be consistent with the defined default and have both of these functions return the default priority IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM) when the user did not define another default IO priority for the task. In include/uapi/linux/ioprio.h, introduce the IOPRIO_BE_NORM macro as an alias to IOPRIO_NORM to clarify that this default level applies to the BE priotity class. In include/linux/ioprio.h, define the macro IOPRIO_DEFAULT as IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_BE_NORM) and use this new macro when setting a priority to the default. Signed-off-by: Damien Le Moal --- block/bfq-iosched.c | 2 +- block/ioprio.c | 6 +++--- drivers/nvme/host/lightnvm.c | 2 +- include/linux/ioprio.h | 7 ++++++- include/uapi/linux/ioprio.h | 5 +++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 4b434369e411..e92bc0348433 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -5411,7 +5411,7 @@ static struct bfq_queue **bfq_async_queue_prio(struct bfq_data *bfqd, case IOPRIO_CLASS_RT: return &bfqg->async_bfqq[0][ioprio]; case IOPRIO_CLASS_NONE: - ioprio = IOPRIO_NORM; + ioprio = IOPRIO_BE_NORM; fallthrough; case IOPRIO_CLASS_BE: return &bfqg->async_bfqq[1][ioprio]; diff --git a/block/ioprio.c b/block/ioprio.c index ca6b136c5586..0e4ff245f2bf 100644 --- a/block/ioprio.c +++ b/block/ioprio.c @@ -170,7 +170,7 @@ static int get_task_ioprio(struct task_struct *p) ret = security_task_getioprio(p); if (ret) goto out; - ret = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, IOPRIO_NORM); + ret = IOPRIO_DEFAULT; task_lock(p); if (p->io_context) ret = p->io_context->ioprio; @@ -182,9 +182,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_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM); + aprio = IOPRIO_DEFAULT; if (!ioprio_valid(bprio)) - bprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM); + bprio = IOPRIO_DEFAULT; return min(aprio, bprio); } diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c index e9d9ad47f70f..0fbbff0b3edb 100644 --- a/drivers/nvme/host/lightnvm.c +++ b/drivers/nvme/host/lightnvm.c @@ -662,7 +662,7 @@ static struct request *nvme_nvm_alloc_request(struct request_queue *q, if (rqd->bio) blk_rq_append_bio(rq, rqd->bio); else - rq->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_NORM); + rq->ioprio = IOPRIO_DEFAULT; return rq; } diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h index 2ee3373684b1..3f53bc27a19b 100644 --- a/include/linux/ioprio.h +++ b/include/linux/ioprio.h @@ -8,6 +8,11 @@ #include +/* + * Default IO priority. + */ +#define IOPRIO_DEFAULT IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, IOPRIO_BE_NORM) + /* * Check that a priority value has a valid class. */ @@ -51,7 +56,7 @@ static inline int get_current_ioprio(void) if (ioc) return ioc->ioprio; - return IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0); + return IOPRIO_DEFAULT; } /* diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h index aac39338d02c..f70f2596a6bf 100644 --- a/include/uapi/linux/ioprio.h +++ b/include/uapi/linux/ioprio.h @@ -44,8 +44,9 @@ enum { }; /* - * Fallback BE priority + * Fallback BE priority level. */ -#define IOPRIO_NORM (4) +#define IOPRIO_NORM 4 +#define IOPRIO_BE_NORM IOPRIO_NORM #endif /* _UAPI_LINUX_IOPRIO_H */