From patchwork Tue Nov 15 21:22:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13044188 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 85FDFC433FE for ; Tue, 15 Nov 2022 21:22:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 204AD8E0003; Tue, 15 Nov 2022 16:22:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B2388E0001; Tue, 15 Nov 2022 16:22:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05F366B0074; Tue, 15 Nov 2022 16:22:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E44F46B0071 for ; Tue, 15 Nov 2022 16:22:46 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B188D8063E for ; Tue, 15 Nov 2022 21:22:46 +0000 (UTC) X-FDA: 80136951132.13.123F4CC Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf12.hostedemail.com (Postfix) with ESMTP id 381B24000E for ; Tue, 15 Nov 2022 21:22:46 +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 2AFJXdNS016540; Tue, 15 Nov 2022 21:22:35 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=UrtIfo58Nj3Y1eE1w+Ej6DcDMXYyYYkYY6rJykOyjqU=; b=jjQ96U4b9SFf76nI6jMBxDSDj0xUqjQLdwwwEOlXCT3EC/0MeXkV/KrXiRLiQHkMu3sK CAdNhh8djw5jkhYaQAxkPnnF5v1aDpv2XjwmvTrrme6+1IhiQ3rDS+0/pTkkOX3gdeat 9TbZlK7MF7jlPOOUh+rTa3zc/L+u6FiM3pCM0omSgu7Csnj7JFEA2uzuIru633wY0Pz5 kPP86fn094zPwJhptGkG5RTkHvB1t9IClXDQGPt+HD2pfdAka3H10zr/SWSCqW2+KDK+ nSoSi5qmXdJ0QHdEQx8cIv6JEmlGEgUbZSNOmdGG/dxC2K0PAt6VOOGSa5xybtAvRG4B 5Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv8ykj8mq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Nov 2022 21:22:34 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2AFJl43Y031742; Tue, 15 Nov 2022 21:22:33 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kt1xcfvgc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Nov 2022 21:22:33 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AFLMSRg002082; Tue, 15 Nov 2022 21:22:32 GMT Received: from dhcp-10-132-95-73.usdhcp.oraclecorp.com.com (dhcp-10-132-95-73.usdhcp.oraclecorp.com [10.132.95.73]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3kt1xcfvb0-4; Tue, 15 Nov 2022 21:22:32 +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 03/10] mm/hugetlb: convert dissolve_free_huge_page() to folios Date: Tue, 15 Nov 2022 13:22:10 -0800 Message-Id: <20221115212217.19539-4-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221115212217.19539-1-sidhartha.kumar@oracle.com> References: <20221115212217.19539-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-15_08,2022-11-15_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=952 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 adultscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211150146 X-Proofpoint-GUID: B3Cp_OgsD9uqaB9D70IPjTPw6dsvggnd X-Proofpoint-ORIG-GUID: B3Cp_OgsD9uqaB9D70IPjTPw6dsvggnd ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668547366; a=rsa-sha256; cv=none; b=NdQHnR5hJtJb+RoYgFs1ffSZhyoQSrgwQQ0TjV6xxvMCfQKVg0pbTFWr8jDLJc+91jN1lo iI+VtMaCHfzafuzQ5rG4k3kXv8t3vyWcs3+5sf7aOBfWvBYyYcXb9LDX73ub+NaXjdYcLp L8iQ819sgbjDtFdLIN3bKZ9Gap8RqVs= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=jjQ96U4b; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf12.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=1668547366; 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=UrtIfo58Nj3Y1eE1w+Ej6DcDMXYyYYkYY6rJykOyjqU=; b=JDxutIBE7QVxAlhpe4GxEA/cGzZuXYPUrSOqBH8zmG5BevcCTlJJ2vXUjfAkmOYvcbDM1x +/g2W6wJTzZyoUMpULit2+KZPYdCHYc/lH9n/TmxjyGqklSv395GW8KiRsak44kdZVSaog aIBanhGsylToZTXCQS3k647P9NzyDWQ= X-Rspamd-Queue-Id: 381B24000E Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=jjQ96U4b; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf12.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: gqrx1puqccgk8dgc9gw8px95i5kn6cm9 X-HE-Tag: 1668547366-573177 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 cf52cd0d571e..19657f990900 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2116,21 +2116,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; @@ -2138,7 +2138,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(); @@ -2153,7 +2153,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); @@ -2165,12 +2165,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); }