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 9CFB3CD1296 for ; Mon, 8 Apr 2024 15:53:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00DF86B007B; Mon, 8 Apr 2024 11:53:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F009B6B0082; Mon, 8 Apr 2024 11:53:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC7706B0085; Mon, 8 Apr 2024 11:53:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id C0BB26B007B for ; Mon, 8 Apr 2024 11:53:35 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7349BA0AD4 for ; Mon, 8 Apr 2024 15:53:35 +0000 (UTC) X-FDA: 81986809590.11.7E9E925 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 60FC41C0009 for ; Mon, 8 Apr 2024 15:53:33 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VyGDyBa+; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712591613; 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=CFuGX1yyoTN69ecCATsVj4UhORzkDiRUWoktVVAJ3+Q=; b=LYPD6fC3KmhAKjkoBrjs84kwlJ+lIjeFs/le9UWZClcT0wb6/g5KsrhVQpLcnZAVKkf6OE WqDiTaT5NTrwmN1KdWeZ0mMsZccjwifPVNGQC9C1IaJ1Esrp1c32WMOJzz+vjYUiq+teU3 pFKJ3bSnA7q5IBN1JeGBifuy6BYcnZo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712591613; a=rsa-sha256; cv=none; b=4IDsC62V4pBkhDL1fYTFRjMfvw12FQD0MgXpxJ7j+yfw+//vlNjwu4V7+oH2KMNy/A7w9S TZRBFof93vEESdZX47jRtsQZ1ZZIAstCHgQlSYSyqPjKRO57hUYkFIi+cd32Nw3m1BIOt7 My8WYQ9pmtBkFAq11fvSvO4K+pSc6sc= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VyGDyBa+; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712591612; h=from:from: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; bh=CFuGX1yyoTN69ecCATsVj4UhORzkDiRUWoktVVAJ3+Q=; b=VyGDyBa+h8TPU+dWbJ0sYT3KoDzOIl3rIXze9P3SBi9Z9AoimgqtbbWh0HrcJAbyE7MV3+ a7fZHOLRygFXsQ79Eq0HLYrhRlA3lRNdLx6lCQKWVE8ZnsFncUKnlWc1+rOtjbsU5/GQqn WbujvoiuD4DAmrmJ6CdHgT1LKIfnllw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-137-HJAhESVFMaKi_61YaghcgA-1; Mon, 08 Apr 2024 11:53:27 -0400 X-MC-Unique: HJAhESVFMaKi_61YaghcgA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EEA2C90ACC7; Mon, 8 Apr 2024 15:53:25 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id 084C62033AC1; Mon, 8 Apr 2024 15:53:21 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20240328163424.2781320-24-dhowells@redhat.com> References: <20240328163424.2781320-24-dhowells@redhat.com> <20240328163424.2781320-1-dhowells@redhat.com> To: Christian Brauner , Matthew Wilcox Cc: dhowells@redhat.com, Jeff Layton , Gao Xiang , Dominique Martinet , Steve French , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Latchesar Ionkov , Christian Schoenebeck Subject: Re: [PATCH 23/26] netfs: Cut over to using new writeback code MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <877901.1712591597.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Mon, 08 Apr 2024 16:53:17 +0100 Message-ID: <877902.1712591597@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Rspamd-Queue-Id: 60FC41C0009 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: xsc1xdyff48qoou3m7p7bm3ch4hne1ao X-HE-Tag: 1712591613-59558 X-HE-Meta: U2FsdGVkX1/fh8ejj/0QS4nWEu1I8WnFSxpvWKL7fL5UkHtRAVV03i/w8Ol3L85JSYV3vEAlXprWHHZ/piOnHHSc233EDPdbZbY0Zi8ynnKYSUG71jf/OUlS8Z0YhWzGL7J1sB3VIjbfM98pFIQAAwBeU95+JdIlKMw4zYa7oBsgN639jyt4sg1AO+5wnZ41gmjcPqLhr2GaLpPgkY1/SsUNLk2juTbH2wRhiDpu1jElzKtC7OcEeoj8UJuQ1/pzGqdYWkuaai8YHYus+aNeWcG/yDrvSbmU64Zrmc+I8a8AuSS3pwPTKWWxnfk28fKEnn0HtbEMKmWVfXmTtwyY6wRutLMwxHIkRZCVRtPeFa4qRrv5HX8xDjDUFHKBvAJhsRL3S6Lq0+KVOwTNC7Sy2kb3rkVaV+7kcYYmt9cfCpL5vuampiNTjkYhxkpl+eE5QxICueUwWtFhLODXPMrkP2NQEC9xd+gDHqxb7hkIM8ihXG/rEjBr57nt9jxBHhucPKkgOt628YzjKF0HeB9PQSmYY8gJZVFgmvlJCC36IzoN/XmY1Yu96MMgHvEfm3lVpmHy3LcMGwcrMMdeSzzazkWLrqh84TVjkYk43ej3KJhh/dNqeiOQaThGRD64zJ3LSFCAYxiaT4FTEA9w5nP5sogMfNjt96qckJZ9JDV6tAkB8i/Fbkw9CvqejL0HbsUo9Re+qa6lvgDwqQewO6IpGQPcJaCLEUB8/ed21YRAJrJMcRG77Mq6dolpP6D/AxvTExRGxbiic4jKlQG/ANrCglra4KkYMBpZiTg+npTt5VI76ndLmc2Go4YOg8OuLK/aWw0L8avH4skjuIw62nerYcBP/GteNWekazcE1GNyWlOKLHXHBP3SGs0m5kE5QlQnK0H7dzRF1D2xnhIe3VtlJr6qPoj0jkDkhXf0rKMQbCJm+UGSunuwFTMv1aqRn4LbdJo2L420cqNN5O0obih XClOj6yi I+fTLqxHNyuVyMRm1sbkLk05gR7Qp4NWGPcsFZrwC/+iLnZwvYjDrfraoHJ8RQfieDgi8GISlS8mJPbaGCiJ4jKRZ5opXqb02RDqWabeQwSdRaQAw/qVvNOAVhDRW4XmsAGh8HSkfy4n6iOSjlY3FJ3gQZc4fakrWlsZefoALY6Lvlf70CwUxKxa0wQ== 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: David Howells wrote: > + /* Wait for writeback to complete. The writeback engine owns > + * the info in folio->private and may change it until it > + * removes the WB mark. > + */ > + if (folio_wait_writeback_killable(folio)) { > + ret =3D written ? -EINTR : -ERESTARTSYS; > + goto error_folio_unlock; > + } > + It turns out that this really kills performance with fio with as many jobs= as cpus. It's taking up to around 8x longer to complete a pwrite() on averag= e and perf shows a 30% of the CPU cycles are being spent in contention on th= e i_rwsem. The reason this was added here is that writeback cannot take the folio loc= k in order to clean up folio->private without risking deadlock vs the truncatio= n routines (IIRC). I can mitigate this by skipping the wait if folio->private is not set and = if we're not going to attach anything there (see attached). Note that if writeout is ongoing and there is nothing attached to ->private, then we sh= ould not be engaging write-streaming mode and attaching a new netfs_folio (and = if we did, we'd flush the page and wait for it anyway). The other possibility is if we have a writeback group to set. This only applies to ceph for the moment and is something that will need dealing wit= h if/when ceph is made to use this code. David --- diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c index 1eff9413eb1b..279b296f8014 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -255,7 +255,8 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct= iov_iter *iter, * the info in folio->private and may change it until it * removes the WB mark. */ - if (folio_wait_writeback_killable(folio)) { + if (folio_get_private(folio) && + folio_wait_writeback_killable(folio)) { ret =3D written ? -EINTR : -ERESTARTSYS; goto error_folio_unlock; }