From patchwork Sat Aug 17 09:51:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13767120 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 86AC0C52D7D for ; Sat, 17 Aug 2024 09:55:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F239E8D0066; Sat, 17 Aug 2024 05:55:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB7278D00D0; Sat, 17 Aug 2024 05:55:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D7E508D0066; Sat, 17 Aug 2024 05:55:38 -0400 (EDT) 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 BDD218D00CF for ; Sat, 17 Aug 2024 05:55:38 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3621C1A05D0 for ; Sat, 17 Aug 2024 09:55:38 +0000 (UTC) X-FDA: 82461280356.14.CD40FA0 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf30.hostedemail.com (Postfix) with ESMTP id A947F8001B for ; Sat, 17 Aug 2024 09:55:35 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723888436; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8XkKxLrmBCSX6p5WCCvAz0doZCiQjZUC4v8jCk75XOA=; b=DqCRJ+cvvLOeo++hwb0PBDii6G3JhUPs3zzhH4Tk24QiDz0/R5hgxNtx8slEwFauOw+PbZ G4tKjhaTz5HoK+O4bWgKf/olf5rNRHJcdnm1Sp61WJg0/xYwsqwJ1H9Bb3e75iBN44kiJ0 k7r2Snj2Hg6oLlkwCrsMsa5Hi2QyFo0= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723888436; a=rsa-sha256; cv=none; b=33eKpXw7QEIrANhDtUGKuT2axmn1wC1IQaJQGTp5FsGmbulXm1SLbCPwQCmTibnPDBZ29z QhynVPixaOVpcmaVSdAVaqpIpHEc6ZJ1smrlRfXdmwYdxFPsizBAGTpBUePv0gB1RonbF0 b3uNRy8PpKPwDA4F5GAtoh1HcgWwrZE= Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WmDk85ltSzcd4J; Sat, 17 Aug 2024 17:55:12 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 07AB71800F2; Sat, 17 Aug 2024 17:55:31 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 17 Aug 2024 17:55:30 +0800 From: Kefeng Wang To: Andrew Morton CC: Matthew Wilcox , Alexander Viro , David Hildenbrand , Sidhartha Kumar , , Kefeng Wang Subject: [PATCH 4/5] mm: khugepaged: pass a folio for set_huge_pmd() Date: Sat, 17 Aug 2024 17:51:21 +0800 Message-ID: <20240817095122.2460977-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240817095122.2460977-1-wangkefeng.wang@huawei.com> References: <20240817095122.2460977-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: A947F8001B X-Stat-Signature: tncdrdnuy6hjixm5n3wew86k9a5i5emm X-Rspam-User: X-HE-Tag: 1723888535-341099 X-HE-Meta: U2FsdGVkX1+IXdZWDDJoo2spLtuW/64TAwlD+ucDl2vqXRuxxpyK9SjhAiK6O+2bBGO434UNcDeWo4xqN5wYK0jO7L6cQdmcDiRKUs4Kjg2sJ003Kzgd3eLY4zI173VavCxSscq/It7ntKPrVFIwKPe4NIGBkl37rXaER4ry+XFZ44cPJIFYsvuZoYuOnkLWqtyX2elhCxbuaEUMYtsPpdwlymaCh1Rhrrp0rpoLxsXD3cwuDlbA4GYY38ry5WShU/kw8mrsNm/4hfEnji2+QSEBSQStMp8F3HqoeA2y/57+bAlCNqZ7Un9Tt6adZ/uLyA4/gFkoqNXF8R1YP+uVPbbwUyd8/akK0V0HIc8mymaECp2SeFHM2QpDXQoi3nwNpnnCwUiJp3KTLR4DGbAk9BdJNdVbKCRrgQkEDPQLAxvP0rfQM4bV0p7BLRAbUcOhqXqNuwsSZv8x07XzzVFNapCZEEZStwiUOYyVReOgNQBK4JdLooqB2a7NUKJZzz0ewwW0Ysjg4R8vW/YSQwj830dNn1LJKrsCcY44pAYs1WVG2MeeFaf/wIwAl00Htai9Dn5iGLuIDDC3oWVK6PjC+RzH0bLkLaWudt2XxSlGERc4IJRotKyCTAB0L1Zw4zGUpaYvSZfQ2OoWGTtEg80iV0VUh0cBCDbHu4kkYjtrSXEMLKXpvySEbE5y+rAxqjtncnidRzm2Y7C6ZGzyD/xlfzo6Ra//3G1arecrr/+TrVDW26hvs5f1H4Fo+hK/UBa2RvXmySCb8K3QUV1A56xWVtTxsiCL7Inr71aElx3IlP6M//uzJs6KQP6uy5qdIrYoUSWU6N52GDMsp/TYF4xUWsRf9Ypk/B7oDC8u0MEuI9Z5blr9t2//uAPV8/KJKoMQ4BA0Phcyn0ej8/bRAw/H7oG6/lRrOYDXk0RqwOpyuVhxoq+K2Y0mtBxd1kkr7lVOzi0ERRrWYBqwkhTg3/D xGH8VP4m hFgGhFB1n7i5OHN7RFfz2eDVSrpL+4amdV8Wf2m4q6HmoSFHQjnJwGQM7/cCrrKbU7iBpQ3CNc6kDCYYKBZFzL9V1OcQ/Ld/sdaYrc7R6GiDxbXiWI+FsMzrbvmQIHv0dtxfU9yVTAi/zPhdSKWVXtIgmNSB5kWbkJPjeuq5Y4gchtnlizuxOuZ3DAMfztHw4H5x1 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: Save one compound_head() and remove last PageTransHuge() in set_huge_pmd(). Signed-off-by: Kefeng Wang --- mm/khugepaged.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 02e1463e1a79..ae796219f8a0 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1455,7 +1455,7 @@ static void collect_mm_slot(struct khugepaged_mm_slot *mm_slot) #ifdef CONFIG_SHMEM /* hpage must be locked, and mmap_lock must be held */ static int set_huge_pmd(struct vm_area_struct *vma, unsigned long addr, - pmd_t *pmdp, struct page *hpage) + pmd_t *pmdp, struct folio *folio) { struct vm_fault vmf = { .vma = vma, @@ -1464,13 +1464,12 @@ static int set_huge_pmd(struct vm_area_struct *vma, unsigned long addr, .pmd = pmdp, }; - VM_BUG_ON(!PageTransHuge(hpage)); mmap_assert_locked(vma->vm_mm); - if (do_set_pmd(&vmf, hpage)) + if (do_set_pmd(&vmf, &folio->page)) return SCAN_FAIL; - get_page(hpage); + folio_get(folio); return SCAN_SUCCEED; } @@ -1670,8 +1669,7 @@ int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr, maybe_install_pmd: /* step 5: install pmd entry */ result = install_pmd - ? set_huge_pmd(vma, haddr, pmd, &folio->page) - : SCAN_SUCCEED; + ? set_huge_pmd(vma, haddr, pmd, folio) : SCAN_SUCCEED; goto drop_folio; abort: if (nr_ptes) {