From patchwork Wed Jan 13 10:22:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12016409 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.6 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 48CEBC433E0 for ; Wed, 13 Jan 2021 10:23:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9BB8F22B4B for ; Wed, 13 Jan 2021 10:23:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BB8F22B4B 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 0FED26B0177; Wed, 13 Jan 2021 05:23:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0AE708D002E; Wed, 13 Jan 2021 05:23:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDEA46B0179; Wed, 13 Jan 2021 05:23:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0235.hostedemail.com [216.40.44.235]) by kanga.kvack.org (Postfix) with ESMTP id D937F6B0177 for ; Wed, 13 Jan 2021 05:23:07 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9B0511EE6 for ; Wed, 13 Jan 2021 10:23:07 +0000 (UTC) X-FDA: 77700364014.01.star23_1c086dc2751d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 79BB610045C13 for ; Wed, 13 Jan 2021 10:23:07 +0000 (UTC) X-HE-Tag: star23_1c086dc2751d X-Filterd-Recvd-Size: 6279 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 10:23:07 +0000 (UTC) Received: by mail-ot1-f50.google.com with SMTP id q25so1387250otn.10 for ; Wed, 13 Jan 2021 02:23:06 -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=EZdWjEiE6JU4dDIJ/Pyi7n34O5hqZ+ARLNb+PckQnXM=; b=ietyQfRtI0nge5UQtyiDTZ4uIxLua/JTSqhCwmUcofLsKnXoXIqW4xcVZLIkvMQlhh dw+gB7uRVgSVbdYO06x/2BoZSXSB7UDAQjy0Js/U/MC2nHXmT1IJ0KkUB+Zq8cyyrEmv xnoyDbBoPyJXaaKf53GCftPPJLk+qYPS9qzGTvZhBnMARFBkU1IaoHjdebJY3b7pClZE CtYtzSnXlL6/ya7ETA2RymcBQRNaqNmXNqR33Bp6fdy4BXkkOnlEUzA7z0qLzb0r/sdC Vm2ticv8iP8sgApOKjBBbpbvJahWeqnX1sfLeYDbOi8ynZtpK7GQ1zcf+3BkrPdfy+lt iPUA== 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=EZdWjEiE6JU4dDIJ/Pyi7n34O5hqZ+ARLNb+PckQnXM=; b=NgGXdOrcaF3uDr4QuCuEPj7qDt8e4UTvfWyBuVWLLocbXWoNeXsHXBN3UWRt/9ix1R MrVe1Htrk5vBv0bhKusNMWyBAked5uV8GCD5hTqLA7cHoqT3M1EB17Rf4FmUtgHLoqi5 8bIAPNFVxkEaV5sVvpDEkd6tVJSl8c0cmxiRGgXGABAEEYWaoXcUqYn6QlTsY4ImZ4f6 Xiq27wy7wJx72w0TQ9KDDcAFshL5XXABJU7cIZ2pDm4N1CW1pguKazcdw1Nk+iSSoRq1 w/sTccz3EwpdeIPAKXQPDgJW8jMuY1wtSr9W4L43Y0HCh5j3h1pZgGV8oaAu1y8mPSj8 1rSw== X-Gm-Message-State: AOAM533XCJfvyWxvIJpJVJ9yeT02wStIIx2IYJOl8v0jdg9jMDISd4v9 tcd5+m11eE5n1RnKe95Vj2g= X-Google-Smtp-Source: ABdhPJxzpcZ6oajkxTk/IqALwgCtGfZtB6bXMnDlhxhsoNwGNY4Zv4RvzAHa0fEt2VE6pimAVRh7CA== X-Received: by 2002:a9d:19cb:: with SMTP id k69mr732136otk.75.1610533386389; Wed, 13 Jan 2021 02:23:06 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id z8sm335571oon.10.2021.01.13.02.22.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jan 2021 02:23:05 -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, oliver.sang@intel.com, Yafang Shao Subject: [PATCH v15 0/4] xfs: avoid transaction reservation recursion Date: Wed, 13 Jan 2021 18:22:20 +0800 Message-Id: <20210113102224.13655-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 is the refactor of xfs_trans context, which is activated when xfs_trans is allocated and deactivated when xfs_trans is freed. Patch #4 is the implementation of reusing current->journal_info to avoid transaction reservation recursion. No obvious error occurred after running xfstests (with CONFIG_XFS_ASSERT_FATAL enabled). [1]. https://lore.kernel.org/linux-mm/20200625113122.7540-1-willy@infradead.org v15: - fix Assertion_failed reported by kernel test robot - run xfstests with CONFIG_XFS_ASSERT_FATAL enabled 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: refactor the usage around xfs_trans_context_{set,clear} 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 | 26 ++++++++++++-------------- fs/xfs/xfs_trans.h | 36 ++++++++++++++++++++++++++++++++++++ include/linux/sched/mm.h | 22 ++++++++++++++++++++++ mm/vmscan.c | 16 +--------------- 8 files changed, 91 insertions(+), 48 deletions(-)