From patchwork Thu Dec 28 08:57:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13505700 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 0A0FFC4706F for ; Thu, 28 Dec 2023 08:58:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7143F8D000D; Thu, 28 Dec 2023 03:58:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C4D38D0009; Thu, 28 Dec 2023 03:58:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5185B8D000D; Thu, 28 Dec 2023 03:58:10 -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 357E68D0009 for ; Thu, 28 Dec 2023 03:58:10 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 15DA7A1B98 for ; Thu, 28 Dec 2023 08:58:10 +0000 (UTC) X-FDA: 81615625140.10.9722D26 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf10.hostedemail.com (Postfix) with ESMTP id 770ACC000D for ; Thu, 28 Dec 2023 08:58:08 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=G5aowaOV; spf=none (imf10.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703753888; 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=qq6toJgeJkdr/5JghJ29GuO+I4LJuHGsuPSOYf2lO/zR3xnCkbQ3eEtpJqg3aFgEKgGWsi uLkq6/3kBIbwed2yMrFZbTdqO34Al2wdad5SR0jL+ku2X5bVQKl6uMcb4NoxxpqtrYNhLK IoKyP/DNSVRhUetEsMsJJREji82omtw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703753888; a=rsa-sha256; cv=none; b=SSEnWlrE2N9rlYcjqIzU3yMjyYSoMGlSjIgkm4YrqvuuWkinwDwxlZnLP9KGR5Kko9epia 69ryBocw+HFY1E93FzU74bsUlFS37ppg9gw1Ix38+7wDGjSSJP/hARvlHJy0kw7AFERW/r 6QWsTkYPWc6elBFMO+Vg14iaQvb4Oes= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=G5aowaOV; spf=none (imf10.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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=G5aowaOV0KLhgOuqCTkb1hlJOk RvQzczRTVSQtwowJqZM+eUNsoeJLlgKEYY/Y+7fGf5Z3LIn1m8HHq2eA6NZNhJqI8aiFCRBQWPk8Q HCmMc7zmIyFDcfGVQOpjH52ByMuB8hbEt66p+1v/Ffc8YSpMhm8vpWIzgcakXB0jYRTdbS2ekQVUU PEij/jgqmGmcmanta4uOpb/BHMHJRcP5kHzeWCZ3HbwJpek7hsH5q+D19+XgGtRRv9wOCHCZfqAtC LoDiFqT5i0K0hxyt2NoGPjMSMmijQc2HtCGutu9TIwx9iohOcSRVyT8yDTTJLaGsyMaUOmlSYUOht b1/LWy8Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rImD8-004XzL-BP; Thu, 28 Dec 2023 08:57:50 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Johannes Weiner , Vlastimil Babka , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [PATCH v2 5/6] mm/khugepaged: Use a folio more in collapse_file() Date: Thu, 28 Dec 2023 08:57:47 +0000 Message-Id: <20231228085748.1083901-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231228085748.1083901-1-willy@infradead.org> References: <20231228085748.1083901-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 770ACC000D X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: yuimerjababkgcxq345r41ibaex9bced X-HE-Tag: 1703753888-542947 X-HE-Meta: U2FsdGVkX1+JCHtwPjZs16o6tlHYSacqnnJdv35oTE+4l3LOJoGHQw4S6m8D+wIFA20KB/UzOkpq2lcuuQVhqdsoe3Y6bR6D2pmPJvqE2XIKtK4XRx2/E3ajHcxEHWHAb0I9ofG7y+cO3DdSFuV+8eXTmkpFlQGcC8mLEF0E4ZmtUF/Y/9DcIg19CUshoYhRIqvy+CU//8Y16UuIaBBVDIlu9YPeMlrrjuVmw9rLA/dMm/SR0jo4ztFSWqGOGGK3ATMHFNWb6dtzdGbeE/7oUx6G3LEjrXH9xN3LnbYEIvLL8Q6E4YYm0vaicMAbyLOYlklnsM0PbJLfqUzTsK71AVrliPcSW6jgnRhXiwiIKtuu13RhFB270iLCq5FDXS5yXSxh+gm95ErApRacbqAQATbeR81UR0ozb+OM7wwrZeLHFlSSYXmNvMfC/Tt+Cj2Cqns9/RiXWrtxUKdNxViyno9CoKJWvZKuDyHFxqKQD68uOxZ8rANhIM8i/3Jv6eHV5GTvWY6e0aHiFVCDn0IxUhCUeuXie0wDJWug0GFIq6Q90ESuQaruloRTk52XaPrZ0A2cvVuh7ww9P7uTNkEZ02xkHrf7/K0o0ZvAZ769cBHa5iFJsFIuol/rRodtV1E/JsnKPDpOUGXnvCOpyaR+31Rgpacj9OfIYvg9KWBsSNwQtBgtfn1CrojaeLVL0e451L9sKkLFcEUTaLIPk7qA/wNI7pVw58AVzPG1ByPlWy8y/YF4NE2Y8FLvrPqdyq3Vd5/3iPRRJSY08zRKzO2+aqYJMXnQ538tvL7NWSkkAx/ZbpFu/+U/8isOPGGPBkGeJmVW90VPnGjuZ8/7zZhJb/df/Gsnee2p0NgAsPv1KuDLgvQpsvyvpTcshIE4GxLXPNjXa85jO4KcRE8JnlSNKF2nqPHi7Dd3VWHpTYcVGHuIMya1vGxdtYOMLaxgxeiBqy5oCrx3sdicKFb1bgM 95a08Iw3 r3gsKnDfjGelW0KrNQGvLt4nTNgJ/DSnWk35cf3jWOnOKjVz9KY6zuz+6bD1mkvvQkEw0Qta9iWWwTS4tEmBSRFUkIGMg3dY+f9mbauxae+9EsYwhF3SjKxDPvSipiFqgQ9iNlQeOqFbyspmoOHwnEdndZvbOM+jZEsvoco6AFYTcZawafvRJCx9B8J/gcKroLhXBG5nUZ68l5UyJBbUoM+NNOnBVFks62In5khytTdIwNJVEUnxy5E8QMO1D5MPS4p8g0GoLcNh+6X0UH4ijZP6lXI1XN5WC69NHB9VOdjYAZJs= 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) Reviewed-by: Vlastimil Babka --- 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.