From patchwork Fri Oct 14 03:12:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13006632 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 27B6DC4332F for ; Fri, 14 Oct 2022 03:14:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9E6E6B007B; Thu, 13 Oct 2022 23:14:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A27496B007D; Thu, 13 Oct 2022 23:14:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 805206B007E; Thu, 13 Oct 2022 23:14:16 -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 696336B007B for ; Thu, 13 Oct 2022 23:14:16 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4295980799 for ; Fri, 14 Oct 2022 03:14:16 +0000 (UTC) X-FDA: 80018086512.30.396B25C Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf12.hostedemail.com (Postfix) with ESMTP id BEBD340027 for ; Fri, 14 Oct 2022 03:14:15 +0000 (UTC) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29E0HvRI025579; Fri, 14 Oct 2022 03:14:03 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 : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=1b2Agnqraxu+oJn88SnZ5zrHf4rJCayWbQEFBe9+MkU=; b=WSlTCLG5ruakkQSnrgZjNgZhoI7yK8xPwuMNWZfoSXO2+B0utuvkxP2onlzN8/QgNEGB gKHm6LQZd44VJGDzKk/mDhnBVVB5EZNHjGZKd4pD4r2gAc3kTpE4RywTdIefOf3cXgCY 9AGlP3NEJnTy5XdXenCyFwaDyVpiuPV2hkKYvRZlbGIaxtBww/iqgxuOrtMgtiGZ+32+ ZdAUT/ufT8zcunu6PpmnTnn4zTWggsD/wMlBy39qSDGrmi1CEXcw9LFFeTQ/4S1tNdvj KOVJSwjGCUvtXHVkfxNwtzdPGmiHKujc1KvcFzaNN9bOch0yT+QY1l7KpwEB5XaE0lr5 uA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k6r4v8tm6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:03 +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 29E31XVp033961; Fri, 14 Oct 2022 03:14:02 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2107.outbound.protection.outlook.com [104.47.55.107]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3k2yn6j1jp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KHJRPJnTwZQbFMv8PNMvUxM7wanjawELicy31RDc4fVRpkgIScRkVqKgxjJb1jCDED3uJgJQ2hwyRKUuGBAXoL3OWqFwGNq7UoDfYT5f0/5vllWKbLi8JdOKNsbU2NA9AdvsRP3/TFQvrvaVjQZrB2lqk1f6dSuqCW3tbpxFKRPYFFr70ZXB2cNHavonjGgyfYCL/Uni21YVDD5YxgCYZl0JU9E+gvlvKhpu6qyVMAT7tCoBnv6z8hXDS6gWrVW4k/z/rhXYiM/Xit7c9r68yyHdvvp6ygQ3A3p6vrhZc3RGx53Wfozdl6OYajCr9mkyFYHNwq3nPj8k6K8ZJwW7Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1b2Agnqraxu+oJn88SnZ5zrHf4rJCayWbQEFBe9+MkU=; b=ByV1ZhdS81/YYw6nHRePJfOccMQfKo96yzKshyeZOuXAqOGyPd85vNIZqFeE5vBWtLWjpc31Pj3fSJ0N4jpvNsSVL6nQU6J80HSeh2BBCBxoKk42dHMc7ta3x2w5nQfnCCWbTQp6JNIsExFsl2u/awsLOoLRcG4ej92bkUY/ALvOZuwYFWF3Ucgkgqa8dUWqO8FjytKBkX1VvSsrzBe9BP8gml7eVYJO1TKJap1FlB66TzejuVo3ge2J23rneBemrW629JvwkDOXASj+flYvJeZ0KDuzuTifMcmAVjikSvNTEcXPtO7PDvTe2Kyj8q2/8XXktQ63dc5dw89/ln95qQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1b2Agnqraxu+oJn88SnZ5zrHf4rJCayWbQEFBe9+MkU=; b=ZfFI8mUb0b2tp4tMgKExrghM+p6p+rx8uboLoRrydnM58qSVsh6KOpJTbxiK/ptgqMo4uyMjDeX3ev+GLt/vz/6kmlnPiYrc6QeQsikeKwvmr9BifaInbaAvrAoF1yraKVRbtNpH6rYXMgOHejYHMeUnj3oSxb2imeJtqiktJrQ= Received: from DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) by CH2PR10MB4182.namprd10.prod.outlook.com (2603:10b6:610:7a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Fri, 14 Oct 2022 03:14:00 +0000 Received: from DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8]) by DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8%3]) with mapi id 15.20.5723.026; Fri, 14 Oct 2022 03:13:59 +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, minhquangbui99@gmail.com, aneesh.kumar@linux.ibm.com, Sidhartha Kumar Subject: [PATCH 3/9] mm/hugetlb_cgroup: convert set_hugetlb_cgroup*() to folios Date: Thu, 13 Oct 2022 20:12:57 -0700 Message-Id: <20221014031303.231740-4-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014031303.231740-1-sidhartha.kumar@oracle.com> References: <20221014031303.231740-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BY5PR20CA0014.namprd20.prod.outlook.com (2603:10b6:a03:1f4::27) To DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR10MB5117:EE_|CH2PR10MB4182:EE_ X-MS-Office365-Filtering-Correlation-Id: b5c46b78-2333-499d-39ed-08daad922340 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tc1JQMK5n/omnoZkDGChU/t2XQsWPrOHyQbbYF3PxiUCW3GnI7VDdvldY/F/FBycLdY49lg6tKUgvzXbNXFQhza6cVkTGRvkj0KffJAcDPALGoBsNPyb9kdPupONwr1tsXY6g+dNyQSgK7aUelJ76w/5Uo/zZy0Oh3adV8fJC6aU+HqM7GLs3vVgfgWWOCEVloX1jU4k6O0ZuWYt7r3W4iwTq2Z2IOx356ASzm6Stf2ef01pSWOzmB15a3i/G9HFWYj9Z5FgsiRGeLtO322EasJXv8+VT5O2EQwppyYo12R3XZsGynaT3dquAoJ7eojagw0eUbGbFBpnMnBHgY57N26Ef2GGBig43cEuBrgshPK73lHB/MPCWcb+GrzkSwGsc5Ivclg8dqZGIn4kobntpmd+KfVFSVi1Df9M5d2a5Lz5++jDduLuYVnyChH768Q2tfD2nfZGCiOMVzKpVu3qsZo6LTdumndBwqX/XIgDSnLfPKKnJG2ixcOzSHJOcxg017ggCzE62Gs8zhsPdXbNKISiDsZARH6SoRIdLTS1GXO8HvauYLfaYPQcPj4eSD5Z6e/P6iG2ms0ZvlJzsPhFm866U451M/02pgrg/eBlnxAqyD8XtBVdwbB7ThmYFX1a2UjuGm16gq+6hvRvR7C9lqKNdTgB/6UJ+3o7sXVjexESdVM2WnLU+4G14CMKl/iP2ILKvovpcy9WS+bUtTGB1w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR10MB5117.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39860400002)(376002)(346002)(396003)(136003)(451199015)(478600001)(6486002)(8936002)(66556008)(66476007)(41300700001)(6512007)(5660300002)(26005)(36756003)(2906002)(4326008)(8676002)(66946007)(83380400001)(44832011)(316002)(38100700002)(6506007)(86362001)(2616005)(186003)(107886003)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fJx0UHXk3LbwlDu+fvLVbWC+YijCFoV8pMsMZ0KwiXuQESgOexuRTx8Wf4oBQDQMFAbnj89lePwFAz8IkQoA0MzB0LHbdDWCuuu3ARwjaoj/VFvoNAp5Y3Dmr8TSYTFTKryezKhsFcCcuGGptOz5lP3+KdPm7uhhZyB/fp0D+JPhFQBoarxW3BSYWAp+6JGdPiQSG87JxLi/7S1BTN6GfBl7r2Etb8/ykfY5cVJMveyN3bThlf2wtdZM1vIorPTL5U+rUiZBf7T64r9ROw+bkzqyTaa+Q44xTy9Up5D4vA9D06wqtPJ17h8dPusnNM8fV5ReiT0iqhltMtJ0SBdvG2GO0GFwjKIfeXngTLJTiA55KqsAAyrYelp8TLy/gD9guYIJfTPrZOlerxBQPvaxmVlEhRWLrrHW2ynX9WAwOpwcRt3JQclbmQzEepeUOi1kyuwOg/FbR5WStelzqs9eR2E+MMuqWWeBfwGhijncSEiUhS6xieLLRyndM29Vj6hb8VjIU/lb/dchd5B3emxPbgcoa70rOkhB8WzAC7DMzw4jvA6r0tVy3UQdjgwNFcs2kycNoie4W1ZbsNQ+QPyI2hFgHoCr1wmNwuhU6008+d8Dm3GIuQICgL/0lfN2XcEDPCU23JCiIytyYTGwsEDNa+TMAAl6jRmWcJ98KHkqihzu+ZOA5PmjvsU2imOUBRM4H5TazIDD/gSiADK3+FyesCdUyUXgBaOJmkYaM1Ms7yGCQ2bdZgjoyC5bMbNqyrYAGs5WyKdFs8WNrxFg0nv7JJTCfBIKy8VB64ngzTFzMUo/XYp8tOyoVgqThlA4VuxLXVkNE/GeVOCnvuRUBodEwk0KwFaqzXQzLAZ04rukzXw+Wjw12RP8PXeGynE7YskMbllrFfvyXcKv3dj/WaiM2Ebtal2BL5evIjk4eVepYlRo549cHJX7MahTBWiYIRPBu3UMUQhZ8Sqy5z3XmsT70046wgg305m9Kgq+gkeI9Bu+iwcqCOG4IH4ubwyOV6o+qVxzAGV5gPMweSt6JQ6B5NosqxGz2t7d5KxXVjEWpvaZf5ZWAnetMd226YCbRfwSv0DCukOS++G1pdZbzacWKfcoDkbGNgh8ZKdLX505ebgT7mDSuNgsOCiAkykIulfQyp1PkbZAxR0obgyZVG/nN7UTbi4V75xoJSOA89d81E8WdL7CfkcsZUl3NoZllSvrF1YKKYR1XSKjPTtQ/g0Lnx6B7SdMANmdWBTUiH/r1UC8mWQVpY5KDotKdYv2teNdg3gQieuzgQv6szVP6KwAnbzdLi2VLt+VVJxT+CAuVUZS2DTEpARCS5Yw1tV0CjyAknm42mjXzjQ4DnP+lUHJ0RKjoKCfkLJ/bozbmq0/lwKGvLB+u5IvdO0hsyaOK1AWqqCQM60TVWCiJN71c7q3uH7ln1/+vcjwRwRS+dWh8L7SbXtaWOQte0JczVc0tMdhhoBdW8BIMKMt476eDhGrfxQ3SE5IT2iHvq/m3Pwowyq6Z1e1I4p1hFW8Y3zwMMtVdQ1MKxs9aFJvS7A4aYLBoAj2W14h3kX42+z9am9cyL8iPugiH1mv485+k8tLzRufTWEFdL+4DJAB66dtN+k7BQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5c46b78-2333-499d-39ed-08daad922340 X-MS-Exchange-CrossTenant-AuthSource: DS7PR10MB5117.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 03:13:59.5526 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dTb4ZCoJ4TY6vq/f/oAIc9vWv+GxnKA3+F2MW4/YRlrRcOaWnMjc6K2BjG1gbQ4J25F+Yu8IbUURc47gonQLpXiAQ438249tvaKJ8ZdFbyI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4182 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-14_01,2022-10-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210140017 X-Proofpoint-ORIG-GUID: VgCWlwDxQRs6oks54bePRwP_a7ha_Usw X-Proofpoint-GUID: VgCWlwDxQRs6oks54bePRwP_a7ha_Usw ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665717255; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1b2Agnqraxu+oJn88SnZ5zrHf4rJCayWbQEFBe9+MkU=; b=Y9JO82684jZo7sskzwOhOHBSZnTatRB583/U2A184h9VSPGwISV0V/9GJxjNhTqMQuHvp3 oQwR31EwF1oz4M/WZjXvn0lnQL8iYy5jd8XmwRi3ynW9rqIkHSoE8owluX94edJUxOMJR9 E9MqlndDgJ/u2JUK8kBFq8Q+lkVppmY= ARC-Authentication-Results: i=2; imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=WSlTCLG5; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZfFI8mUb; 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=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1665717255; a=rsa-sha256; cv=pass; b=dX7dqM/csTWxMV8puP6jZ4ixsoWKw9ISYwmD4FgYd4UX6SVcsVeap/Rh6qFQf6iXXwsWc7 YhIBdJrrk+EoKCTrsZMQDijg9WDzFYao9gxXdQi9QrANNQRbXi/9SsV906tzEpShERAAAl jS+BTbF15pcSd2A1YZ/br3f+W0liFfQ= X-Stat-Signature: y1791i87ky11k1j6o9x5ybxrxaaom8t5 X-Rspamd-Queue-Id: BEBD340027 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=WSlTCLG5; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZfFI8mUb; 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=pass ("microsoft.com:s=arcselector9901:i=1") X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1665717255-459754 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: Allows __prep_new_huge_page() to operate on a folio by converting set_hugetlb_cgroup*() to take in a folio. Signed-off-by: Sidhartha Kumar --- include/linux/hugetlb_cgroup.h | 12 ++++++------ mm/hugetlb.c | 33 +++++++++++++++++++-------------- mm/hugetlb_cgroup.c | 11 ++++++----- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h index feb2edafc8b6..a7e3540f7f38 100644 --- a/include/linux/hugetlb_cgroup.h +++ b/include/linux/hugetlb_cgroup.h @@ -112,16 +112,16 @@ static inline void __set_hugetlb_cgroup(struct folio *folio, (unsigned long)h_cg); } -static inline void set_hugetlb_cgroup(struct page *page, +static inline void set_hugetlb_cgroup(struct folio *folio, struct hugetlb_cgroup *h_cg) { - __set_hugetlb_cgroup(page_folio(page), h_cg, false); + __set_hugetlb_cgroup(folio, h_cg, false); } -static inline void set_hugetlb_cgroup_rsvd(struct page *page, +static inline void set_hugetlb_cgroup_rsvd(struct folio *folio, struct hugetlb_cgroup *h_cg) { - __set_hugetlb_cgroup(page_folio(page), h_cg, true); + __set_hugetlb_cgroup(folio, h_cg, true); } static inline bool hugetlb_cgroup_disabled(void) @@ -199,12 +199,12 @@ hugetlb_cgroup_from_folio_rsvd(struct folio *folio) return NULL; } -static inline void set_hugetlb_cgroup(struct page *page, +static inline void set_hugetlb_cgroup(struct folio *folio, struct hugetlb_cgroup *h_cg) { } -static inline void set_hugetlb_cgroup_rsvd(struct page *page, +static inline void set_hugetlb_cgroup_rsvd(struct folio *folio, struct hugetlb_cgroup *h_cg) { } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index bcb9bfce32ee..4d98bf7ba81c 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1758,19 +1758,21 @@ static void __prep_account_new_huge_page(struct hstate *h, int nid) h->nr_huge_pages_node[nid]++; } -static void __prep_new_huge_page(struct hstate *h, struct page *page) +static void __prep_new_hugetlb_folio(struct hstate *h, struct folio *folio) { - hugetlb_vmemmap_optimize(h, page); - INIT_LIST_HEAD(&page->lru); - set_compound_page_dtor(page, HUGETLB_PAGE_DTOR); - hugetlb_set_page_subpool(page, NULL); - set_hugetlb_cgroup(page, NULL); - set_hugetlb_cgroup_rsvd(page, NULL); + hugetlb_vmemmap_optimize(h, &folio->page); + INIT_LIST_HEAD(&folio->lru); + folio->_folio_dtor = HUGETLB_PAGE_DTOR; + hugetlb_set_folio_subpool(folio, NULL); + set_hugetlb_cgroup(folio, NULL); + set_hugetlb_cgroup_rsvd(folio, NULL); } static void prep_new_huge_page(struct hstate *h, struct page *page, int nid) { - __prep_new_huge_page(h, page); + struct folio *folio = page_folio(page); + + __prep_new_hugetlb_folio(h, folio); spin_lock_irq(&hugetlb_lock); __prep_account_new_huge_page(h, nid); spin_unlock_irq(&hugetlb_lock); @@ -2731,8 +2733,10 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, struct list_head *list) { gfp_t gfp_mask = htlb_alloc_mask(h) | __GFP_THISNODE; - int nid = page_to_nid(old_page); + struct folio *old_folio = page_folio(old_page); + int nid = folio_nid(old_folio); struct page *new_page; + struct folio *new_folio; int ret = 0; /* @@ -2745,16 +2749,17 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, new_page = alloc_buddy_huge_page(h, gfp_mask, nid, NULL, NULL); if (!new_page) return -ENOMEM; - __prep_new_huge_page(h, new_page); + new_folio = page_folio(new_page); + __prep_new_hugetlb_folio(h, new_folio); retry: spin_lock_irq(&hugetlb_lock); - if (!PageHuge(old_page)) { + if (!folio_test_hugetlb(old_folio)) { /* * Freed from under us. Drop new_page too. */ goto free_new; - } else if (page_count(old_page)) { + } else if (folio_ref_count(old_folio)) { /* * Someone has grabbed the page, try to isolate it here. * Fail with -EBUSY if not possible. @@ -2763,7 +2768,7 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, ret = isolate_hugetlb(old_page, list); spin_lock_irq(&hugetlb_lock); goto free_new; - } else if (!HPageFreed(old_page)) { + } else if (!folio_test_hugetlb(old_folio)) { /* * Page's refcount is 0 but it has not been enqueued in the * freelist yet. Race window is small, so we can succeed here if @@ -2801,7 +2806,7 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, free_new: spin_unlock_irq(&hugetlb_lock); /* Page has a zero ref count, but needs a ref to be freed */ - set_page_refcounted(new_page); + folio_ref_unfreeze(new_folio, 1); update_and_free_page(h, new_page, false); return ret; diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 600c98560a0f..692b23b5d423 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -212,7 +212,7 @@ static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg, /* Take the pages off the local counter */ page_counter_cancel(counter, nr_pages); - set_hugetlb_cgroup(page, parent); + set_hugetlb_cgroup(folio, parent); out: return; } @@ -894,6 +894,7 @@ void hugetlb_cgroup_migrate(struct page *oldhpage, struct page *newhpage) struct hugetlb_cgroup *h_cg_rsvd; struct hstate *h = page_hstate(oldhpage); struct folio *old_folio = page_folio(oldhpage); + struct folio *new_folio = page_folio(newhpage); if (hugetlb_cgroup_disabled()) return; @@ -901,12 +902,12 @@ void hugetlb_cgroup_migrate(struct page *oldhpage, struct page *newhpage) spin_lock_irq(&hugetlb_lock); h_cg = hugetlb_cgroup_from_folio(old_folio); h_cg_rsvd = hugetlb_cgroup_from_folio_rsvd(old_folio); - set_hugetlb_cgroup(oldhpage, NULL); - set_hugetlb_cgroup_rsvd(oldhpage, NULL); + set_hugetlb_cgroup(old_folio, NULL); + set_hugetlb_cgroup_rsvd(old_folio, NULL); /* move the h_cg details to new cgroup */ - set_hugetlb_cgroup(newhpage, h_cg); - set_hugetlb_cgroup_rsvd(newhpage, h_cg_rsvd); + set_hugetlb_cgroup(new_folio, h_cg); + set_hugetlb_cgroup_rsvd(new_folio, h_cg_rsvd); list_move(&newhpage->lru, &h->hugepage_activelist); spin_unlock_irq(&hugetlb_lock); return;