From patchwork Tue Oct 12 12:02:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 12552283 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6415C433EF for ; Tue, 12 Oct 2021 12:02:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6A32960F23 for ; Tue, 12 Oct 2021 12:02:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6A32960F23 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 026866B0071; Tue, 12 Oct 2021 08:02:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F18AC940009; Tue, 12 Oct 2021 08:02:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBA30940008; Tue, 12 Oct 2021 08:02:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0176.hostedemail.com [216.40.44.176]) by kanga.kvack.org (Postfix) with ESMTP id CED4B6B0071 for ; Tue, 12 Oct 2021 08:02:51 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 84C5D8249980 for ; Tue, 12 Oct 2021 12:02:51 +0000 (UTC) X-FDA: 78687648942.35.06DE1C9 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by imf08.hostedemail.com (Postfix) with ESMTP id 9FBB23000098 for ; Tue, 12 Oct 2021 12:02:50 +0000 (UTC) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20211012120248euoutp01966b26e7c1ab00a0c12984876b992a87~tRuA-1dWR3056130561euoutp01- for ; Tue, 12 Oct 2021 12:02:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20211012120248euoutp01966b26e7c1ab00a0c12984876b992a87~tRuA-1dWR3056130561euoutp01- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1634040168; bh=vD1DwHi66vesD8XbwOs/nORqYO5RHC+xzmZvxIEFZpI=; h=From:To:Cc:Subject:Date:References:From; b=cAzr81nT3k/JeFDHvXfoWDvFpRmk5i3APLiuIVdJbfxVF+dcqvLnM/bILmplSQ9F7 Af3jQMvRgh+NJ9DYMhwjqx5noodxOc0kaGyc+0uFb64MtY7mf42JmLLiR0+PnDC4xC oTAWSyFAFPwPGpZ5tBmGhM7BwGoUIqDldkVo1ps8= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20211012120248eucas1p2b0ffdd19750a6574dcebc5d4a391d163~tRuAiLSub0733207332eucas1p2D; Tue, 12 Oct 2021 12:02:48 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id A0.BC.42068.86975616; Tue, 12 Oct 2021 13:02:48 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20211012120247eucas1p1f66926c6fc334216cdbdd39285601aa8~tRuAFkaqW1263112631eucas1p1C; Tue, 12 Oct 2021 12:02:47 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20211012120247eusmtrp20094289c6c85a4c0c78b6f8f9ca74d35~tRuAD7P_A0452404524eusmtrp2H; Tue, 12 Oct 2021 12:02:47 +0000 (GMT) X-AuditID: cbfec7f4-c89ff7000002a454-af-616579689574 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id CC.9B.31287.76975616; Tue, 12 Oct 2021 13:02:47 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20211012120247eusmtip13f44d1420ed233588ffe3c5d4ff5e752~tRt-ZSLIg0194501945eusmtip1h; Tue, 12 Oct 2021 12:02:47 +0000 (GMT) From: Marek Szyprowski To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Andrew Morton , =?utf-8?b?6rmA7ISx7ZuI?= , Song Liu , Rik van Riel , "Kirill A . Shutemov" , Johannes Weiner , Hillf Danton , Hugh Dickins , William Kucharski , Oleg Nesterov , Yang Shi Subject: [PATCH] mm/thp: decrease nr_thps in file's mapping on THP split Date: Tue, 12 Oct 2021 14:02:37 +0200 Message-Id: <20211012120237.2600-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOKsWRmVeSWpSXmKPExsWy7djP87oZlamJBiu3cFjMWb+GzWL1Jl+L Az+fs1g8/dTHYnHz+RwWi8u75rBZ3Fvzn9Vi7ZG77BZb97cyWlzbtJXVonHacnaLn4fPMFts XtzFZPGx6R6bA5/H4TfvmT0mNr9j91iwqdRj06dJ7B4nZvxm8dj50NJj3slAj49Pb7F4vN93 lc2jb8sqRo9JL9w99qy6yujxeZNcAG8Ul01Kak5mWWqRvl0CV8aPk/eZCq5wVmz6l9jA+IG9 i5GTQ0LARKKzew9rFyMXh5DACkaJC80/2CCcL4wS7WfPskA4nxkl9i69wwTTcmb5XiaIxHJG iSMP3jLBtTx/0AFWxSZgKNH1tosNxBYB6tjdPJcRpIhZoJ1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YlNSezLLVI3y5BL+PHyftMBVc4Kzb9S2xg/MDexcjJISFgInFm+V6mLkYuDiGB pYwSi5e/YoJIyEicnNbACmELS/y51sUGUfSJUaKlvw8swSZgKNH1FiTBySEiYCYxccVcsEnM Av0sEt9a34GtEBbwkHi5+CNYA4uAqsT+V71ADRwcvAI2EucXQF0hL7F6wwHmCYw8CxgZVjGK pJYW56bnFhvqFSfmFpfmpesl5+duYgTGw7ZjPzfvYJz36qPeIUYmDsZDjBIczEoivIYZqYlC vCmJlVWpRfnxRaU5qcWHGE2B1k1klhJNzgdGZF5JvKGZgamhiZmlgamlmbGSOO/WuWvihQTS E0tSs1NTC1KLYPqYODilGph0Z+bPFaq89Dzg/rafAa8vna59Kr9mjuqHOSpmu/08E+75nJKd MPvqjDtXNmj+Kc8tXjf1fnj343ksm2c0LNczYoqdMaGvIrHFTXFmAmuBZtnEgtDGiBOHQ+8F dpyurvsS8WCHxM3o6d86NFl6J+U/ydZ+cfGrXu0rda+G+5NOOVyoMmhM2mn+gG+jT3rFtkvT 5l/hWmqqnrNXRCombP/XfS8uPvmm/D3s5NO/yn0OIZO/rH+1PC8uubJl4aQJhRM0Zyor8tzP UFpz5jXj3aQDPxubnFdbz0g9afAoOMW4v+ee4r/wFzIaq8WMavavNj20dfdTr9ICsXsXVF2V X25yuid++e57rZoNBVoTlLk0lViKMxINtZiLihMBaNBWoRADAAA= X-CMS-MailID: 20211012120247eucas1p1f66926c6fc334216cdbdd39285601aa8 X-Msg-Generator: CA X-RootMTR: 20211012120247eucas1p1f66926c6fc334216cdbdd39285601aa8 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20211012120247eucas1p1f66926c6fc334216cdbdd39285601aa8 References: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=cAzr81nT; spf=pass (imf08.hostedemail.com: domain of m.szyprowski@samsung.com designates 210.118.77.11 as permitted sender) smtp.mailfrom=m.szyprowski@samsung.com; dmarc=pass (policy=none) header.from=samsung.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9FBB23000098 X-Stat-Signature: wn6ayaqioa11b7bzqz1cqa7h5aa6wqmf X-HE-Tag: 1634040170-541805 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: Decrease nr_thps counter in file's mapping to ensure that the page cache won't be dropped excessively on file write access if page has been already splitted. Signed-off-by: Marek Szyprowski Fixes: 09d91cda0e82 ("mm,thp: avoid writes to file with THP in pagecache") Fixes: 06d3eff62d9d ("mm/thp: fix node page state in split_huge_page_to_list()") Acked-by: Matthew Wilcox (Oracle) Reviewed-by: Yang Shi --- I've analyzed the code a few times but either I missed something or the nr_thps counter is not decremented during the THP split on non-shmem file pages. --- mm/huge_memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index ec2bb93f7431..a6c2ba59abcd 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2709,10 +2709,12 @@ int split_huge_page_to_list(struct page *page, struct list_head *list) } spin_unlock(&ds_queue->split_queue_lock); if (mapping) { - if (PageSwapBacked(head)) + if (PageSwapBacked(head)) { __dec_node_page_state(head, NR_SHMEM_THPS); - else + } else { __dec_node_page_state(head, NR_FILE_THPS); + filemap_nr_thps_dec(mapping); + } } __split_huge_page(page, list, end, flags);