From patchwork Mon Oct 14 18:22:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13835387 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 ABAFAD1813A for ; Mon, 14 Oct 2024 18:32:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F9526B0083; Mon, 14 Oct 2024 14:32:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 382D86B0089; Mon, 14 Oct 2024 14:32:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2231F6B008A; Mon, 14 Oct 2024 14:32:02 -0400 (EDT) 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 02D866B0083 for ; Mon, 14 Oct 2024 14:32:01 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2B04AC11D9 for ; Mon, 14 Oct 2024 18:31:53 +0000 (UTC) X-FDA: 82673052000.28.150D3D9 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf08.hostedemail.com (Postfix) with ESMTP id 50C95160003 for ; Mon, 14 Oct 2024 18:31:55 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XziBxpge; spf=pass (imf08.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728930577; 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=qUW0W3ZYpo5yrkhIlDPyYy/jLNeC+OiB6o3xInhHHd4=; b=Rs2H5xicKW+NkPNJ4sBv51kUFmAcjXg5t+oakhf2ay3Sc5qUMsS7Ghb6P6JDHMgCQozS6k bJi1hccV+2b1+t3mqfVOUUTRIzN0XSVkAlc5QvERTxuzoorITCDNJI8IyOF99pb2zS9ajk kbiIK7XnOI42c0h450wRIJx8oxOBti0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728930577; a=rsa-sha256; cv=none; b=hyGKUZkziacEZ2INZasMer6U2IhVvnb0hMCb4TnUVFVV8ShMuedEW6hNf9qsKKpInRwep3 yt9EeFCqLOW7vOpFxOLqN3Vp1oFHsi0YUJJ66ipuwfpv0ZQtwadOL4MUr11/ONmRydO+Mj v5/OAaVlH1QnH2X3C6JZ9uit7a+PvOQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=XziBxpge; spf=pass (imf08.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-7163489149eso3714308a12.1 for ; Mon, 14 Oct 2024 11:31:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728930718; x=1729535518; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qUW0W3ZYpo5yrkhIlDPyYy/jLNeC+OiB6o3xInhHHd4=; b=XziBxpgen2Vrm5XxALckKuIRYYjWm282NSuVHZkUtxkvRRe0W2dSV58H+yilHjsw3H bGdAR6t9WC0j9MCRH1r3e8/GpBMdpTIrOJ+GgiibqXIj9D/X21AZpaHtmYwud3tHcKaM hL0j9X+HotX8mlfuZqMJg2YcCG4IjKTC5Vxm+fDF1hVSl93n7GxIfQVzNKyBNBnBT4B5 OvnzK6dFgO1h3sV7yAeN2FUQgF5JYzKyMlAO18gG40aBOiEtVpu8VZNYUcXJq60R9ZmU fx9M0OE5hBASbgPuiJKHQywV3Pj/Shs5xdiTKcQq3B4zJqVzP1aL7S2jpVl3mGzTCkz5 NyhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728930718; x=1729535518; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qUW0W3ZYpo5yrkhIlDPyYy/jLNeC+OiB6o3xInhHHd4=; b=LPKuj7k2ZLNFWnqMXuH4WW/Rla2TbC5KdcwIlIyR/53T3BM7iqaPtSXMArEPsCFNVR MZ6Jgqqg8RtvNZUO2aoUhybvUN7xbreWd/7yrm9IY+4zdlw2j7PGqkC+/I+SmqJ9UzIo LYzF8AeLbk1YHItCJRMQpIzRBdKSrI6m2c28wG8ApPr0P66jGvxaQVu4uWAY6Y1bZO6T 7cIhBt0sIG1BjxR5JxdaJNSkDHHI1n9Z9XYOas/E82uW5p5dL3bjZ3p4dcv99KCjD2jR M8SWUNeadTUcelZWHu/sDK0H5WBbj+986DOJMoN2hXFkF3UBnOTNwI/qG+Q9vLapbuP3 Jldg== X-Forwarded-Encrypted: i=1; AJvYcCXa7mBK+3A6Dwpjouw1bFfDGHeN3ff6OGClns1u3/pNYJiWfQ9FfRYxBYDJrOo1oSWCcxMGaKEoPA==@kvack.org X-Gm-Message-State: AOJu0YxMOwKMDT3SLNqZ9q/ga1hZydhlb5a7M0wPsrWJGZpgqrfE+XW9 QgOrJz65bp+hx8NuRD03dF8mQsGTEpC4XqioaCdzQEBhObSSEVhuaxpyHw== X-Google-Smtp-Source: AGHT+IE672zZjQ5ddWW1IuDHcJ2WYACurGMsHxdrpv7sze3pdWJuvgaUDJHKCdZVmSKnEkkiVq0n1Q== X-Received: by 2002:a05:690c:680a:b0:6e3:1537:3d54 with SMTP id 00721157ae682-6e3644cbcfcmr61465727b3.45.1728930227226; Mon, 14 Oct 2024 11:23:47 -0700 (PDT) Received: from localhost (fwdproxy-nha-112.fbsv.net. [2a03:2880:25ff:70::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e332b618absm16108177b3.22.2024.10.14.11.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 11:23:46 -0700 (PDT) From: Joanne Koong To: miklos@szeredi.hu, linux-fsdevel@vger.kernel.org Cc: josef@toxicpanda.com, bernd.schubert@fastmail.fm, jefflexu@linux.alibaba.com, hannes@cmpxchg.org, shakeel.butt@linux.dev, linux-mm@kvack.org, kernel-team@meta.com Subject: [PATCH v2 0/2] fuse: remove extra page copies in writeback Date: Mon, 14 Oct 2024 11:22:26 -0700 Message-ID: <20241014182228.1941246-1-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 X-Stat-Signature: tczjrh4s96jar77j34pkk5egiomh8yth X-Rspamd-Queue-Id: 50C95160003 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1728930715-784447 X-HE-Meta: U2FsdGVkX1/AZtloRwWYTK8Nliq8gtJq/td0dNvkdIg9J+GQ2C5Dr2bBfnz83VX/Dy/2Muz4rLkRH0XO87d/vSlV2zsavzYXArrVdPylgSXtWD61kOQWcvtFe0cPg1gQX7QJ2gfnrEftzcThhr4BOkrhVJrdbGqFFjKPiUBrurZOjTj1Ffo27EGXoxd611sbbsf7H/LV7y8L6x7r57WQ+OCEvcHXh/sReeoj9eCf9qtz1p4NAtvrDKONydIKXmxQScgo+eKl41Mq8sVkpCFOvj3t7PnNe9Zj6s9QhnWCGbZbi1Qv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ilter, 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: Currently when we handle writeback in fuse, we allocate and copy data to a temporary folio in order to mitigate the following deadlock scenario that may arise if reclaim waits on writeback to complete: * single-threaded FUSE server is in the middle of handling a request that needs a memory allocation * memory allocation triggers direct reclaim * direct reclaim waits on a folio under writeback * the FUSE server can't write back the folio since it's stuck in direct reclaim (more details can be found here [1]) The first patch adds a AS_NO_WRITEBACK_RECLAIM flag to "enum mapping_flags" to indicate that reclaim when in writeback should be skipped for filesystems with this flag set. More details can be found in the commit message of the first patch, but this only actually affects the case of legacy cgroupv1 when it encounters a folio that already has the reclaim flag set (in the other cases, we already skip reclaim when in writeback). Doing so allows us to get rid of needing to allocate and copy over pages to a temporary folio when handling writeback in fuse (2nd patch). Benchmarks can be found in commit message of the 2nd patch. Thanks, Joanne [1] https://lore.kernel.org/linux-kernel/495d2400-1d96-4924-99d3-8b2952e05fc3@linux.alibaba.com/ v1: https://lore.kernel.org/linux-fsdevel/20241011223434.1307300-1-joannelkoong@gmail.com/T/#t Changes from v1 -> v2: * Have flag in "enum mapping_flags" instead of creating asop_flags (Shakeel) * Set fuse inodes to use AS_NO_WRITEBACK_RECLAIM (Shakeel) Joanne Koong (2): mm: skip reclaiming folios in writeback contexts that may trigger deadlock fuse: remove tmp folio for writebacks and internal rb tree fs/fuse/file.c | 322 ++++------------------------------------ include/linux/pagemap.h | 11 ++ mm/vmscan.c | 6 +- 3 files changed, 43 insertions(+), 296 deletions(-)