From patchwork Thu Nov 17 21:02:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 21911 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp621551wrr; Thu, 17 Nov 2022 13:05:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf6g5tVbx2jzaxGNI4sP0T2+prXHNRkTh6M/ff3p9WAfCW2U262GnbLvzqUwoC3xe4SAcBwA X-Received: by 2002:a63:530f:0:b0:476:bfca:38ad with SMTP id h15-20020a63530f000000b00476bfca38admr3774741pgb.576.1668719142598; Thu, 17 Nov 2022 13:05:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668719142; cv=none; d=google.com; s=arc-20160816; b=RsjUXEjijcdKSmN1LTgUvFnnBf8DxInFHcTke3JJfAz3zkSSK9uphvq4IVtvm9K+/q sT8BLi/aghd8aadEfTcgqYjBBLzkhyskOHzy0z5Gu/26EI7zE34HEdAkZGNUD9i/5B8e a3HCE/Y71jVFknQqZOdncRt4ZCy+A8VVmFJCot8VTxOCT8e5mau36unm2H/tdNhCdLBL ms1TcyVdZ4LpYyYOnB3reU8gzQTBs/tfMHU3rypYYnjyZPCqP7tH7FrBqu+K0wST14gN z43Vfs+7f37B4vtRvO/MGkfLbTH0EbK8I7FLtUq3jo7VYJwvy1mrTR1XFS5w2pK0a/hi t/2g== 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=k+s6al3wwRtBndCW2ZWmf31NL6al8soF2mssq2Ti0Oc=; b=MiD6xfU8dV7fbQph0wIaIYsdtmNOoNtiCt4620KeEkNslJhPoC8p9tKmxnp9kuVHT/ sG2i6t8ub6Eyenj6FjWtQ4+Qd1eYOvFNofOCRF8JFoI6oqMPT8MFczUGizpe9I/GgTja nWAtSIfzKbNq3ftdftgPCg9AkBl0APWkl4wV6bkcUw9PT36LvGn7kC4Bew0bIePfan/F Ri25g0C4f8d++ZvxCRDN3TOsxUD0uyHxGwxGXLN2lOQMQE/unUT+6OlpF+9vw1Vt+UfQ 1EbCoIvCuDC26IqMIm8eETxMFx7P74vfpBuS8lylsCt+tDOVhDYmpF4Yi8rbtd3Uhs5A YTCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=mZlOHPgA; 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 a7-20020a634d07000000b00476d3de30e8si2054724pgb.10.2022.11.17.13.05.29; Thu, 17 Nov 2022 13:05:42 -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=mZlOHPgA; 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 S240512AbiKQVEL (ORCPT + 99 others); Thu, 17 Nov 2022 16:04:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239809AbiKQVDl (ORCPT ); Thu, 17 Nov 2022 16:03:41 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAA5D275E5 for ; Thu, 17 Nov 2022 13:03:32 -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 2AHKOQbn002482; Thu, 17 Nov 2022 21:03:11 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=k+s6al3wwRtBndCW2ZWmf31NL6al8soF2mssq2Ti0Oc=; b=mZlOHPgAIKUokYiEYU/wm818rb3shzppAw9LoNV9rfPRyh2Hmca0AcnVA4RKROurg1dT e8bLXLt0LzHkhQm+SPWJPLuCZ6X3x/1GfLiBaB/WWSfJ3RcK2lO4HhBZeXOXqyZ0MShI dkQ4sPM37QTzkI63BVK3QWEoBqiCMn2UThfsPJ5GdJ8r/jNegaZcnqx9p3SpbqZ2EKJo Zjb1cLsvaIiDlNspDSmWe1BCeHqqRTaDkVGw9aE0xuLC0xV+znIv7RmK0SupkOLAJJok imGso4NsuPTtYzZBxCjsEibB85WxF5wRJG5URlzxu9JhQWygStYEE4wseIVT3DuJFrTY yA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kv8yktgkv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Nov 2022 21:03:11 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2AHKgvsI010998; Thu, 17 Nov 2022 21:03:09 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3ku3kagy2m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Nov 2022 21:03:09 +0000 Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AHL37Fd032582; Thu, 17 Nov 2022 21:03:09 GMT Received: from sid-dell.us.oracle.com (dhcp-10-132-95-73.usdhcp.oraclecorp.com [10.132.95.73]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 3ku3kagy08-2; Thu, 17 Nov 2022 21:03:09 +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 v2 01/10] mm: add folio dtor and order setter functions Date: Thu, 17 Nov 2022 13:02:49 -0800 Message-Id: <20221117210258.12732-2-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221117210258.12732-1-sidhartha.kumar@oracle.com> References: <20221117210258.12732-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 bulkscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211170150 X-Proofpoint-GUID: 7-LgzR41kaozz5_oBEAW_85xG-oTzz4V X-Proofpoint-ORIG-GUID: 7-LgzR41kaozz5_oBEAW_85xG-oTzz4V 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?1749778843607952336?= X-GMAIL-MSGID: =?utf-8?q?1749778843607952336?= Add folio equivalents for set_compound_order() and set_compound_page_dtor(). Also remove extra new-lines introduced by mm/hugetlb: convert move_hugetlb_state() to folios and mm/hugetlb_cgroup: convert hugetlb_cgroup_uncharge_page() to folios. Suggested-by: Mike Kravetz Suggested-by: Muchun Song Signed-off-by: Sidhartha Kumar --- include/linux/mm.h | 16 ++++++++++++++++ mm/hugetlb.c | 4 +--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index a48c5ad16a5e..47ba2b2b22ae 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -972,6 +972,13 @@ static inline void set_compound_page_dtor(struct page *page, page[1].compound_dtor = compound_dtor; } +static inline void folio_set_compound_dtor(struct folio *folio, + enum compound_dtor_id compound_dtor) +{ + VM_BUG_ON_FOLIO(compound_dtor >= NR_COMPOUND_DTORS, folio); + folio->_folio_dtor = compound_dtor; +} + void destroy_large_folio(struct folio *folio); static inline int head_compound_pincount(struct page *head) @@ -987,6 +994,15 @@ static inline void set_compound_order(struct page *page, unsigned int order) #endif } +static inline void folio_set_compound_order(struct folio *folio, + unsigned int order) +{ + folio->_folio_order = order; +#ifdef CONFIG_64BIT + folio->_folio_nr_pages = 1U << order; +#endif +} + /* Returns the number of pages in this potentially compound page. */ static inline unsigned long compound_nr(struct page *page) { diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 002337cc27b5..157f2392c64f 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1780,7 +1780,7 @@ static void __prep_new_hugetlb_folio(struct hstate *h, struct folio *folio) { hugetlb_vmemmap_optimize(h, &folio->page); INIT_LIST_HEAD(&folio->lru); - folio->_folio_dtor = HUGETLB_PAGE_DTOR; + folio_set_compound_dtor(folio, HUGETLB_PAGE_DTOR); hugetlb_set_folio_subpool(folio, NULL); set_hugetlb_cgroup(folio, NULL); set_hugetlb_cgroup_rsvd(folio, NULL); @@ -2936,7 +2936,6 @@ struct page *alloc_huge_page(struct vm_area_struct *vma, * a reservation exists for the allocation. */ page = dequeue_huge_page_vma(h, vma, addr, avoid_reserve, gbl_chg); - if (!page) { spin_unlock_irq(&hugetlb_lock); page = alloc_buddy_huge_page_with_mpol(h, vma, addr); @@ -7349,7 +7348,6 @@ void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int re int old_nid = folio_nid(old_folio); int new_nid = folio_nid(new_folio); - folio_set_hugetlb_temporary(old_folio); folio_clear_hugetlb_temporary(new_folio);