From patchwork Tue Nov 1 22:30:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13027543 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 9836FC433FE for ; Tue, 1 Nov 2022 22:31:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 109426B0072; Tue, 1 Nov 2022 18:31:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 093516B0073; Tue, 1 Nov 2022 18:31:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8A486B0074; Tue, 1 Nov 2022 18:31:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C2D726B0072 for ; Tue, 1 Nov 2022 18:31:43 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 83BF9160947 for ; Tue, 1 Nov 2022 22:31:43 +0000 (UTC) X-FDA: 80086321686.13.D9535B3 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf25.hostedemail.com (Postfix) with ESMTP id 0A867A000D for ; Tue, 1 Nov 2022 22:31:42 +0000 (UTC) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A1M4RI1022369; Tue, 1 Nov 2022 22:31: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 : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=0y7U4m1rgtY/XjIHSb406R686+vacpNNe3hnGCIrPrQ=; b=dX7mUKbW6thO5lLJCYsM4GvK52Lib1DL+WIGWzl9TrqGm0I9RQFLcj8B8fHm8WIGxY12 mq4FW4uffUjc1kb+MuHeZrxaH3yaSI+fofQLuVSaOOGyA5Rpa/Ok8wXCbfoE8c87eF3O 03LB7yG/HakuZAClYBZEe+O5LcY2TLWLWPmd0+77cUayqIxk7ra0o8wOvRol9YVUA7wU YvvC2YZ8nT5sq8wnf7Wer5czmVYPIBgeI5Eqh+UWJ7ufduMelvEBn9W0tL7X6OTSx/T1 NceMD12IAT377Qd13LWMRJKld/PEJVcGx/9qfR5XzVndglZrO2vTbrTdoUJo4Iicj7RF 0A== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kgts185c1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:31:34 +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 2A1KS202014193; Tue, 1 Nov 2022 22:31:33 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2040.outbound.protection.outlook.com [104.47.57.40]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kgtmay6k3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:31:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oXnswm1HAn68UIehYYBWBiuxggCp6zfTcAnziNpas282yVlddUYDEEKn/N2H+ga5ZXURbMJ52lxQA25K/C0wGlm8YopBcxZL02tuzk9yfFhG9YCMJSGyk/YsFE1NXBIEQ8bPLxFu2lFa4CI6HuZ6SqoDMz+NoIPYpUOrW+SRVmbfod+ohcGapRb27DADk7mvIwvAcU8SqU37Tfo5vDYaSzOHAGUk/HA5cqsTHElh2tRg76B46hhnfgbmoPC1QvyFDeJCLtbgCjOJCFSf02CScQxFIlb7N7JJ4TNMknedWT36xhmNE0qSiocsPzsNLUn6XEj7WEsI3bxu2Iz8aeLeFA== 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=0y7U4m1rgtY/XjIHSb406R686+vacpNNe3hnGCIrPrQ=; b=acK1GOgfMZPfGaTm8A4WevypDENSde3WJvyKTIqwNGtkYzs56gBkskFR0kDGvKyVMvmgpch33h21or5bGTjMFxPFR0mdhpWSTPzLe7tl0N1n8Dul78czMftqgK1Y3DVIsWcFKT1rFgid3Gz7ACP33AyxRE74/eBJ9mi1dSzdnYSZC3umhKoZy9U53W/WjISzANMisuzQXnwxS4WF2LcIPCVRvOZSjxVsw/c1/joWNMxd89ejVNQnihg7CM0s/ZKPFiAmPp/8HwsUPkunxQEHkoV8X72yTmXcmdkFC0cVjcfShXkQCspXTq6o/EWL9SQIPYRLkCEPuLKLbG7UGxla9Q== 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=0y7U4m1rgtY/XjIHSb406R686+vacpNNe3hnGCIrPrQ=; b=ZigcA0rdMbcJ5l/+5UXoQKvBUPipb+JMM+vgYrISUFxxKnjm2OFtLo1uISxGC8jMovLymIPcl6culz74QpqbjXBCXCupDk6wn3GUoGXs7Ij9OXRddyNlLFJl/U+mfvGOCB90Yq875czBWCYFP4qJoBNGrd34+WyxE2eXCtF0X3A= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by IA1PR10MB6075.namprd10.prod.outlook.com (2603:10b6:208:3ad::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.21; Tue, 1 Nov 2022 22:31:31 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954%4]) with mapi id 15.20.5769.019; Tue, 1 Nov 2022 22:31:31 +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 v2 1/9] mm/hugetlb_cgroup: convert __set_hugetlb_cgroup() to folios Date: Tue, 1 Nov 2022 15:30:51 -0700 Message-Id: <20221101223059.460937-2-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221101223059.460937-1-sidhartha.kumar@oracle.com> References: <20221101223059.460937-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: SJ0PR05CA0195.namprd05.prod.outlook.com (2603:10b6:a03:330::20) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|IA1PR10MB6075:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c06e1c3-2ed4-40b3-07df-08dabc58d31e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3eDUFZtxqU2e8W3zC7XuW9flI3m7JMMpUb2exux2+2PGy+o4kazCIIzUSt+r8Fiux8KbDn3J0TkpkQHLbYrEcFx/NpKl+kRiU0yoL5xyH3YwL9w8QYQ1slxx879LaYpqyw39MXGj0iFb306huSXmopMDTnKAeGnVgLVAEM+wrzPg7NAAA5kWnVnL/AoFV2OPnIodNa7qDuFtFrBdXSyTQ8kFTiZtjfDsEdlYZmzn0xo/K9J8schA/sy4eLbk5nQjzPi2aGnAc/TYdluhGnMlf42wH4Q2WY5uEtu4JD5fu4K6Aw90vTRMPXSdRZ2X0yKlYGJjZD2H5C1E1ycPKUrigiJTbG31GF7nUb7O77eqCAKgpHzXCirrax9fYXl1iz4RsLrzw0zvsTmiZbRaBgiZrwFRj1G1jb3Ad1nLWCI3XwpXAS2zIa8rdPmMPu9pZI6VcMf8KZ7mTEVeV+SCZWaNkYmazpiqoITSxq/UA+Xq5Az3txYOA1qr3CAElGvgK9tJL8VySwKDYAK5UHOVxoaiOCF4NDXn+zz3937mkIDl/jlZh1asYO5SkhRWGAGK/CiDiki8wHXAtRsJFRTxVYS9GWFRHHeJM7T5v6jkIKkpF+Rgiz46YWwFkygYxnuhg1sqdwLwe3JC6cUHFZtsMdUUu6QT77C/GjoSqIZK2C8lEV3xH6wIAMM0TH7rVwhRmpVqBMih1BzMJZIMcjqWLczzVg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(136003)(376002)(396003)(346002)(39860400002)(451199015)(36756003)(86362001)(38100700002)(83380400001)(2906002)(5660300002)(44832011)(107886003)(2616005)(186003)(1076003)(6666004)(6506007)(26005)(6512007)(316002)(478600001)(4326008)(66556008)(66946007)(8676002)(66476007)(41300700001)(8936002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IP/PHilhxeLZYLbw4UsjUl9JGT8dQFQvJgAvLwOxhILe5rL8mhz7Nm3p+fyUqN9QubYkUkc5b8pVhPmS7dUS7XGMclMhcCGDZaZ0zJllYT3eO8tmEOOGCSWR3LU27hQiDmaS8LnUjOQW3ceRf9CIGFhjpjaSbkugjGLneKQJAz4ZTxOHnx4qGcgy3Qe2/e9nHkWekbyuX1AODqgqREb2tabOQs408/pAu55W7esg+DV2IAJw1+XVdcEvWcHmSRMCez7Oc9kNQMRMA0EitU4nSkckVuxX5Qq0mG7VgR6ajwkN29fSSXcisZzgZpUBBd0abe9HlPiPeL9y90848NOtVTW3rpLC1lLFIxz7BPOFrVuFQLNP4HSxVMU7W2MRbdH7jmfVPYxeO2MRkl5ej4lyFFlXsBbcdiv2L93q8e/qTIHhIiNLKV7/5sAL6wzccK1bQ5Dj+3Uoul3F6rH7bo2FITF23orgACoS9BU7EiEkzhF2FY04ShPV9YbjY7byh+hisirEZbOhV25/7a1d3yYG/UbRqPGBE4Rq9aei3nLd/vvuXTv5Ifh0/TTkM515dAssA7sya8lh21Lml8j7GhU16DlnpWrry/WskpdM7ndKoBUuywqVxNYDIc66vWtSS8P8IPLs9AcVc1oe2rC3jGgKn2vfDWa3jxzwsGqwLLYOJ0hdpLvqDTvPkYVZvrMdT/BfN6Oz5pBkT8WDjVOPcpi81ISjxiPVF4LsVXk+QjaG7m41ISRuYfJDmv1lO9ssrNK5WKJp3DppqlX5cZUomoum1dastdjZIJK6ARxhqdGDF+48wky5708eHCXnD12mfZ94iDYBL8rU0EeDuuPMYNoWrusu63IvJOzEpEQIzXY6xvnxSLX7tljo8TVlwnvRt5JOdGKVl1ChnbQKMohEs+xQNxW40XcjYkyPIPPq/o7+QTPnpDm3t1ZaFW0RqzZRp6PRGmBZryh3UGgiVNWAUlPtDxQ/oUhyK4hMX6yaY16QZiASnTmp2HQ+PUhxbkha/RoE7SKj95sdRsA67SMmWNuVTQTcUrfzS11fdgEYQ+k1Gy02QomVOAxEVDOsl2UpSaVzsPD7N8HU2N42aDJ0Cqc35CuoA+pZRXocaMzebEyijDL4ZwLxgz+aAwxA6wCEPY+unMs97AjDEyeB0uz2b0DOcIxm6q1mDKnBFqzkuX8oSNoLVGA+nDSIoV3551x4p0BAvSdUvb/jRWBlkubXONWbWWqhnvEZPf8mSMCCXxVWmw6Getj25bV00DKloJf6GsL0S915UHndMaoQHTuoNV1nRikndavI5bD2aNJd+Mpfmj/LQqIrLmGVarycKeU1L4uQa6pRNZlTnCh7UsCiQgzzLlaJoxl1kk+hba1VwWc/fRHP+kPkbJPPArPLozrr6PPW6Ly4vRwwitbTMEHoTzyTzcDDCbxW4gcrHkLWt92qSLkeP6u6D3TnXU6EUJpmqcJwqyZNK+tEXd+kbmKCAu2lpheRXgeVOWrKeoainKT3xuzmRifDSlAoZNWeCtdzdMUCns2k6Jm3grO6RUhBMB+2dEEbT7p6kmjoZzuEn8rrjFjxob6VXIdg5bLcWJpHWNlYVfuB6a09L85OFhb9onWvFw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c06e1c3-2ed4-40b3-07df-08dabc58d31e X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2022 22:31:31.2701 (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: 1tjcug+k4Jut4EsNRYFKxBzte4YWyUJeBQHCZUJAO5U0bLsci79aehNVojpp38RKR+/y4K2E2mWCFDfxdop7A5/YTB9Y6d7BOaBVuVqerk4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6075 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-11-01_10,2022-11-01_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211010153 X-Proofpoint-GUID: YTOsMfqqGSGZ3dvVGy2Sd7nTZy5YGTus X-Proofpoint-ORIG-GUID: YTOsMfqqGSGZ3dvVGy2Sd7nTZy5YGTus ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667341903; 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=0y7U4m1rgtY/XjIHSb406R686+vacpNNe3hnGCIrPrQ=; b=MVm9F2CaP8sOwUVCqM7IAj2p48/QFN5xr+if97ZuccxvBsKzCU6/Iidxg4nDlDd2nr1vpv BPrTKwABsJgEAQkKdIId+aQfjUqpd1JEX4W6swqscC0Pw065I6xmb5KK5w8fjeyQUUB4rq Sjspof2pVSVcy3pj0ms01/kkyWVP2B0= ARC-Authentication-Results: i=2; imf25.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=dX7mUKbW; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZigcA0rd; 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=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1667341903; a=rsa-sha256; cv=pass; b=qXvr3fd2utHC21nk1k12gFQhgJbDucVKKLR7MyEMPUexiQv+tdSbKV839ysvLP1Aaw5gUn Yxs/KOltVkRtUxRcp8Tv2e37wCO2nTu4L1TZaTP1ughHHEQgSbUCR4x4mbtHxTyaM95IgZ lzu6SwgEssTM115uBQSVHSCSxu2vUAQ= Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=dX7mUKbW; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZigcA0rd; 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=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com X-Stat-Signature: kri7h1reg8firb4zg7qpean94nh75r3n X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 0A867A000D X-HE-Tag: 1667341902-469719 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: Change __set_hugetlb_cgroup() to use folios so it is explicit that the function operates on a head page. Signed-off-by: Sidhartha Kumar Reviewed-by: Mike Kravetz Reviewed-by: Muchun Song --- include/linux/hugetlb_cgroup.h | 14 +++++++------- mm/hugetlb_cgroup.c | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h index 630cd255d0cf..7576e9ed8afe 100644 --- a/include/linux/hugetlb_cgroup.h +++ b/include/linux/hugetlb_cgroup.h @@ -90,31 +90,31 @@ hugetlb_cgroup_from_page_rsvd(struct page *page) return __hugetlb_cgroup_from_page(page, true); } -static inline void __set_hugetlb_cgroup(struct page *page, +static inline void __set_hugetlb_cgroup(struct folio *folio, struct hugetlb_cgroup *h_cg, bool rsvd) { - VM_BUG_ON_PAGE(!PageHuge(page), page); + VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio); - if (compound_order(page) < HUGETLB_CGROUP_MIN_ORDER) + if (folio_order(folio) < HUGETLB_CGROUP_MIN_ORDER) return; if (rsvd) - set_page_private(page + SUBPAGE_INDEX_CGROUP_RSVD, + set_page_private(folio_page(folio, SUBPAGE_INDEX_CGROUP_RSVD), (unsigned long)h_cg); else - set_page_private(page + SUBPAGE_INDEX_CGROUP, + set_page_private(folio_page(folio, SUBPAGE_INDEX_CGROUP), (unsigned long)h_cg); } static inline void set_hugetlb_cgroup(struct page *page, struct hugetlb_cgroup *h_cg) { - __set_hugetlb_cgroup(page, h_cg, false); + __set_hugetlb_cgroup(page_folio(page), h_cg, false); } static inline void set_hugetlb_cgroup_rsvd(struct page *page, struct hugetlb_cgroup *h_cg) { - __set_hugetlb_cgroup(page, h_cg, true); + __set_hugetlb_cgroup(page_folio(page), h_cg, true); } static inline bool hugetlb_cgroup_disabled(void) diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index c86691c431fd..81675f8f44e9 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -317,7 +317,7 @@ static void __hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages, if (hugetlb_cgroup_disabled() || !h_cg) return; - __set_hugetlb_cgroup(page, h_cg, rsvd); + __set_hugetlb_cgroup(page_folio(page), h_cg, rsvd); if (!rsvd) { unsigned long usage = h_cg->nodeinfo[page_to_nid(page)]->usage[idx]; @@ -359,7 +359,7 @@ static void __hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages, h_cg = __hugetlb_cgroup_from_page(page, rsvd); if (unlikely(!h_cg)) return; - __set_hugetlb_cgroup(page, NULL, rsvd); + __set_hugetlb_cgroup(page_folio(page), NULL, rsvd); page_counter_uncharge(__hugetlb_cgroup_counter_from_cgroup(h_cg, idx, rsvd), From patchwork Tue Nov 1 22:30:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13027544 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 66307C43217 for ; Tue, 1 Nov 2022 22:31:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 049566B0075; Tue, 1 Nov 2022 18:31:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F10756B0078; Tue, 1 Nov 2022 18:31:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D3C7D8E0001; Tue, 1 Nov 2022 18:31:52 -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 BFA6D6B0075 for ; Tue, 1 Nov 2022 18:31:52 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9686E1C4846 for ; Tue, 1 Nov 2022 22:31:52 +0000 (UTC) X-FDA: 80086322064.19.4209911 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf20.hostedemail.com (Postfix) with ESMTP id 1ED1A1C0006 for ; Tue, 1 Nov 2022 22:31:51 +0000 (UTC) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A1M4JkR022298; Tue, 1 Nov 2022 22:31:44 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=SoiSZrAfuSEEqpTJ9G+tvTZwSqBKFi2fmlrDiYEXpPk=; b=gjMgF6IKhIskf7KabNrBJ5DCrYJpZG9GffF+udzbzL0HHayMmSLppOrsV+mh1mldZhB8 Iwoe/3cA3aDPMlOx/k6LR4L37eU4XbCFtEUpS/sWWn1cKrzXnc6dUbU4IoeztcyYFu0M eYcpS4h0NXWnGQL2K9QVDSlMEIm2xUMlfzJgv8O/MzLPC8GxUgObLu1Y2CwmGv0b6Imr usAqdnVTyFWCNchoDE0rzMuzBPlklaewSEwMwtcL1Vb0/Pqy4GAIAamef8YmhcK9G/6e BCcKLrw6mlUvMB3dlKo21Dskj7gISvSlhVhfVqcy12IhDWpYVVOmnu52Xvd7gfia7Zim lQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kgts185c9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:31:44 +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 2A1Kkd8m030335; Tue, 1 Nov 2022 22:31:43 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2042.outbound.protection.outlook.com [104.47.57.42]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kgtm4x6ph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:31:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A8xr1bkltI3vN5I3Xg9aUpVbWaO5XNnh99ERhC0uYbILFe8/g1xot/+fEzyk/o5Stsi8UrXfs8BbIeUWorhbqWkTUaKZ00Eq2gT6g9oUjdWYRh/OIGCNWZhpDpZReNSPNViVa88oOSRvwcpBncsB8+fyL7mDVTAKk2A9SL7vanyqrP/V91QW2ZCJFrEdfJC8WfxwByBVn2GvYQMLWXI/jmpLch5YE+JTE4KViql8BbxNPEnHms0j/S/pU4w1E5iiGNp3rr1wutIC8yl4tQWTy/xSFGLcgFupOB9lTTiHiULwyZVsk3QxdpbWSSlHR0vaw7P7JL3SEvWlXSVoymzEAQ== 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=SoiSZrAfuSEEqpTJ9G+tvTZwSqBKFi2fmlrDiYEXpPk=; b=H8GB9bSAmUM4GBbeYCDCU5IdwyNcwKUo/Nvx1D+MH+GX+tzbwAlIIF+sL5NhCX4R7i/cIlFuckBAfM4OqCj/z+bPO22/cPdm8Uf1TAvv+nsJJUKBeh3JDJQZxNDXBf+SgcbXWGpypitAPH8qvduHyMLV8TGco253z1pXorsu+af46buaujSKSJw0amPMb+3qGmhdIIGr0p04D8dsnpCVo15ev/fbbsj5gFKyJ/GcF3p4/V3QtRaV3DV/9bVUYFtLKW9fV22c+09lmpakGOy049n1uAY4rXXsrEP0TWR7ACt4sNQAiqPpn9MJgWcZQgYWlQzMOtlTjuS1dlhwYXTYIw== 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=SoiSZrAfuSEEqpTJ9G+tvTZwSqBKFi2fmlrDiYEXpPk=; b=ASEqAG6jQLDaH42agdItsrYtyEF56jqGudHxBZ6SpDbaXuWePqYFG1EIiYI8BKmg2NkwJ7bG8UpOi3gSI71wjMNRjBeuAQ9kUiVVJg0f0XqhbYMeizDvBGx8E9bCFeIUEe4fmIZIqmh/dsZ3BBw+bBQAnaLy8MPETBO9TNxj55E= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by IA1PR10MB6075.namprd10.prod.outlook.com (2603:10b6:208:3ad::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.21; Tue, 1 Nov 2022 22:31:41 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954%4]) with mapi id 15.20.5769.019; Tue, 1 Nov 2022 22:31:41 +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 v2 2/9] mm/hugetlb_cgroup: convert hugetlb_cgroup_from_page() to folios Date: Tue, 1 Nov 2022 15:30:52 -0700 Message-Id: <20221101223059.460937-3-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221101223059.460937-1-sidhartha.kumar@oracle.com> References: <20221101223059.460937-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BY3PR04CA0019.namprd04.prod.outlook.com (2603:10b6:a03:217::24) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|IA1PR10MB6075:EE_ X-MS-Office365-Filtering-Correlation-Id: 94aaf729-55aa-433f-0bec-08dabc58d949 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hD7Nc8ksVvD6yrBpHKF3Y3VIN8uBAXlYiWrK4XAKJl3ouUE+DnDRlZsL0Eel16hMnwhf9ln7ti70RAEf7wMlqRCibRLB50+znuYqzu9Tu9G6Vj0VbzccsXPdlPbJuAVuLSD3Zm1dsgnoM/uCu6b+x3nX8ggEi4WAYp0/lg3cnjkChV8NHjtRuPrzxTeRBQO47j8Ir9VPU8aHRSA/H7lKkWflY48BRaUSXiB0TqxDuND46zMIGl8KYBRXWt6THbcTUhzqHpFuMJ9pQV8DP8v3Gy7eMf5x1QGUb/aGiGfoUyScqK3TFXu+Um9FIPZF7YgRR7Bpq7idFH3tKNOTB+byjgqpclGCec2w28mCkPLdyzK/adWFFJ/O8PUc/L1JCYVVC7jEW3Ozd5VcFJ4Oj1EPG1yefNd/bCZSrq4okV+kqOHYPoYv3MKnBIlvd4Jb3/CTnmnaiD5wSzKna1F3TmNjAv3MHNgg65GRiznfqbaaOrYwVIjy/Uu1nGArVg6AbFw8Za0pH69veZRs4VtT071dQlOlPl5pD4ir8M24nc94eOPMb8KMMg1zqgRgUohdSNHRTtu8lrXDPGng5sY/1f7C5pwRVHMKZGE1rQIumcbmA2KnM8uHKaMnOYnfISwChD0nV4rJlF4kH/f+e/QYM7T1Sn49ShXtrD6IMOGkbL8TLYb1n/Abnc7dQIAosArNGqaW/lCRbMppQ2t3aKDXo9srmQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(136003)(376002)(396003)(346002)(39860400002)(451199015)(36756003)(86362001)(38100700002)(83380400001)(2906002)(5660300002)(44832011)(107886003)(2616005)(186003)(1076003)(6666004)(6506007)(26005)(6512007)(316002)(478600001)(4326008)(66556008)(66946007)(8676002)(66476007)(41300700001)(8936002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bsucmbyEmhjQqVBnqS7Qm7AeDMDKNzuKyPp8sbI1tPNs+iF/AGXIEY70rVXkLee8TAeTqH6Xj+Io/0uSy0POrJ5SOVVvIT80I4XTGF/jikv6ST1xk4v9PvVnv31qQ1+EnXqtV6H3HLYl43PXU1/5x/Dk3B9aSvg4JA+eoq8v6XYSVwg1oYXmsRZk0zQXFyFjCMp005F1SL1lOUI5Kxl+Iuygp1USHpqd+3+00UzlROi7s9kDZW0lVcn4K1ofu0JQ1DaIyBWMFKvtXrKUgHwDM4gEseWmoY0GPGNZePinnPiHr2QLRarhPq7wksM/Wlbxz7r9gIubnnWQ/+mtxsxGrZModQvxaJabyq6Ui5bbHauiwTfyMOeXlHh5a8fb7YAkrmOyB3BUYu0JQVDIQFyDo4XNI0S24oBT3ttloGFj2FaIjZUxqSZbWAlArb28M4i6E2vPz9yzMiSMhKHrblskPF4OzcTmHSxsvz0P/yTT4QMGMVGTClRY3YXOD90vCr5aSDzhHYO/aLSL8T8MdSzqgp7RZ8yyQxLTW6TJeiNfiohSZvhIWTDJVHmk15uB9oMVo7j+mQrO73gSJfif+FveQkANDcNd/qBRVcepUJBY/Y8iTQLKURjHZwme0uNH5E+0weEKOqr6q4EycxzYn3PkNl6skXi3bxCN6MZpfGWQRbhlbXIocgw5o9RL8j45Mi8pzVLNPk6qSf1EXFJB5W1yJZH6tjGwSM9p7Ev8GmOq5w1sS0NsAa8hGVBCfZbKUZ8X7hnEefn4/wUALd6eXtzhUbaGsrNSqIs01+NHEWNzhUgZln+MP81iXbhLFxwlX28ZzeYyYlAQyOlOCi8XIWjJsSxeIeTp79b1KAMZp/h/VfYZnauzonWNx7NaQbtI2LOuJcnOVTTVUuYQFVrsjHHl0qm28pLuuee2KjBizo5Xcx0ZjvUa0AQGxzIflmncnyUNgcx0tFhz/hkhcNT6Z2ikTJ9L1q+lb9lBxmjnWmtGH0MuX8Z+qIasmei1xA9dT1+/wrIsaIXG+wkCx9R9JoUwHWZZ28/J8yNr69KoW0xGjAk2cZBtL+fWqvVGWZimO0UgzNSs/yZ1AzJhD9H0RrdKq2sexNEsrEvUVrkXY99iEd4/ejTxaGq1Pr8KA8Q8nOuFKtHX6b0qfNalnbTcXMDdhs+bcn2MMN9+ndTycBi4+VLglKKNUI7BtliO1ldjrOQsixRIw1u60PYV+f48OGyaX6LTAUB2ncGXhgcwweO9ql5WSeV2c4EM+mjsfk9oTUeVOJG7cHQMj3UuvBkdXHz2y3+VNtCzI07y1Pp0WtgDYL3ZpPURUB5Ep3IPDEipuJP7UQ3PKElcFsnDsVpeweuQFzBeArDFwjAtDC+mXohSd7amp6ye7u94uAJCJRkeaATLTu5kI4XSnSh466zs8oEDzQ4fQ1JiYD7ireZywQF5PP1F5EJNxiiyZGQgiTnHf+zUQMTdFBbg4qdT7Zr+310P0QFUkuXNZhDWL1GNedcBwO+NihBMb8WSuNBC/DvowqV9Tx7HuLjFOLFHqZM0KxEw2YbgBHboWrE4ibkh0K22hqzqpE5sFBPiwYWIdMFbJnWWPhJaAEb3mCy0Q4haW4TBPQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94aaf729-55aa-433f-0bec-08dabc58d949 X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2022 22:31:41.7589 (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: 3iUgagMhTJLIxyP8vgDvQ7tM/9t9VFqm+0TIBWDFE9OKL7hiaOUZZD6xmdYuMD3GZ+zkpdhK+lEpnQ5JnBpbglxarRXMcZIubqsRfqn79KI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6075 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-11-01_10,2022-11-01_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211010153 X-Proofpoint-GUID: SEtxQbJ1PNByXguBpFBl4bFlbgLavqOv X-Proofpoint-ORIG-GUID: SEtxQbJ1PNByXguBpFBl4bFlbgLavqOv ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1667341912; a=rsa-sha256; cv=pass; b=wxXAxaM/u8wivYVns+xbBgL6YYRA+kNymt4IStc7CtlxmdHnKniZ1kZ703u78TRYBkD91v zmphIyzt+n3/Rle+1hkWCooCUCI1a0zPnFhhuEtVoKQ41I/p3vwr9hJL164ZQj9i/5cnrW H9JSe1jYb3svQ2Ty2PFC5jJOH3ow71s= ARC-Authentication-Results: i=2; imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=gjMgF6IK; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ASEqAG6j; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf20.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-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667341912; 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=SoiSZrAfuSEEqpTJ9G+tvTZwSqBKFi2fmlrDiYEXpPk=; b=a4LtLYWlffwPByIcXinZ/ENVT8pT3NJ0DUnGbnVRY/ZrVMxoggo3eFULjkIodoA4TWj9dF cBwZ7O2BY2CYBKVa+9C64KZosoDWhYRRRg0QvU5vG1suBNfsN/ADI2wCB76xon7B+6h6BX 2UpkNXaAHedc8TqjqLS65TwW1iROURo= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 1ED1A1C0006 X-Rspam-User: Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=gjMgF6IK; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ASEqAG6j; dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf20.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-Stat-Signature: ocw8zxsnrywoonxdp1ap6s3t8fh3c6me X-HE-Tag: 1667341911-793358 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: Introduce folios in __remove_hugetlb_page() by converting hugetlb_cgroup_from_page() to use folios. Also gets rid of unsed hugetlb_cgroup_from_page_resv() function. Signed-off-by: Sidhartha Kumar Reviewed-by: Muchun Song --- include/linux/hugetlb_cgroup.h | 39 +++++++++++++++++----------------- mm/hugetlb.c | 5 +++-- mm/hugetlb_cgroup.c | 13 +++++++----- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h index 7576e9ed8afe..feb2edafc8b6 100644 --- a/include/linux/hugetlb_cgroup.h +++ b/include/linux/hugetlb_cgroup.h @@ -67,27 +67,34 @@ struct hugetlb_cgroup { }; static inline struct hugetlb_cgroup * -__hugetlb_cgroup_from_page(struct page *page, bool rsvd) +__hugetlb_cgroup_from_folio(struct folio *folio, bool rsvd) { - VM_BUG_ON_PAGE(!PageHuge(page), page); + struct page *tail; - if (compound_order(page) < HUGETLB_CGROUP_MIN_ORDER) + VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio); + if (folio_order(folio) < HUGETLB_CGROUP_MIN_ORDER) return NULL; - if (rsvd) - return (void *)page_private(page + SUBPAGE_INDEX_CGROUP_RSVD); - else - return (void *)page_private(page + SUBPAGE_INDEX_CGROUP); + + if (rsvd) { + tail = folio_page(folio, SUBPAGE_INDEX_CGROUP_RSVD); + return (void *)page_private(tail); + } + + else { + tail = folio_page(folio, SUBPAGE_INDEX_CGROUP); + return (void *)page_private(tail); + } } -static inline struct hugetlb_cgroup *hugetlb_cgroup_from_page(struct page *page) +static inline struct hugetlb_cgroup *hugetlb_cgroup_from_folio(struct folio *folio) { - return __hugetlb_cgroup_from_page(page, false); + return __hugetlb_cgroup_from_folio(folio, false); } static inline struct hugetlb_cgroup * -hugetlb_cgroup_from_page_rsvd(struct page *page) +hugetlb_cgroup_from_folio_rsvd(struct folio *folio) { - return __hugetlb_cgroup_from_page(page, true); + return __hugetlb_cgroup_from_folio(folio, true); } static inline void __set_hugetlb_cgroup(struct folio *folio, @@ -181,19 +188,13 @@ static inline void hugetlb_cgroup_uncharge_file_region(struct resv_map *resv, { } -static inline struct hugetlb_cgroup *hugetlb_cgroup_from_page(struct page *page) -{ - return NULL; -} - -static inline struct hugetlb_cgroup * -hugetlb_cgroup_from_page_resv(struct page *page) +static inline struct hugetlb_cgroup *hugetlb_cgroup_from_folio(struct folio *folio) { return NULL; } static inline struct hugetlb_cgroup * -hugetlb_cgroup_from_page_rsvd(struct page *page) +hugetlb_cgroup_from_folio_rsvd(struct folio *folio) { return NULL; } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 518dfd0a7dbe..27b87dc85c48 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1434,9 +1434,10 @@ static void __remove_hugetlb_page(struct hstate *h, struct page *page, bool demote) { int nid = page_to_nid(page); + struct folio *folio = page_folio(page); - VM_BUG_ON_PAGE(hugetlb_cgroup_from_page(page), page); - VM_BUG_ON_PAGE(hugetlb_cgroup_from_page_rsvd(page), page); + VM_BUG_ON_FOLIO(hugetlb_cgroup_from_folio(folio), folio); + VM_BUG_ON_FOLIO(hugetlb_cgroup_from_folio_rsvd(folio), folio); lockdep_assert_held(&hugetlb_lock); if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 81675f8f44e9..600c98560a0f 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -191,8 +191,9 @@ static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg, struct page_counter *counter; struct hugetlb_cgroup *page_hcg; struct hugetlb_cgroup *parent = parent_hugetlb_cgroup(h_cg); + struct folio *folio = page_folio(page); - page_hcg = hugetlb_cgroup_from_page(page); + page_hcg = hugetlb_cgroup_from_folio(folio); /* * We can have pages in active list without any cgroup * ie, hugepage with less than 3 pages. We can safely @@ -352,14 +353,15 @@ static void __hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages, struct page *page, bool rsvd) { struct hugetlb_cgroup *h_cg; + struct folio *folio = page_folio(page); if (hugetlb_cgroup_disabled()) return; lockdep_assert_held(&hugetlb_lock); - h_cg = __hugetlb_cgroup_from_page(page, rsvd); + h_cg = __hugetlb_cgroup_from_folio(folio, rsvd); if (unlikely(!h_cg)) return; - __set_hugetlb_cgroup(page_folio(page), NULL, rsvd); + __set_hugetlb_cgroup(folio, NULL, rsvd); page_counter_uncharge(__hugetlb_cgroup_counter_from_cgroup(h_cg, idx, rsvd), @@ -891,13 +893,14 @@ void hugetlb_cgroup_migrate(struct page *oldhpage, struct page *newhpage) struct hugetlb_cgroup *h_cg; struct hugetlb_cgroup *h_cg_rsvd; struct hstate *h = page_hstate(oldhpage); + struct folio *old_folio = page_folio(oldhpage); if (hugetlb_cgroup_disabled()) return; spin_lock_irq(&hugetlb_lock); - h_cg = hugetlb_cgroup_from_page(oldhpage); - h_cg_rsvd = hugetlb_cgroup_from_page_rsvd(oldhpage); + 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); From patchwork Tue Nov 1 22:30:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13027545 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 B85CBC4332F for ; Tue, 1 Nov 2022 22:32:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 501016B007D; Tue, 1 Nov 2022 18:32:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 489016B007E; Tue, 1 Nov 2022 18:32:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B4D08E0001; Tue, 1 Nov 2022 18:32:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 16B666B007D for ; Tue, 1 Nov 2022 18:32:03 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D567B80A65 for ; Tue, 1 Nov 2022 22:32:02 +0000 (UTC) X-FDA: 80086322484.02.76A213D Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf07.hostedemail.com (Postfix) with ESMTP id 4760040006 for ; Tue, 1 Nov 2022 22:32:02 +0000 (UTC) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A1M4JCd028857; Tue, 1 Nov 2022 22:31:55 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=KdsTBTYZo2zEACK2jZOJjNNyRhYH9a6Qvdu9EMo+Lyg=; b=VyULCVEpNhKG3o7B7XY73zWpXQO0mddCgo0+WcV+qLe44zPMv9zfc4nMdXVTa+Qe4CZC o6Ihd7ihLfzp5ArU+cooZtDxep6qpIEgcRHO+l8LhdOTHXbf86x+QQWAsWZRPe1UjZoA Jcja4jjPcVTBT1CcpWFk5lm22bwoEmlCVm7qm5qPt1N5e+EaXk91Ue9FcRcwpIKayC8S zxdHO+xv9gd+m/mJIJf47zQ5l04Wy/WHqY2r48ia2NkvxEk40lmThZZ/xwlT/iKQt7R1 x7WBuhVACdSgGvxFks6rjyfgQRFlk3XbFDn58LBA4eTTBo/31EoYUOaNm9PN3eHs4WZc Lw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kgvqtg3s4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:31:54 +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 2A1KF29a030232; Tue, 1 Nov 2022 22:31:54 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2041.outbound.protection.outlook.com [104.47.57.41]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kgtm4x6tk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:31:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SLT1B8lV+CuR87uwcjW1rxoveUJHn1V/PP63wMUlmvivDDzzDbhNbtZvCzdggZFip3cJrFhxZ4lK02CNxbr9bWLPQ7AC8fhHuE+vOMqVuDP7WoigVY6DzAqNZVlR5Hgdxh6JHt6XsmtWaWBRsQyyN93AQ1UqnYtN/sUqpAmUaDJLTj/V1E/OhGN6sfEuX1e44RDhmf/I4FzgCn6XnI5jYL8kqrGgtF2QJpWzRSkpIR87ZQ9XVZ92KHxZq/xYBd8A1vQc5OFdkhhX61NnxsthsVfSMvAGhPrbIv5OJHRH9q0FtojdDuMEEQkKRenVS6gQ9iONBpEaxo5t8ZaepPPfNA== 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=KdsTBTYZo2zEACK2jZOJjNNyRhYH9a6Qvdu9EMo+Lyg=; b=NsiQvz8AH2eOujNYNfdtj8cAXnb/+Tej7hzquz9eKPtFAHpfl0Yozrm9PM+7kY4UiTdh56rHrv3C9RQsccBg7xkhA//V+P3IDRAw3Lv1+/uquf9JI7jkfPhi77bI0Yvm/uHyqhvMyTKsNVi901gG3ASvpM1TAYUUQqHK8rm9knm/OaEwd9dxZd/tWb1stYRl6skAVp+RWcHJj4YujE6V90txZURahF9sVsZWRPagJfEQzj/cQvG/H5CVTfYSfjD3J24rUPenr2NFPpCy0NXu4/QdEPMA93bJM8zDq9Ptz0iDG8oswFpkiJOb+HmHBueBFp7nadkHkSkbn8pSiPYyVQ== 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=KdsTBTYZo2zEACK2jZOJjNNyRhYH9a6Qvdu9EMo+Lyg=; b=AvD41R2PtfQ/jjBlbEuNLnLD1KarWWY1kL4+1UnvaWmUxubWBc1qO0E++/NT0yitwt/en6fDhi0VdKFd/9nQB0D3MmcqIBWnLXNRS8MYc/XiFJtjnPBF8fPNmYNC6khFtBsMvtdpmj2OCfggQygXtKDjYFF/ZywA0t84ThyVcTE= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by IA1PR10MB6075.namprd10.prod.outlook.com (2603:10b6:208:3ad::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.21; Tue, 1 Nov 2022 22:31:52 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954%4]) with mapi id 15.20.5769.019; Tue, 1 Nov 2022 22:31:52 +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 v2 3/9] mm/hugetlb_cgroup: convert set_hugetlb_cgroup*() to folios Date: Tue, 1 Nov 2022 15:30:53 -0700 Message-Id: <20221101223059.460937-4-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221101223059.460937-1-sidhartha.kumar@oracle.com> References: <20221101223059.460937-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: SJ0PR13CA0014.namprd13.prod.outlook.com (2603:10b6:a03:2c0::19) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|IA1PR10MB6075:EE_ X-MS-Office365-Filtering-Correlation-Id: 20df8c7b-6efd-47c5-7f9f-08dabc58df76 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: opJn6QpbQ1J4U+cu+b/r7jFZNIid56xmKlHtGxU1Uo3GMH4aBLPEflS23UT9rR8Y+VqVwAc2Oi9MvmmA8CsbXZ4zg5LsxPG0D1T7rWhaT7wL++m1S7oi15umhCJacz9oQPdg3tFTR6tehuzWqEVaVcwtXw24ZzA/dkrUqTisvM/HFoQXKu45Bfy2RJlMI33d6zUNfq6yb/SX78SFBQ1UPP0XbkNQ1I9aQkcJYigFwBxJLXuNjS+AH5Thuw1zC/ypEahScGb+XJbYk2Y7oBFunXRtXcte/2hCNYapLe66atxsl11bfJMGJc8+45i/ZXuRIoueuktHvHjikDcSi+AuJdROZZe66D0wnKTSljmlriVHU/GqVel5uMKjJuTy9WB05dp7GsgVfhWJoP17eSG+YzuLDPtyOHNSrwuNtNkpq5wKe6QVjT4vx8fkz2xRBLdseFu2DlE5QnVV/n3s/HWTirQinVqeTP0Vzi82391f3h61bvD+a3PjOPRhn0sNheTY9ACUOH/trtNx10tOt2OKrqRVI//125WO69g+MvYysQuc3nVzyP2ugjybRhjU2G5Q8gOloekfdIHCLT6bBLXRiomywyS5XbIFQVGXX/Dkn86e7lO5quyNntfKuncEMD7cGbWECNxkohLHm0IcTtx+uFWPeOGqjWCyfyLzJpIEDsUx/PFfA40raI/KBc3wXFcfL0KdyrDqNS65ehMI8E9A9A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(136003)(376002)(396003)(346002)(39860400002)(451199015)(36756003)(86362001)(38100700002)(83380400001)(2906002)(5660300002)(44832011)(107886003)(2616005)(186003)(1076003)(6506007)(26005)(6512007)(316002)(478600001)(4326008)(66556008)(66946007)(8676002)(66476007)(41300700001)(8936002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8uwvm5xOc+u2rYtdqgT6e8vZOkkN/widhml5YtJAWo+hjBq2EmaDgD0xdDULIpN6qUo4uwBMh+YGbzswjpEYtcGBzIgL7Yg9tnRYEMAhj8ZBlQnh/piKV7PrmJa4DjUZfVMnIK/WB3nVm1aILq6Tdtr1cG/Qrx+STYWiVYx0SYQUsdbSC19+316m1p1MNWVnvIy4MVphXjnLuUaPitRbaLVEAA4krK2k/edePt9NXVOKXH/v0v05vdKIPqegjgZdeQBU8dvlUbMb2PabAiAqc/CWD9E1lPuQ8+1rw+X6pL/KzcDsWWqJ6YGjKxy3ZDE6bFMdAwwPDJ3yck24BqxNjHFx+UqUlj7IxAlpH+iJQlYq0YzQDpP88uSvCpBTmzaFrL9XHlp8jjn01DHQpY/T2dgpyHR7yU7Xx0uJxLoW5Jy3P/rZFJPosN/Y0ZiX2IPDJvBzpM9+VbbTSFSW6/IwcDvofqJiYa1u3QKF5Mk+UE6/DmwIzP+WxfH8ERFQp4Q9gLT7fwzNdZOFz7ajGAudc9VAW8tzeV+7hcfi6tAnsFP9BDiSYjyv7EDB0Klye1v1+9L92htBqJoyMiB8heQGca/C644q4MDv4vVFq0hNKtxgCn7G4Pz3VcZ8/FrUKDEuUPAd2lni5t6kbTJWOznJ0RkZynl+sdlLIhlDQtFZLWEJHJNw+MpbyDvMli8J4iuutk/NkcqlGGD1GWUZkU6YX0HcgHeRSYa/YNjRd4MkhY3nvHsh/9R2rK38vJmYMQbl8R2w5qapFktQsnsvYRKpUkwd50FG81uGMjJX5s0tmYK+N1oiTqVcR0sjgDU+0mwWwV7xI0kKHSsoqRTgRY1ZL+Hip4r50OSUgbLCYv/Rj+bdv1Jd4N9ILgSZqqpkSHMTgbEV2Xqo3/FuvSDuQxKUk8Mw6y5eeEwwPUEwKAR9qC0p4yoIhEaefHqvdHopf5xH8gIrfUh5Td+7cAy+o4kiNnc2cC6zDfLaIu6p2jFWbHiYSR5i8sR+KOjsnv5952AzNBCdse29bPPGjROtKn95Ceu2hj6En/oA9ImTT9X42kF0InXlRyAH1cE5dSz02eQ+Go47J8TEkl1wRQ6SgJOauI8g+TygiValKDulNeN6dLi4AmeeRi3IN9tOLyXPdBwHPvvCMJSJSGuqzmUfYlVIR+RHWzWoq4Y7x3svEv8eA43FOpIhSctWTNMh3qMjDfJwpDJvCuFRpmk/NCEbl2gQSuHpvSSb0w0hc7CbZCGDRypKMTgaUH+g+NgGTzYmPmXTIGIQJEWRZIFtziQVmsf2j7cfBKJiPVOKh2AV5qEPI7+QSWOuuwHo/bPSUpI42V3AJSVmPx6pf43m/WLWbeka5c1VS0vDZUL3eEUvUac6jNy+xfdsn3SWkDuJCb33uZWJmDWzScsRDWYPqLUwwqyMr7yZhq9y4J8EMll2JuIikiyVSrWHx5eR27Hi9+sm6FrNns2JgM3gprQC11bUZz7wHTZJpVGzLNjNTct33zSuyPiXJVNgmO3LoUy/6fVKvwZkBT0b2eMsukCmL9j9iigSNl0Vh7TuPCphJanvmsp0v0ipchKj6snZLkAI0Sm5ref2/Sn46JsYNA3tVS2SKEnrcA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20df8c7b-6efd-47c5-7f9f-08dabc58df76 X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2022 22:31:52.1231 (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: ux9XJ94S/jx6IowvAUtprtQ5P42aeFUg9CjUXr8SOvyeGffkcp+NVpSHTVrU16zu1t7h/P3YyswGQ5sjx1i8AQmFXgp5206yq/4lOItvd7Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6075 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-11-01_10,2022-11-01_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211010153 X-Proofpoint-GUID: jFH3CoGXk2zKwRVj2eiCVUOydnTd1XdM X-Proofpoint-ORIG-GUID: jFH3CoGXk2zKwRVj2eiCVUOydnTd1XdM ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1667341922; a=rsa-sha256; cv=pass; b=OmE0NmjzzfkXY0m0kD0S7Lq5YYCWDOJCAQFHBpfuj19TiqEbegptp8xmEUW2aFZg/lJ0RK 3HAV28qNsMW5fSIbX9fArBcry5bBRYYLLDKGVzvmHCuKHazLQa4APeuOm65bJejxw+lCAT 8aqkFw7CLK7mAfP6vIrhG7E9p+xba10= ARC-Authentication-Results: i=2; imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=VyULCVEp; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=AvD41R2P; spf=pass (imf07.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667341922; 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=KdsTBTYZo2zEACK2jZOJjNNyRhYH9a6Qvdu9EMo+Lyg=; b=w5mZCLGn0vlu3nNfMil39dbTJzMshu62Yc/VM13KPWfFeu91lprZLcrDhUA2VUWw0FE39L IZQaty6pyiWIq7LjqjfWUcn29uPjR+8qcIQ5tBJJGeZErZPbuQ0+P6sa8mro1TTQPQSauJ /NruK2mYhDYXmhe4gd6eU2QuKMj/jME= X-Stat-Signature: wy815miwbqsppa8ctewdpk86e79riy1f X-Rspamd-Server: rspam09 X-Rspam-User: X-Rspamd-Queue-Id: 4760040006 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=VyULCVEp; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=AvD41R2P; spf=pass (imf07.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") X-HE-Tag: 1667341922-919860 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 Reviewed-by: Mike Kravetz --- 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 27b87dc85c48..a6384fb0b57f 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_freed(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; From patchwork Tue Nov 1 22:30: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: 13027546 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 D4D8AC4332F for ; Tue, 1 Nov 2022 22:32:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 574D06B007D; Tue, 1 Nov 2022 18:32:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FDE66B007E; Tue, 1 Nov 2022 18:32:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 329B06B0080; Tue, 1 Nov 2022 18:32:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 20DB06B007D for ; Tue, 1 Nov 2022 18:32:17 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D938A1401C3 for ; Tue, 1 Nov 2022 22:32:16 +0000 (UTC) X-FDA: 80086323072.16.BE166DB Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf13.hostedemail.com (Postfix) with ESMTP id 71CF020008 for ; Tue, 1 Nov 2022 22:32:16 +0000 (UTC) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A1M47Bc000479; Tue, 1 Nov 2022 22:32:05 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=CdIzfapkQVtbsXAtb8JOdiuB/Or3txdKboEQfHS7EJ8=; b=c0oE/fHmIzWpu3mTihBDjklHwh8ROfcSX4S3n0Z/pikpzlRS505TE7cdzx0rkL2HpwfD rovOnWMGxupTRm53yxWhQzs02FD7Me0c5cWfPuNJDBsiKcIFN/MZ4jf5Bm9FKWmADYr3 bI1jiIBGAlzDqQ/7OMWqlRaW4RVlEVGgNPhl8SPfGD0ozDGaq4MCg19OLOptMJOMNz9K XK5s96/MqRNemUMTdS+F5sLyw6SJlv6lTTlCdeHys9SOwucdn/F1250RsneSTIQy9LoJ ozwDZkrRAUxEgxt+htGJA11inN6p3UrTCd8V0Tq/Z0/UZHeOEbvlqCiRuoW4rto4oH7Q HA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kgty3036e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:05 +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 2A1K49x5030290; Tue, 1 Nov 2022 22:32:04 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kgtm4x6yx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NNcZtmt49yQQlhITg5qiV3DhIvIlbBextyqLpgyhYdRs1YzbImgWEpVH/3OYR8Af2/lIzNbEkWQVDfdB5a20YGVGRI5XDef4P8YIcCInG120ZrDWJ7qbtkWqPI/YjAe6DFBea5mDJWlr/a1zbWFtZlC+r/r6wdaI+MccNZ1V54GqhCL+LHJWN8JGKmfo7HFRXrB2wpTv+82XTEVE/5teNKXiDeqxnMUO8XvjFnmWz8DXUz6uv5vO3x2DJRG3JO8R56+lOkoq0GcHyVM76y81tmSidZM+A02v+iDCaOWtJBf9qCWgktG61m+tss4U6VEUcBr3OlvggZInHRZj1kgCYg== 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=CdIzfapkQVtbsXAtb8JOdiuB/Or3txdKboEQfHS7EJ8=; b=ddOlAwNg6XzEEgbK2tgipYVcRmjOjRC9jT9LBZfMqZ4dW2zq0qr2kcYnz5Kxx1WHR9dwJQqaj2uhcI+e3xnuUaXlIy1LSKaA8ndbBCCXV+TF2I4hmHuIsqTJr5XhPdAx9/nCsOPqqDyYKZzyN/OiLv1s9TkkBA2IekbyF4vB1rTygMC9soVXb1GCfeK4mNS0bVyw1T0Z0OI0QGNtQGa8lbe/thWzvFDOrkEIaq4icDGKtEsCtPCrpWeLKYOlbsQ4WxU2G1VbEilEFZneTmkIJWm+pccEoUPVt7se4dsqv0fah1/mu5cXxaTW3weIZ140pI6wskN8cXvgJELP7rnsJw== 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=CdIzfapkQVtbsXAtb8JOdiuB/Or3txdKboEQfHS7EJ8=; b=CsDHHNOolvGnZ+VP63eoiyeeIIZ15s5Nula3U28LvuFvC+DzSLFyCjENg0aHUL4KEJaM50u3R0NNEkTVXR6uvaSacI7706BqQGR8RY27rW/YM9snkSgnkkUKE/ch4gePfSE/LW0f7zgT1F5noRl1//zpUOYLnBZvuyCMg/VFyJI= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by DM4PR10MB6184.namprd10.prod.outlook.com (2603:10b6:8:8c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.15; Tue, 1 Nov 2022 22:32:02 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954%4]) with mapi id 15.20.5769.019; Tue, 1 Nov 2022 22:32:02 +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 v2 4/9] mm/hugetlb_cgroup: convert hugetlb_cgroup_migrate to folios Date: Tue, 1 Nov 2022 15:30:54 -0700 Message-Id: <20221101223059.460937-5-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221101223059.460937-1-sidhartha.kumar@oracle.com> References: <20221101223059.460937-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: SJ0PR05CA0159.namprd05.prod.outlook.com (2603:10b6:a03:339::14) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|DM4PR10MB6184:EE_ X-MS-Office365-Filtering-Correlation-Id: 898877bf-93ae-4607-753e-08dabc58e5a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +lv2+sjijDaJNY3W8lYdSATshLgQE7P2EE1l47XcgH/ryKap+aBCNoCYvq3ZbgrLd+bvYSDe/hFz1Nnom+DKJyftcKweIEjKf7EW/Xzco2VIodATwk9uQq2zB94OjwuM9dQGt74dw6uCNw3CoEkT+ifYDLA+c++7OFts3vR4SEVRKX2HtF1+rQ38GRNdm8CItGkFzdTe4DsgPhsNFoXLumeVo/x4TYdr6hRTSfa+z7Z8cwL/JY0z6EehMsqj1eNRQOgNqB7OZi8t0cTDLjvOe9BbR9IYuk/FQkB/z/zJrLzmZW/e50+5jNq7PXtKelaxGMw6ude3Zo/HYcgdChz2qXRxH1ufcgsqZrN/tjPew+hpVuDbuSInC2yqRscOkiiLjWgqHhabzwdl/s8loPRcjMUz0ryXK9VBHH+Gu2KeQfa0iTN/5OGHilqHpSpkvXiS1Ib7JZwNkv/GJEcsgP2eVsUrvpG9BqDP9FWkUNdKh5LV5s2Uw49Y13YH3U3VzD7xvSH6ENQqcM4AFoPBKbnUXM9HswJ6hTN3AaVGPdH8o3kC7KSFDhMBZfoh5o0s8NXyfkUWiPD3WtPhIhPq6Okw7i0NOh7soqxtZTIp+tpuInH3UQahFhKwwuiBMVMCKogs/BDSweULCjxpg3sPkqrAek4rDZ79aJEApS5RNPSXESNpy3IeH0ciwVZRRmk5cVQKmcrj6xoHlT1p7EpiS+xIRoCqPNUSElFkQUMx3k/Xj/hLopaNRZj/3MhirC/jvrRF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(39860400002)(376002)(366004)(346002)(136003)(451199015)(38100700002)(36756003)(44832011)(6506007)(66476007)(107886003)(6666004)(2906002)(4326008)(316002)(66556008)(8676002)(6486002)(41300700001)(8936002)(66946007)(5660300002)(86362001)(83380400001)(186003)(1076003)(26005)(478600001)(6512007)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1ssI+HkU8FLXTYEGQdIyGBGuGCmrnFbPWBbHKTXyOc7SQnSh0TKoUUFr5CnveFgZCMbPWoaX/X+oM0o+AvsTOIo4LLbnQg3PzekAc41O0Ec1hrJnKaStxGSJn8cok9iUGir33Oo/JMaYODE8REn5GVr94qdfGoKgnqC4kQswKQa2fn0CLkGcLt1mGFrH2z1fHOnoRjAZnT+FTGXA2TIevLmdiy1rthwRPlLOAEZnPdkkeIolYgMZByPTGxQu4ecbwt+XAYBtDF/jRPUqelLG9eJMIA6aqu8lEu+6EAtyQFXwc7dbedttDGoX9zqSSSooQrWrZFOPSCyjl0l4eP/pDGDEfm3e9HmbWxZhFW8z1hOxJWS/+1rb4Dharg66+JQcE8m/5sXa07EwIdONeaqTccVBqyANYDUDwmybta7rQ+7s84xoq0BO9rUbeCVgzPRFT2VbETETLyjiroo/wEmYbOgiOObXmB4MMOU/k8KlunwWR8RMYHUw+EWrKLniBb+jDSLzgI+A09ymWwlagr6e2cdlrqLnkm/jVJH/Rl+GC68hs9HR8imoim2hkZ+yYH/psVspysxOBvTTkXN6Ytnpm7mGEAL4yMtccrzQpbIlIEj77Gg5D2C7jLWPZWlMqpvP0EI243n9Akn0YEl1s4lyJMt+z0uJIWc4ZnLYIp+roY/sADvMxeg+xAp5mkEFx8yVJVmXeP9ooqEzDd0hUH2Sh4cyQubvEo5yzZAouk0k+G5oBaGcJz+U6ymZpIZ8tppD9TbtyptdjYa6mxY9RuDpCcX3cVULArEMSXBFxR1sMwoCk4B2TJGDxG79RDD7FuBgQh6rcDtS91E5JCgXV9Pd2yAMwFTaS+g+crtgAgKgAl0PfgKHtwzUHbR54dHppuecRrJ9xBD9M6RiUvcBMot21RRMhwtbUgUv9kbkBdwz0sH0ltkm7tuAv8Nj9Acy7XlfX1W/MceLmRAyolfRYcHpEGRF13LKtJHcBMXkcyK9Ca80w+bMKzht+qH7z3Zphy5kWF1IiakKuidvo9ItJHKLgTgNq3tZn7UGkrJWaDxisCPr5mlJKqHrtlc9SH3lP9RfXnepf2KyxcIDvPAfqJG58sdBeWaCf/K6tx8sPPAWol0scgxIiR/ifcP5sM2VkEj5IcEyFDJSHEB4KnoXYzrV8dCGGdaVV+fZbivuwoNuL0GJ4cr6JczE2msPX49CeMZ37HHuw19ANMK5214C0zufA9gTPHqjMvd9bNoeXzGHuhvtLwHdFijHIGLPkIBIzCFXu1NPAWJa/ccMDtMJWrFGC55uFkTa9Up5RPeVcI6szQxz/OHODSyZxdUsDHmU+8MewFNBG2Jv8jhuwA1PV8erjb2xEgoN3+j2nf8Txa7sJHuCLxP9SWEw7fO6aR7UcflZ9+3NygF3WDe36UWa7pm8HuQ5HAej8riQDfoI6F87vdZh4a/Fwuw4o3J2c7gVCrXI8tcdWVovxzaM2R4t9ZRSsXTQModw9fHD5OPVQjqHs2tFc6YIn9hebgpU5g2Tcax19hYNNb2XlY7/gZhaCJ285dxaELnTRbC2WN9bs8xTHzhM/6eehRXg4GpW6jYWGRS705yGM8SgIQZCz/AdJYPx1Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 898877bf-93ae-4607-753e-08dabc58e5a6 X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2022 22:32:02.4100 (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: BiR5hfbOZ4LPSuVbl4hUSv6t4PZkyKuNiuN/8fXryvReKDvIJJKQw4OaoOndsGb05fi/vMe5xcP+f1AF+/52wKeyJwfH220OjJAoGIl0QFM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6184 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-11-01_10,2022-11-01_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211010153 X-Proofpoint-ORIG-GUID: keq2EAMAWdL9QVtGVzVZVGUr1Tgdr3sF X-Proofpoint-GUID: keq2EAMAWdL9QVtGVzVZVGUr1Tgdr3sF ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1667341936; a=rsa-sha256; cv=pass; b=K2CgmdcAOPJ9LsCZS9UtCwbY1Hdl6jGFRQdhmzDN+PZ2whRwrrLBLfFI31pZvob+2Kx6W2 c8XVY1JHszkhQ1hPsbtSt5ATGd2X8WjuEAw2/reUG7p3h31Dvdjhtk7Lg+riuoE/xFGPHc y+m7LKzYWV4CvGRdRvWTej74Crj7VtI= ARC-Authentication-Results: i=2; imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b="c0oE/fHm"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CsDHHNOo; spf=pass (imf13.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667341936; 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=CdIzfapkQVtbsXAtb8JOdiuB/Or3txdKboEQfHS7EJ8=; b=dVsG1U9xDPgzN1LtUbgMB4wm/HXcQF4x8Hv4TK/K2ctF9G2F1JsLQraPFWbr41WDrNnt+1 8O7ZN/j5bpX4TYyLqNkqO+VqcDjnOV/Ng6/oztAAynU/skjoDtpeTkgyj1B/XzoD/oVNkf vL0acD44rPKYN4327malxzcGOP5x6Tc= X-Stat-Signature: 5jh76onx1uh88sp6c9uedmeqtagpin1d X-Rspamd-Server: rspam09 X-Rspam-User: X-Rspamd-Queue-Id: 71CF020008 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b="c0oE/fHm"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CsDHHNOo; spf=pass (imf13.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") X-HE-Tag: 1667341936-348132 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: Cleans up intermediate page to folio conversion code in hugetlb_cgroup_migrate() by changing its arguments from pages to folios. Signed-off-by: Sidhartha Kumar Reviewed-by: Mike Kravetz Reviewed-by: Muchun Song --- include/linux/hugetlb_cgroup.h | 8 ++++---- mm/hugetlb.c | 2 +- mm/hugetlb_cgroup.c | 8 +++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h index a7e3540f7f38..789b6fef176d 100644 --- a/include/linux/hugetlb_cgroup.h +++ b/include/linux/hugetlb_cgroup.h @@ -177,8 +177,8 @@ extern void hugetlb_cgroup_uncharge_file_region(struct resv_map *resv, bool region_del); extern void hugetlb_cgroup_file_init(void) __init; -extern void hugetlb_cgroup_migrate(struct page *oldhpage, - struct page *newhpage); +extern void hugetlb_cgroup_migrate(struct folio *old_folio, + struct folio *new_folio); #else static inline void hugetlb_cgroup_uncharge_file_region(struct resv_map *resv, @@ -286,8 +286,8 @@ static inline void hugetlb_cgroup_file_init(void) { } -static inline void hugetlb_cgroup_migrate(struct page *oldhpage, - struct page *newhpage) +static inline void hugetlb_cgroup_migrate(struct folio *old_folio, + struct folio *new_folio) { } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a6384fb0b57f..2a48feadb41c 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7290,7 +7290,7 @@ void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason) { struct hstate *h = page_hstate(oldpage); - hugetlb_cgroup_migrate(oldpage, newpage); + hugetlb_cgroup_migrate(page_folio(oldpage), page_folio(newpage)); set_page_owner_migrate_reason(newpage, reason); /* diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 692b23b5d423..351ffb40261c 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -888,13 +888,11 @@ void __init hugetlb_cgroup_file_init(void) * hugetlb_lock will make sure a parallel cgroup rmdir won't happen * when we migrate hugepages */ -void hugetlb_cgroup_migrate(struct page *oldhpage, struct page *newhpage) +void hugetlb_cgroup_migrate(struct folio *old_folio, struct folio *new_folio) { struct hugetlb_cgroup *h_cg; 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); + struct hstate *h = folio_hstate(old_folio); if (hugetlb_cgroup_disabled()) return; @@ -908,7 +906,7 @@ void hugetlb_cgroup_migrate(struct page *oldhpage, struct page *newhpage) /* move the h_cg details to new cgroup */ set_hugetlb_cgroup(new_folio, h_cg); set_hugetlb_cgroup_rsvd(new_folio, h_cg_rsvd); - list_move(&newhpage->lru, &h->hugepage_activelist); + list_move(&new_folio->lru, &h->hugepage_activelist); spin_unlock_irq(&hugetlb_lock); return; } From patchwork Tue Nov 1 22:30:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13027547 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 C59F7C4332F for ; Tue, 1 Nov 2022 22:32:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 638D06B0080; Tue, 1 Nov 2022 18:32:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C15C6B0081; Tue, 1 Nov 2022 18:32:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 413EF6B0082; Tue, 1 Nov 2022 18:32:24 -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 2CDF76B0080 for ; Tue, 1 Nov 2022 18:32:24 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E6F77AB538 for ; Tue, 1 Nov 2022 22:32:23 +0000 (UTC) X-FDA: 80086323366.20.1B3CC74 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf03.hostedemail.com (Postfix) with ESMTP id 83FEA20007 for ; Tue, 1 Nov 2022 22:32:23 +0000 (UTC) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A1M3xsF016218; Tue, 1 Nov 2022 22:32:14 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=OjyqufhItJZNQqVVuotec1/lf1wZzFO6juqFsw+19r8=; b=GvRd29NzRgmCHvAQyaEE3bG+gsBdceZke68wZ6EXOO3NbWQDxnnoxDy/AeZyXlfhg4NL YB4CPuBfVtFQRtGMjXz2srQKupf74ODsexrz3fyMiAYOVPrI8BK5Dr3tAwcAEOf8NyfJ zCoUY5zQkPcze5JtBO+LPykDv8UKQQe0M3vb9D/FULh9ZCOgh9PB0cSojLDo1nBzhWTX v7kw8kxUnBI0ulIFsX7TYVcLwu98Yez2CFbg1wj5I4gEsC2BrO2e/fCZMKz+q1LRdgbW zBMwQoF8sEuwlVHnrjDh2H3igCGTrftPjyr/x6QUAGPXCfgEdefiUAwg+q7TagOBHX1i Pg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kgussr1wu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:14 +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 2A1JkV6e014190; Tue, 1 Nov 2022 22:32:14 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kgtmay6yk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bspiOvKCVaVFrV6VPbLYkewXlYtG7jMqMWot04gIHhArBKMBpozsqtAirbn7L2o4uUzEj7MkvC4FHLPz1dEKYZtwIr1Nrgylm6aTkMowafqGVgdGTKg/CLBSZiFfKX3qPVTLfdJQufUPz9Ka4t0uB+fSBkdId5owVoteGTRLMPZfX2qzq3s1qOUv8f7cWBwOnMVudRu7SuI+msS1kfEeXPY/ICSVyh6s1asq0VN3wA2f19L2YSLdTG6DmGu42O73PIAdO3aYnoP41v3zzsAQIgBcNof0Qfz2cb1UaZLe1DH7trhqBTJoQ9pzc2xrGeCwwI0q6sVxJapMuefbYhVpIg== 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=OjyqufhItJZNQqVVuotec1/lf1wZzFO6juqFsw+19r8=; b=HtxQJCtiKgJOQRf0wsv5zUV7/1W2ZPFqvb+Lrh0Nw3/qsTgRHM3sbNMnB7jmjBA/iEv5ts41bO5TgV1zcq1r+M7lfI/N829o8SpRolhCy19wFRt/e3czB2CaZ7AWbWbk3yXrnsV/wa3rmiEIjxEVPez5xKD+DwMBL2TSUXB8C8pxxMR5xS2wS7llJA3MB03nBaSEULdie0axYjC6PBhU5wZIbmTFvnhoIrg9leNnrtvmd7ncpMBzX0QWil6dzS8CVAzKCvQd5NeO1B+iWPkvKUm1EkBnj3k6buLZ2YwIXKxFG+OcWT4jjHfppoQPsOZBwB73T1+7c2tHE8L+3FHDQw== 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=OjyqufhItJZNQqVVuotec1/lf1wZzFO6juqFsw+19r8=; b=iKRJY8UnIfsFd0+4oF3pApmhXnhUXaeawbzhDmuPqjg8rGvwDKUJxLAEcIHZWQQzMDrL7Uf5Uyn/IqQ5C+W27ukf1B/bYRx344iqtGI9SQgx09V8idDKejWqjSJ8lAj3qraC+Lcoh67kw2xDajbv+vCnF+KF8U8TktG12NZIbxY= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by DM4PR10MB6184.namprd10.prod.outlook.com (2603:10b6:8:8c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.15; Tue, 1 Nov 2022 22:32:12 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954%4]) with mapi id 15.20.5769.019; Tue, 1 Nov 2022 22:32:12 +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 v2 5/9] mm/hugetlb: convert isolate_or_dissolve_huge_page to folios Date: Tue, 1 Nov 2022 15:30:55 -0700 Message-Id: <20221101223059.460937-6-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221101223059.460937-1-sidhartha.kumar@oracle.com> References: <20221101223059.460937-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: SJ0PR03CA0144.namprd03.prod.outlook.com (2603:10b6:a03:33c::29) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|DM4PR10MB6184:EE_ X-MS-Office365-Filtering-Correlation-Id: de5eacdc-9052-42d5-ad27-08dabc58eb9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pw6oMyWlcztfsZ89m8u/7L46ahGIjJrTKpqhXEn6eFFIX+56RCQNk42lVDA83tCMao18PDO86S9AehFKTmyEBOmZsrfLXvhKlj3LUJ5cf/RzuVRPdtDU/k2/vmDZ01Jzxg7QuccvStcA+50IwiGH8//sdc4pt8oH8GJKv9kfG4pvxTcdsPspAMTVbX0aK00e6Vkqe0UWXZNZU0pZh2lnkYqP1JJ5ddutYq208SuY+tR7dtTlSxfjHHxFv7ggNgZRXGxHucFt+935HZoTAkGZFw/vD2Y0n8VoJ8xu9PEldU8BzRmxScxuBF2DL05lCE8m2vJMjVAiXooyNDpr4U9iMo83GUubY4iq450xw7dt97KsrmBoI1tvN5PWqvEa1hVObd/quvOhPyNB5p9pZS8jwt4JlVW1/VF/Fgp6p+uiSm7nbYvrFNYTM4vHv3yHEheu6zinhvHOIeO/5SZCIMnhylcYmsJ6c6CsEn1FmPIMlYa09CYwqefUktQYuGaGGUdJi243ILgichRJkteVxCC5FDX24EJyMDBgmkjKRqATdS1Bcw42jE+pa0kd1iRKH7ZHS5gaw1BL/hcf5l6RjAfYvX/6hWjzwtTHesSVVuWadBpKp0yqc3r9qFV3HQ6qksjnFWkN6lw/OH3JbUnfOTDkiC3I/4rOpVFLQP7fZplwmr3oEcQ0vLi3Jszz+qi+X1KGpsYi+Xvtgds72G5QJgbXbiA5p4cENZBVxThqr+ArzV4E6qZrYTSv5yJ7Y/yetEWwBcE4pm/fWFyj1LvCPcX4bXn+ykmPMgqwzVp19XsueGmA22BFjOhWHlyQuiAy0I1/ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(39860400002)(376002)(366004)(346002)(136003)(451199015)(38100700002)(36756003)(44832011)(6506007)(66476007)(107886003)(6666004)(2906002)(4326008)(316002)(66556008)(8676002)(6486002)(41300700001)(8936002)(66946007)(5660300002)(86362001)(83380400001)(186003)(1076003)(26005)(478600001)(6512007)(2616005)(14583001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: m6qj685AkQFrKy7gs3KRI5oYqJoxoYPOTfJr+XxVHG7ZJdFSTaNkkSm5/sydgPosG5Yt4QheykRuZ23YC9yUr1ZOTCUR7/NypchnQH2Di20BpQDVUNeO6WdXHmXA90E26TaYqA/IVLL7auH5u37c1k1ubohtCGt5xBwirk8yUY699kG8Rd11JQvWvQDaOZKNIY4/3uxCLVmqfzgFf+l8NSxy4UqE1DOo0e+LtMUR5oSxO/+Slaf6rXjqvWzkBjbjJFVidc9T1LfkM82cjmPmmQ1/03rJRkw949mQQZ17rulzHvb4xHs7eL1Td98UBUe6mH8Wiej9Dt+ZW8XRD/WgW9krRm3kYyvfFzIBJ2XC1he+pfPd5Xd1KS1HDFZq7MJ82spsi+kp2zHPQHI7QGeaoHjjOhysIUfXQs2q29i9pgeOhEyMmLjitM1VFW3WtlTNPDCCRVQPDN0G4rJP+SG5VFvd3TB3ie3D6p7MQtm8ssCbV5QQae9CxrNSmaLz7Cl/kfjOhkCdXXEqLAhi13WcCEC+13x+CjUVh5Xwt8ZLF7cx8T60CpOAhZHU5ejrJAzUc0lUBFd+fuwv5cQNF108eMd3Np0wcKXcik65oM0tcYp/Fn0JIuWGdSHvrN9GOxo4RKKOXBn4l0SRWPonZIB4hW9BOC99Li1kgPOA16QVIgDbomCtsIXgvK5bl77fDTDCcuefnKBPL+sC2VNDHlZ3skoa9iZssJDl2BB0fzqHLOl7uAlht0MITILMFYWFkkl/Ef4OEgG28pOgXjvqhFONfGqo4v+LzThO2ZM/9+PS3VBlAA0AKjtwfcuREBdsHK1+F135DM7D6L/9R/gCrvTrpidpCpbum3lS9fP4RlUBHlC/dszmitTCL4vg2KiLuApBSSTNsXRfbQW94U7JZNmnUS2DRQcd5vKWOlo/FlRwBw5TqJkcLAl7/U79ciKl8sIfxvi8F5cW552Kfdd4UJW34blJ2MPCm7DokvhCiNBTWsERkUjYNm7HzHTAJvOSgKb/B+wxjAA09rB9x7JNtQ6HVeoegWzal7g6s+ce6p0/5Mw2ZbNHg+4P+34P5/nFMTR0jkGlcpmHAjDPsCp/tJmpBzN1yfxNzQBaJlNHjDF8yPht0DAIfRz7q1AJzwiyxg6DqFf4wfcoxbmrK2Na8c261lPoCa/WFWAeGcDZwhob4GrPWdlbRRy+k+VhlBfdI86qczTwh5EBhpwffO9DfdWoqg1gsPS9Coe7948W2ex9lARdq41NBRQ0KChPkdziJ03g0BxPA9NnIbaBdZHy3v3sDhM0GYG4npji5vsnPgCsjrQ/YEOOCY0429IgRa0zxKRqIww1KCLMkg+B3wLut0R+XGydXDeBcsP8iB0ojz+qxVsYNa6eHaerz9m/neGuUKZ2FjkbQaEIVTFDzTiYQYtsiXdjsP0r71SlZKq12FJ7SWzqb/TEuEu30x6Xi3md4XtwMFSZyqHu8G20W81ug0KDhJoIYDdC6YpL7KaFkN756NdFehjGFMbpDwzlC73ZCvnW5CiWbaOr4/K2q1ABnJErEjNE24PVQf2gubTgW6+4J9h2LuEw5e896iZgl7c324dKjfwMKunrT/CgTvgP0WXR/w== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: de5eacdc-9052-42d5-ad27-08dabc58eb9a X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2022 22:32:12.5253 (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: xSNT3zbfWhBaxnu+VLB8KOqTmLvjMGEXNQ7rE47QQFi1njedjlUF5tzmAaTV6Ja/KdJ0hBN0aSXPIMqWA7Js0Fjnw6QMcAiunqSrSsACuvk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6184 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-11-01_10,2022-11-01_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211010153 X-Proofpoint-ORIG-GUID: -rUlxgouV6x5bNV-rYiiCj2VTvLnmCsg X-Proofpoint-GUID: -rUlxgouV6x5bNV-rYiiCj2VTvLnmCsg ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1667341943; a=rsa-sha256; cv=pass; b=CyujOpib3YHhLDZUcBviKXTjcJSWSNRoij+MC1f10iN5iTOM4FfHz2JqayevzrriY56gFV gmLuGZx4PatqL8nu1bBC2mrfaptnm2KGY7X7sQWRjUlrvaasmeezBQLkcsWl0uhMYrd9Ct bSxaTnfxlhBtqL7RysrSWiG6i79fieE= ARC-Authentication-Results: i=2; imf03.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=GvRd29Nz; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=iKRJY8Un; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf03.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667341943; 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=OjyqufhItJZNQqVVuotec1/lf1wZzFO6juqFsw+19r8=; b=mvOE+ncEOoJtj44XFra3RLEflvlv03UuPPQPPxzB3jTvuZpXemmoQeDDTySayXeIxubRO+ hbc3b9SG5PlZtUZEq13GxItEVlJVyu7+FUhO3GOBR9dBjzFtUiNaBy/Men/Dugsiw/9IB/ 7Y8mx1LbYnfZGtQ0KL5eJ+Vf951PmEU= X-Stat-Signature: 85htbrhik31i7sppcrdsnyup74pqms9k X-Rspamd-Queue-Id: 83FEA20007 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=GvRd29Nz; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=iKRJY8Un; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf03.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1667341943-246525 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 a call to compound_head() by using a folio when operating on the head page of a hugetlb compound page. Signed-off-by: Sidhartha Kumar Reviewed-by: Mike Kravetz Reviewed-by: Muchun Song --- mm/hugetlb.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 2a48feadb41c..bcc39d2613b2 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -2815,7 +2815,7 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, int isolate_or_dissolve_huge_page(struct page *page, struct list_head *list) { struct hstate *h; - struct page *head; + struct folio *folio = page_folio(page); int ret = -EBUSY; /* @@ -2824,9 +2824,8 @@ int isolate_or_dissolve_huge_page(struct page *page, struct list_head *list) * Return success when racing as if we dissolved the page ourselves. */ spin_lock_irq(&hugetlb_lock); - if (PageHuge(page)) { - head = compound_head(page); - h = page_hstate(head); + if (folio_test_hugetlb(folio)) { + h = folio_hstate(folio); } else { spin_unlock_irq(&hugetlb_lock); return 0; @@ -2841,10 +2840,10 @@ int isolate_or_dissolve_huge_page(struct page *page, struct list_head *list) if (hstate_is_gigantic(h)) return -ENOMEM; - if (page_count(head) && !isolate_hugetlb(head, list)) + if (folio_ref_count(folio) && !isolate_hugetlb(&folio->page, list)) ret = 0; - else if (!page_count(head)) - ret = alloc_and_dissolve_huge_page(h, head, list); + else if (!folio_ref_count(folio)) + ret = alloc_and_dissolve_huge_page(h, &folio->page, list); return ret; } From patchwork Tue Nov 1 22:30:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13027548 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 B8189C433FE for ; Tue, 1 Nov 2022 22:32:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54CE36B0082; Tue, 1 Nov 2022 18:32:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D7C46B0083; Tue, 1 Nov 2022 18:32:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DB566B0085; Tue, 1 Nov 2022 18:32:34 -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 1B9896B0082 for ; Tue, 1 Nov 2022 18:32:34 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F1F6EAB527 for ; Tue, 1 Nov 2022 22:32:33 +0000 (UTC) X-FDA: 80086323786.24.195C7F4 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf24.hostedemail.com (Postfix) with ESMTP id 9828F180004 for ; Tue, 1 Nov 2022 22:32:33 +0000 (UTC) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A1M3wvs008145; Tue, 1 Nov 2022 22:32:26 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=NgzM/uc542FIf90DF6eXVseMOqdsd7MbkDuWx3iKQNw=; b=vwqqLDnfJWEdsJU89cCHjg9+ukUwvIEKGng95YqM2mNSGImUg4mVdffraNFqOpqcyVOj f0CCBjv5tAw87oO+qAhF2Njml/vtrzdcAcfVmqUaB9L/Whpjn0tb1yg8FzcL1Q7vpVhX sYUeja2ocC3BA7RGmn8khNXHVnFHaXPewIm2S6A/3kMlMqwmUbJMBA+vYiE+7YfH/WVL RMb2Ky41s1iLR86o1nGOzeQmOTtjFF9Q6VNC44BGwpcAWlMSfLssFhXITQkckzDBmOrz ZW79m+emrg/+7Y7DopatgGzkXrZdjnJwSOmvmcVBaypMWhk89HbJ7rthm9IO7TKeaURj qw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kgtkd7src-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:25 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2A1KbWq4014088; Tue, 1 Nov 2022 22:32:24 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kgtm4w2s5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yr8g98akcftOU5py7Fk4CyZ54Xf2liAbLNiL9x2dLS5oJeQ3VZZvC4V1AS2wU7B3uDjPh1plRGfGZ0uUiEUOFon5xzsNHN5nlF9Nbw/7lubJxNXCG0h4ohx/qjD+lQMuv0Aet2aSVy1x5BrzrBmR+SXHGBsIw51letP38zbpoVBNqarDum52HYhq5u0OKEed0vbNNw9fTCPDeHcZwGeseOffiAkctcUuXJ6jdYtesvkb39UEdwPbsK5eVHcP5CnfKcfI6qH+pfScwQMhbcRzkSrW7U0pks7tv00uDswQ7Q+HjBrOCG+OxYjkkJlB33bkLlNwzFDiy3Ya+OcjVHdQHQ== 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=NgzM/uc542FIf90DF6eXVseMOqdsd7MbkDuWx3iKQNw=; b=YF6NRclSF498nPQNZ2NucuG25pg/Xb9p1n9OOhaKrbDK2t4jPg3FWXR4CseCzXpevhTPp/REXNDCbr8tAZIy1FMktHCVI+xt7BBteqzSKJucU8/fEae6wlAtAdSpKM+yrCYC9m8LEfON3kGwRyLjelIkP5LlqL4/FCmaV+Ky1LoH6SSNoEq6o5h+Y9uN9hDXi4lrTqng/z2eGeR4t1GEtB6nRb31ZMPpcxvDybm2P+x05t6ij4+JsrirUKItKbUpBYqCqCBf2o08dEUuW3sJBndjvc+NS/9XkfVZ4TQI8koscdMxFajOC1qUqp43mhsAkQgtcNGSaxbAF82p2d/fAw== 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=NgzM/uc542FIf90DF6eXVseMOqdsd7MbkDuWx3iKQNw=; b=FbNVwmBtxMw7ZyWsCiektv6fj8zJwMN01GZUQIOHv1D2sHp2pRXicgpGV//MvynCwIsqGR0NMDG64I1NhnPV78yj/rcX8yUUDg7wIRnvAil7PH6f7LZ1n5VjHrrFYhrKbOCBuGYGRyM7IWzU9GUE+Fcl1VLHVAZMOE+9opHtvBU= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by DM4PR10MB6184.namprd10.prod.outlook.com (2603:10b6:8:8c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.15; Tue, 1 Nov 2022 22:32:22 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954%4]) with mapi id 15.20.5769.019; Tue, 1 Nov 2022 22:32:22 +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 v2 6/9] mm/hugetlb: convert free_huge_page to folios Date: Tue, 1 Nov 2022 15:30:56 -0700 Message-Id: <20221101223059.460937-7-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221101223059.460937-1-sidhartha.kumar@oracle.com> References: <20221101223059.460937-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BYAPR02CA0017.namprd02.prod.outlook.com (2603:10b6:a02:ee::30) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|DM4PR10MB6184:EE_ X-MS-Office365-Filtering-Correlation-Id: 135548f8-3249-4a60-84bd-08dabc58f1bb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DEGL+iBiZCA1XPvEA+PPaz0lsDPGjn5No1gwjwLqQ4S1GEkdGtpE8E8xUDuHO9XxqepV2zbNXARPw7SrqcFEgbTq6sYG0R+v87xF9cmvLrgG8rf5hq1xlFjSTvABE0AbRXwawWe09CEe+Z+cjwdZSm+JMV+55ccDa4tEC6tUJ4VK8G49NNd35PIN0KL603YUT1kCwEK8nKxTFv5wV6qtGNeIxHMumTIXd98OIv5EcP9RKUF6YYcf4jkaq+SdWGNsulMU45XfwT7TSMLJXiTg6j8ypvcwbytuYhuXh3Mi/ASwoZ9K9bmlF7qYm7nGKp5nnzETnm551m4oDJguKih0GAH4qYT02PubagP5okGK9X+dwxd1vM+NzC4s5zIagw+PmCv+OcKMFZ7lO4E9DhXISb/U6IgE7sZyZcRIthNa/B2l89w6Ibly+uF00hxmsNo6IboK91aFfrvOwlHAsMi/afAM9EGLMI3Md87wl61GF1ixrpp8BWD2SEs1PF2OWtlp+15P+3NQAXnCRWvPzZ5LiNoKE5kw8l5+yVICTBVrC4bjT+qG1Nx9wwbXJtNf0gYtZsFYAMMnhs3ktQ9nVUQzkkudmS740GzVlKEDp5ePG3f/9Ozp2RrDZWCEBW4v8FtpbCBtUnyjLETPoBmi3eN2OcSraUh4CcUK4DNOU0sS1tzBQvmlhn5mOotR8UAEkhfqCrNgrI+1pQ0HWjdfnUiU5EkfuZnYRliej82oCduoOXS9kuDIEeknpSz3YxXk8n/RQ3jPFgBVEf9aB9cIxdd9Xzfgcsun8Iu48rvjGuSjeztMXrmhqs//RRHevwyr8vvK X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(39860400002)(376002)(366004)(346002)(136003)(451199015)(38100700002)(36756003)(44832011)(6506007)(66476007)(107886003)(6666004)(2906002)(4326008)(316002)(66556008)(8676002)(6486002)(41300700001)(8936002)(66946007)(5660300002)(86362001)(83380400001)(186003)(1076003)(26005)(478600001)(6512007)(2616005)(14583001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: J9busoF8641pajFMZK26QDJWMC9eNJnMEUb9Em7swpHrHtPU2X32rScp53BPGtNYJMhc9q7Gm8Fe665WY+u0mKd7mc24ngd2aRGIzRDYfUCR2ER4n7ovlT47PxVmame8ZBMwfIkd0E796/WzNr5UjdkNTZTHAY3/IVzLf6qgYS6bqb94oMmoD2ekX1BHvx8q7rrCG+CZDvqtv5PIqCla8Nz64kUMf2FPrNkOKN8diBQVUVzxFEGg+3rE5msjpAdPFt1IjDXY/kUxGBS1z8I/9C2BYpRp1O/zsz9Q5LSoDumc4iCWfX6SKSem3qX4nL0UZD1dNrAp7grBYGmIk70nZK4DSb7ltwnJpvlyjYixY25NOwNga5TvRtzTpRi+nfyizppeCN5OnvlsObYhntjLTq6ZNBMsO9quQISG4khB6rNQ665Mvjcmx+DBdRhBmKMiJaCU0fsWMTRhlE7M1H47Vrvihq5bWWBW9qjYbvnQjEEQ7hsgOqBL/WXB0tlql7tGfTb+CsBaHeOb4OvPglSeXg5M0tvnKzQ8tq/OGA78YMBi/eMNi33QEXvjhMiUwBwk2Yf05Lgj1GOCrLf7LXeuPfb4reI0qXlANuCvp9BMy1fakf6JMtK/ad4x8nsIEnmxZ0SC5cCT2MGcBmibUlT9gwEkTBCaRP/ynWMxagqA7ocpwvgaXtQQQhsqpP9sEvRLz/85A5Nb7a+9F/IUDlSQXD4/VGJkflDyYapsTuwpoApj+6EsKmc2ntFDgKFpwg5S+pLnF9m2n1ez9ggG1h05U2aPX00t4Jb4CeT5IA+qs7CuuxfdjTu1KScaGwuU6u51+Q9LihQAn81+fjRHwb6juSOwnqyFqks5H0A9F8qsKnRKkxrH75syrynxAXtf7x/+dnwtmQ9syXnG2G7iTnPMLgXNu8osGqitSKAK/lCbQyeCbZyIEvZMyI1gxLU0qJwdVtkfrVyatStakhusCUS5cgf9GrSfj7mtydHMdXHj1S+OU/XJn/YiJem3LFzs8D/EPShPiwyYLTeqayNr+AT5AXyEbABzze55/wDYJnANRag4V3RLw65GitcQGs2iGiO24exVdUDDxHvy5xQRr++firDkv8wm1/hM4FdZPQF3CIIn9LMxydrfXcH6psp7mT6RTYwMWuiTrFHGDdTBgvRQlP00Zh2xOcSJ4VtRzjAgZlZ6jpZoC1PgWF3XgJ89gZRfkbU8ND9MsNYPbQocMKO42JgRlWptfucWkQFs+5Y0cDMvTmln5segISHmV0RI407vcbTrGlz0BwsZ4asR+/syQpnxkyzBv1P9Nl3Pg8BViydvNuGQhs4eX78dG/nC+h01KinTgqO+W+0VRVWTLhR4xiGyes9czQhSZ2flnqOPO5munDNrZGAkKjPh4K/YU1fXWO2eknhr+p9jgShwIjDzDmwu8QQhMb8y0c/YkhpaRpzYCjgN0ZEqoYgxgy4unL8w0HaexK0mDidmDStxqrY4KVpj6tSwe9h464uFi4culWvvdyxdcPzF+VGwT8zpbY80oMTwmNKbcaPKH/Rs8VupaqNTsdkMs4Dckg8MCiC8pHQ/ypp+WEDy6ESpqEAu/M9k+904qM220G1/YAj5BLrw7Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 135548f8-3249-4a60-84bd-08dabc58f1bb X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2022 22:32:22.7432 (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: 9tCCZN12z1p4r9TM0rxZVW/o5Piq3ddKpgI1ZDkIRqRy8RxUW5fyJj4U7WI6d0yDk2qp/AGU1vaydA+f9MtVwp7PWTmAgH+qr3kjnhZoWKg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6184 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-11-01_10,2022-11-01_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211010153 X-Proofpoint-ORIG-GUID: YQZ88rmXGSxGHijqNTIs84qIUW4GC6b8 X-Proofpoint-GUID: YQZ88rmXGSxGHijqNTIs84qIUW4GC6b8 ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667341953; 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=NgzM/uc542FIf90DF6eXVseMOqdsd7MbkDuWx3iKQNw=; b=Z0/QhQbZuFSVxW43BCy6HRaFDYysZ6wJsZe8AxNHuPcV7CtInh+Ik5I29C++mSrrZEZFIE FrYXM3lqeIEZnwaN97Gg1hHW3PtyJGobXhB0jEepm74GRKxHpp65xaEbcSF8mk171aGNNn 4LeBVW713V65+eaGP9QkgF9hEYSsapo= ARC-Authentication-Results: i=2; imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=vwqqLDnf; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=FbNVwmBt; spf=pass (imf24.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1667341953; a=rsa-sha256; cv=pass; b=c2AcvZhAF2sBStNadqu3HSgzWHfi7PDyKI/OSqeBvLvhbZ0FmsEkTsIyayPAtPknivVO/l QZI4XQqepYLesaOkb1DFKnADRP+cSIHn7ASUITY/c6YWXltWldLU+u2hZm+Jd9uZruJaFq 4kJ4fb5XICNGOzQNVqVzcpPPE4UR5tY= Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=vwqqLDnf; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=FbNVwmBt; spf=pass (imf24.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com X-Stat-Signature: tb3z3uu4hbmpj9f6qd48hgxyz9ku88pq X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 9828F180004 X-HE-Tag: 1667341953-152388 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: Use folios inside free_huge_page(), this is in preparation for converting hugetlb_cgroup_uncharge_page() to take in a folio. Signed-off-by: Sidhartha Kumar Reviewed-by: Mike Kravetz Reviewed-by: Muchun Song --- mm/hugetlb.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index bcc39d2613b2..387b8d74107d 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1688,21 +1688,22 @@ void free_huge_page(struct page *page) * Can't pass hstate in here because it is called from the * compound page destructor. */ - struct hstate *h = page_hstate(page); - int nid = page_to_nid(page); - struct hugepage_subpool *spool = hugetlb_page_subpool(page); + struct folio *folio = page_folio(page); + struct hstate *h = folio_hstate(folio); + int nid = folio_nid(folio); + struct hugepage_subpool *spool = hugetlb_folio_subpool(folio); bool restore_reserve; unsigned long flags; - VM_BUG_ON_PAGE(page_count(page), page); - VM_BUG_ON_PAGE(page_mapcount(page), page); + VM_BUG_ON_FOLIO(folio_ref_count(folio), folio); + VM_BUG_ON_FOLIO(folio_mapcount(folio), folio); - hugetlb_set_page_subpool(page, NULL); - if (PageAnon(page)) - __ClearPageAnonExclusive(page); - page->mapping = NULL; - restore_reserve = HPageRestoreReserve(page); - ClearHPageRestoreReserve(page); + hugetlb_set_folio_subpool(folio, NULL); + if (folio_test_anon(folio)) + __ClearPageAnonExclusive(&folio->page); + folio->mapping = NULL; + restore_reserve = folio_test_hugetlb_restore_reserve(folio); + folio_clear_hugetlb_restore_reserve(folio); /* * If HPageRestoreReserve was set on page, page allocation consumed a @@ -1724,7 +1725,7 @@ void free_huge_page(struct page *page) } spin_lock_irqsave(&hugetlb_lock, flags); - ClearHPageMigratable(page); + folio_clear_hugetlb_migratable(folio); hugetlb_cgroup_uncharge_page(hstate_index(h), pages_per_huge_page(h), page); hugetlb_cgroup_uncharge_page_rsvd(hstate_index(h), @@ -1732,7 +1733,7 @@ void free_huge_page(struct page *page) if (restore_reserve) h->resv_huge_pages++; - if (HPageTemporary(page)) { + if (folio_test_hugetlb_temporary(folio)) { remove_hugetlb_page(h, page, false); spin_unlock_irqrestore(&hugetlb_lock, flags); update_and_free_page(h, page, true); From patchwork Tue Nov 1 22:30: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: 13027549 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 B4DC8C433FE for ; Tue, 1 Nov 2022 22:32:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FECB6B0072; Tue, 1 Nov 2022 18:32:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4AF118E0001; Tue, 1 Nov 2022 18:32:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 301F56B0085; Tue, 1 Nov 2022 18:32:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 19EA56B0072 for ; Tue, 1 Nov 2022 18:32:44 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id F0FB48016F for ; Tue, 1 Nov 2022 22:32:43 +0000 (UTC) X-FDA: 80086324206.01.7003D41 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf23.hostedemail.com (Postfix) with ESMTP id 76E0914000C for ; Tue, 1 Nov 2022 22:32:43 +0000 (UTC) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A1M4IQ7022294; Tue, 1 Nov 2022 22:32: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 : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=oMoaqEGsyjXMIw0FpWQmzwCjhrFnxArtk8XMtNUcCPg=; b=MO+PJM/2T3ULc9/NlMiM94gKM96/yPQYSwpW2RfsVWQ86thYE21Nx+MqTbZefzFN9O9R NKl7srUp5sbjLPAvSC48TJSQoCSLfGQBVS9p+cTZd+GkENjbGwnZPw8UpNn+Krmwdg8D 2ld7zsSquTYJDZ6LucMedboOcXpuGAlAqLFdVkay22+MrlFZjqg7SAdFvUyAs3Kv819J yVpAYRTzSnX023OXnWk99K3o7PeXGTdmToOO6RVIkkibp5j/x6uhPZOb940l1KBR/FcL Um3qg/bjeu4iVCNI/Jp0dMT06D4DAM4qFDEb0rGiqYd6hIVTwmrLX8/b43sEJEIfZHqw Ug== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kgts185ds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:35 +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 2A1KUFO0014174; Tue, 1 Nov 2022 22:32:34 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kgtmay744-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C+qEyADnYwA5LCaIMHJXv6vTY67doYyR8GiiRDXFO2aaHnV0xCIG/EKEf2a0J3ZvEpA/QIuxTKk7u7ThGYEuvN9nATJqwsG97TvzjPOMoeJWbZZl0ZSBFQG6yQVRGT3FoXTAlxJ2x3WKb9qAT0KA3djZwnndzK5JM4X4vlGeYpJuIFnyQf3eoxbhSf45VQTgXuIMT8lYQvPzZ7ROFo0FU1XGRfYZvNC3OWHXG7TUSzNcPHG5KYjiCqAhwJ8x5u43P91vfXPFDVUqdUI2Ai5aE43o8LIlXAm52LhG8w3ETQs52mO08QrD+5XcsmolUkTcckNUmSwC7GLi79TK+KOUWA== 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=oMoaqEGsyjXMIw0FpWQmzwCjhrFnxArtk8XMtNUcCPg=; b=NTg0S0iYLZpI5XpnWKttjDLNDD5c2QZ9v5ddJDiY2Fu9OmJV+ZbjTtCH1zF06DCSaNTqG9uGOpV/XYqr9v74V6HV4nLeuFb13bp2Zz+PiAbjuprTgdpk6uh+1C6qpztnqZc+yCSJ+07AvwRtJ+1Ma0ryWGvpvXX2jjWG7TF12h0c6YOBlXKVn5/mqiNnTFSW8zZy3V37xxfPG3DtB/ZYtUgvcAOHH0vZrTo3cZ/SHZrUN4/WrqQ9KcoHFp4mFSr49xITq1yz0WeA39uIDJkuWbe1Xc1vbxJHlSkuavXeWKGo8MRgdkjcF8cnIDI/kGBEd6c2hRkjYYUsZ98kxPW3IA== 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=oMoaqEGsyjXMIw0FpWQmzwCjhrFnxArtk8XMtNUcCPg=; b=Q9TWcM4OhzCGn7n7bSbOuEZgPwZsptfzPVKxH9S0tSpAbiQUizuCONKpyDcnYEygN9suxZXwsTcXzbyALpf+39oaKDS8WojSvhbC2HIx50O4ArNVBv+s0DNvSLeV6ipFj0C8LwkebdGuV+RDwW++chlfN5f5o+7/XkbSVkQTXHA= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by DM4PR10MB6184.namprd10.prod.outlook.com (2603:10b6:8:8c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.15; Tue, 1 Nov 2022 22:32:32 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954%4]) with mapi id 15.20.5769.019; Tue, 1 Nov 2022 22:32: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, minhquangbui99@gmail.com, aneesh.kumar@linux.ibm.com, Sidhartha Kumar Subject: [PATCH v2 7/9] mm/hugetlb_cgroup: convert hugetlb_cgroup_uncharge_page() to folios Date: Tue, 1 Nov 2022 15:30:57 -0700 Message-Id: <20221101223059.460937-8-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221101223059.460937-1-sidhartha.kumar@oracle.com> References: <20221101223059.460937-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BY3PR05CA0023.namprd05.prod.outlook.com (2603:10b6:a03:254::28) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|DM4PR10MB6184:EE_ X-MS-Office365-Filtering-Correlation-Id: af68a9a9-7d8d-4190-0850-08dabc58f7a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xeQ9jYxa8G9aYaiJV+4T0JLSuoSdXI6L4+Higx1LB4pIhaDJL+F/6fwfxrXtPVg5wbHOlvm5KhWg+KEPz3uynzrr9mSQ9GpoEAsJ1fhnbHxcFzULY/DVjiQ7T2d2xApuLLYulk388Mn7XvPQJCTArTrawTGUgoL4rdP10c9JChPqmIbWhoi5gCKWFEh9m8yBtfFsYALVrod/ybqLHrx/3d9HXKCw83tscIK6AvH+bibP2Pk6AyMxWSADv/05zv3ioL+rWTv/i8J4cb1yld1dUdz+S/pOqGnDISLd+obsqBoWe9dkAvC9OqJvh/FwMGFQpZ3rx3l5qhB6oXn7g2DEtGCnwTUgMMa0/CixyMDud8xHRc7wBrTRBSTmR7gtM5p3J88Bd1RZYj+f4rrZzARwtzflcDMIAkp5TTjEv22qKuJztfIA6WKUpTaoFT/jcJUI3ES0vs4JwxezffLTV2vN4pa6gk53erZHZBisj1Cb6cUzpiq8xLMkX7JxHLFIrQIutxcMvyZXdpOUQOxt3ZIt0mDU8ZXZzLjXwPj8rU8BtCTtWjn/FRIsbNfJkAhI1jmAHt8es6X91Cps3GoiwYgKgO43KkYqXjLO7YkuW5z6aQj6QmiIAcdyVihtl2firdzzm2Ul+bMIV8buYR3PcahDLMJ9oAKpNC3ivtozLKNQR7SrIc8g7CKBz+iwa5gisDQOjtOy9Pr+jzsXu6k4jBXEOhBEQTBuKSURiGF0FlIkCtuN72WRmbWhaoq+bu7aeFE/ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(39860400002)(376002)(366004)(346002)(136003)(451199015)(38100700002)(36756003)(44832011)(6506007)(66476007)(107886003)(6666004)(2906002)(4326008)(316002)(66556008)(8676002)(6486002)(41300700001)(8936002)(66946007)(5660300002)(86362001)(83380400001)(186003)(1076003)(26005)(478600001)(6512007)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aZCCmPcY7r6gGpMgB27Sbn97EIy4d0IZxzsZApIXXczPA9jwv+6Tqdny0cFIk8T9kGwQkreG4Lp6q51QzGB/eo93IpKA5sHZN27Lsi28AZRrcmGHYUH3K2i5JcQwYa3QHpj2ez7PMyomJVC3xHJUu8nUUbhE4+3M3Bqw8Yih1Pkr1ZNlsqiBefKekJIzLHyVaUihlcATc922X2TBCBG2SQG6ntyclaMcQnDs1fF2lg4TiYYvFWfZmRYwzUiU2v1Nx+m2tECUkU7MjNCa0IeVDuxAMh5KopDnHLIYg3l7Djf3IhnE7Q7zquGLfi3LeaKRzbZTy3qhYxzO9K/20n/nOHHAqyAY2/609DmRkn26kjDnVC0FrAPOna3CoTMzKXBW9jkE+nndgBPjw1E/CQcTWd8GyyVNailZ+hp3kp85huTZ4ckF2/1XPbsJWfQ3FQpzXbk6Oafdnb0Ml38uj9OXxV2xu9B5nH87Ds2ZT2YTcp51UU3CNIRrkZ46B54RPL0BawJQKJ00UjdVcdA6Nrlj1ffOzTpxAPeKOGX423/uKi7nDY2aZsctpBvesLo7jXV8ztIJWW9YVQEDSVSyviiOCK826JfC+HYtw5ALX1CzqeiAsGkuzfRVz8v0gqKsVxoxm5hJBHDA4hWO2NIqH8wnPixKg3nunGS4p0Yc5DU30QVY5BfjJqPwy0jAJGgc7cEMHXupioQXBwGU/vMYrTwrk4hI4VzfCPnF3IVy0YlPPegP7WN2nUfOcLEkCVDGLNbZohJphDHiTkg+/EfXG3r25DrI28kAG2RIeuHhcd+XqdlMitt2xOOzQXBzxlO/ElMA2hNgZaIH2gxuANaqXLMD8lm0dcG/fnZW4GC9X5WIoQWFeuChtjyV5RCxCIDuykRYmQuhctqx5znaPSuVRkAiFHMnCMnr3MskApo+xFgEz5ZvUZx3gMxu3ZqGRiDQTrRJLTKh2FtM7v0AC1QkMc+8Wzw7sqnvh0eQQHbGEYqnB4/YnaVatnLg1BMp3QMbip1gRiQmOocwLG5KeAtmOAcgCh2jPYGh4UYO62GZvigsE6NbmIv2zUgptjBgQkXvIsskh5pIFpKrKYhGyf5E2NTqFy/VTvydDAKDo2L8K7NRy8HS+HWiGokpw0kur61BVg7KbNrH3biq0ymyHFCNoNTTZKnTfU6vRm4QexCoWzLhL65SyzuNyLeNlKnv9btvGDsmPO315oPgAhlVeExRBZgZp780oPZjaM0ouXhUq7SvfPiDQUk4GOLyhw9qnzYVvMLIZOtdmwWUm65QdxzIto84tKunG+2KyCLpbjdWGmn7DiEtHil2V+YSLLR8MsaAobUDtkSZH2ITLB4oRmeM4YbnpZKkeegkK3mOpOLuaAAbP5QDq58LhSeRW5hRqwKIUufkofwY/46AKGAqrvtw58BDdoh/gOdy1tOsD3g8Efae7CkOazEZBFA8Q851a1Ed9S5uLEHCdKOjEB/DXKEvvJKq7PicUllsq+fjpTmvm2lHkKg3zrUIpNKMY5SB3A9WYNJnvzCMgD3NongY1CIH0eu1VtGrNho0BF8AMX4h5CUbpygAZVIl9lbttlXqlXUgg4q7z98MTS4Me1+/vstS/sNMcA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: af68a9a9-7d8d-4190-0850-08dabc58f7a3 X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2022 22:32:32.6660 (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: dlwY7KQL6VHI8eakBGdeeQ0j2aKEIkdm9FUGoc4XzGUejF4Q5r/MdiDHzyUe+c0b60f0yN2tz3PB8gZVIsVYeFzYs3D0YxA8cwvPe2ZPBOU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6184 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-11-01_10,2022-11-01_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211010153 X-Proofpoint-GUID: 7nS8A8G9AwEmyi43NEDUG9Q1-R_Ptfwl X-Proofpoint-ORIG-GUID: 7nS8A8G9AwEmyi43NEDUG9Q1-R_Ptfwl ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1667341963; a=rsa-sha256; cv=pass; b=pEkMFN1CDlQ3VD7/cY0tPEjsn9EWgUb2ZZV+rRTdaSlgR6x19zFVDtfyxq38PJhUGZpJty /nZhZZBdTMmxQV9kOQSl20/cd/ocRoYXpQAC8Ype5ab1oXz1Myek78Rh+c020h6NWNqaiN ZL2pwUvMinTbN2WlaD6eWJzey8ydWDE= ARC-Authentication-Results: i=2; imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b="MO+PJM/2"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Q9TWcM4O; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf23.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=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667341963; 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=oMoaqEGsyjXMIw0FpWQmzwCjhrFnxArtk8XMtNUcCPg=; b=gC2aLGWfNsj0NMxounxMvP8XGm9sYfqJrm1lgeUXkgcns4XmYUWEk878riQKA0QcrBo+Ww Bb75iq03sgizPee3rTFKvyTdDPwfX9fz8wCkS2eDnPo6Er9BH0FZ4zsD6XCZgNpEXwPAad I1KCZn4zXjWA+PzbGpNpZl7IRBcCwUk= X-Stat-Signature: yxqaxmjbqqbzbqhhg1nmbketkwsqi99a X-Rspamd-Queue-Id: 76E0914000C Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b="MO+PJM/2"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Q9TWcM4O; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf23.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: rspam07 X-HE-Tag: 1667341963-81262 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: Continue to use a folio inside free_huge_page() by converting hugetlb_cgroup_uncharge_page*() to folios. Signed-off-by: Sidhartha Kumar Reviewed-by: Mike Kravetz Reviewed-by: Muchun Song --- include/linux/hugetlb_cgroup.h | 16 ++++++++-------- mm/hugetlb.c | 15 +++++++++------ mm/hugetlb_cgroup.c | 21 ++++++++++----------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h index 789b6fef176d..c70f92fe493e 100644 --- a/include/linux/hugetlb_cgroup.h +++ b/include/linux/hugetlb_cgroup.h @@ -158,10 +158,10 @@ extern void hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages, extern void hugetlb_cgroup_commit_charge_rsvd(int idx, unsigned long nr_pages, struct hugetlb_cgroup *h_cg, struct page *page); -extern void hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages, - struct page *page); -extern void hugetlb_cgroup_uncharge_page_rsvd(int idx, unsigned long nr_pages, - struct page *page); +extern void hugetlb_cgroup_uncharge_folio(int idx, unsigned long nr_pages, + struct folio *folio); +extern void hugetlb_cgroup_uncharge_folio_rsvd(int idx, unsigned long nr_pages, + struct folio *folio); extern void hugetlb_cgroup_uncharge_cgroup(int idx, unsigned long nr_pages, struct hugetlb_cgroup *h_cg); @@ -254,14 +254,14 @@ hugetlb_cgroup_commit_charge_rsvd(int idx, unsigned long nr_pages, { } -static inline void hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages, - struct page *page) +static inline void hugetlb_cgroup_uncharge_folio(int idx, unsigned long nr_pages, + struct folio *folio) { } -static inline void hugetlb_cgroup_uncharge_page_rsvd(int idx, +static inline void hugetlb_cgroup_uncharge_folio_rsvd(int idx, unsigned long nr_pages, - struct page *page) + struct folio *folio) { } static inline void hugetlb_cgroup_uncharge_cgroup(int idx, diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 387b8d74107d..2ecc0a6cf883 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1726,10 +1726,10 @@ void free_huge_page(struct page *page) spin_lock_irqsave(&hugetlb_lock, flags); folio_clear_hugetlb_migratable(folio); - hugetlb_cgroup_uncharge_page(hstate_index(h), - pages_per_huge_page(h), page); - hugetlb_cgroup_uncharge_page_rsvd(hstate_index(h), - pages_per_huge_page(h), page); + hugetlb_cgroup_uncharge_folio(hstate_index(h), + pages_per_huge_page(h), folio); + hugetlb_cgroup_uncharge_folio_rsvd(hstate_index(h), + pages_per_huge_page(h), folio); if (restore_reserve) h->resv_huge_pages++; @@ -2855,6 +2855,7 @@ struct page *alloc_huge_page(struct vm_area_struct *vma, struct hugepage_subpool *spool = subpool_vma(vma); struct hstate *h = hstate_vma(vma); struct page *page; + struct folio *folio; long map_chg, map_commit; long gbl_chg; int ret, idx; @@ -2918,6 +2919,7 @@ 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); @@ -2932,6 +2934,7 @@ struct page *alloc_huge_page(struct vm_area_struct *vma, set_page_refcounted(page); /* Fall through */ } + folio = page_folio(page); hugetlb_cgroup_commit_charge(idx, pages_per_huge_page(h), h_cg, page); /* If allocation is not consuming a reservation, also store the * hugetlb_cgroup pointer on the page. @@ -2961,8 +2964,8 @@ struct page *alloc_huge_page(struct vm_area_struct *vma, rsv_adjust = hugepage_subpool_put_pages(spool, 1); hugetlb_acct_memory(h, -rsv_adjust); if (deferred_reserve) - hugetlb_cgroup_uncharge_page_rsvd(hstate_index(h), - pages_per_huge_page(h), page); + hugetlb_cgroup_uncharge_folio_rsvd(hstate_index(h), + pages_per_huge_page(h), folio); } return page; diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 351ffb40261c..7793401acc12 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -349,11 +349,10 @@ void hugetlb_cgroup_commit_charge_rsvd(int idx, unsigned long nr_pages, /* * Should be called with hugetlb_lock held */ -static void __hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages, - struct page *page, bool rsvd) +static void __hugetlb_cgroup_uncharge_folio(int idx, unsigned long nr_pages, + struct folio *folio, bool rsvd) { struct hugetlb_cgroup *h_cg; - struct folio *folio = page_folio(page); if (hugetlb_cgroup_disabled()) return; @@ -371,27 +370,27 @@ static void __hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages, css_put(&h_cg->css); else { unsigned long usage = - h_cg->nodeinfo[page_to_nid(page)]->usage[idx]; + h_cg->nodeinfo[folio_nid(folio)]->usage[idx]; /* * This write is not atomic due to fetching usage and writing * to it, but that's fine because we call this with * hugetlb_lock held anyway. */ - WRITE_ONCE(h_cg->nodeinfo[page_to_nid(page)]->usage[idx], + WRITE_ONCE(h_cg->nodeinfo[folio_nid(folio)]->usage[idx], usage - nr_pages); } } -void hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages, - struct page *page) +void hugetlb_cgroup_uncharge_folio(int idx, unsigned long nr_pages, + struct folio *folio) { - __hugetlb_cgroup_uncharge_page(idx, nr_pages, page, false); + __hugetlb_cgroup_uncharge_folio(idx, nr_pages, folio, false); } -void hugetlb_cgroup_uncharge_page_rsvd(int idx, unsigned long nr_pages, - struct page *page) +void hugetlb_cgroup_uncharge_folio_rsvd(int idx, unsigned long nr_pages, + struct folio *folio) { - __hugetlb_cgroup_uncharge_page(idx, nr_pages, page, true); + __hugetlb_cgroup_uncharge_folio(idx, nr_pages, folio, true); } static void __hugetlb_cgroup_uncharge_cgroup(int idx, unsigned long nr_pages, From patchwork Tue Nov 1 22:30:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13027550 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 75C1DC433FE for ; Tue, 1 Nov 2022 22:32:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17C9F6B0075; Tue, 1 Nov 2022 18:32:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12D166B0078; Tue, 1 Nov 2022 18:32:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE87E8E0001; Tue, 1 Nov 2022 18:32:54 -0400 (EDT) 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 DB5066B0075 for ; Tue, 1 Nov 2022 18:32:54 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id ACE0280EA0 for ; Tue, 1 Nov 2022 22:32:54 +0000 (UTC) X-FDA: 80086324668.30.24137EF Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf06.hostedemail.com (Postfix) with ESMTP id 49B7B180002 for ; Tue, 1 Nov 2022 22:32:54 +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 2A1M4FL2025143; Tue, 1 Nov 2022 22:32:46 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=U8GNRVdIZHDwJjSJicnPzgyXDu2AHHtDvyuYMdP+V7U=; b=k0fhNIbQ7b/86LTdsvNqlx8+Qumi+VTZrlV4SQ8iO9ug6zE571yRkIGZZslmhxAMyt52 7YyaGwcCe/vP3OZ7eDwM23DhOQK1Ohq3nReU10WtdeO96zgSbd91Xwo2dq8C1JU3gfGb 4o/zJFLeWVEAf1ZES+NopUQgoTjyRMDnbcyretvIT4Tbu8GV9vjxpKM99NjYHCkoaKR3 9Yii2TM5YxF1U8nE2EydNUDax8+tj6U/xKyGNE2WBdZLhHaWGdPSH1SAPoISYDaLnPg6 xqsPXSBrJHI708btvSUQbfvEbfELNg0KKO/AtbOUu6N9AcMKGxdbUemVA/IGvqhYxZ62 Ew== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kgv2afx2h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:46 +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 2A1KaD3L014155; Tue, 1 Nov 2022 22:32:44 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2044.outbound.protection.outlook.com [104.47.57.44]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kgtmay76j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VkUhIQJHBFV6H/8t9sfk1TPzfCv2iL8aV6qhimv8j7BAPvuu0wX5C6k8Rj/4hs+rPnFLilTugVyUXy6s5063cK2M4O+jXbz+pEIP7x7J2Zk0yl0qVRQ3SNXrbsxjAjv7v/PZDJI15htL9bPALZRKCl0Jisa+SpWRf+jwcjh6iQGnjRQjizylnTZVChIqSQlRhngQs20v51niR2ylegk1967AB5dnx4UQMcvRK/dtFVyYQK7H1lidG0we8H/MzDPa3J1t6lmq6KNlS7S3djJt494P6K9yoQ0ZWZ4yrCeYfQOHuJvqMlau0qSNTXsTsf11GTTw9QgpMiTqZiaDpnilWQ== 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=U8GNRVdIZHDwJjSJicnPzgyXDu2AHHtDvyuYMdP+V7U=; b=CaBSgOfemhb2VzOmbFGY9NfB5nrcqChHnQ66oX4gsPguu2/cPLxHM/pDf7Ez68z6OCKCkqosT8ugxhx1cJ8NqqonG7mq4pj91d8aVbuS4gF3MvfPuk6oYzRYVNYhetdfRG2i9FDMPe7QA18FeoD+aXDfv+B9+gtrshT2axny/71YBk91FjTbyuE4efG48oxNTP/H/3ATJC7XeJFLkLaO3ppe1fxxL0T/SAo9qWZPm+GXIn1kG+iRI6uuaUViP4r+U1kNOn897eVUuq2/YyGja+M6gvhRraB34icUXRreyw3dz+k3ubbeFrqZ9OUa2lU8z4s1GUfG6TqrQxRGPiQOrQ== 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=U8GNRVdIZHDwJjSJicnPzgyXDu2AHHtDvyuYMdP+V7U=; b=c3q6WUBJod9yiAe3MVR3gVEHWjPS6u7zA75Kd4IQhfnG3joUJI5IFEM2vb0UIaNH2MGXzmZo/8g9RjjH2/AgGVN32ngvehQMBiRjCOhEyvqop2Bh8MVh/igzuLdgmSzb2IHyJUjAR3hinv7LS8DpAzCZSuQdwLV7qYdJ/j3ch4Y= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by IA1PR10MB6075.namprd10.prod.outlook.com (2603:10b6:208:3ad::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.21; Tue, 1 Nov 2022 22:32:42 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954%4]) with mapi id 15.20.5769.019; Tue, 1 Nov 2022 22:32:42 +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 v2 8/9] mm/hugeltb_cgroup: convert hugetlb_cgroup_commit_charge*() to folios Date: Tue, 1 Nov 2022 15:30:58 -0700 Message-Id: <20221101223059.460937-9-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221101223059.460937-1-sidhartha.kumar@oracle.com> References: <20221101223059.460937-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BY5PR17CA0048.namprd17.prod.outlook.com (2603:10b6:a03:167::25) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|IA1PR10MB6075:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fa8d2c5-80fe-4182-bf5a-08dabc58fdaa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /L8roKBLr5lc1a95u+kYdzzAKlq7gpQmVUFWJJxDgQtP40D0uZpKYzynY7emrWtr6R8UnoN7nspiZi46Z4hSLNAPMCsZRMvFldd9Vz7nRfYwnuVFX1QHBFTiMuTB70qy7/GV9DZzUsPQMxy9n/uY2chy3S3iMYzJTfMpcEgoGkmCtC1FGJrugidB9vOB+2PL2TVc5JuKSHBABNzHHxJnRxbD9glTfR8aWYxizYT9Uc5dTxGYPg+wJA+n1Hnl3e7CxhKCfY3wYUWJ9d60coEPJrlZhJaYaIyWmRy7AnmEKIMMv2ROFxz8Xak7EDxr5R8b9nYGa7+SFrLo+sUmA7/q/pGi5qCIeIdQKAJCU1h8FVedFf+SZ2zSkk3Ss3nl4hFN5E9OZLoGFtGQ4zEPFsE2oqVDNuDayAjojkloaYglQnsBZO2K0hFb96w/pXRdluNelI751JHUocrPFHc3brQuC4dsEn4Hfl5RPHe08GiY3EU12PR56vnnnMxt49nkKYNWCxzaOq7mn49J8kEO2o2GZiEVuptYUVjaMYNISRDUeOja3nPsf/uceCmGRpnroH2ifqLNrUUCRjTfI6VBWbBZK0V/FQNAHHKznjbUSpTKYLvAHJ2ZIP4ereTpW0MaBlZXty7HQFKa6rkw40esfKFMzn/Qnjd9/fSuHvPsWRDRyXlMjxSlsL9gN+6oEd4uvLggT8wBZhI7h/JdEhsUURs9qQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(136003)(376002)(396003)(346002)(39860400002)(451199015)(36756003)(86362001)(38100700002)(83380400001)(2906002)(5660300002)(44832011)(107886003)(2616005)(186003)(1076003)(6666004)(6506007)(26005)(6512007)(316002)(478600001)(4326008)(66556008)(66946007)(8676002)(66476007)(41300700001)(8936002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cr6mnHx3HDzEBQki4iK7S0Vh+Ph8zrK1Zq2nxlbE4Kixp9OhHcUqSQQcH14nBFnOTsXoF5UWXg4nAs3FMcfHWGtd2XrFCpOjKy7i+BFLUxvpX6oNRf7cpS7FVgnCXK4/dsX0b4SDun4gc0x38oMQK3q35RDRlmn/DEbxWf4kVWU4DUJ4hsVSnHihYq62wpJ9HyCR8gM7P5kA01mROF6qeKzyOtK1P1sjVIu+mxjOPm7DA3WamVtBc+D5yI12puewA06si/d24a7C1p9y4mqt+9tsWAVlyBoB2nhFtEpGYpD2LckxpaZ/fKoZDZG+GYycll8bBtlp3CLN94Skwa6hSDq4x9xeKsm6i2t35c2Ku8woBQyVScV9UaC6c5Vz5vpnqbg4i4EZ+wfRVO1XRyCiFGUl8OayjV0L7Vje1l2wckOKO04qQ+MYwRQSPb+3uu5ckEf0Ijj28ilAUPHCcup08RIDcgJMyqD1slAe6rqEezEOFYQ5+cA2HwjvJJbg4Cdq8bZ1Obn2BN51sdSzliMUUcVvA3zDtsm7xvpzSpN+Qf6eD38tXn4/QNWFEfkdq/NHUxFmTPAaRkI5YsMGZO9ve0hYuVv3NK8SkYlKA/1as2UUYPyJlNc6xINc2xLJlptO8Dr+zd/2QGoXx8wCzSrW4OFvG1aO1LrE3PxWwp1ybmwSJJRtZ666nBsaDBqm/oiejYv960bD3Ah7lpapftS145VJfDtGvPMC6r+t7Jr8g7QofUiUG+B7BYLoO0oqDEt4Z9f/afsZdruddVayfWiaIRhEp4WNrd+y8GGYG/Tiu3uF7UC0f39Fa3HayIXr9JWbKNT3liPfqLtp13hLkBF6AEAaIP305S8yXQ8qOi9CG4Ck+d+knRBDg4P/zq1WaPOCMv6japNQpHYux9HCrWovscBvJxxLbtY1O+D6c8UcgtbcqvHKwdepJtKgARmHgWc383rZ7r2NFUibHAVWSI4jaDeGly5cjmcpv72YXWk5YpITcsZ370LEsenUgBG7NZzZmBho/9wnI9twXQMWRJm2I33ngafO5sWqPP8JV2fQffNyFwU0NUhIloNA4+qjUP6bpTgNnex4PtO21BfpBMLSPE5wA/y6oXu0gyl+jRllqImwz3kJHcEQAmu6N/uOorZNmMdWd6gVbpP53hQzNZbwXsQQuAWqnQUw4vgMVAN6niBgcu+DFbLOO7a0vtfDmpGMm2fVMvLF3S6SMmaXrGKUt6LMvthYMRNSu6IoDCWWU/R32sBORTSFod3Ww5cLFnleanxWfsaFK6KXUdNOCoQoo1XE5txVJ7IpASnUt63bTWI6EoKise2lW7jleo1bOtc0QyLP9GXwAqetLxL67IyCIs4KfgLzB+tx9MVkus0r5N3JfnlhNjbwmKnOC/TmGNUvx9Df3ckNGDM19t4Q31iB3CmnE+CPxvjs5COtOUGfBUCxgmXCnSkvWw91iFw56i+jrzfcBHT3+t6J3vlsiJ7xWV0J90MvY07kkcAuWi964sVfXB9fLnWZYEfMuDk2mMND7cqu3U1DyXV0GPfHTHNohbwpxgbSSspr7bJ2jdsJR5B5ldSFGy8bdfQ13jap16tREK9fMO26JgR2yPZQKdoErQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fa8d2c5-80fe-4182-bf5a-08dabc58fdaa X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2022 22:32:42.8129 (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: CkQ9oohsh+vj6yLqYTl/ddruHVJeBb8y5w7GYjsOnWxZ/1XaO/T/PtBHctnwXCF0dP3z2Wk7I9ePOBfMSbndL49V8zv/2Nn0GCPbHjLYfXU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6075 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-11-01_10,2022-11-01_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211010153 X-Proofpoint-ORIG-GUID: PrvyYc3TPCdxkyBlbsklyfp4fw8O3R4i X-Proofpoint-GUID: PrvyYc3TPCdxkyBlbsklyfp4fw8O3R4i ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667341974; 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=U8GNRVdIZHDwJjSJicnPzgyXDu2AHHtDvyuYMdP+V7U=; b=xwooI1r3+aVck2z+ewmMnwiVKF2Jz6BpCZOIXu/Dyxb3pRmMGmEVHSG+W7DXgDqZxOwd9Z REcaEpr7FSKJdNfinhuHJNdihi+5hfXIaTsK+HKBungLVB2DVBoZRVl3w3BENgVnSX2XUt u9cIOscd1rpgflIDH9Lm9WQxYRN6Fe0= ARC-Authentication-Results: i=2; imf06.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=k0fhNIbQ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=c3q6WUBJ; spf=pass (imf06.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1667341974; a=rsa-sha256; cv=pass; b=aPJmcG8dwuOEtmipXW6YmyfUqf1sS9HLRXrQE6xWA2bm9Y9tp8IAlYMRwPl7JQda8hOa+w 4Xs7TzCfQiOihIAarWDOIFCAJbepo3PkDEavVuNHN1Ix+zmalnYRLrhd//gbj+px8qXG5O L9fzm8q/t/FonnKa5gci/cYs+Onopog= X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 49B7B180002 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=k0fhNIbQ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=c3q6WUBJ; spf=pass (imf06.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") X-Stat-Signature: nzrjrayod9gr6ytgbttkqp989or9xhqm X-HE-Tag: 1667341974-405432 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: Convert hugetlb_cgroup_commit_charge*() to internally use folios to clean up the code after __set_hugetlb_cgroup() was changed to take a folio. Signed-off-by: Sidhartha Kumar Reviewed-by: Mike Kravetz Reviewed-by: Muchun Song --- mm/hugetlb_cgroup.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 7793401acc12..69939c233f4f 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -313,21 +313,21 @@ int hugetlb_cgroup_charge_cgroup_rsvd(int idx, unsigned long nr_pages, /* Should be called with hugetlb_lock held */ static void __hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages, struct hugetlb_cgroup *h_cg, - struct page *page, bool rsvd) + struct folio *folio, bool rsvd) { if (hugetlb_cgroup_disabled() || !h_cg) return; - __set_hugetlb_cgroup(page_folio(page), h_cg, rsvd); + __set_hugetlb_cgroup(folio, h_cg, rsvd); if (!rsvd) { unsigned long usage = - h_cg->nodeinfo[page_to_nid(page)]->usage[idx]; + h_cg->nodeinfo[folio_nid(folio)]->usage[idx]; /* * This write is not atomic due to fetching usage and writing * to it, but that's fine because we call this with * hugetlb_lock held anyway. */ - WRITE_ONCE(h_cg->nodeinfo[page_to_nid(page)]->usage[idx], + WRITE_ONCE(h_cg->nodeinfo[folio_nid(folio)]->usage[idx], usage + nr_pages); } } @@ -336,14 +336,18 @@ void hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages, struct hugetlb_cgroup *h_cg, struct page *page) { - __hugetlb_cgroup_commit_charge(idx, nr_pages, h_cg, page, false); + struct folio *folio = page_folio(page); + + __hugetlb_cgroup_commit_charge(idx, nr_pages, h_cg, folio, false); } void hugetlb_cgroup_commit_charge_rsvd(int idx, unsigned long nr_pages, struct hugetlb_cgroup *h_cg, struct page *page) { - __hugetlb_cgroup_commit_charge(idx, nr_pages, h_cg, page, true); + struct folio *folio = page_folio(page); + + __hugetlb_cgroup_commit_charge(idx, nr_pages, h_cg, folio, true); } /* From patchwork Tue Nov 1 22:30:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13027551 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 28538C433FE for ; Tue, 1 Nov 2022 22:33:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDDA18E0002; Tue, 1 Nov 2022 18:33:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B8CBA8E0001; Tue, 1 Nov 2022 18:33:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A067D8E0002; Tue, 1 Nov 2022 18:33:04 -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 911CB8E0001 for ; Tue, 1 Nov 2022 18:33:04 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 670E5AB5D7 for ; Tue, 1 Nov 2022 22:33:04 +0000 (UTC) X-FDA: 80086325088.05.DB1C3EC Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf08.hostedemail.com (Postfix) with ESMTP id E38B6160005 for ; Tue, 1 Nov 2022 22:33:03 +0000 (UTC) Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A1M3xWC016221; Tue, 1 Nov 2022 22:32:56 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=S17dg2dyeQUIoXTB9U1R9CMRu2YgHFA8Z60QOzRAZ7o=; b=Jr+UOFti3vagBqAktcoRadVUKEkNGiD906OrBY7jjb89KrwK4D4EnPb+i8x7LaIgyiPt VnNvjfl4JqMcU2BJ23q0U+1O+qPn8kX79He9nd2tnCutl+XqYjOfVJ4CVLxySTKq8hV6 gUIGPQmnKKPli65kNkqWHJONituGAs3O7MDUbMcc8M8fcK22b/SD5XbbyAAsp2IbVpYM x+3LKtYWtYhKPRs+N+ekbujhBfK4oFqOE67yFizIEAppOLlwsRvdQpsRS9soqpZjqPe/ CNUVGW/YWWx7bONw9psx/nScHuraOk0iw+HXtkzwVco+Km2VyFjGFD9ySIAs3IejjJVX ow== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kgussr1xm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:55 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2A1KbWqC014088; Tue, 1 Nov 2022 22:32:54 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3kgtm4w34x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=euUPyiBWkBgxH6KIlWovRKYJS+NoQyGhXxRtg77RlhhGPc0ZPOGPy8A9hlg32bMmGxXGtrZLMV9+B90T0vtH1psbFj+1+Jia6H3iPdBQqZTUd5lnr6LFHOS9sLf/Bvc+tzge1Ncc7OHH0OKerVr4LmNVIEp8FgvByPMHdmuudOCxAZBmmKTkdUzexZRzCZsyuPnR/9O7Vnf4R1HKXLbTKIhObu37np7ykTbgQ7q0j+6167dfEjQO3Xuf/lwg7FNs4LocLURuV4rx0NUaWkhx9BhQglEirSt5Mx+Jl4CESTvFcrS2Tbg6PTcmgYJRE1iMx9LjB7Ctl9gTBWpOh78xUA== 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=S17dg2dyeQUIoXTB9U1R9CMRu2YgHFA8Z60QOzRAZ7o=; b=XZ0J0GQIUxm8g7OGBBj6pcLBVkJygpWznYp24DjbKBmxB3Narp/L6At2eZrRaDqKQyc06RdDqweOA98rRFEGje/y24HUt83zHx0AOguZtRyTb7Z/yQoMTYJNvCfo1Okq0hD61MUbx3jEHCeVxJlBQ9PGMINZvfeVAOPWIvfqEmR8YFgJHRmnr5eXU8XL5UXV4fivv5i/ujpm+2EjwooMLyxs32poPb5yWsBrcSjKl8GHEMcYK1XPW5B8za4RZbTMgkIG/4vBWZDIeS7uWDfnUYfGms+CCn7W7a+AEEVJORBEeFWF0U7vU1bdtq+oVcl15dmrBcPyBwofKa06wexTGQ== 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=S17dg2dyeQUIoXTB9U1R9CMRu2YgHFA8Z60QOzRAZ7o=; b=rUuZMVtKi85I5TDzsR/tq8dH73VrKUHfSiK5qcDhV5oBcCNtJV1b69K56MA9/Fza38WGthSpDyVXG7azZt9z3SVbB7j9dfNTB9D+qq4pEN+KQZPqv+mUWLbrNyuIOzuxx4auw43x3aLqJ00Au49ICfc7QAaBNg9UxNJWJCsASrU= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by DM4PR10MB6184.namprd10.prod.outlook.com (2603:10b6:8:8c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.15; Tue, 1 Nov 2022 22:32:52 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954%4]) with mapi id 15.20.5769.019; Tue, 1 Nov 2022 22:32:52 +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 v2 9/9] mm/hugetlb: convert move_hugetlb_state() to folios Date: Tue, 1 Nov 2022 15:30:59 -0700 Message-Id: <20221101223059.460937-10-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221101223059.460937-1-sidhartha.kumar@oracle.com> References: <20221101223059.460937-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BYAPR07CA0001.namprd07.prod.outlook.com (2603:10b6:a02:bc::14) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|DM4PR10MB6184:EE_ X-MS-Office365-Filtering-Correlation-Id: 09bbf4e9-4ef0-413a-bde8-08dabc59039e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z9PtVLjkl8kkh9zOZ8k4H1g/XorjWHAdWsijrxL+QfLV92HomvVqCShUUVBE8KW7faGIo4V7iw/esYmxRbLWG9SBx3q5RVJXESWZavoJsYZEhZagiW7w96qbvcft6lbkFc2SlxV80d8KCVz7xRrQXsYOMKcmqKKGDChXKE02EMcJ/syCYxHD8+OAMF1SxUERY+7ELlQEHvt3U8mKbMSV5R1QMlCEBx2U3Pri8HBMECQ33t3yZrOKfTs5mlSAedKpktlkwdG+2LMzCbi5iEagl4iAS0qoaHJeBnWCMN1IOH9EnYQAZCko2Aa+zShvDAAfSW8otQ/Q7ddqgkvITb6HfKlcWTxMT0KAqzr1PBsI/Ha652owlc+Pa6LpxCt/7cbRwT3/EbYfPNuXujNSUbnhoFl6NDcKe90Wtgeg9TRgEtozF+ZJYtVu4/eWDfJFRND5xuXOz0ZgKXpD+B+PEpvpftZ0pNbYo4iS/VQxwkX64/TP2hTVM6J7P4T0dmLG1COBZ0dvQ7CIPl93cQ63j2AXYdp7k6YpRrFeZ9ygXUiO/DvPnbYPPWNuvjLoNb1FvNaLYanELfwB3nVLP80rmevsoEtLA9/4Ir7pQxC2o9Ww8XvkkMFyfElnhz31G3JXSzE1ppNj1MzJwJVFFwLsh3R1xwulMukb+6mRXALpplOBCHlP2kjsGP8O+MC6Mi3rWm2fbHj2v+6GuSmQVl2bT4wNhnUo76T1467mDks2zFd7GfHgqSmSGlSUXVFnr/UwV7Za X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(39860400002)(376002)(366004)(346002)(136003)(451199015)(38100700002)(36756003)(44832011)(6506007)(66476007)(107886003)(2906002)(4326008)(316002)(66556008)(8676002)(6486002)(41300700001)(8936002)(66946007)(5660300002)(86362001)(83380400001)(186003)(1076003)(26005)(478600001)(6512007)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IUrYBReM8eErcC1KuLAXTTbGtLqAj37GNPGK2OkUWm37RU6yje5P9L00XpYFFkk0S8vTBXhYCbvMVhag4iuJtckSN59+qYQZLl3aJ5240JYmXzpM/FlDEVeEcTt0XWRQRXwPZwm3o4ixagkgHrn7h/5rz5/3WPsBn7OJmApDx6NnMhDgSKeCxDcgi/QFTby6TsXzx4yFxUSJi+17UztEKSdCkdTwmPrsW7FbIlvN+Bwuh7apg7SzDG+He/l213wCFXbMHruoYwxaQIh1NIZRnJqhjtoa8XxmaMV9/DfjPm+fewNeFIfzxJLYxD6Ncu+D4bkewxzmQM04drUfeP4r7rTDRoh6zUioXiIe1tzbH9ofnQQiLYAXlqvlByjggWO7w43biaGh4R2q07KiWqLlUHymRKTV66cZ6HiVYxLk5AfkT5jaiOmtu8+sKguD6vCUr/R68pG78bVo8MKzJlbxspgqzVWyzznmY4hqoxYL5/DU1J8y4TG6Vf9vm2WPpmTdW7zs20SQstre5dg/rEks3vfrkamjeH9ZfLciCQj2PQkjRPX5Uf5UpNwuQUivjjfUTU4in2rJ+/tDZKngTyghoONQaVF3lEFqkIjYyfXm3MPB3Q8NE/7KghNY5tuLfspwiECMkAs651wTGiziQv96yDpEeeBhTqIa+lIfY3ccQjBepZRlglrFipxeKZ0zaQpmhcxY3qfVdgm1SydHYuAHQHtaOjxKI2+VouEY8j5eERl5a2JiwGSiruwb6/QQDBz3crMCrR7HCWjLA3BImxvpMEl3YQE0qM5b4Y/rYluDb9yJHviL+QIg5Jifqq11KxMkt6i3Fq+lHlfwNTJI0BUsY8rfavxTYzX2zO4JciJOYAUQ+vLHRDz8/V05SqkPrmgRh3JlW2tYo1+jklFDFk7JdL9dpY54u92WDguJysBMMErqzo2guJrFLXgGtDINtpe3BWP+RP8Mj0CZeqROpr3qkqwVMe0MUAGz8xzTJpzQ18Q0B5tQsGeMzswSIfo1eaAvqycw+Kmy5uwRD+OKjV+uMcKunKaE611posdc103pkzEPvYIPfTyEb/1d3VSEksMhBkn8sbF3oDJzIngnDJmbUdVOh4UTYT8cDUM6jad5UafipXQt1atTNSAlzRHBmdn0wuBWvT8r1gE/XZ1Nj0BLBu4ZFHui8KYnT/c3zzlojCySEJ58rUtZgd+tHHCqZSx8++at10fn36tmqlTXLDgGk697B3SIUM0APqTHIZVgPGfHdy144cwcoEMRkgfOFD+xcK+JO+6sVhQYGfGhLcGX4MGWeYOjkREeiNzW8k1b7+WS9zkOtq3K+x0rzvLuJe/mmeyk719UMZ2idT/Ns/QxkAalyFEGarWvi5dwwwTSXjA2QNQC+bGn9v9Mqi7ykFpSLMWI7A+7+Lib4PQGQsYZdvq7DovGLssfpITTSVhaBRZQ2bSbHy2FMZqn0Vv2Yp4XKkhwkGXmJCBVKCLUXaBd3o2xq4ofwNFGF1Gyo2Z4CkSPYLfZHY597Epnh7utFc0r2xAjCzdR8Tic4KbStEIprG2UpJPecGRIIudLRZB46aBlALcEiyFllbDBQbASDEQbS/maabR42cMtvkjDro3QuA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09bbf4e9-4ef0-413a-bde8-08dabc59039e X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2022 22:32:52.7084 (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: /n377HLAIYQcJ8lgYrKqw05wCtirD3my68dfjeBZEq5f5xl/a5LZ9JxiqUttQi/6p4X0KX9Ua9KbPVCnKg8kNFULkBz+Rd+Yr940KxQn4/o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6184 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-11-01_10,2022-11-01_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211010153 X-Proofpoint-ORIG-GUID: j1spNW1vW_Cn6TdX8aw24239zZYUOnu8 X-Proofpoint-GUID: j1spNW1vW_Cn6TdX8aw24239zZYUOnu8 ARC-Authentication-Results: i=2; imf08.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=Jr+UOFti; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=rUuZMVtK; spf=pass (imf08.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1667341984; a=rsa-sha256; cv=pass; b=Us4G/wB3dyrjrnpOILShH4QFUPTZe1yArIxO4jMJS1pIk6GR+Z4ZlB5P3p2MpLk7NyhRwG 7jpQrbC80OjE87jPUdNSOgiVGeOnY1kgB/86Wh2Hz/LA2LPEMhN9maDXz3xyu2jeH1v1iv qgXZj2SjuW1GD4e0J6O3bpHAJx2YDVE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667341984; 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=S17dg2dyeQUIoXTB9U1R9CMRu2YgHFA8Z60QOzRAZ7o=; b=LJ+SPSZx4GFPY+ynAI3BjQaFF2IfHQW3+V57OvCHybqFkndMRxAxn64cJ+EkFtgCUHW87W Z2ozVPAaDGaxXbdr8nkfxRzXTCHI7YOzFESZeWpTfn7rjIlC9pMawe3yM6PT93Di+e3Kjd 3lvtlO+Dfb/093o32AMJNTu/4LwB3rs= X-Stat-Signature: 1jnoeeehd957he1sye13gdqmh45ks9pu X-Rspamd-Queue-Id: E38B6160005 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=Jr+UOFti; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=rUuZMVtK; spf=pass (imf08.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1667341983-456742 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: Clean up unmap_and_move_huge_page() by converting move_hugetlb_state() to take in folios. Signed-off-by: Sidhartha Kumar Reviewed-by: Mike Kravetz Reviewed-by: Muchun Song --- include/linux/hugetlb.h | 6 +++--- mm/hugetlb.c | 22 ++++++++++++---------- mm/migrate.c | 4 ++-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index d81f139193aa..375cd57721d6 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -184,7 +184,7 @@ int get_hwpoison_huge_page(struct page *page, bool *hugetlb, bool unpoison); int get_huge_page_for_hwpoison(unsigned long pfn, int flags, bool *migratable_cleared); void putback_active_hugepage(struct page *page); -void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason); +void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int reason); void free_huge_page(struct page *page); void hugetlb_fix_reserve_counts(struct inode *inode); extern struct mutex *hugetlb_fault_mutex_table; @@ -440,8 +440,8 @@ static inline void putback_active_hugepage(struct page *page) { } -static inline void move_hugetlb_state(struct page *oldpage, - struct page *newpage, int reason) +static inline void move_hugetlb_state(struct folio *old_folio, + struct folio *new_folio, int reason) { } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 2ecc0a6cf883..2ab8f3b7132a 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7289,15 +7289,15 @@ void putback_active_hugepage(struct page *page) put_page(page); } -void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason) +void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int reason) { - struct hstate *h = page_hstate(oldpage); + struct hstate *h = folio_hstate(old_folio); - hugetlb_cgroup_migrate(page_folio(oldpage), page_folio(newpage)); - set_page_owner_migrate_reason(newpage, reason); + hugetlb_cgroup_migrate(old_folio, new_folio); + set_page_owner_migrate_reason(&new_folio->page, reason); /* - * transfer temporary state of the new huge page. This is + * transfer temporary state of the new hugetlb folio. This is * reverse to other transitions because the newpage is going to * be final while the old one will be freed so it takes over * the temporary status. @@ -7306,12 +7306,14 @@ void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason) * here as well otherwise the global surplus count will not match * the per-node's. */ - if (HPageTemporary(newpage)) { - int old_nid = page_to_nid(oldpage); - int new_nid = page_to_nid(newpage); + if (folio_test_hugetlb_temporary(new_folio)) { + 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); - SetHPageTemporary(oldpage); - ClearHPageTemporary(newpage); /* * There is no need to transfer the per-node surplus state diff --git a/mm/migrate.c b/mm/migrate.c index d7db4fd97d8e..81f9a36c754d 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1278,7 +1278,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page, * folio_mapping() set, hugetlbfs specific move page routine will not * be called and we could leak usage counts for subpools. */ - if (hugetlb_page_subpool(hpage) && !folio_mapping(src)) { + if (hugetlb_folio_subpool(src) && !folio_mapping(src)) { rc = -EBUSY; goto out_unlock; } @@ -1328,7 +1328,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page, put_anon_vma(anon_vma); if (rc == MIGRATEPAGE_SUCCESS) { - move_hugetlb_state(hpage, new_hpage, reason); + move_hugetlb_state(src, dst, reason); put_new_page = NULL; }