From patchwork Fri Dec 22 20:28:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13503794 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 B39E3C47072 for ; Fri, 22 Dec 2023 20:28:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D60426B0085; Fri, 22 Dec 2023 15:28:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D10B96B008C; Fri, 22 Dec 2023 15:28:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD82A6B0093; Fri, 22 Dec 2023 15:28:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id AAE496B008C for ; Fri, 22 Dec 2023 15:28:18 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7D2051C196D for ; Fri, 22 Dec 2023 20:28:18 +0000 (UTC) X-FDA: 81595591476.09.E9AB2B2 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id E243740018 for ; Fri, 22 Dec 2023 20:28:16 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=W48EYwdf; dmarc=none; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703276897; 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:in-reply-to:references:references:dkim-signature; bh=NccTglOgefcrO3rZHgTRFfPB5Ozz6huMlwZ2e954KZQ=; b=8GfKDiWreDihBYkErgqK8V0wo9/wl5l9XKcSSw+iVAlJDhE9BblIwNdhv4XfS5YyPRcU/i kWmx/135u0o1fIl5RvJ0xzDt5eNEeOgVcRKobjmXdvfFBw9XCAD3nFFlxK9XhVPTeXEEkx SKOqduotruVyDuna060oTg3PJI+dTqI= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=W48EYwdf; dmarc=none; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703276897; a=rsa-sha256; cv=none; b=dOxpnYxUGN1XVdr/JgodhFruLYwiG45R2YxyaI9ZNp6TuqiFwU3YDaCG73AeNxMVn9jbsS lZji1ze6VWZcvwF0gU0fnsT8Zi1ySfB9a1fbNQWGShQmiV0wQ8pRxZspfr2aWJ35BQrS1g /jMkuLcUyI3WEDlViZpnE7qUeXdAVvQ= 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=NccTglOgefcrO3rZHgTRFfPB5Ozz6huMlwZ2e954KZQ=; b=W48EYwdfHtnKe5AxeywjFkXkwh 3Owz09ExUw+tPMpAzwAaE0PVONEM6hDPbesCwibsRKoz847aUeOlAGzHfiihH3JD3/hCTEBe2js5l Q/EwipkfRA/ZWdNmh7vRDLQuI/NmINWYbX6ndK2xIC9k5U8OhuCvpCvPUVlVfTezMf0BOJM0CxH5a ApI+FY7YzswVlQNkrs2rwSIxWwQ1MKJLhWxWtINxru7Yosor+7cwb3CH5VWTdq9H5zyS7VnjsKOr4 jnUmb7bCh8dN6FLIFDu4+HsspPnyA0L+r8xikQOpaA/ZQXvRb9Q/3rLV5sAGYNUKZE+aWvEHWKYUZ h5KFpr1A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rGm7u-008xbN-Vt; Fri, 22 Dec 2023 20:28:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Johannes Weiner , Vlastimil Babka Subject: [PATCH 3/4] mm/khugepaged: Use a folio more in collapse_file() Date: Fri, 22 Dec 2023 20:28:06 +0000 Message-Id: <20231222202807.2135717-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231222202807.2135717-1-willy@infradead.org> References: <20231222202807.2135717-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E243740018 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: f7fj1y4xc5kn1n6miyqxbe1w4isosatw X-HE-Tag: 1703276896-889624 X-HE-Meta: U2FsdGVkX1+k4aade2uXF9Z5LqKWQmc5xpgsORmB2A2bYnid1Rvt/9qpsymGgwM3L2HbEH2TU0ac4XfgdDIDMUUDkpanaNnLW4RnuqEFT9D+7m0BhIdUmGYAhocgR2wrExtXeWe7spUjaJG/uSaUJEFkNlMEhLpjTSoH6Yapbqe+DmOVT+2nuR9Tthg/qHmqG8WsXV5MNPioxdPmANTzOx1xaamqmZz7q1gRjW17vMp7Y7/kCVCcMe8AK6M9yug5Ujml2gYm1422bZM/Jcsql8/o/tQoOjYWjTooc/Ha/Im/tzTs5Y0GlnWgdyHD91v9icGzak9MmBtxBrX61wN64niw84smci8o+HzCkwp84TMqlBObEX4RL95Nhmx7YbOoTF/VckMcfUhZvlnulLpoFsC8kPDNUxOkfNzgo+wKhT5qCUTWPM+3DzJN/6iwQk6dFspql6T2CAOYvJtF/XLAUFIGPBveHj2pD/B99pTBS8vHnj+px+MiwJbf/ngluceMAwBMod5AfYkxQmcNfnQD1Pelj9Hw7kGQir6KDnD4f65HPkz4yhCKnEeFpgB5tr3YMHzP0CLh04n6rPzp3SBjkRCGtEg4iPA0pwxYvkPBhaw+E3+2A7lx9o/c+2ixgmWSwLOGh63aYc5wILjbupg65nygBtTRpT644C6Y5P2fgSh8H45L8H+FFINlB88h0A+ah74wYr9A/zPz4VTv2tmChYr9KbVXf/RZcrpcjbVyPIxnMUp/Q5EnvBTzeE1qKZcPWMqsABa+p6FNED3yFsPkccrGBdnboJBOnn4ddE7uPJWY5/XkG+x1m9489mehsUFp3MKdxO7I3HTlrbpCu6+Q2HCLvXqKNtMtjVTItGTYrS32zszOuKlYLNsVwrItPJXo/35NWJnKmzl74px+xRVwQtg1aSNwgWYN8clhm2h+40QPeY20Zssh3xoaeYOY7wNAEpyxvtFaocbybjeGY1Q xvds7VAi RCuJCSCxq1SswWERrQS1vY5bTGQ6VUJ0AmWOKRPPUldnl22I5I26adLVHIWzxRc+cbPRhwx+59EBdZiTIlOxQC4WSdYFYIzGDhOpVIvzv6Nq5jtT9T3fROs90MPtGz+CG/c2oMLd9uM/sxuyynLa8RVY4Th7qTe385Qr6UdMS4PyZm5HWOCG4aBD/zeEKsxOiwHoI/0l0JWUHISTEPLDSbDo6AiVftSdYlU2m 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: List-Subscribe: List-Unsubscribe: This function is not yet fully converted to the folio API, but this removes a few uses of old APIs. Signed-off-by: Matthew Wilcox (Oracle) --- mm/khugepaged.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 13c6eadbeda3..b9b0742e4d9a 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -2126,23 +2126,23 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, xas_lock_irq(&xas); } - nr = thp_nr_pages(hpage); + folio = page_folio(hpage); + nr = folio_nr_pages(folio); if (is_shmem) - __mod_lruvec_page_state(hpage, NR_SHMEM_THPS, nr); + __lruvec_stat_mod_folio(folio, NR_SHMEM_THPS, nr); else - __mod_lruvec_page_state(hpage, NR_FILE_THPS, nr); + __lruvec_stat_mod_folio(folio, NR_FILE_THPS, nr); if (nr_none) { - __mod_lruvec_page_state(hpage, NR_FILE_PAGES, nr_none); + __lruvec_stat_mod_folio(folio, NR_FILE_PAGES, nr_none); /* nr_none is always 0 for non-shmem. */ - __mod_lruvec_page_state(hpage, NR_SHMEM, nr_none); + __lruvec_stat_mod_folio(folio, NR_SHMEM, nr_none); } /* * Mark hpage as uptodate before inserting it into the page cache so * that it isn't mistaken for an fallocated but unwritten page. */ - folio = page_folio(hpage); folio_mark_uptodate(folio); folio_ref_add(folio, HPAGE_PMD_NR - 1); @@ -2152,7 +2152,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, /* Join all the small entries into a single multi-index entry. */ xas_set_order(&xas, start, HPAGE_PMD_ORDER); - xas_store(&xas, hpage); + xas_store(&xas, folio); WARN_ON_ONCE(xas_error(&xas)); xas_unlock_irq(&xas); @@ -2163,7 +2163,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, retract_page_tables(mapping, start); if (cc && !cc->is_khugepaged) result = SCAN_PTE_MAPPED_HUGEPAGE; - unlock_page(hpage); + folio_unlock(folio); /* * The collapse has succeeded, so free the old pages.