From patchwork Wed Apr 3 17:18:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13616533 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 A6B30CD1288 for ; Wed, 3 Apr 2024 17:18:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 022906B0098; Wed, 3 Apr 2024 13:18:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E9EDA6B0099; Wed, 3 Apr 2024 13:18:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3F976B009A; Wed, 3 Apr 2024 13:18:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B0EBF6B0099 for ; Wed, 3 Apr 2024 13:18:42 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7DC06C0CFC for ; Wed, 3 Apr 2024 17:18:42 +0000 (UTC) X-FDA: 81968880084.01.B7A23EA Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id D09041C0015 for ; Wed, 3 Apr 2024 17:18:40 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=onBeYxW+; dmarc=none; spf=none (imf18.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=1712164720; 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=Z7HWqHXiS6gALWSH/SSFJ3qdbLs7tqqs0zZ3mdj/GGg=; b=xUC+PxHETyTVEch7T1kIUuQIruJmVln0B0Q7ucN6mxOAgN+whgTzGnMxduAs1H6vq3RmVi xxqw4FN6TKkbkQoUtqHnyCLMUR5eXnhgmLRaPBZxz+dNVMOaoweZSgSV0/TjdN+u61YXF2 iXxBdB0K9JnrG4ar0uZRFEkDhin5bnY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=onBeYxW+; dmarc=none; spf=none (imf18.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=1712164720; a=rsa-sha256; cv=none; b=tmBNeBaTMDgDOvgQhRXuHqqrUTTJZSuvi/y+HhrJAPii07tvNhVGLUQylZpmA/xwHHSr/8 Dmtie5OgHDSlIvTIxub2fD9ITsbGTn3Pu9H5tp0gGwOHm/UprGMQPrdJbKLOiwxzH1eWZE hGnuyK6uPSlNXS8XYmx6SzHcL3kIEbQ= 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=Z7HWqHXiS6gALWSH/SSFJ3qdbLs7tqqs0zZ3mdj/GGg=; b=onBeYxW+QSqrKaZhLvrJFSdE+Z nrLdr4iI1OLNVpEFeFxHXr4xyvi3Ih5IxEEvv8cOLbBhv8u1JqSmXrbzdPspuDXWxnzdf/Q4W5VBS BcDnT6B6svjfmrpuLPzkrj9pBz8w3LWZ0BwMivrWzlcok/adWfcHzM9sFtBFumgFUryAg5eNiRwmM YcdsLosspYe2Ub+QAa0SOezouPQpcOCB4LtXWnVmIN+wGhLW4Fdu6fp1eh/brfvlGOwfui2SLxjkh F7gokTFJKwXAEbdJgMLfD5xpTuabsOjpBsR3JAnav3hDwqPswga8I8jEBS2+7IQu9KOWC2A1D4CII 8MQX1R7w==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rs4Fz-0000000648m-1zSh; Wed, 03 Apr 2024 17:18:39 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 3/7] khugepaged: Remove hpage from collapse_huge_page() Date: Wed, 3 Apr 2024 18:18:32 +0100 Message-ID: <20240403171838.1445826-4-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240403171838.1445826-1-willy@infradead.org> References: <20240403171838.1445826-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: D09041C0015 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: bgkzukonruontcs44nh13uhhpspgaheb X-HE-Tag: 1712164720-37176 X-HE-Meta: U2FsdGVkX1/cXrjWazzGvLpczE0auUExCG/mihNdcbQhwMxDjIZ49CFRxEMRJ2JErvbp4Rw6xFueoGOoIuXRsR0MTirTP/QUejo4jfusIRVY4tgtzdw400V4Kzyq9PvjpgcdSZqh4JfVyPFAEYo4HaYOECfOK+pCVGFozspMJziTIVii2Cd5S5+vrJm0IObf4nKjTAh2xCqYsqeq82uNwXxavr9sUtwWlmIfzGRXY3z2TYGP+oDhAuGL//vq8WuyXrnPMRHTo/n6bEdBILxAg1NPqaItSducLhXWSfLiC0RzlD+EOeJ1/jSICivglYgOOd9ROc71I44NjmPfJXBoWEyCkSB+U10Vo3t3bzulat3UXoqCf5bawfl3VM2IEJzYJ6vNxrsR9jDtmKUdCfVMdyXZAody3kVCZUA38yVMa3eGQr9cG/F5a+iVqukA7wUmz5bvbAl+4WtOzbR/8Xk7/YbA+PUx3ujtA6ufj118ec1hVjsm1ZRIiDSM54x9kU+BrF6kxiYx4N1QL+taFnhpP561XmojW8bJiXv25YesjkIAMhQsLMGS16C83fjNimqoX2Pc+don2OnnnlU+LJuzvLbVQ7iopMilTRORX8Qqb3CXUMEzrw+Epva/LxZUtN4rjDYJRO1E8JmvVB0uo0aW+9rDPhPcgqnLENzwrtTEv6j2vNa6x9nKuGTMpoTzv5HCOl7ug6PG6JAPyRbtGG6myNCo7mdimns0HL/vJ5+bB3EXHxJ7Pa6QuvucvM65SD2fCX4rccTfusOQS8v/tue5X7FyjWy09jyFSRlwxuiuf85PXniyyrJm7m2I1T3NaYq8NFtgaDaRXjtPBrFYnaQZKjB10hnOCV9lQ1iamjrXghUBOGDDqjM4iCTBcsqjYM+aso+YzNGMuAWaBYdH4ld0BlpXEEK9nnc+5m6MOJSxXgiqIlV8uZ0ZqE32uerl1RuFKmyJ0onLaX4EC1SXGrp hLaIT0nz sqnJJecKN3ayo7gFxnozldDQXUhQmBBf7WFcQetO/KHrz3kAJjI6xDydBRFD2Q2NvJre/XCsxaKnLwWPcpOMJuwRE7401M8k246IZRj9YDqfCUxQgUceimoTgoNPUxNqYC1XoKF1MO24mFKrXe6mGM4xCVCCnTfISemqn2AP1EVokQucdek6l+wa3a6Xelbvi3vGiwz0QFFLZo48onn48tAlPi+aBAxBBoOw6 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: Work purely in terms of the folio. Removes a call to compound_head() in put_page(). Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Vishal Moola (Oracle) --- mm/khugepaged.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 2f1dacd65d12..1c99d18602e5 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1082,7 +1082,6 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, pte_t *pte; pgtable_t pgtable; struct folio *folio; - struct page *hpage; spinlock_t *pmd_ptl, *pte_ptl; int result = SCAN_FAIL; struct vm_area_struct *vma; @@ -1099,7 +1098,6 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, mmap_read_unlock(mm); result = alloc_charge_folio(&folio, mm, cc); - hpage = &folio->page; if (result != SCAN_SUCCEED) goto out_nolock; @@ -1198,7 +1196,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, */ anon_vma_unlock_write(vma->anon_vma); - result = __collapse_huge_page_copy(pte, hpage, pmd, _pmd, + result = __collapse_huge_page_copy(pte, &folio->page, pmd, _pmd, vma, address, pte_ptl, &compound_pagelist); pte_unmap(pte); @@ -1213,7 +1211,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, __folio_mark_uptodate(folio); pgtable = pmd_pgtable(_pmd); - _pmd = mk_huge_pmd(hpage, vma->vm_page_prot); + _pmd = mk_huge_pmd(&folio->page, vma->vm_page_prot); _pmd = maybe_pmd_mkwrite(pmd_mkdirty(_pmd), vma); spin_lock(pmd_ptl); @@ -1225,14 +1223,14 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, update_mmu_cache_pmd(vma, address, pmd); spin_unlock(pmd_ptl); - hpage = NULL; + folio = NULL; result = SCAN_SUCCEED; out_up_write: mmap_write_unlock(mm); out_nolock: - if (hpage) - put_page(hpage); + if (folio) + folio_put(folio); trace_mm_collapse_huge_page(mm, result == SCAN_SUCCEED, result); return result; }