Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1438830lqe; Mon, 8 Apr 2024 08:56:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZ5Owf/lGwvLZ8wtZX8sBRB+BcBB9VUKS2thMoR1YVETbxjfICp43Tan1o3eLYqapYbmslsA4uFmeD2mT3WXMEt/sTF9A1qnSz7Hnh4Q== X-Google-Smtp-Source: AGHT+IFD2tMjWV8nXpyZrjg/fQdkcDLblWB/JJVFLrQR2HBwfzGt0YAvUX8AsmzcZsRmQ8iPPEZT X-Received: by 2002:a50:d4d7:0:b0:56d:e765:4356 with SMTP id e23-20020a50d4d7000000b0056de7654356mr105271edj.3.1712591759856; Mon, 08 Apr 2024 08:55:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712591759; cv=pass; d=google.com; s=arc-20160816; b=MUM+qGieut9uVmGAPeG7soudpMElQECAFiCuuY4qi3V3wcMVMLXwxm/DXDaRMROQdV PKvM5vBQJXUh1c0H3FkIOevG9Y11RyNNOOBc3RgVKAhvrP2QN8rM+v4TrRLGLuPU8OTb iWX2aXOPgT28fYcJNBGQ8wgu+k/vYXZdnEHLIBopWv1Suhhc3rGQpErm0YS+tXZVs5o1 hARzRooClzPPuWilOP5L8H9Swn/V8hhmelwsqXpQ1jexdRivcXS+ZbqYe9EzXsHVqEnw xcp1VCWS6ffo7WnQUbm/zhREFJdpGqle5GO4hc+pYsp4ZSRhXt3cL5Hv+VSN9ZW0Jsf5 bpyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-transfer-encoding:content-id:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:cc:to :references:in-reply-to:from:organization:dkim-signature; bh=CFuGX1yyoTN69ecCATsVj4UhORzkDiRUWoktVVAJ3+Q=; fh=HxuIBn4wGaz7X+1wW1RTc7kXUXNobpWqZwDeaFIEZuk=; b=N0vobA1DEf5dp351m9VSCIigO0R8iXT9kEXDL3iYvkJsfj/6cYJ23/LVi9ODopJNXJ HP+ZJlg3SAWnTvz1IADVTr/Js7XrmqjhbVX/5jChb+HqpuMgOMmsUgVu+T4cpp72gUks 7ZjaKb5Jh6RQ4v7J/4N5uA67i0erHZrZ9Du7yrFnTyC6br/4eenKVi9M47jJ9fYa8GuZ UoxLzi6YzR0OKTJl19xwMymWOIz1Nq2bvSO9aAW2Xzq/VTnDgGD0+SM3k53khoeN3Iva SlTtUVg04l1Z5gbDSqN+Y/CkMZo46QxmOsk0GyjCoJ2LUCU1BcXKVFL9aG7zQbbhCFVv kAcw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AbhCQEqe; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-135640-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135640-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x4-20020a05640226c400b0056e217142e5si3919896edd.452.2024.04.08.08.55.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 08:55:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135640-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AbhCQEqe; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-135640-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135640-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 252821F2209B for ; Mon, 8 Apr 2024 15:55:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1DE92146583; Mon, 8 Apr 2024 15:53:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AbhCQEqe" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C4C9145346 for ; Mon, 8 Apr 2024 15:53:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712591617; cv=none; b=OntCFCwAxAiOKtbY3SFN2L9eMSLrVufxIECL24GsrX+FhC3VeYPgFyFCSkINge0cs2H0qewRqjF4RLWUwEhvSjLZANmK6b9Mizo7TUUfNnxQ2h13pHbQBAWAOcevQ2dYU+F9YGnKeEbmVMzLZgQDE7gpK7qmIXyjV/8cLCToM6U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712591617; c=relaxed/simple; bh=c7hBMA4mXgWP8KpfW/frrWt9OAipSAHQsJKBjgulmnE=; h=From:In-Reply-To:References:To:Cc:Subject:MIME-Version: Content-Type:Date:Message-ID; b=oZHmmL0oxREsFhpwifAZhltY5Pjb2QPR0fn0aO31LK69fXjPfsJbcvz2GO0pA8tb4RoFVqaroaw9RGORp6+4GG7r5XOLO2FjpBTHnoJqoxZswRx3eCzgpmWA1hFHWK42+EKbuHqicWMAicyt78sWFPC5oj0NmPTOfCUls7R2jUw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AbhCQEqe; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712591614; 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=AbhCQEqe4XB+w97u23xa8D6LgttyUXW5z5q41kcS+pR5+4jXhi+M2pECCiZetUVEvC4q42 JLhS9kYGnmI7Jbhc24ve7TyfwcZa5o+l6qaYOAp9JBT86JZB0u3uwiI0puWU68L55kM6Gx h5wMs9Hhdxv6KiQjwt6B6fD1T+bne6U= 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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; }