From patchwork Fri Oct 11 22:34:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joanne Koong X-Patchwork-Id: 13833218 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 E6297D1A427 for ; Fri, 11 Oct 2024 22:37:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4686D6B00A2; Fri, 11 Oct 2024 18:37:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 418206B00A4; Fri, 11 Oct 2024 18:37:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DFA26B00A5; Fri, 11 Oct 2024 18:37:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0FFB66B00A2 for ; Fri, 11 Oct 2024 18:37:09 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 87180160CAB for ; Fri, 11 Oct 2024 22:37:03 +0000 (UTC) X-FDA: 82662783336.28.8068F00 Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) by imf29.hostedemail.com (Postfix) with ESMTP id 30596120014 for ; Fri, 11 Oct 2024 22:37:02 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Ep/pnhI4"; spf=pass (imf29.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.180 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=1728686088; 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=GckUEeUkGJ/MXaNICUW/EN8rJNPMFxf0v5zONX3nnpg=; b=OuuNARZh7Sv3mAtoz1i8/kYNbiexUvK7odQs6frN/nihuVnDODlknPmCxUKFavQf+vYrUe RxdWWVmlt4e0Egl3cNNXpt25rQ4XzHHyDgZ4798+N2frcXY9HW+7CCF7tP00u5/13mkHFi JsMt7jnAFuiC1+HkpZSgY5/1RJqfsgA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728686088; a=rsa-sha256; cv=none; b=tw+Xdr3TGqvaVQ04Gvb3Rr/zs+G7l+Pg7m/oXdYHNhAmxSx8Woi/sS4lS0u23cQRJ4k14h Q4aAhsjucWD79xwmg1o8o5cCMzZpWTbML/W6sJTZ29ouhuBscj6hg4LDrBmkKRN2wf9Coj iTeeQCYa9P0X9kEPai05bce8QhjP4h8= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="Ep/pnhI4"; spf=pass (imf29.hostedemail.com: domain of joannelkoong@gmail.com designates 209.85.128.180 as permitted sender) smtp.mailfrom=joannelkoong@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-6de14e0f050so21698527b3.0 for ; Fri, 11 Oct 2024 15:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728686226; x=1729291026; 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=GckUEeUkGJ/MXaNICUW/EN8rJNPMFxf0v5zONX3nnpg=; b=Ep/pnhI4EhkaWkECIRtPoYgbTkM4HkG0Q9675D3RvFZAT0+vwx6iIJFZbyOg+od9c+ 1zLM/BpGmS+VS3dt8APE+BaEuFjWUwmlKmSgl8PRv+NSTArmqXdM7exkPIXtjsqtvGvF 3HnAXt5b/ulks5FSUJuqQB/brSgbXuXtb+wnsbjBM0TBKgMXb+mLpTZM2syiL+aOPXmw 3jSMiPthebPtLS4DrbsP41hZe7lvWjezqJaLUyjXqmVohHe4EVPOKL8WXx9upJ5P4Hw/ 85nJKcilptcNeMTyxKl27eREDBRY2lc7OnEPP9ByfhWzfHbdkCZdge3jec4po/5NiN4k Vgwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728686226; x=1729291026; 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=GckUEeUkGJ/MXaNICUW/EN8rJNPMFxf0v5zONX3nnpg=; b=SpfN7DH5hn4vtAD47wheTL5/5qFso2lZx/quhWxpthdZ/h78F1mId7xjgEmNoQjWl1 Ba95wDSTxTuw0Ar2kINEeCh3y14ucYDTvZ6wjHKFQT5FowLhJeDOuXm7Ie+9Jlk/n1Sa mJtxUTtpTNYhbEpAwSLduM60VjbIiEfo8RhdpqJWqpp4YZFbW3AC3ubv8ZqanAKnnAwJ YlIU5QXwEDAsdqZ21ScTrb1AGPSq8r23coA3wVKSX0mvMm+xjj41UN+4bOOYsY/UdVYJ Fqq8cCXjiuZCJTDnEE1ufBwT8WVJR7yXYH5obSwPKn9iEB3dhZ/npyK2ntifx8tCYEPg Fm7A== X-Forwarded-Encrypted: i=1; AJvYcCVS+IsojtuNNSxz9AIPizGQMicDzFgwq1fXISvdpQcQ87OsgKs0fy/Gia45vxOHn8+MmcVP32CoUg==@kvack.org X-Gm-Message-State: AOJu0Yxq0ItlkxxR5lbafZdX9WyZvZ/sKg0bcpl+fT82akHb8qWPtxs3 kXp/nGpEvEzwG9RTICoBAh4fJMNWjbI/mYU9nrY0FG/gzBrdhZp1J5svpQ== X-Google-Smtp-Source: AGHT+IG2sFQdjWeH9vJvJDAyO5XNnPVbYOMSEpEREKhf1EN18EbBSHjKmnEC6BXy8I5GKdKTJ+LvQA== X-Received: by 2002:a05:690c:3586:b0:683:37a8:cd77 with SMTP id 00721157ae682-6e3644c023amr10213517b3.29.1728686225953; Fri, 11 Oct 2024 15:37:05 -0700 (PDT) Received: from localhost (fwdproxy-nha-001.fbsv.net. [2a03:2880:25ff:1::face:b00c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6e332b6199dsm7744117b3.1.2024.10.11.15.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 15:37:05 -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 0/2] fuse: remove extra page copies in writeback Date: Fri, 11 Oct 2024 15:34:32 -0700 Message-ID: <20241011223434.1307300-1-joannelkoong@gmail.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 30596120014 X-Stat-Signature: 9dpqmsygixkn8idxzffz6st3y7gu74zy X-HE-Tag: 1728686222-255184 X-HE-Meta: U2FsdGVkX19URNWCScI10Ad5xLQZz8pTJCRutU2oM/Y5BRn/XqjQzsWsE2eVkLfyNH/XQ61cJe7XCC1T78AKzFuS4IDe75sDUEWbFPoQP5PWSXGCTVC55oDl4RhzuVdTLvIXYXvsWmsTBKI9G8DA87UjGLtzywjR0PTuukZfYNIwnZARMeCkHGsV9tA3cXLJZzy7zJWYK3YLg0ZGYRM7TX+YbRQ/tu4Jfz2ozhRliuZNT4ePvDtFBaSp3uVgG23mLnIlwfmSHZ67Gdv3g5xS/DwkAAUYmwShfikRr82+ldWfl3vbTSzlMDTh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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 an ASOP_NO_RECLAIM_IN_WRITEBACK flag to the struct address_space_operations 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/ 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 | 321 ++++----------------------------------------- include/linux/fs.h | 14 ++ mm/vmscan.c | 6 +- 3 files changed, 45 insertions(+), 296 deletions(-)