From patchwork Thu Sep 19 11:29:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qun-Wei Lin X-Patchwork-Id: 13807648 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B5F5CE8D78 for ; Thu, 19 Sep 2024 11:30:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1EA06B009F; Thu, 19 Sep 2024 07:30:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DCE5D6B00A0; Thu, 19 Sep 2024 07:30:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CBCF56B00A1; Thu, 19 Sep 2024 07:30:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id AE5AA6B009F for ; Thu, 19 Sep 2024 07:30:22 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 480C080C11 for ; Thu, 19 Sep 2024 11:30:22 +0000 (UTC) X-FDA: 82581269484.23.B4FE470 Received: from mailgw01.mediatek.com (mailgw01.mediatek.com [216.200.240.184]) by imf16.hostedemail.com (Postfix) with ESMTP id 813A418000D for ; Thu, 19 Sep 2024 11:30:19 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b=JpoSK834; spf=pass (imf16.hostedemail.com: domain of qun-wei.lin@mediatek.com designates 216.200.240.184 as permitted sender) smtp.mailfrom=qun-wei.lin@mediatek.com; dmarc=pass (policy=quarantine) header.from=mediatek.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726745270; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oyX6ix+Ca+kuBSd2zaDcetxDLf8fGfj/eEE4RWU8lsQ=; b=zmv8dJqJpj1UfrozCupDMiiGPmfsnMUI2oUltccaDmnWC/wdHJVHxIw69AZvnCm0STNaI2 sHeBLFrUEQJ4HmBZYweTT0e9M7jIWCRlzCQmhl/hpE7HLiDtxHMztLbkhwL4nSGkHAtQlZ gvXnLu1qGES9fIchVtZPguRbvQ9A9fQ= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b=JpoSK834; spf=pass (imf16.hostedemail.com: domain of qun-wei.lin@mediatek.com designates 216.200.240.184 as permitted sender) smtp.mailfrom=qun-wei.lin@mediatek.com; dmarc=pass (policy=quarantine) header.from=mediatek.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726745270; a=rsa-sha256; cv=none; b=NXz8w+bJ/3iZlmAekTLiQ6OhZBpacKDIyDOMujiKd2DGAzNKyEb83xcSU5TyWLjiHAiFvi IzSk6B8d+smnOmVr+VsDiEixIIZrc6i1IWb77wiHauOJrg79BPbDhRRepo/Grqyezcnuu5 T7S4bfLReSGGb74P3eUmCB+5Jv2CtrI= X-UUID: 89a67c3a767a11efb3adad29d29602c1-20240919 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=oyX6ix+Ca+kuBSd2zaDcetxDLf8fGfj/eEE4RWU8lsQ=; b=JpoSK834JdxhsMfYUVK1hDaZCq9YE9044w41Yle4h+LdHzSZKymPykj3vRiV6sdKKCTI6a2M9wG4FdtbtC0miLERvDSZvB+DrqjcwApRRTVJ8A19FvchOE0OFsjr7+o27ewfgwElCnbx9byDn8Bpn6g/ksHWagblqNHn+IhcXzo=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.41,REQID:1ff07fb1-1fa1-4f4e-8525-375b2f703bcd,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:6dc6a47,CLOUDID:cef03d9e-8e9a-4ac1-b510-390a86b53c0a,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0,LES:1, SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-UUID: 89a67c3a767a11efb3adad29d29602c1-20240919 Received: from mtkmbs13n2.mediatek.inc [(172.21.101.108)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 961147067; Thu, 19 Sep 2024 04:30:13 -0700 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by MTKMBS09N2.mediatek.inc (172.21.101.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 19 Sep 2024 04:30:10 -0700 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 19 Sep 2024 19:30:10 +0800 From: Qun-Wei Lin To: Andrew Morton , Matthias Brugger , AngeloGioacchino Del Regno , Ryan Roberts , "Huang, Ying" , David Hildenbrand , Chris Li , "Matthew Wilcox (Oracle)" , Al Viro , Dan Schatzberg , Kairui Song , Barry Song , Jens Axboe CC: , , , , , Casper Li , Chinwen Chang , Andrew Yang , John Hsu , , Qun-Wei Lin Subject: [PATCH 1/2] block: add BLK_FEAT_READ_SYNCHRONOUS feature for synchronous read Date: Thu, 19 Sep 2024 19:29:51 +0800 Message-ID: <20240919112952.981-2-qun-wei.lin@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20240919112952.981-1-qun-wei.lin@mediatek.com> References: <20240919112952.981-1-qun-wei.lin@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 813A418000D X-Stat-Signature: qjmmyqb4cttetky9jabr4iidqwyxc1fq X-Rspam-User: X-HE-Tag: 1726745419-888425 X-HE-Meta: U2FsdGVkX18FYCOEACkM8lnpnmYt3W3l3end2Mfzgkrf6EDUtqPC9san40sKzRQbCiEatf5eQb/URZjN/bV2XJWC96xWRJzI/70UpLh7wsSs93D6jwkK0aFNMbodFrsdnIheusX98eJDdlJvazZmVufeAupLeWer00ST+b9MDTjuJ2XnevzQCiPfMAn3PpJaTaPiErkaO1887OEwRnlMjWYqZk7lL/TBjYrBxg5oufN83uFtYCy49MvUXZpwzfmY8T8aR8fzY8Evq3TCpUg1p54SQUXWJvZWCGJVVKRdcoOuAyweudoSv97ADnINRJ1pPgYtHmLJZff3xnDaM2JDV5KKrCo89JP2wuWW7F2ZXl6vMmKcm+ToKKwLkCEAzfPccwYa+yv5Tm8WSvVOmVn5/dhComxjjDGBFxBYdLnrMFrLK3wc81k0tdJWG3Th6CMAqO40yl5Gqhfqi3y+A4hHAwn/Pj9lWVa9VGJ7I5ayrz2JIPjuuv3HCeY/Nw1yWd2Jtc2pmt2jdsNjIyBKRT6+7zZKVOJOzSqR4RX6bavg9W+3jddxmXHtcuwHcdSspk5ZerYDi0vhSo5b5nqL0KwrcgBvvBZ1XCqI6Alo2J5ITvzfMgU8ZojoagVX2XaLIvqcV/yto3SaQFnmW1VsGBYf9CVcKIj/oPsIwisia4d54fLUWqB166q7pTqKRIzDKUmvhs0sfGUMnrsB7UPdC37TSVmjxNNN73D/NvohmaeQ7poCJub0C8yr2KY6NnpOJnsGR1b/J6SytYUxoWhsvVvY7cKVYmzE2TtJBh8K4rFONG0GfEHghs8HA6m7ajt7gDmMCOoPkB7GsqyNkOjCnpgfHuakk+nGGNvbqA6qR9vp6nArmjUGw3GcKxG859aC4TuoKxNYYifvh3qWBtfd19KRH13Qk6Oy26+qK9/O8FheKH8O8kAlum8CJnVgC43iji7clOZkoKOqR1RBvwHs+Vj qhR5iwli dpMTFPZ/7ZOBeg9f6IsEbIEbEo9n1CA1U98LchIekYDwxSEia61ES3/c/27GQRqfM5H380FNclcKmBNEPbAWAWsKS9YMw4ZMh09n3h1FbOZdBiiPDw+hyZHajnlkEBejbRn+gfb5tR4TqyPyG6ie+UCSJ6hwKFzQaxoSbQ9MrkrH5wsa685iTXCbiuE+OSrniUQmCuDg3dGumXqbnsrHGpWITt2tfYBnOA3zoezqXFBz0HD3b+DBLVNsK7dIH4O8eNZdZAqk48OCM5EM97CHRXncfyrWEErHm0dPd X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This commit introduces a new feature flag, BLK_FEAT_READ_SYNCHRONOUS, which ensures that read operations always complete in the submit context. This is useful for scenarios where synchronous read operations are required while allowing write operations to remain asynchronous. This patch is preparation for optimizing of the operation of the swap device with next patch. Signed-off-by: Qun-Wei Lin --- include/linux/blkdev.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 643c9020a35a..a697db11d91c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -332,6 +332,9 @@ typedef unsigned int __bitwise blk_features_t; #define BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE \ ((__force blk_features_t)(1u << 15)) +/* read operations always completes in submit context */ +#define BLK_FEAT_READ_SYNCHRONOUS ((__force blk_features_t)(1u << 16)) + /* * Flags automatically inherited when stacking limits. */ @@ -1310,6 +1313,11 @@ static inline bool bdev_synchronous(struct block_device *bdev) return bdev->bd_disk->queue->limits.features & BLK_FEAT_SYNCHRONOUS; } +static inline bool bdev_read_synchronous(struct block_device *bdev) +{ + return bdev->bd_disk->queue->limits.features & BLK_FEAT_READ_SYNCHRONOUS; +} + static inline bool bdev_stable_writes(struct block_device *bdev) { struct request_queue *q = bdev_get_queue(bdev);