From patchwork Thu Nov 17 21:14:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13047312 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 F2491C433FE for ; Thu, 17 Nov 2022 21:15:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7EA436B0075; Thu, 17 Nov 2022 16:15:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 799468E0002; Thu, 17 Nov 2022 16:15:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6130A8E0001; Thu, 17 Nov 2022 16:15:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 54A606B0075 for ; Thu, 17 Nov 2022 16:15:13 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2F640141349 for ; Thu, 17 Nov 2022 21:15:13 +0000 (UTC) X-FDA: 80144189706.10.4249141 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf25.hostedemail.com (Postfix) with ESMTP id A050BA0009 for ; Thu, 17 Nov 2022 21:15:11 +0000 (UTC) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AHLEGi2000828; Thu, 17 Nov 2022 21:15:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2022-7-12; bh=THT0/VFA6cUN/tQQrWJEQ7HX1532qlc3yOTzGPja16Y=; b=nYejCUa2hGvXjWw7PuLQKlQ+J+btYMrMHrzN6pLpEYuqK3gOpLDt8Z3af4VNc0psDfbd HHKKlnHmt64vymMOcRP95zUJMY+jK86ZUwz9/+Gvx+ugFUmqoFt7rFVYtdnYNoHsa/Db j0D5VY0vxwUdSCh5PIZAE+8AvHhg0DgmQ1y1jUWv1rBND4Ln9i8IaKiptLwnkz3LUn+r 2SvPUfh+qY64Zi/gRj4mwcxlgyI6j3oGvqB3HCigB1OSpYh6h89vKFNnUQV0iXb3o+JN YcJJ3u2hDhOADkWwizkK2w1jNjUHA9LyBDK3PytJk5aNP4BJllN1OJG99zBL+wAQQ+ns /Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv8ykthfw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Nov 2022 21:15:02 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2AHKaQqD010773; Thu, 17 Nov 2022 21:15:02 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kt1x9nqnq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Nov 2022 21:15:01 +0000 Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AHLEx7W024557; Thu, 17 Nov 2022 21:15:01 GMT Received: from sid-dell.us.oracle.com (dhcp-10-132-95-73.usdhcp.oraclecorp.com [10.132.95.73]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3kt1x9nqku-4; Thu, 17 Nov 2022 21:15:01 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: akpm@linux-foundation.org, songmuchun@bytedance.com, mike.kravetz@oracle.com, willy@infradead.org, almasrymina@google.com, linmiaohe@huawei.com, hughd@google.com, Sidhartha Kumar Subject: [PATCH mm-unstable v3 03/10] mm/hugetlb: convert dissolve_free_huge_page() to folios Date: Thu, 17 Nov 2022 13:14:54 -0800 Message-Id: <20221117211501.17150-4-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221117211501.17150-1-sidhartha.kumar@oracle.com> References: <20221117211501.17150-1-sidhartha.kumar@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-17_06,2022-11-17_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 phishscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211170152 X-Proofpoint-GUID: -PMEYwNm4fFfVTV2DX1WZVa4xzQORiXu X-Proofpoint-ORIG-GUID: -PMEYwNm4fFfVTV2DX1WZVa4xzQORiXu ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668719711; a=rsa-sha256; cv=none; b=GhsLGgeqL8g6G8ZOIH67ixL3rdSCSibi+LM6DQc4doQNQimAGkZWTs2ycoEYicOsEIgvKi dJGpqhfgcy+F9nlUskYDWt23a8sqXRXU1aarkqlhDHP4gh0kgL+T/O6D5cN77zRPFr8NHO rPApyq03ne89eUwOsgxu7NZ8ATHuNsk= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=nYejCUa2; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf25.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668719711; 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=THT0/VFA6cUN/tQQrWJEQ7HX1532qlc3yOTzGPja16Y=; b=5R93/tmb1Y+EbLOVdZuuTKZmrySpPTxvyYAJlO8uAuxV+b0DkPJP0dQpiRhkfqH7GKedyp 1dZI6wUVyR6VJz7+Mc8AsiVxw7b4QLnkJvU/FIU3poq9pJMMlun5TJ/fMDrWs7IzlFDQ70 5DmH772m2DC7Y2ubUhmxvZEQPSEBTQo= X-Stat-Signature: ijgheqztqzjyxjqzu7d89mk7rc7imf49 X-Rspamd-Queue-Id: A050BA0009 X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=nYejCUa2; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf25.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com X-Rspamd-Server: rspam09 X-HE-Tag: 1668719711-383409 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: Removes compound_head() call by using a folio rather than a head page. Signed-off-by: Sidhartha Kumar --- mm/hugetlb.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 5edb81541ede..ff609efe5497 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2126,21 +2126,21 @@ static struct page *remove_pool_huge_page(struct hstate *h, int dissolve_free_huge_page(struct page *page) { int rc = -EBUSY; + struct folio *folio = page_folio(page); retry: /* Not to disrupt normal path by vainly holding hugetlb_lock */ - if (!PageHuge(page)) + if (!folio_test_hugetlb(folio)) return 0; spin_lock_irq(&hugetlb_lock); - if (!PageHuge(page)) { + if (!folio_test_hugetlb(folio)) { rc = 0; goto out; } - if (!page_count(page)) { - struct page *head = compound_head(page); - struct hstate *h = page_hstate(head); + if (!folio_ref_count(folio)) { + struct hstate *h = folio_hstate(folio); if (!available_huge_pages(h)) goto out; @@ -2148,7 +2148,7 @@ int dissolve_free_huge_page(struct page *page) * We should make sure that the page is already on the free list * when it is dissolved. */ - if (unlikely(!HPageFreed(head))) { + if (unlikely(!folio_test_hugetlb_freed(folio))) { spin_unlock_irq(&hugetlb_lock); cond_resched(); @@ -2163,7 +2163,7 @@ int dissolve_free_huge_page(struct page *page) goto retry; } - remove_hugetlb_page(h, head, false); + remove_hugetlb_page(h, &folio->page, false); h->max_huge_pages--; spin_unlock_irq(&hugetlb_lock); @@ -2175,12 +2175,12 @@ int dissolve_free_huge_page(struct page *page) * Attempt to allocate vmemmmap here so that we can take * appropriate action on failure. */ - rc = hugetlb_vmemmap_restore(h, head); + rc = hugetlb_vmemmap_restore(h, &folio->page); if (!rc) { - update_and_free_page(h, head, false); + update_and_free_page(h, &folio->page, false); } else { spin_lock_irq(&hugetlb_lock); - add_hugetlb_page(h, head, false); + add_hugetlb_page(h, &folio->page, false); h->max_huge_pages++; spin_unlock_irq(&hugetlb_lock); }