From patchwork Tue Dec 22 01:21:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11985567 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A000C433E0 for ; Tue, 22 Dec 2020 01:22:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D4EEA22B51 for ; Tue, 22 Dec 2020 01:22:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D4EEA22B51 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 02B8F6B006E; Mon, 21 Dec 2020 20:22:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F1CC66B007B; Mon, 21 Dec 2020 20:22:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE56D6B007D; Mon, 21 Dec 2020 20:22:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0027.hostedemail.com [216.40.44.27]) by kanga.kvack.org (Postfix) with ESMTP id C7A9B6B006E for ; Mon, 21 Dec 2020 20:22:01 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 90364181AF5C3 for ; Tue, 22 Dec 2020 01:22:01 +0000 (UTC) X-FDA: 77619166842.30.unit57_1700c442745c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 6BC08180B3AA7 for ; Tue, 22 Dec 2020 01:22:01 +0000 (UTC) X-HE-Tag: unit57_1700c442745c X-Filterd-Recvd-Size: 6029 Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Dec 2020 01:22:00 +0000 (UTC) Received: by mail-oo1-f51.google.com with SMTP id o5so2619267oop.12 for ; Mon, 21 Dec 2020 17:22:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zfyd8+tCEuNHXvryEXCzCH9GQPnu047cakpfMip3n1U=; b=p80XqYZkEluA9Fxrf3nI5e6MMvRJMeT1+yJnONO/ywrNuYRPDweJhgyoB2MMdu2a8f L3CVtl6jTjyOfM+9zJ8eilUn+rKPIMeJoFJoFS8cBz7Sjha9eT5HKFk/fC5TOaGzhP26 I/nkP0tNkZiWsLdAoQ7RSfpCj9mI6RjsUOcLXd9nhb9SkGBayJFp9yOIGPiXRwZD8piU 8mWFxdSQqCtP99ZmIycirFdk0kdYDhff7GLJJvTJfYzeVFHcTzWZzladVJ8BD6ju75Ys 5hcEOSyAMucAB6wru27exc9OpJzZic6eL8ukZ93Xht/Lz7/mZig09c2mrf6dcnIBIZ0t XcXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zfyd8+tCEuNHXvryEXCzCH9GQPnu047cakpfMip3n1U=; b=VK6BngacP0aLYEwfWKEPeyM2e8h3JTQ/4wS1jyEAvspa/n9xzLDxs6k5zKBla6ix6R q15r7FEYdXCqdRHONnFDPDVtKv5TkJlbwMyPa5gqoxuLd8Rjbzn36hwrMvg2BsGkBQwW Lt/6C7KgAbzNJON1KwLenqlwyUEehNxggFeXOmHa9XhFhmD5La91kZOA/7XsptjNq1Y0 PlCnfUNb5QD5L2rrqn4EDH8RFhHj4JDnNUT+WIjEY1GNarVa7kq2tR3fAwJU0n2vkPUI geFqT/nTg+djhM5l1JHU5MFkI0WwzJgDMwQTIXdxj4es/f0FFoOL95may7AkajMQQMWU RF5g== X-Gm-Message-State: AOAM532f32wB1XS2Fx2swKSwkKydDfEJ7t2PtVNV6mryy4OMy/sc5Z/g 18nbahYfDt/AD8ozKn76tdA= X-Google-Smtp-Source: ABdhPJxHbyNtUyWl/WAzlJIE1qh8PdfS5Lc7Wnsu58XQtOTCmiUcs7dFLLap8LrPisiuzgB49qLBoQ== X-Received: by 2002:a4a:d118:: with SMTP id k24mr13348179oor.8.1608600120359; Mon, 21 Dec 2020 17:22:00 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id x20sm4070098oov.33.2020.12.21.17.21.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Dec 2020 17:21:59 -0800 (PST) From: Yafang Shao To: darrick.wong@oracle.com, willy@infradead.org, david@fromorbit.com, hch@infradead.org, mhocko@kernel.org, akpm@linux-foundation.org, dhowells@redhat.com, jlayton@redhat.com Cc: linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com, linux-xfs@vger.kernel.org, linux-mm@kvack.org, Yafang Shao Subject: [PATCH v14 0/4] xfs: avoid transaction reservation recursion Date: Tue, 22 Dec 2020 09:21:27 +0800 Message-Id: <20201222012131.47020-1-laoar.shao@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 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: PF_FSTRANS which is used to avoid transaction reservation recursion, is dropped since commit 9070733b4efa ("xfs: abstract PF_FSTRANS to PF_MEMALLOC_NOFS") and commit 7dea19f9ee63 ("mm: introduce memalloc_nofs_{save,restore} API"), and replaced by PF_MEMALLOC_NOFS which means to avoid filesystem reclaim recursion. As these two flags have different meanings, we'd better reintroduce PF_FSTRANS back. To avoid wasting the space of PF_* flags in task_struct, we can reuse the current->journal_info to do that, per Willy. As the check of transaction reservation recursion is used by XFS only, we can move the check into xfs_vm_writepage(s), per Dave. Patch #1 and #2 are to use the memalloc_nofs_{save,restore} API Patch #1 is picked form Willy's patchset "Overhaul memalloc_no*"[1] Patch #3 introduces xfs_trans_context_swap() for rolling transaction. Patch #4 is the implementation of reusing current->journal_info to avoid transaction reservation recursion. No obvious error occurred after running xfstests. [1]. https://lore.kernel.org/linux-mm/20200625113122.7540-1-willy@infradead.org v14: - minor optimze in restore_kswapd(), per Dave. - don't need to refactor xfs_trans_context_{set,clear} - remove redundant comments in patch #4 v13: - move xfs_trans_context_swap() into patch #3 and set NOFS to the old transaction v12: Per Darrick's suggestion, - add the check before calling xfs_trans_context_clear() in xfs_trans_context_free(). - move t_pflags into xfs_trans_context_swap() v11: - add the warning at the callsite of xfs_trans_context_active() - improve the commit log of patch #2 v10: - refactor the code, per Dave. v9: - rebase it on xfs tree. - Darrick fixed an error occurred in xfs/141 - run xfstests, and no obvious error occurred. v8: - check xfs_trans_context_active() in xfs_vm_writepage(s), per Dave. v7: - check fstrans recursion for XFS only, by introducing a new member in struct writeback_control. v6: - add Michal's ack and comment in patch #1. v5: - pick one of Willy's patch - introduce four new helpers, per Dave v4: - retitle from "xfs: introduce task->in_fstrans for transaction reservation recursion protection" - reuse current->journal_info, per Willy Matthew Wilcox (Oracle) (1): mm: Add become_kswapd and restore_kswapd Yafang Shao (3): xfs: use memalloc_nofs_{save,restore} in xfs transaction xfs: introduce xfs_trans_context_swap() for rolling transaction xfs: use current->journal_info to avoid transaction reservation recursion fs/iomap/buffered-io.c | 7 ------- fs/xfs/libxfs/xfs_btree.c | 14 ++++++++------ fs/xfs/xfs_aops.c | 14 ++++++++++++-- fs/xfs/xfs_linux.h | 4 ---- fs/xfs/xfs_trans.c | 17 ++++++++++------- fs/xfs/xfs_trans.h | 36 ++++++++++++++++++++++++++++++++++++ include/linux/sched/mm.h | 22 ++++++++++++++++++++++ mm/vmscan.c | 16 +--------------- 8 files changed, 89 insertions(+), 41 deletions(-)