From patchwork Thu Mar 9 21:54:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 67124 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp545402wrd; Thu, 9 Mar 2023 14:09:59 -0800 (PST) X-Google-Smtp-Source: AK7set80y/WpOClqF5okv2bznBCFASPjOAk2rgKyXCLeeXECJd3rLSiFrjkno4LIm4uMW0y8S5Xr X-Received: by 2002:a05:6e02:1447:b0:318:89e6:6a3f with SMTP id p7-20020a056e02144700b0031889e66a3fmr1699909ilo.10.1678399799374; Thu, 09 Mar 2023 14:09:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678399799; cv=none; d=google.com; s=arc-20160816; b=QlbT0ZwI9mzKdSLGCQot9sQ3ppDwzZPyv5DLFlUwc3BB+DOHsx/wRgYKh51+J8DT0B 99uA6xJgbV/Sd3xJ5+SR/clB2qiIQ2BSQLciWvs2fYbF33FWutGwGeQv8xnrl4fah6gu cmv5I4KJxe4S1ZBHmiLrJnVCVpLba2rR/CPpkRkHpbfxCZXwW2P/vVHUQ8/j+v6u7jR9 OSBsI8rbapKP+8IJC6BslNHCo2j3bd1CbehHSqa5chx9JjUppc0x03bn36Pn8FOFNYxc cfJEIsrsSKFvJJkc/2ACLOKK59jv89cymtNC3HQydFuUkezp7xivYjnxCaU0SO64CzIb fsIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :wdcironportexception:ironport-sdr:ironport-sdr:dkim-signature; bh=Bti8eJLltyo1mqrSI8i502Bwxb9uKtmIuJYoUhM+oGI=; b=OG5D8cb4ANM122KXqUzYVhCpfXp6yQ3JIbLvuwMkyVNOc/0t7sUtaovFj2Uo8bSB9j ukAF2+8FLEQMuQ/plq+6LzUUtvRYOTH3pPeHrRU9mmp8lUu6Ble0mF9E7v8vjIztHqth GrpvEVK7NhNNYZxncmUSEd1CFppLswPtg5hl/SjuW9cqCWlIML+pFBescB9je6LQjbkI hh978H4p9rFl+NHVjYqvXfcD1ldaTu3qU622X3e5CtxYVoChhTcu8+GAhbDZIwbqqHGE MDtzIZsikd7EVU9mtrakR3smPl6mwfgsRdxlC/snFtDCavTN4wqzybO9YwYBiE60hJM4 UwfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=ngE7lfhy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a92d784000000b002f909ebfbf7si397624iln.111.2023.03.09.14.09.43; Thu, 09 Mar 2023 14:09:59 -0800 (PST) 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=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=ngE7lfhy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231192AbjCIVzz (ORCPT + 99 others); Thu, 9 Mar 2023 16:55:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbjCIVzc (ORCPT ); Thu, 9 Mar 2023 16:55:32 -0500 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49619F05C7; Thu, 9 Mar 2023 13:55:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1678398931; x=1709934931; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FHO3iDOGQC1PtH6j/1w7cXF0Z0P1HSJgVq8t6FkMnTg=; b=ngE7lfhy7+gkIPJffzvyT7hlKsbMelmyJOVvyPSQtFeGjNy6Bl7iqDLb 6sDIgDIaP+gQJ2Lj3flA05LIJN4km9u0ThhVfgeU4PO37n3LfxWiHYpw4 N8+/YqgNVm57ZsXcjZ6k/wteMu+4SUel3SvRB9lioA65SCnmyZWp107TB Ea7tINy0PgVi+gD4qz53kyFnXUCHQ2iJmdT295HDmPSXe2fflPVxvEHTU kxOi2OWoEhFfwFOULnLQUw2wX7oU5cj4KiNMhYb5nyk7EB4CebrpYJnjj 2tHZQ4dUvlQjoaSsPdp+Hsc9wVPQ3E05ydiJjSurySj8JYc3AEsqHBBCD A==; X-IronPort-AV: E=Sophos;i="5.98,247,1673884800"; d="scan'208";a="225270945" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 10 Mar 2023 05:55:30 +0800 IronPort-SDR: hEcBmawp54fI/DZx1IKvBVK4dhuyq2vEgk+OKMSy+9jlAq/8ngpFWopNOL98JHVmllb5peWCaX 2XO76RMCAR4oe3Bm++/7BVoCLSI9Wnte1b8LNlVLS0u80wmsW88uqYM/eo4w6lRS9N86AeaUXE 8es2wuFhJNutqQtvwM049wC37A2eswSGUo4mT9qO995NbcCZOS/R6ehvLmmdxtRHWL/ePvUuhp IRnZxfhNuEAUeXZrRM3AmFPXbGHVeRwmnHtZjDhxRIZZ118pflMIvWqG74UG4gVm3yBjYpTX/6 P+4= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 09 Mar 2023 13:06:24 -0800 IronPort-SDR: 3z8t7a+Lp/mB/akEZGLabMdpoRdhWDPKuv6uLbdbS3tGze1jPSrfAbjyOL2Sys0322UQiHyt20 fmoDG+tpZXVd0N1EgOXkg9tgxHWHz3GvKd9u/U2yWQUCApKlYsWtHiFSJb07nxyyFZvgypvkLi 10z7tmaQqx0y9XntPEwX7HIcyhnNe4y8wrAvX81n2HtVccve5Hv1tTtvIA/G7C3apaQqyyP0EO hyi3Z94/QaQI039Ch+mbp/fwKXaB/M0g7bhhSe0zfE4ZkznfIejTYq4kMcUpdSjoqm0rJfB8kq bBU= WDCIronportException: Internal Received: from unknown (HELO x1-carbon.wdc.com) ([10.225.164.41]) by uls-op-cesaip01.wdc.com with ESMTP; 09 Mar 2023 13:55:29 -0800 From: Niklas Cassel To: linux-kernel@vger.kernel.org Cc: Christoph Hellwig , Hannes Reinecke , Damien Le Moal , linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org, linux-block@vger.kernel.org, Niklas Cassel Subject: [PATCH v4 02/19] block: introduce ioprio hints Date: Thu, 9 Mar 2023 22:54:54 +0100 Message-Id: <20230309215516.3800571-3-niklas.cassel@wdc.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309215516.3800571-1-niklas.cassel@wdc.com> References: <20230309215516.3800571-1-niklas.cassel@wdc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759929748036341508?= X-GMAIL-MSGID: =?utf-8?q?1759929748036341508?= From: Damien Le Moal IO priorities currently only use 6-bits of the 16-bits ioprio value: the 3-upper bits are used to define up to 8 priority classes (4 of which are valid) and the 3 lower bits of the value are used to define a priority level for the real-time and best-effort class. The remaining 10-bits between the IO priority class and level are unused, and in fact, cannot be used by the user as doing so would either result in the value being completely ignored, or in an error returned by ioprio_check_cap(). Use these 10-bits of an ioprio value to allow a user to specify IO hints. An IO hint is defined as a 10-bits value, allowing up to 1023 different hints to be specified, with the value 0 being reserved as the "no hint" case. An IO hint can apply to any IO that specifies a valid priority class other than NONE, regardless of the IO priority level specified. To do so, the macros IOPRIO_PRIO_HINT() and IOPRIO_PRIO_VALUE_HINT() are introduced in include/uapi/linux/ioprio.h to respectively allow a user to get and set a hint in an ioprio value. To support the ATA and SCSI command duration limits feature, 7 hints are defined: IOPRIO_HINT_DEV_DURATION_LIMIT_1 to IOPRIO_HINT_DEV_DURATION_LIMIT_7, allowing a user to specify which command duration limit descriptor should be applied to the commands serving an IO. Specifying these hints has for now no effect whatsoever if the target block devices do not support the command duration limits feature. However, in the future, block IO schedulers can be modified to optimize IO issuing order based on these hints, even for devices that do not support the command duration limits feature. Given that the 7 duration limits hints defined have no effect on any block layer component, the actual definition of the duration limits implied by these hints remains at the device level. Signed-off-by: Damien Le Moal Signed-off-by: Niklas Cassel --- include/uapi/linux/ioprio.h | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h index 4444b4e4fdad..607c7617b9d2 100644 --- a/include/uapi/linux/ioprio.h +++ b/include/uapi/linux/ioprio.h @@ -58,4 +58,53 @@ enum { #define IOPRIO_NORM 4 #define IOPRIO_BE_NORM IOPRIO_NORM +/* + * The 10-bits between the priority class and the priority level are used to + * optionally define IO hints for any combination of IO priority class and + * level. Depending on the kernel configuration, IO scheduler being used and + * the target IO device being used, hints can influence how IOs are processed + * without affecting the IO scheduling ordering defined by the IO priority + * class and level. + */ +#define IOPRIO_HINT_SHIFT IOPRIO_LEVEL_NR_BITS +#define IOPRIO_HINT_NR_BITS 10 +#define IOPRIO_NR_HINTS (1 << IOPRIO_HINT_NR_BITS) +#define IOPRIO_HINT_MASK (IOPRIO_NR_HINTS - 1) +#define IOPRIO_PRIO_HINT(ioprio) \ + (((ioprio) >> IOPRIO_HINT_SHIFT) & IOPRIO_HINT_MASK) + +/* + * Alternate macro for IOPRIO_PRIO_VALUE() to define an IO priority with + * a class, level and hint. + */ +#define IOPRIO_PRIO_VALUE_HINT(class, level, hint) \ + ((((class) & IOPRIO_CLASS_MASK) << IOPRIO_CLASS_SHIFT) | \ + (((hint) & IOPRIO_HINT_MASK) << IOPRIO_HINT_SHIFT) | \ + ((level) & IOPRIO_LEVEL_MASK)) + +/* + * IO hints. + */ +enum { + /* No hint */ + IOPRIO_HINT_NONE = 0, + + /* + * Device command duration limits: indicate to the device a desired + * duration limit for the commands that will be used to process an IO. + * These will currently only be effective for SCSI and ATA devices that + * support the command duration limits feature. If this feature is + * enabled, then the commands issued to the device to process an IO with + * one of these hints set will have the duration limit index (dld field) + * set to the value of the hint. + */ + IOPRIO_HINT_DEV_DURATION_LIMIT_1 = 1, + IOPRIO_HINT_DEV_DURATION_LIMIT_2 = 2, + IOPRIO_HINT_DEV_DURATION_LIMIT_3 = 3, + IOPRIO_HINT_DEV_DURATION_LIMIT_4 = 4, + IOPRIO_HINT_DEV_DURATION_LIMIT_5 = 5, + IOPRIO_HINT_DEV_DURATION_LIMIT_6 = 6, + IOPRIO_HINT_DEV_DURATION_LIMIT_7 = 7, +}; + #endif /* _UAPI_LINUX_IOPRIO_H */