From mboxrd@z Thu Jan 1 00:00:00 1970 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 0CEDEC0218C for ; Mon, 27 Jan 2025 07:52:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 74FDE28012B; Mon, 27 Jan 2025 02:52:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FFDE280129; Mon, 27 Jan 2025 02:52:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C7F128012B; Mon, 27 Jan 2025 02:52:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 396EA280129 for ; Mon, 27 Jan 2025 02:52:13 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A7A1A441E8 for ; Mon, 27 Jan 2025 07:52:12 +0000 (UTC) X-FDA: 83052463704.04.ED8C3E0 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf04.hostedemail.com (Postfix) with ESMTP id 5D78740002 for ; Mon, 27 Jan 2025 07:52:10 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=yosWjN2y; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=pWQ1oK4R; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=yosWjN2y; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=pWQ1oK4R; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf04.hostedemail.com: domain of hare@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=hare@suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737964330; a=rsa-sha256; cv=none; b=uhqunYYIxeOItSX+j04gZbeBOTL6UdQIc6VVnkDM8PxxPktNxzS6Tgi/K8oATt2T7d+Kub HxvLEyKrE1cv9BXSwvJbZ13YXT06bhf3d2cotBWJiSB7FqBXnCib5S6lPvfgCqKzo0whT2 x51atl2QLCHZMLUefC0ALSJxcmqmhEY= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=yosWjN2y; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=pWQ1oK4R; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=yosWjN2y; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=pWQ1oK4R; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf04.hostedemail.com: domain of hare@suse.de designates 195.135.223.130 as permitted sender) smtp.mailfrom=hare@suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737964330; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HOVLpoaZTDnha9bY1uEyVw6fbwPqCer/OmqkPcifpwU=; b=Z1hBMAUKGkzZxA+S4N+4spC2RCbQ2+bDmMWPlRmRvY0afhjv8Ibhmc2WEM1kcEGcX//zzc acQwv2S6AmI2D3zUUeAGNHuFarUA256aH17wYQk2i49CM6z+FzdJVOWCBvKiK99VLQB+TQ ZPlJ1URoutsxSb9jp6qmxOoEURa3NZI= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7BBFB21114; Mon, 27 Jan 2025 07:52:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1737964328; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HOVLpoaZTDnha9bY1uEyVw6fbwPqCer/OmqkPcifpwU=; b=yosWjN2yiUpKSokwv6E86cYpWLnbfQn9y/k/zaf0+ve0aGaQpOcXJ68hH7LlhzlwlmZTU6 lgUIj0LB9JjskMX6ZN0ULJcH5mTI0wQFIt8hdsD9nPbo7r9YjXysS5UOomF5ieHFhvjNdn mQlCgoMkWpNskcdf7e7ghXj5IQXLk0A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1737964328; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HOVLpoaZTDnha9bY1uEyVw6fbwPqCer/OmqkPcifpwU=; b=pWQ1oK4RzhvLPISTPnIcdtlRoLklOfNkpMuFhnWcZ/yTlxOenlhj6hkCcb8yHQbbHs9QeR RCiG+wvfe980twCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1737964328; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HOVLpoaZTDnha9bY1uEyVw6fbwPqCer/OmqkPcifpwU=; b=yosWjN2yiUpKSokwv6E86cYpWLnbfQn9y/k/zaf0+ve0aGaQpOcXJ68hH7LlhzlwlmZTU6 lgUIj0LB9JjskMX6ZN0ULJcH5mTI0wQFIt8hdsD9nPbo7r9YjXysS5UOomF5ieHFhvjNdn mQlCgoMkWpNskcdf7e7ghXj5IQXLk0A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1737964328; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HOVLpoaZTDnha9bY1uEyVw6fbwPqCer/OmqkPcifpwU=; b=pWQ1oK4RzhvLPISTPnIcdtlRoLklOfNkpMuFhnWcZ/yTlxOenlhj6hkCcb8yHQbbHs9QeR RCiG+wvfe980twCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 33E69137C0; Mon, 27 Jan 2025 07:52:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KX7KCig7l2faMQAAD6G6ig (envelope-from ); Mon, 27 Jan 2025 07:52:08 +0000 Message-ID: <8a7b1eb9-6b9b-4883-9813-401cabf669da@suse.de> Date: Mon, 27 Jan 2025 08:52:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] block: Skip the folio lock if the folio is already dirty To: "Matthew Wilcox (Oracle)" , Jens Axboe Cc: linux-mm@kvack.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andres Freund References: <20250124224832.322771-1-willy@infradead.org> Content-Language: en-US From: Hannes Reinecke In-Reply-To: <20250124224832.322771-1-willy@infradead.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5D78740002 X-Stat-Signature: q981jjh11fkagcbb4cn73qhmes69wbcq X-Rspam-User: X-HE-Tag: 1737964330-637948 X-HE-Meta: U2FsdGVkX1+sam7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q9KIrTOW3yDz78dV2JLXJiWCSdWYCPFpzvoyeVPpMHCmuSYhb5PJEl774BBuTd35rBot1Q3rrwxM7t6gk7b/XPaLejuGggwWDTU3qBUFjhfu3gHUV8sQYCgOpUWuetrxE0E1KdaNAQWRMfE7GlPGTPdJMHCSBtaChKz6gP+2yeEVzlvkLffhPWyYOuKqcUAlkvYWGu3o8zI/Xpu+UOICT/LYaN5RavPMdvK6RzkYNZffchIkySKnRs39RFmG0w7NUGVJEoTCYPHUd25iyI/0BmrUKdsPCYkSyF X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 1/24/25 23:48, Matthew Wilcox (Oracle) wrote: > 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 > Signed-off-by: Matthew Wilcox (Oracle) > --- > block/bio.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/block/bio.c b/block/bio.c > index f0c416e5931d..e8d18a0fecb5 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(folio)) > + continue; > folio_lock(fi.folio); > folio_mark_dirty(fi.folio); > folio_unlock(fi.folio); The same reasoning can probably applied to __bio_release_pages(). Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich