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: 13930 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3246887wru; Tue, 1 Nov 2022 15:33:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4GJ66haiDVoXtoFkAyrlCr1ic5cAk6fzXBOReASfwjPPT3CPx9TL9ulBSCaqLaXRcx6ruv X-Received: by 2002:a17:906:4fce:b0:78d:9fcb:50c7 with SMTP id i14-20020a1709064fce00b0078d9fcb50c7mr20889635ejw.63.1667342021059; Tue, 01 Nov 2022 15:33:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667342021; cv=pass; d=google.com; s=arc-20160816; b=gTvKRy2bvEH4Dp/bjOHEDK1sL591vfEaVkZddFw4/wSsZdUxJG2+sn9LwCeQrAWAAl MbDCF798FU/3NcCnkHlX6O3hShTvMdpSD744FY/N/eH3ArQMg+6O9CPFC9couo9bh3Zs FK8PnHFoux71MNvKh4PNR/K2THhUcoVnIRtOzqsDsGC+YT0kHM9JUCiXnqvH3Jc82fHf wiyiQtU18GfYPMNgJ4sz0tqwIbo07+IleNGNzrAn+L8p6oMtkJgFq4La0GTybcCjxA8t 0wP6I5t4kiRYRPO00/uweKa255/y8iRvlwsgpetCdfuorDs7UFeYtuZk6uxUJNU1iCRU hFGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=0y7U4m1rgtY/XjIHSb406R686+vacpNNe3hnGCIrPrQ=; b=Pw7Fq8CGhrGRGjy8vEDVVDCM9thyBRpa/bUJ4a8kW50GdeDt+zPNsXDFXaafrwF98F ejWWQI3EAAoDbmmuAj4yg66CqtaynTJ3CX4UjsfapObD14TXTELMGyLI4mYctEjyHBGf XJ4PWwh4iMv/1w3WKr/x+/b0OFMD3DsfVqTn/Qg3X3VlFyVj7FNjOTtAOa/7fKRxcMg6 cXetE2n9jGSC5gr26mnFpBcir8IP995p1+1JkrzKikc8/caW6in98MN7y+at+PBgXxCw p5IQ5wCAahJHFdIhlQMoKdaKvYI4geahQaiaYI91KmkUHEAXn6DJXgr04ZLK/smafsP+ Po6g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=dX7mUKbW; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZigcA0rd; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g14-20020a50d0ce000000b00461c50013b8si11481178edf.192.2022.11.01.15.33.17; Tue, 01 Nov 2022 15:33:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=dX7mUKbW; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZigcA0rd; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230216AbiKAWbt (ORCPT + 99 others); Tue, 1 Nov 2022 18:31:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230174AbiKAWbp (ORCPT ); Tue, 1 Nov 2022 18:31:45 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE240DFB7 for ; Tue, 1 Nov 2022 15:31:44 -0700 (PDT) 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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748334826889708366?= X-GMAIL-MSGID: =?utf-8?q?1748334826889708366?= 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: 13932 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3246988wru; Tue, 1 Nov 2022 15:33:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ui7siVN1PH4+Bar27a+mnd5Q3QeUOVgmw5PbcbsDm4Hu8vG0BfIe8nArqvW9bRyzUtzAY X-Received: by 2002:a17:906:444d:b0:7ad:eb7f:8697 with SMTP id i13-20020a170906444d00b007adeb7f8697mr5553936ejp.770.1667342037954; Tue, 01 Nov 2022 15:33:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667342037; cv=pass; d=google.com; s=arc-20160816; b=iolfWJYMGf5xhflzHJ/UTuRcgfdlK8wNXJ1jgcgGtNRDHPoLqA2N7tnKe2GC/3PjaM o9YjiPuWJCMl+NuQSGCgUS3GVIqj3zG8A/oNocHtZiBk4mXz2stDbLsuBsiCTMhaH7uy VE2WG/mcfDtS+UUDydHPzKIyU/EBPu0HPg2BVDHCpfpihJ+dJZDFCkm+CsH7nkWcTX3f KKE9aXsLFOKLiLYeqVDoypuIGWJq2qJcoHyBHTUXjoFidL3rq3zo5aPYeOTiIO4QWefT xVAXuOQXJIWYMRfJsATmCtglsxAQu6BIZ8aNLwqVTr2OduLdZ/EAaoFmD84LFmT1QJNV pmfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=SoiSZrAfuSEEqpTJ9G+tvTZwSqBKFi2fmlrDiYEXpPk=; b=vX5Kl7tNAPQalfYHtFiRklUqNBYvH8OnRRYl11/ayqQN+n/LhksERG2RsFH57nasw5 0Xx1sWjOx5T7jhEjFlPIwxoyDbugrfPXPNYbeeT9snH5rrIIxl1Dv7sCjjSIAjCDDuFg wDmqcXHi9y+AUOrlYISuPRzS3KqEjQfmJJdtIq/TCHxwk3jfjmPpCAwBQd5EGRXj3qo5 9hNSm+mqZSZlU1BtQlbdaS0gW8wypRiC2ohan1YDzORo//ZmTnIaY+1EU6zNNyGUx785 y28Pde2r8iXPO5bpCFQDvVcBHdVTGO//YpbutAOdHFvUF6LXFVqXHE/Ml/xvKgeYLjVX jytA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=gjMgF6IK; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ASEqAG6j; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bo1-20020a170906d04100b0078e1d213831si10386169ejb.122.2022.11.01.15.33.34; Tue, 01 Nov 2022 15:33:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=gjMgF6IK; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ASEqAG6j; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230347AbiKAWcJ (ORCPT + 99 others); Tue, 1 Nov 2022 18:32:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbiKAWcB (ORCPT ); Tue, 1 Nov 2022 18:32:01 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDB391DF29 for ; Tue, 1 Nov 2022 15:31:54 -0700 (PDT) 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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748334844402291897?= X-GMAIL-MSGID: =?utf-8?q?1748334844402291897?= 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: 13933 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3247100wru; Tue, 1 Nov 2022 15:34:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7R23aaB+WiYPMKzZQrxUlYtacZ70GTFmNwF5B+YsJ88VkEcTdHH2sB6sLw/+GHJUhSeI2U X-Received: by 2002:a17:906:9c84:b0:7ad:90d9:a6cf with SMTP id fj4-20020a1709069c8400b007ad90d9a6cfmr20148417ejc.595.1667342053963; Tue, 01 Nov 2022 15:34:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667342053; cv=pass; d=google.com; s=arc-20160816; b=x3GQ8nYrizr+eu0ks+tWsJD1y0j4bsTPGzr/JngQec+hr4w5HMcUxj4Ef5UrcrNUhB dUSZr2zgfoAN1iKsHdXZ7otD+nsn01EBwi0/Una/VSBmKBV7zmND0sm/J8KO15rFW0LY kYMVZoj+4tuwHOvYdyhTbpC4EHJDznJkoQk/mr+eU7KPe1wahhFAk1l20UiANDJYlE11 2XSK1wgRkT28K0NGwP5supWa3803KRPrOqyqW5xPuOIMd7yImZag08FZ1DYfobWBzpy9 WrYoe9ZFAwaw2UN6JdjM1fa1YljJ779ReW8SJbsul6VyhcwIpGaIE6kMbUlH0QpcJvZh 9Tvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=KdsTBTYZo2zEACK2jZOJjNNyRhYH9a6Qvdu9EMo+Lyg=; b=g6R+piwu/XHYsNNot0HMoUI6LZ2kRBo3wD/luS/URS84/sdA6wWb4/M9WVWQQlcEYv Y7qawgIJTk5+c/KhdZWc6OceaYkPfUkjd8T6xnNk0R4lj1jXFolV6HP71FxIv9PQwO5d yMZnWwcy0LmQmyUVHIBwcLb1MNXxgaU8j3j8BiJ+baJg2lqQju0o5b4uXfN36OGm/i8F fgEXpZjeVbHB9HoQbqej5L7H3xGrvlhFw7E5iP/kePFLV6b3fZj1azXsJ6fUk/LRKRqX 9Zou1pJ8hskLagGVPUoxdBkXL6ZEEB1unCXwiZbFbHKUzRaDKG4RZY8WqffNXsV60+4M nKPQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=VyULCVEp; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=AvD41R2P; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h20-20020a170906111400b007ad8ba75a29si10129938eja.359.2022.11.01.15.33.41; Tue, 01 Nov 2022 15:34:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=VyULCVEp; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=AvD41R2P; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229958AbiKAWcY (ORCPT + 99 others); Tue, 1 Nov 2022 18:32:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230391AbiKAWcK (ORCPT ); Tue, 1 Nov 2022 18:32:10 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4930E1DA5B for ; Tue, 1 Nov 2022 15:32:04 -0700 (PDT) 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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748334861546811080?= X-GMAIL-MSGID: =?utf-8?q?1748334861546811080?= 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: 13934 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3247129wru; Tue, 1 Nov 2022 15:34:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4LoHihYySKIOpUtxLIVZXqLnmo6PkdAlDa/mVVLpG5ck1V5JTKf5DWaW+F8GeFiXNp5nMy X-Received: by 2002:a05:6402:616:b0:463:e2cd:a88d with SMTP id n22-20020a056402061600b00463e2cda88dmr1727309edv.400.1667342056967; Tue, 01 Nov 2022 15:34:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667342056; cv=pass; d=google.com; s=arc-20160816; b=bUJKfXH4GsPPmbK8WM8+dOOkstIEkCPJ6hC+ZrsltpyKo/BlBlxLIWsjmA8doXCJ9V ZS9B3DNs21YDh87hlWTZqgIz/8Fisct2OiMagzYKnVzvLNrSZYMYlIhvJRNzbT6Cg75i 5o4Uo0V/DXhmH4nttZ+/Dnnu/H6wNOk5NRmx6oT9Lv2J1lFWZsmEjMUN5FaQ8VfoioGs sBPRSwkgub6ABFioaEYXjKuzXKaj9o6VEgcbug97PWNNWgipEvW7yxT1jPrHIyizpVgb gcOWaY7BHzl2wpj1R7nDFjFLuRUOYxF/7sZRjBjFAwBMeCh72iD9ezdAIqwngtSYoCnL qVdg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=CdIzfapkQVtbsXAtb8JOdiuB/Or3txdKboEQfHS7EJ8=; b=oJ8K4w1uxY6yFT3/ya7kyicUadSwRvQJy4/0mwDzKso9AVLp5YV7anxZq2OHliT1SU dah/YkSqYx0mXb0CFm14SjjXNwQ/pFV4rbsRiGSlpi+50x+9zYN3rpA4hX30LlI3LNn1 Sw6duHKO71q2XiEC4F3/55TdEfOfbSOOVqkFtDRCqY7R5/NPzA4J1CjfVSPQXcaJdA3w nt8WacEK0kymnVA+5xoua/fZlK0qVG9thgMnuZ+DOqNIg4/EBVhonYF82XxMMZILbk2B AqSEJ+qH4dR31qZILu0aI6kUf+SbdYptUowchVz/fDrwFTvLG6dB2zhKwSUhV+mKFSDg n5Rg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b="c0oE/fHm"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CsDHHNOo; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a50ea88000000b00458ab55ccc9si12110256edo.168.2022.11.01.15.33.53; Tue, 01 Nov 2022 15:34:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b="c0oE/fHm"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=CsDHHNOo; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230368AbiKAWcn (ORCPT + 99 others); Tue, 1 Nov 2022 18:32:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbiKAWcW (ORCPT ); Tue, 1 Nov 2022 18:32:22 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 189681D661 for ; Tue, 1 Nov 2022 15:32:18 -0700 (PDT) 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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748334864327664535?= X-GMAIL-MSGID: =?utf-8?q?1748334864327664535?= 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: 13935 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3247174wru; Tue, 1 Nov 2022 15:34:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6I9dyaVL8KqbJhErx3gm1B0sFb5v3Uk9Dq/Nv1JqU4gAERnaFqjn2x6n5W59q6k997dr/E X-Received: by 2002:a17:906:9bed:b0:7a6:a68b:9697 with SMTP id de45-20020a1709069bed00b007a6a68b9697mr19907943ejc.218.1667342062852; Tue, 01 Nov 2022 15:34:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667342062; cv=pass; d=google.com; s=arc-20160816; b=Qe3RNKRnqOg52SDCqnGUg9xCotEclOPWJzHqAd7EeyUBejEGPvPPtLurmuUJfTVTbd hn5yU4eiuqDl9YDC/drtgaqLdAZVQzQskp8twB71Mxps2PP4+U3TslbVOu7ArKRSPg6c G4JfM+khVtzJDgQnGixoN9vC4JmxA0QFMb+fHQusuH5QMQ6zBmkmclJszCMsiDnUQDdO qiIcAeCTWadHJZm0RwDqEpRTQYeG4fYuEIDFxhmEP26lcjm8bv2kCX8d+Yfe1llI8ozF 5jpBV+GJDBCUYhLVhhWgBxg6Tgw2vBBJhUFbgmBy0zLL8By7/eNjCalr0ERer+vE/jCN 6Iew== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=OjyqufhItJZNQqVVuotec1/lf1wZzFO6juqFsw+19r8=; b=o7ZOKUPKJyw0OaeH/xCn1c8aK91pXYBOQBwez94k6BG02OAz/hcLv4pUSW3Vyq6f8k GmiO9gYAd0mhihcCyOKCZdU/UlAp3i/oIynS1LjHJz23AKpUUlLGKkLXekfLK4ygN4TD 2aAJZw6N3f+Fs1bd6XnmgzuO676iiykLAoOcgvlzUb6Ufxye6C4eApZ1t4riIQ5gKjM3 nEBvIniwOARYhkzyRjHUwB4XP+2PFkUhEV8NfI47W+4NZSwaqWJ5vCdakvHMlnW5oo+T M5EpEz820+1yWfgE8Kn9K3X68sfwEeoDpfLVkHx1V68Q3YuD6fO6P/l3lZ68iglhUqjm ElRg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=GvRd29Nz; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=iKRJY8Un; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a17090685c400b0077d1df3967asi9224701ejy.563.2022.11.01.15.33.56; Tue, 01 Nov 2022 15:34:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=GvRd29Nz; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=iKRJY8Un; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230337AbiKAWcw (ORCPT + 99 others); Tue, 1 Nov 2022 18:32:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230317AbiKAWc1 (ORCPT ); Tue, 1 Nov 2022 18:32:27 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 992AC1D675 for ; Tue, 1 Nov 2022 15:32:26 -0700 (PDT) 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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748334871115352130?= X-GMAIL-MSGID: =?utf-8?q?1748334871115352130?= 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: 13936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3247197wru; Tue, 1 Nov 2022 15:34:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7CmfQ75zCZ+F5ZEC53RQ82O4nFYu52X+McasfsHmtKEl44r+yoPPI50D5xykWh9pcqG8Fw X-Received: by 2002:a05:6402:5202:b0:461:b7e3:e6b7 with SMTP id s2-20020a056402520200b00461b7e3e6b7mr21237041edd.282.1667342065051; Tue, 01 Nov 2022 15:34:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667342065; cv=pass; d=google.com; s=arc-20160816; b=U+E0oGoyEm5/mbtCpJDV9VL2A4HfBoNk+xUduAce37XDMM7a+YdNz6fqnHzQ9/bGJh 0PdrfRSqBiliw8GFvXAysIrz9n3yJ7FQlQyLRYzG+JEiAuEQNEDsnFlsY13nOXEUc8Ie DVqnYW9QId+plFQ/Kafr2io08rHQyXER3uaQMHuJUfNGqE2Hc2Nudy3aoRH6TEIo1JFA QIYR0OOlUtQt8QkmpipZ/n4nyHy6Z4BrwRbSixG27QcYcRTxJaeMWlU0YqtLELhzPnw3 rmTr8Hfnt9BC1KOcq74XxTwgw8KlOS2EPuaXgLn1GIxSVKXK+KK8uvuMIjJxmBDmHjy4 w5xg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=NgzM/uc542FIf90DF6eXVseMOqdsd7MbkDuWx3iKQNw=; b=fDqzrSJRMUPncolSWKA89almr9AIEUP5N3+aBsas/BS0lNu0GwDcKte5ucAA8yNzP8 6B0HctDPJo0kCn2pE0R+ILh87JlvfcWI4vbrldpSQkrte3GU1acj29CnraCy/OvdBaWx IBcZHcyYIDMsDZBW+xHLrDZi4ZtJKPGY0yodpFCS5SFybgvrfw+fwzzLv+OblZdWjJT+ imtJ/vws3slG+MIAbcLQhglOgFCzGZXQ8hax8gPefeQg/8N79aIMmb5m9YzGmUQHAArV xAJclACQEgLMppFj+fDCB0ulOf6yTg8IDCdJvJy4B037pmdjtvVSdJOOba0nhDkwKS+C yNkw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=vwqqLDnf; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=FbNVwmBt; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a1709063c4600b0078255525a6fsi10435499ejg.671.2022.11.01.15.34.01; Tue, 01 Nov 2022 15:34:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=vwqqLDnf; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=FbNVwmBt; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230463AbiKAWc4 (ORCPT + 99 others); Tue, 1 Nov 2022 18:32:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230527AbiKAWcg (ORCPT ); Tue, 1 Nov 2022 18:32:36 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D8F81EC53 for ; Tue, 1 Nov 2022 15:32:35 -0700 (PDT) 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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748334873187139645?= X-GMAIL-MSGID: =?utf-8?q?1748334873187139645?= 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: 13937 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3247250wru; Tue, 1 Nov 2022 15:34:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7JVH44lrL6lZkyuxZUnkKxNEsgE378OUjbHuy+lX7MOgxxCWEg/5/hlLdSKNW3/X2jbMJE X-Received: by 2002:a17:906:cc48:b0:7a8:4a3b:11f7 with SMTP id mm8-20020a170906cc4800b007a84a3b11f7mr20963778ejb.388.1667342074708; Tue, 01 Nov 2022 15:34:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667342074; cv=pass; d=google.com; s=arc-20160816; b=J8py0OW6oyDXwImWWQ1WvuOcHFSDyRbdOnwuso3xWF6EaBzhi+Ys+L9mj9ZIltHvvE G3q3iFNOi1t2v4ms+mh1Twxr/jIVRlLR/rF+VrvdgQztsEZPB0xIle+F2fcM9EmaK7Ya FsWqKfWDvYxUJo3A/434d5qVbwriAQRJ4ykr51uo2IXhAFbre8R9G7J/xehqesonpy8D l22ZplJ6uCKlT3skbxlo9xCQQIU8z4mTglqn9INNUXpF9GwiBmME+tqrQqtmsEWtSPwg GCTzw5+MI5vaOYiOR3fjUwMDWmp+3tQDNBDm4/ZUa4aINpOoSGKQ75auq5uvgtyAKkEy vnnw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=oMoaqEGsyjXMIw0FpWQmzwCjhrFnxArtk8XMtNUcCPg=; b=Wzh2a2l1p9D0A99aMyj26VHUz0zM/1djjDrLGdSKILyfR3jqO2DRgrmoG3BY1l8o8t ugqslYA1/BM/EVGumhPXbXbRhGiNFCnG+UXP5PPH6QZkMp7WZZejI8ki8hfJRtYEu4Ts ZoIPdauuYN7dwkg8xKzL7qTk1v++dZ3WMLYeiWY1l5B5wwOk2TAGPRK6RxmzpSVN6QGB ohnQpAw8jr0gAZCURpq1Sq7qKHfsufcKYHkFljYcBAfAX6TkXudWiIqWl2yKV36L9WYH EoGDuTY7nY/nY0mu0R8ItrnUuk876wWuX955JP/hXfOxloJaLL4sooA3RxMCmvo21koe nLXw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b="MO+PJM/2"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Q9TWcM4O; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 26-20020a170906015a00b0078dcd8dfac5si11466849ejh.467.2022.11.01.15.34.09; Tue, 01 Nov 2022 15:34:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b="MO+PJM/2"; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=Q9TWcM4O; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230315AbiKAWdK (ORCPT + 99 others); Tue, 1 Nov 2022 18:33:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230174AbiKAWcq (ORCPT ); Tue, 1 Nov 2022 18:32:46 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C80BB1D644 for ; Tue, 1 Nov 2022 15:32:45 -0700 (PDT) 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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748334883276309588?= X-GMAIL-MSGID: =?utf-8?q?1748334883276309588?= 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: 13938 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3247331wru; Tue, 1 Nov 2022 15:34:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6kJHTqFmdKGteQslU3vLq+mboFgaPpzIGcb1G1fjtS4R7+5kfN750GLGJ7o/7gyC3DlC/I X-Received: by 2002:a05:6402:2937:b0:461:32aa:32da with SMTP id ee55-20020a056402293700b0046132aa32damr20783112edb.78.1667342086520; Tue, 01 Nov 2022 15:34:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667342086; cv=pass; d=google.com; s=arc-20160816; b=kmvtv5lUvbuMjhA+fhVrX5wmd3BKun9Y1/CEYcvg0lPde0wXk0ws11NzDHsIufbb0h SdKEU81F5vYiDlYEuv6kdDjjujKteCz3stNlZdo+bb1k+mIN4ErXMCx5uuqaZ4n/leZN 28wuFCDEGPdt7+qkAXXdfifuT8WAN9UY1NgiSE1G7rFUGlCM5xRA1CfOSA8ryfEx7Tre TlnmZp4BgslS4oZAATsHZH9IoxRIOejtjOEAcNk0LiE0QT9bKn11/jBZhV70vVO8qGgp CGl/gAYi/Y5WrBFKDDM4ZBdOkkSZv6DR1QcESPSTbpxYFJy++dn1ZmgdagZguCXbmK03 81Ag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=U8GNRVdIZHDwJjSJicnPzgyXDu2AHHtDvyuYMdP+V7U=; b=TpedTBghkMp+Xl0ugsjJPEuxxhcMIBRIiqXcfkCUAu+uofpbc99gFo0LbhYm0haudd Zg7xTxqt76CJn1olk0z0a5FZAw8ID5g0MZkpI7FtA8s6pkrYcV+WJpnaU2bQAfqiZAaZ Q9xIuDFf2FLYgFDKc7eMeUy+wLQoH4gyZeo2eNMUrhJK2tdaIl//yBpGhsjHfOjH/j5h oyFfDyv1eK6jXbJQUBK+0NHIPfCSnubEoV0qCc4O+CmIuQ/aybjStFWrPaaJiy/2ThKR woAjJvoZgUOvth73+jXXr7Jd5hFh9mNoeBNGMRXMowkJQQcjphacZi7UmYVRVMtDbzCv baKg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=k0fhNIbQ; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=c3q6WUBJ; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p10-20020a05640210ca00b00460346c1763si11860150edu.449.2022.11.01.15.34.14; Tue, 01 Nov 2022 15:34:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=k0fhNIbQ; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=c3q6WUBJ; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231246AbiKAWdQ (ORCPT + 99 others); Tue, 1 Nov 2022 18:33:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230505AbiKAWc5 (ORCPT ); Tue, 1 Nov 2022 18:32:57 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03C441DA7D for ; Tue, 1 Nov 2022 15:32:57 -0700 (PDT) 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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748334895604168064?= X-GMAIL-MSGID: =?utf-8?q?1748334895604168064?= 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: 13939 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3247366wru; Tue, 1 Nov 2022 15:34:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5VYjZ9TLWeasGLt6ZConi1jkMURACTzBUtYnulR1+49hNuVGvTSh8TrmeLp4h3e+9scdJF X-Received: by 2002:a17:907:7637:b0:7ad:b869:2cc7 with SMTP id jy23-20020a170907763700b007adb8692cc7mr17366078ejc.159.1667342090919; Tue, 01 Nov 2022 15:34:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1667342090; cv=pass; d=google.com; s=arc-20160816; b=AzVOjFE6YPW/Ud6EWAkTrvQbLV0uj+hY/cGujh3+URHFhnrPbrm4atxYpzxG+OUI8B r3KlDvmSC3RDzm5OfGLzVPFdvRZcrJndsfNXOVN6u/89T+h/cv6mbY33FhvyheGRPaP7 uso/rCUbk9CmlnvDmgwpjjHRjcjMkr2Lz9myc2dLU3JRg9rdv116NNYIYwObLmZkuvfv SUycUnxBnB2+sGsqiruXRfLFBG7kcdOROcL8TtQ0rXihEQWubRv8L+k9+sydRClLPHJb RkhYzDJB8U+hIgvRHzHXd0L82cTc8G1u813YkrNh1JygjzRxnNteVuFS+CVIKm9iFYf2 /mZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=S17dg2dyeQUIoXTB9U1R9CMRu2YgHFA8Z60QOzRAZ7o=; b=gvV3Eq663CudXIZ50bWAHVTZshh9XWAJrIMYbbvMntvKvK0BnIloQfonIzVTu8KGRi qbqg3ikFNb2pAkIEWcg52mlv8Ofo1QcBTotJyG1Bg7PRjdW4srIehmDG4tvHHsEtfrtD 9IoTewr+SBbydsnToy/wWjZMAbdd0A2yFksPV1PzbJunDp9Tb62DDtfrjUkq4cv7EC+I WVS53BVI8OXCvMJxPfqhaVtPEyTTiEi7gRWbLZptghN0bzELlf3sDVH175OZi3pJV2nF iPjYkrnFhcH4NEM2iO7Qon33dl8LidqKXclAceTxyFLRvJoipANhDuPu0uaZd6Q+AkEk KZlQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=Jr+UOFti; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=rUuZMVtK; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n5-20020a17090625c500b0078da856a4ecsi10110470ejb.391.2022.11.01.15.34.20; Tue, 01 Nov 2022 15:34:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=Jr+UOFti; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=rUuZMVtK; arc=pass (i=1 spf=pass spfdomain=oracle.com dkim=pass dkdomain=oracle.com dmarc=pass fromdomain=oracle.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230355AbiKAWde (ORCPT + 99 others); Tue, 1 Nov 2022 18:33:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231185AbiKAWdJ (ORCPT ); Tue, 1 Nov 2022 18:33:09 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C88C21DA56 for ; Tue, 1 Nov 2022 15:33:05 -0700 (PDT) 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 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748334900534669115?= X-GMAIL-MSGID: =?utf-8?q?1748334900534669115?= 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; }