Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1043545lqj; Mon, 3 Jun 2024 08:33:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWFMuRus0Hg++Gf7Sw5uimcl2uXG6UBkexX0QEN/hdU/XGZzlUzJYjCdTSX77uEpzherPSpo1gQ/yVorn06ScBELk4zTUDFyJRlncT68A== X-Google-Smtp-Source: AGHT+IHvZf5AOG0W7zj3yp+CDzzEjf2//iwbbRnhj2VXODwfCxtrYDKcRP+4d9sRL67RdFkrwo3B X-Received: by 2002:a05:6a00:1a91:b0:702:46f6:64ad with SMTP id d2e1a72fcca58-702478f8822mr9200235b3a.28.1717428810163; Mon, 03 Jun 2024 08:33:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717428810; cv=pass; d=google.com; s=arc-20160816; b=A2APlBJVL17Mcrxqvve87jAznEJfCz8zIQTxjKJ1BAuveHX5LUyqIEyfqY69033rMM /5wXBXj0DW7fF1yUpcOIn+AcKS+Clv5qOTmINsiSjDwvI3jhrNvZVzlNq5o/9fEU1CDj MpbM4zaZXFNsgBYgxzQSJeh4XpLxwi56QJtiRDj/9e62pvRjuqOBnFW3btOt6OPKomJs Sd7yumNDih6EmN/fecbHP8DU9VxBiNYEo3XOBvL64gIcpYAn65RnP6oIoid7PxbBIfis OvdCrFZY6o8wHc/jaXfz7MmLe5liCe3U9Jl3673xFZB19TgsYFwbuv4RDBDBj1jSbxG5 6bzQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:feedback-id :dkim-signature:dkim-signature; bh=/TZQ0dkrHtiebumwKyexBxCJNAE82zu8Fq9CXg3TirY=; fh=O/r1AWZ0/uzSQuzLNsUzriXMmoBKnRMaaI8+fPVdMAc=; b=hY156JCEobpCc2MLdqCCuZ4/0YiHTSUZRoOvBYq/PNT00H3oKzRWga/MFRY7/72ewL 1TWdBmxfPJdern/ae8ZyA6xKQy0lh2/oJvjx71/FTyZIiLBhPTZA4T8B3Bng2EuWNeMs cvaNrWA8JMS+QF3FQed49AarEtziuZ3C1C8JXK05tU6EW0ZhSGWjvULAbEuhICu9qzsW +fEkHl1l3tz0oYlj49MO5IKYmUuc3ozCDSG7ZS0dQDu0YOIihUq2x/Hj2KUIntN1AY8U H3/KDKBIowllqG/ffN+JGr2byd8PtCqShsxSQkIyPzsfi/wp5eYr7droN0PW7ot73ppG 0RPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fastmail.fm header.s=fm1 header.b=FIWJPd3l; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Fkjra8FF; arc=pass (i=1 spf=pass spfdomain=fastmail.fm dkim=pass dkdomain=fastmail.fm dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=fastmail.fm); spf=pass (google.com: domain of linux-kernel+bounces-199369-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199369-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fastmail.fm Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c359e09c68si6528907a12.287.2024.06.03.08.33.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 08:33:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199369-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@fastmail.fm header.s=fm1 header.b=FIWJPd3l; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Fkjra8FF; arc=pass (i=1 spf=pass spfdomain=fastmail.fm dkim=pass dkdomain=fastmail.fm dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=fastmail.fm); spf=pass (google.com: domain of linux-kernel+bounces-199369-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199369-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fastmail.fm 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A7124284FC3 for ; Mon, 3 Jun 2024 15:33:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 270F213210A; Mon, 3 Jun 2024 15:32:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fastmail.fm header.i=@fastmail.fm header.b="FIWJPd3l"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Fkjra8FF" Received: from fout4-smtp.messagingengine.com (fout4-smtp.messagingengine.com [103.168.172.147]) (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 1EB821EF1A; Mon, 3 Jun 2024 15:32:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717428763; cv=none; b=qQzPtGKLDyFd7gkkT29Y2JQabTRNMLTCuaLwCGmQA+K8nCXdkaJmK7UkctstLcSLOvhQZW4EuXiSN5fLbmWZKmcYXp1jRKba9exy+vzf2DnqgdhcHifZbD5/1j1o+EY8+87aPEqTaKmFqgAmxZ0SjoAxrLeNTLKl9z2J60Cd7ac= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717428763; c=relaxed/simple; bh=1PB5TAZWxS/S7OzA5Yx0jsbtLvaHqz8kwPOK5A57Bhg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Fn6jaFzS2MB7V5AZLaagsjBcG6yeL8tlk5Pyu03I8ZcSSiFm6I6a9FKQYOKa7+eENy/5nPmtwYRrIG33L+Eet7jsLpWMRo2ZiyfgNskEo5O8KTYXwuXloH3WIso85o2NYhEYa9PlSay6NDGyJAWJEdtCyTqWLBbN3ZE0767uqZI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fastmail.fm; spf=pass smtp.mailfrom=fastmail.fm; dkim=pass (2048-bit key) header.d=fastmail.fm header.i=@fastmail.fm header.b=FIWJPd3l; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Fkjra8FF; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fastmail.fm Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastmail.fm Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id 24A7313800D4; Mon, 3 Jun 2024 11:32:41 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 03 Jun 2024 11:32:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1717428761; x=1717515161; bh=/TZQ0dkrHtiebumwKyexBxCJNAE82zu8Fq9CXg3TirY=; b= FIWJPd3lO3IbyjBq1T358WBBsg49l+qrtihAccUkUtpax0B7TZ4IAzu4Dk15YUz9 oR2aPD6QsxACU42UmQscdjfNSDz1cz9Ly7retRalj2xIvLe7WRWn4Kk9o0OF0Nvm yXwgMSr9xucrlS/I/4hpWg1imjc+82EUGBD4iK2zb0IeavRlbai42hb+w12Rfyao iYdhvsOKrPl2MWiKKRbTnUsdd6wmeiK46e43qsHeDbGaCh5MXqcyn3BTrZNjzB+Y DEHvGxd/dbUeVkPGLOJ2fNQuQesAZvvjG+FN7JQGr10a0/jYj5EUEs+kBP2jMd1n PbtvhxIMTwFQ/SGigXzvkQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1717428761; x= 1717515161; bh=/TZQ0dkrHtiebumwKyexBxCJNAE82zu8Fq9CXg3TirY=; b=F kjra8FF/JcxV4aWFINBDv2Pq4p5vGBJJY33XUzsNYl+j9qD9kPxyA+wTrJLQECNR JyaTjCSJlR94KrUd0iIWasMJYShV84rtGbvsmLVUILQonZ2KAVtb0okptQA13Rvr dlfDcIZdbVtJ9xNM5ONIpQE3A2A106T/PBQHy+wpxvjquQpIgefV/nCyLBAOmedO 6j5SR4iuSsu7yTu5Zs49HplwyZM+nGadWA3HmQwP1LFpeqHt0JygecTZ6/qFJbgv 1SttApnG3/CwmA7e4T/Z/09wPjGFaIdMOmz+/Gg2dHaxMFu7FDKsLGkA4gVmCVWK i0ch8Rv+IZaWtvXF8wnog== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelvddgkeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeeuvghr nhguucfutghhuhgsvghrthcuoegsvghrnhgurdhstghhuhgsvghrthesfhgrshhtmhgrih hlrdhfmheqnecuggftrfgrthhtvghrnhepvefhgfdvledtudfgtdfggeelfedvheefieev jeeifeevieetgefggffgueelgfejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepsggvrhhnugdrshgthhhusggvrhhtsehfrghsthhmrghilhdr fhhm X-ME-Proxy: Feedback-ID: id8a24192:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 3 Jun 2024 11:32:39 -0400 (EDT) Message-ID: <233a9fdf-13ea-488b-a593-5566fc9f5d92@fastmail.fm> Date: Mon, 3 Jun 2024 17:32:38 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [HELP] FUSE writeback performance bottleneck To: Miklos Szeredi Cc: Jingbo Xu , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , lege.wang@jaguarmicro.com References: <495d2400-1d96-4924-99d3-8b2952e05fc3@linux.alibaba.com> <67771830-977f-4fca-9d0b-0126abf120a5@fastmail.fm> From: Bernd Schubert Content-Language: en-US, de-DE, fr In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 6/3/24 17:19, Miklos Szeredi wrote: > On Mon, 3 Jun 2024 at 16:43, Bernd Schubert wrote: >> >> >> >> On 6/3/24 08:17, Jingbo Xu wrote: >>> Hi, Miklos, >>> >>> We spotted a performance bottleneck for FUSE writeback in which the >>> writeback kworker has consumed nearly 100% CPU, among which 40% CPU is >>> used for copy_page(). >>> >>> fuse_writepages_fill >>> alloc tmp_page >>> copy_highpage >>> >>> This is because of FUSE writeback design (see commit 3be5a52b30aa >>> ("fuse: support writable mmap")), which newly allocates a temp page for >>> each dirty page to be written back, copy content of dirty page to temp >>> page, and then write back the temp page instead. This special design is >>> intentional to avoid potential deadlocked due to buggy or even malicious >>> fuse user daemon. >> >> I also noticed that and I admin that I don't understand it yet. The commit says >> >> >> The basic problem is that there can be no guarantee about the time in which >> the userspace filesystem will complete a write. It may be buggy or even >> malicious, and fail to complete WRITE requests. We don't want unrelated parts >> of the system to grind to a halt in such cases. >> >> >> >> Timing - NFS/cifs/etc have the same issue? Even a local file system has no guarantees >> how fast storage is? > > I don't have the details but it boils down to the fact that the > allocation context provided by GFP_NOFS (PF_MEMALLOC_NOFS) cannot be > used by the unprivileged userspace server (and even if it could, > there's no guarantee, that it would). > > When this mechanism was introduced, the deadlock was a real > possibility. I'm not sure that it can still happen, but proving that > it cannot might be difficult. Thanks Miklos! I need to go through all of the GFP_NOFS allocation, but I wonder if we could introduce cached allocations and fall back to the slow path if that didn't work. Thanks, Bernd