From patchwork Sun Jan 16 12:18:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 12714553 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 33589C433F5 for ; Sun, 16 Jan 2022 12:38:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3706B6B0075; Sun, 16 Jan 2022 07:38:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D4226B0078; Sun, 16 Jan 2022 07:38:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 173966B007B; Sun, 16 Jan 2022 07:38:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id 01FE66B0075 for ; Sun, 16 Jan 2022 07:38:09 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B1FB6824C429 for ; Sun, 16 Jan 2022 12:38:08 +0000 (UTC) X-FDA: 79036102656.26.F28E936 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id 419E980006 for ; Sun, 16 Jan 2022 12:38:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=DgDHeNwPS9XAK0JO3fVKJQ4TsoEJSTs7hmi2i7kzloU=; b=UsA9wMhthgEmyRAyyN0eOL4wHq BBnwv4WAChPolc/5fswDbTKaaDo66RdkzsTTI77OvtwhbWCU2bmvauPXmje3o0PKno99CGclqqmvw KrgLAxFpOgGk7Q7DncaNjS1uO5K5txNCvb+3rat+Ow9xSrtr9eKD/pSjxnVK9tYZe+siGUYINgB/I R6I1L1xj+LXUt+zzQsmJ3UaQp378toif1wubVCuxlr96YYkkbpHXNKOSGF6WiTT0bEB1OaAfIQaaY PGN3ikv1L1z9YjI6e6SGtsJcuWNy7IsQvfa43s8q9Z/3VQ+0y6YOmEDGip1WKpxhfIynTzLXqiVJ/ 5IIEHkHQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n94UM-007FUH-D6; Sun, 16 Jan 2022 12:18:26 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 04/12] mm/vmscan: Free non-shmem folios without splitting them Date: Sun, 16 Jan 2022 12:18:14 +0000 Message-Id: <20220116121822.1727633-5-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220116121822.1727633-1-willy@infradead.org> References: <20220116121822.1727633-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 419E980006 X-Stat-Signature: ftwu1gx689kpuct19iroi3x8sdineo8q Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=UsA9wMht; dmarc=none; spf=none (imf30.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam08 X-HE-Tag: 1642336688-331733 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: We have to allocate memory in order to split a file-backed folio, so it's not a good idea to split them in the memory freeing path. It also doesn't work for XFS because pages have an extra reference count from page_has_private() and split_huge_page() expects that reference to have already been removed. Unfortunately, we still have to split shmem THPs because we can't handle swapping out an entire THP yet. Signed-off-by: Matthew Wilcox (Oracle) --- mm/vmscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 700434db5735..45665874082d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1728,8 +1728,8 @@ static unsigned int shrink_page_list(struct list_head *page_list, /* Adding to swap updated mapping */ mapping = page_mapping(page); } - } else if (unlikely(PageTransHuge(page))) { - /* Split file THP */ + } else if (PageSwapBacked(page) && PageTransHuge(page)) { + /* Split shmem THP */ if (split_huge_page_to_list(page, page_list)) goto keep_locked; }