From patchwork Mon Dec 11 16:22:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13487533 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 A5251C4167B for ; Mon, 11 Dec 2023 16:22:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B1EC06B0158; Mon, 11 Dec 2023 11:22:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AA9F06B015A; Mon, 11 Dec 2023 11:22:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 949416B015B; Mon, 11 Dec 2023 11:22:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 83A236B0158 for ; Mon, 11 Dec 2023 11:22:30 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3F0F71207A3 for ; Mon, 11 Dec 2023 16:22:30 +0000 (UTC) X-FDA: 81555055260.08.5891D6A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id 51B5D14000B for ; Mon, 11 Dec 2023 16:22:28 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=oQVjwU28; spf=none (imf23.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=1702311748; 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=zoQam+lgSCVKznPzA1mgGP6oN8kp6O3aIFrPBTA1x1E=; b=E8GuWW7JcqTkDJCmDddARC88lBm7ck6VoHdNwajSASSfUfCj61Ajl/wwjIkO3BV0DVU9HT MjVqRM/NhsJNf8US5aUsBHQW0v70RPTnV7i9RGrNLFpoa0YrQM9hJMxQHXHjejs/pw5Xi8 2V2FDaPwVTVB3MjRyO0+dXwXspgu1gQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702311748; a=rsa-sha256; cv=none; b=0h7NJ11QQXf1YLIY6c05l+D3vz+h/HTqgwdtzfJosZDVFopCVpq3LQ3jHnZFsSFbmVmail 2f0c9hjjdBGWwNyvj8T/U7NSQ1bmWSIatXnXz5+jf3hcqsyvh2OqqPRayFc9bs/uP/wsJn 2/8aL2AVNF2Tfwe6b2iAUtml67lpPyI= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=oQVjwU28; spf=none (imf23.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=zoQam+lgSCVKznPzA1mgGP6oN8kp6O3aIFrPBTA1x1E=; b=oQVjwU28l1GLpq5GtrmYSry025 KTC4QC4rtkH1XvS0Lwz8opHa0Byprx9UDf6+IJddV80WT78Docn6bEOvYPqVUZDOBLnLovYacmmer EqHAaThJ87Qy6A23VYAvcOpr3jek6wh2aqin31ywlEyjmnPO4Y0NjyMVc7YngoRg9HUGnl4mxJGbv qLDBlgQwmoOLcMNXo0UPo4mIgAmBbYpCqWtpjuulyEHdcd9N/UJMbM5YZuYx+NqNF0vrb4CBpu1rb vJBzF6bhSr39CZX0iPh9RD799rmUnnaLYjqX7QS9gVLlDv6UgWYiDVo2Npxz4Y9nVx9iyBKSeOrpe Z/IkXLwA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rCj2u-0090JX-JT; Mon, 11 Dec 2023 16:22:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 8/9] mm: Convert collapse_huge_page() to use a folio Date: Mon, 11 Dec 2023 16:22:13 +0000 Message-Id: <20231211162214.2146080-9-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231211162214.2146080-1-willy@infradead.org> References: <20231211162214.2146080-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 51B5D14000B X-Rspam-User: X-Stat-Signature: 3pf8599w959a5k73gaxw9dgr9mt8ugyy X-Rspamd-Server: rspam03 X-HE-Tag: 1702311748-462447 X-HE-Meta: U2FsdGVkX1+koJTe+i+/5siPTkg0wVDRBIYBbDAvpKEoMONFCllw5QPjWzzcAXRYVfYCcX88th4txARJ5pONGPxoPD5QXlLiOPbWbq1tjwTUJ/8slUd5FZjaHtfWN8TmS3qCNKXT60Z3gCCk5oNms3ghYDV4j2l9Trv0RzCvtm8tJ/+IZSmIQZRuzOO0fQcYcZ3nfjGSng4dcCLVxMqE7qxYbTFb+dI1TXr/bfqNnjzswIUBqiUx92hOlfaRxcMwRhmbCDhKN0zzhyaKH8Ap4q4QCGgusmAIpkz/8DV/toArwD9Ykt85BNo5ZmKKaM9VCwcwTBsBfH9+O2D0CzHiFj3v5Qis6NuCjMrX0m9VqDgkJzBVmYSWYLvbMVZN0Q2xnCPWPn2S8Tk/FHDo7aKzcj6k8MO+4Noc4ziKFfE4dGQX1Mw0I/GmBp+oTO4sagMLZ0onE91eiDgmZ5qTHwPtXHm/VfDcOf9hkENEG/NvMvilFoR3dGx5i1Y+Ca5rbBtHUdRcDxgfMdmS/QU2mUDOclLtZGSdTlIEuPznORUPC1uTGl2L7nfP96PhJlSUJW3jnFUknNHs4WKY/OX6c3V3VLvxeZan+d2ovxqr6pDRj5uvoTgVz1TkmoWELt44mCJOzzowSwg84O+v769wAT3A9Bx12gajJ0d2Q4gZyWS6rZR6JD7RCdVX83LQ7LYb2VKpfeduirGeMCyMahqni9sjCpagnqdnlaK9NuHA9nfgT1wwX9K5CU7ietRUMHbkaIebZnh0TN3M5QC7edBWv3rHnc7nexCVqECrWGrAXZg8W3tZtwLLxK2jaOLSSjatiH4tAw4mm4ZqgaLVqUtwwnylV+8IzjQDX5hu4pOcPhpkCDqgfRzQniBfeytQXvMQmZq6TdtIHsXhz9zwyaVe/zl0DiEquKYm2DYP/kzcc88i+4AB6Mt/hMpq2ZB+YM+rhP4HJE3hz+5UZ2ns962fXYy OlW9kHHd SghL3Sf1yEsAgDEiNVdGaWe8jqTQ3uqiwjrjyyFmBwXqWAf9QkVBxD9qfgGQVmipC3WXjxuRc3saguyAB8Upz7R85DPCfWlTMqHhF8p4kD52o1PKVPdJohJFHXsmnvQsWt9PqE7r7tdcBvsw/KwETelS7I7W3XYNOX06nmyAcDg1QaJgu08y7pxEkP5a/VnDRSKIYdc0BNJPffAzvjiYZMzjI/K2D6WAo0Vrk 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: Replace three calls to compound_head() with one. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand --- mm/khugepaged.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index e722f754797f..f7ec73976c38 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1087,6 +1087,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, pmd_t *pmd, _pmd; pte_t *pte; pgtable_t pgtable; + struct folio *folio; struct page *hpage; spinlock_t *pmd_ptl, *pte_ptl; int result = SCAN_FAIL; @@ -1209,13 +1210,13 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, if (unlikely(result != SCAN_SUCCEED)) goto out_up_write; + folio = page_folio(hpage); /* - * spin_lock() below is not the equivalent of smp_wmb(), but - * the smp_wmb() inside __SetPageUptodate() can be reused to - * avoid the copy_huge_page writes to become visible after - * the set_pmd_at() write. + * The smp_wmb() inside __folio_mark_uptodate() ensures the + * copy_huge_page writes become visible before the set_pmd_at() + * write. */ - __SetPageUptodate(hpage); + __folio_mark_uptodate(folio); pgtable = pmd_pgtable(_pmd); _pmd = mk_huge_pmd(hpage, vma->vm_page_prot); @@ -1223,8 +1224,8 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, spin_lock(pmd_ptl); BUG_ON(!pmd_none(*pmd)); - page_add_new_anon_rmap(hpage, vma, address); - lru_cache_add_inactive_or_unevictable(hpage, vma); + folio_add_new_anon_rmap(folio, vma, address); + folio_add_lru_vma(folio, vma); pgtable_trans_huge_deposit(mm, pmd, pgtable); set_pmd_at(mm, address, pmd, _pmd); update_mmu_cache_pmd(vma, address, pmd);