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: 20573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2947942wru; Tue, 15 Nov 2022 13:25:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ufoCz53YgZBlXOJcbjMb1oWE8VZEEhzYsCG9FcKWUt08WvlP9jSthz1rAcB78Sguy/Vsq X-Received: by 2002:a63:c0a:0:b0:470:a47:996a with SMTP id b10-20020a630c0a000000b004700a47996amr17735699pgl.377.1668547530249; Tue, 15 Nov 2022 13:25:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668547530; cv=none; d=google.com; s=arc-20160816; b=OwuSgQpxRnmAEFQNyOb9fy7u1WEfkxh/enlFEA9aC1UI3STUISB+OT+UoE1WI22BSw i/hYncyzdZWdaQnI0KZzVP2F0+VzCcJqX0i8TkTBzjNrS536GaECMuouZJaLOvoQxNLv 8nm0MIBrQFn2vksPU6fVbBwrcc9xYiJOFSo0T+TVBLO2K+m0Kcpl9rdle2ZRJG5DhufI 8tORi3jDTaVShNR5lh/qBhXgjoXwnMSVjdMWvq0Ynnb26N1q2T7/HecoNLwZHD9YOrst TQAVgTeoGCkwRW/Pf/yjAHn4HiAXdxUZgsENf39XlaFFGn3bA+ftZXBIWAuY3cYY5CjY bJeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UrtIfo58Nj3Y1eE1w+Ej6DcDMXYyYYkYY6rJykOyjqU=; b=ooeNmJL7bMjmomxokgTJ5VtE9jFRu2kB+MDxX/3MomYJyvpdr2M31aKSYLvj3jY2Tk unwCe77EYukknA04sHCh1RLxF0hlCLAYZtHvg6FgmONsqjscueN2MwGtn+pVhseQtW3T lKElYjh2EoJAnMeFhDmoeEnXT7KzUtTS9TtNWWKgfmBCD0/qeDDUUCy2BfGPZBdtqkSL Nqw7WSRvtP5MuCrFhUO2FSWcK3S2Evaw96iCth1PYQ8A+S4/hlATR1hqO1Q5Z/O+LfIh /WKBbTRwZqD1WDd4VLI+roRTCqGql4TQXC45CyUsxVdzOa1DZaBfYObyhxOFC54MfTrS 3haw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=jjQ96U4b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u16-20020a17090adb5000b001fb35ed6fdesi10775pjx.53.2022.11.15.13.25.16; Tue, 15 Nov 2022 13:25:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=jjQ96U4b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232119AbiKOVW6 (ORCPT + 99 others); Tue, 15 Nov 2022 16:22:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231684AbiKOVWt (ORCPT ); Tue, 15 Nov 2022 16:22:49 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D12E01E70C for ; Tue, 15 Nov 2022 13:22:47 -0800 (PST) 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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749598894657108296?= X-GMAIL-MSGID: =?utf-8?q?1749598894657108296?= 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); }