Message ID | 20250124225104.326613-1-willy@infradead.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 40CBCC02181 for <linux-mm@archiver.kernel.org>; Fri, 24 Jan 2025 22:51:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB6432800AC; Fri, 24 Jan 2025 17:51:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C66AB2800A8; Fri, 24 Jan 2025 17:51:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B55712800AC; Fri, 24 Jan 2025 17:51:14 -0500 (EST) 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 982142800A8 for <linux-mm@kvack.org>; Fri, 24 Jan 2025 17:51:14 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 43BF1121925 for <linux-mm@kvack.org>; Fri, 24 Jan 2025 22:51:14 +0000 (UTC) X-FDA: 83043842868.12.94085F6 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP id AF3B91C0004 for <linux-mm@kvack.org>; Fri, 24 Jan 2025 22:51:12 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=mSSDvrXL; dmarc=none; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737759072; a=rsa-sha256; cv=none; b=2ehfMQcJVyszQGqb5/AM5MbfypD/9NXDKmzkJ0Ikvq1rrh9OBASyR2JcRfJzk0kEy3ZH9i JoL5xlAlvRXp6400SutTf0v/teK1huMSzrFaFkY6yOh06369fdOCKbgWNzXTu06qH8UXW8 sQBoOVHTGpeP8PgUIhfsrKJ+xgcS3jI= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=mSSDvrXL; dmarc=none; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737759072; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=ONWpJCQ1y00OH6khfXOorwlc6DOA2hoNVf6rj3r415k=; b=D4KI378jo3hBzZpMOLJM6P3p++2ZfNQQptsuaNbhwpVJEZ99qnY94zhlGPAQsvKENG/miG GGXm/mB/eajo9TLFFWv1v0RjelIHOtCHq+MEYxOT6ffLD3IOd6JpweUqdwEP0Cz4oHgOmb 8JeDsdq2NkwJvNHVYxugS3NTXQ9cX08= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=ONWpJCQ1y00OH6khfXOorwlc6DOA2hoNVf6rj3r415k=; b=mSSDvrXLHDHaJ7EETzZqcol+L9 aQqG11IdzpunfkNU/3p9wBluCbkh63f+B7K7KCitdir9MuUxm1raLnes16gAzD2z6Y5nfqg+ZfJdm KoN1opGDxUsKejCki1u1TwOkKxicCTS8GahOoarsdGy7Fo2qtVxRFcPso6SpzFRp5QSJ7dt0pVrkH eU3ZaVQXeOCZes+55eYTxVt0MFO8RENG3HWCS7DIwVJ/x3gM9XnV5953FBjACWLK/sKMxO8ekhCb7 VON/BcObaTBmtxZkevtitKGBnMRqonZxrB4PL54yGzkvNUdsHDNIOQ+s74RRY+/zItlQJLbFdIdAd p3sw5wSA==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tbSW6-00000001N2G-45Iz; Fri, 24 Jan 2025 22:51:11 +0000 From: "Matthew Wilcox (Oracle)" <willy@infradead.org> To: Jens Axboe <axboe@kernel.dk> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>, linux-mm@kvack.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andres Freund <andres@anarazel.de> Subject: [PATCH] block: Skip the folio lock if the folio is already dirty Date: Fri, 24 Jan 2025 22:51:02 +0000 Message-ID: <20250124225104.326613-1-willy@infradead.org> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Queue-Id: AF3B91C0004 X-Rspamd-Server: rspam10 X-Stat-Signature: mmyz9ge6z49msji19heef6ymipp3hod3 X-HE-Tag: 1737759072-76129 X-HE-Meta: U2FsdGVkX19BcWGKlC15pt/c8+RFnERnY9ODZQDzCCcAtz6zwnmvrm2wfZi2IyOSSQ4sJ/9TWcWYG/0MnmWZKvpi+6lpJcKBqk3rhhbLBYVZLuKmdyoqGhAh8Wkz3V7H08CVCMbFmk4cHVv0L7lQipeF9TT0YDuOIUs8onEP6BlYeQdrSG/s77yhjaaxBIhFffMswtxH3qySmm7bDqCxoCYj2AHCvRgJNr40UR2VR3aZjqPpOOshCU4qgCZUuYIrixqdFscTfkmS48Vb/FQd0XR7B8dHhRKxV7K/oKTVrQnLdEIe0fwDVALAORFdhc4QcCQ7J7TnREejShIapRcR7leJCzMZAVUWvq6inl0td3nGsHSgcpGy2eIfgXHfQczXGoRq7MIxzIB40nMPUwyyLyw+hu6r36fDf4L48ujZEnKR3SS9N0C7b2RYRj+tCuJ1B/+CksVpv+Jmk3cHEGMY4J2Nvf+1+US1YNUanHrHK41cerdxO+vMho24qYIrFFmPCx9KuHGM5ZX9hhg7z/PZbndjXk2LgYFAAoRO+lhBOrWrW/jUb0m6UpGq4OUcEVj5dbbaJojXMaynYe0evOJzqkfZUeXx7dAyhsE+MyKXZtsSUmr1XUPEuEprajmR38yIBa85oz5hMmYyoIBrnBoJPmaXF3nlEw+AWdP1GhLom0cW3sb9nusOTuDcXdxgQWXcqiGVLD2H2ZhxopMJcHq3+udbnaqSegdrLw/JwCMaFlVWW7fIvQPoTJpoRAoTG6FvKZzP/ae7XWifIPpvd/BCCq5lKFuXTMpV88O2Umi5/wEmJ0ETLihfZu+qu0yBvaPZTxX7FRKO9zEPSYdIN3XNwYwwnVsBjElzLc1Z9kUfsDiBRWDOWyABCHCFwucs4sksVdoIeIC5yY15rwUOxkZuksV4/V+veeE7oyTQ/HV0KnKQJmzHQIfSNMBGht23yB6QnVh4JIB0wXvSmJrGw8/ gVGptlLO JLglvHoaF8NmhQdpsd3tyBHufYnVTBnBxd0CWbxR4WZyTvERJv7KEKBM4EGPWgp5cKWz9XYkZB98TtPE446ZwMIf3N9q0TNM5L4CK3MrAYy7/sNPmsJeSruekXBvVu/roJ1r6Y16rRv/rkSUBTXieflMqBWkX8zLzG1jcR9vQeRjCEFgaoqxwNUF9NiEFuK/Z4E1+NKoN3ux055ZjAJX4MIMDxyp9u8BeZiEjkjHOlqPCL96DrsxX2ETNLPOQhTz3a4D5pC4coaADW8U= 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
block: Skip the folio lock if the folio is already dirty
|
expand
|
diff --git a/block/bio.c b/block/bio.c index f0c416e5931d..58d30b1dc08e 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1404,6 +1404,8 @@ void bio_set_pages_dirty(struct bio *bio) struct folio_iter fi; bio_for_each_folio_all(fi, bio) { + if (folio_test_dirty(fi.folio)) + continue; folio_lock(fi.folio); folio_mark_dirty(fi.folio); folio_unlock(fi.folio);
Postgres sees significant contention on the hashed folio waitqueue lock when performing direct I/O to 1GB hugetlb pages. This is because we mark the destination pages as dirty, and the locks end up 512x more contended with 1GB pages than with 2MB pages. We can skip the locking if the folio is already marked as dirty. The writeback path clears the dirty flag before commencing writeback, if we see the dirty flag set, the data written to the folio will be written back. In one test, throughput increased from 18GB/s to 20GB/s and moved the bottleneck elsewhere. Reported-by: Andres Freund <andres@anarazel.de> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- block/bio.c | 2 ++ 1 file changed, 2 insertions(+)