From patchwork Tue Nov 1 22:30:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13027550 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75C1DC433FE for ; Tue, 1 Nov 2022 22:32:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17C9F6B0075; Tue, 1 Nov 2022 18:32:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12D166B0078; Tue, 1 Nov 2022 18:32:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE87E8E0001; Tue, 1 Nov 2022 18:32:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DB5066B0075 for ; Tue, 1 Nov 2022 18:32:54 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id ACE0280EA0 for ; Tue, 1 Nov 2022 22:32:54 +0000 (UTC) X-FDA: 80086324668.30.24137EF Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf06.hostedemail.com (Postfix) with ESMTP id 49B7B180002 for ; Tue, 1 Nov 2022 22:32:54 +0000 (UTC) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2A1M4FL2025143; Tue, 1 Nov 2022 22:32:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=U8GNRVdIZHDwJjSJicnPzgyXDu2AHHtDvyuYMdP+V7U=; b=k0fhNIbQ7b/86LTdsvNqlx8+Qumi+VTZrlV4SQ8iO9ug6zE571yRkIGZZslmhxAMyt52 7YyaGwcCe/vP3OZ7eDwM23DhOQK1Ohq3nReU10WtdeO96zgSbd91Xwo2dq8C1JU3gfGb 4o/zJFLeWVEAf1ZES+NopUQgoTjyRMDnbcyretvIT4Tbu8GV9vjxpKM99NjYHCkoaKR3 9Yii2TM5YxF1U8nE2EydNUDax8+tj6U/xKyGNE2WBdZLhHaWGdPSH1SAPoISYDaLnPg6 xqsPXSBrJHI708btvSUQbfvEbfELNg0KKO/AtbOUu6N9AcMKGxdbUemVA/IGvqhYxZ62 Ew== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3kgv2afx2h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:46 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 2A1KaD3L014155; Tue, 1 Nov 2022 22:32:44 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1anam02lp2044.outbound.protection.outlook.com [104.47.57.44]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3kgtmay76j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 01 Nov 2022 22:32:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VkUhIQJHBFV6H/8t9sfk1TPzfCv2iL8aV6qhimv8j7BAPvuu0wX5C6k8Rj/4hs+rPnFLilTugVyUXy6s5063cK2M4O+jXbz+pEIP7x7J2Zk0yl0qVRQ3SNXrbsxjAjv7v/PZDJI15htL9bPALZRKCl0Jisa+SpWRf+jwcjh6iQGnjRQjizylnTZVChIqSQlRhngQs20v51niR2ylegk1967AB5dnx4UQMcvRK/dtFVyYQK7H1lidG0we8H/MzDPa3J1t6lmq6KNlS7S3djJt494P6K9yoQ0ZWZ4yrCeYfQOHuJvqMlau0qSNTXsTsf11GTTw9QgpMiTqZiaDpnilWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U8GNRVdIZHDwJjSJicnPzgyXDu2AHHtDvyuYMdP+V7U=; b=CaBSgOfemhb2VzOmbFGY9NfB5nrcqChHnQ66oX4gsPguu2/cPLxHM/pDf7Ez68z6OCKCkqosT8ugxhx1cJ8NqqonG7mq4pj91d8aVbuS4gF3MvfPuk6oYzRYVNYhetdfRG2i9FDMPe7QA18FeoD+aXDfv+B9+gtrshT2axny/71YBk91FjTbyuE4efG48oxNTP/H/3ATJC7XeJFLkLaO3ppe1fxxL0T/SAo9qWZPm+GXIn1kG+iRI6uuaUViP4r+U1kNOn897eVUuq2/YyGja+M6gvhRraB34icUXRreyw3dz+k3ubbeFrqZ9OUa2lU8z4s1GUfG6TqrQxRGPiQOrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U8GNRVdIZHDwJjSJicnPzgyXDu2AHHtDvyuYMdP+V7U=; b=c3q6WUBJod9yiAe3MVR3gVEHWjPS6u7zA75Kd4IQhfnG3joUJI5IFEM2vb0UIaNH2MGXzmZo/8g9RjjH2/AgGVN32ngvehQMBiRjCOhEyvqop2Bh8MVh/igzuLdgmSzb2IHyJUjAR3hinv7LS8DpAzCZSuQdwLV7qYdJ/j3ch4Y= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by IA1PR10MB6075.namprd10.prod.outlook.com (2603:10b6:208:3ad::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.21; Tue, 1 Nov 2022 22:32:42 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954%4]) with mapi id 15.20.5769.019; Tue, 1 Nov 2022 22:32:42 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: akpm@linux-foundation.org, songmuchun@bytedance.com, mike.kravetz@oracle.com, willy@infradead.org, almasrymina@google.com, linmiaohe@huawei.com, minhquangbui99@gmail.com, aneesh.kumar@linux.ibm.com, Sidhartha Kumar Subject: [PATCH v2 8/9] mm/hugeltb_cgroup: convert hugetlb_cgroup_commit_charge*() to folios Date: Tue, 1 Nov 2022 15:30:58 -0700 Message-Id: <20221101223059.460937-9-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221101223059.460937-1-sidhartha.kumar@oracle.com> References: <20221101223059.460937-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BY5PR17CA0048.namprd17.prod.outlook.com (2603:10b6:a03:167::25) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|IA1PR10MB6075:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fa8d2c5-80fe-4182-bf5a-08dabc58fdaa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /L8roKBLr5lc1a95u+kYdzzAKlq7gpQmVUFWJJxDgQtP40D0uZpKYzynY7emrWtr6R8UnoN7nspiZi46Z4hSLNAPMCsZRMvFldd9Vz7nRfYwnuVFX1QHBFTiMuTB70qy7/GV9DZzUsPQMxy9n/uY2chy3S3iMYzJTfMpcEgoGkmCtC1FGJrugidB9vOB+2PL2TVc5JuKSHBABNzHHxJnRxbD9glTfR8aWYxizYT9Uc5dTxGYPg+wJA+n1Hnl3e7CxhKCfY3wYUWJ9d60coEPJrlZhJaYaIyWmRy7AnmEKIMMv2ROFxz8Xak7EDxr5R8b9nYGa7+SFrLo+sUmA7/q/pGi5qCIeIdQKAJCU1h8FVedFf+SZ2zSkk3Ss3nl4hFN5E9OZLoGFtGQ4zEPFsE2oqVDNuDayAjojkloaYglQnsBZO2K0hFb96w/pXRdluNelI751JHUocrPFHc3brQuC4dsEn4Hfl5RPHe08GiY3EU12PR56vnnnMxt49nkKYNWCxzaOq7mn49J8kEO2o2GZiEVuptYUVjaMYNISRDUeOja3nPsf/uceCmGRpnroH2ifqLNrUUCRjTfI6VBWbBZK0V/FQNAHHKznjbUSpTKYLvAHJ2ZIP4ereTpW0MaBlZXty7HQFKa6rkw40esfKFMzn/Qnjd9/fSuHvPsWRDRyXlMjxSlsL9gN+6oEd4uvLggT8wBZhI7h/JdEhsUURs9qQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(136003)(376002)(396003)(346002)(39860400002)(451199015)(36756003)(86362001)(38100700002)(83380400001)(2906002)(5660300002)(44832011)(107886003)(2616005)(186003)(1076003)(6666004)(6506007)(26005)(6512007)(316002)(478600001)(4326008)(66556008)(66946007)(8676002)(66476007)(41300700001)(8936002)(6486002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cr6mnHx3HDzEBQki4iK7S0Vh+Ph8zrK1Zq2nxlbE4Kixp9OhHcUqSQQcH14nBFnOTsXoF5UWXg4nAs3FMcfHWGtd2XrFCpOjKy7i+BFLUxvpX6oNRf7cpS7FVgnCXK4/dsX0b4SDun4gc0x38oMQK3q35RDRlmn/DEbxWf4kVWU4DUJ4hsVSnHihYq62wpJ9HyCR8gM7P5kA01mROF6qeKzyOtK1P1sjVIu+mxjOPm7DA3WamVtBc+D5yI12puewA06si/d24a7C1p9y4mqt+9tsWAVlyBoB2nhFtEpGYpD2LckxpaZ/fKoZDZG+GYycll8bBtlp3CLN94Skwa6hSDq4x9xeKsm6i2t35c2Ku8woBQyVScV9UaC6c5Vz5vpnqbg4i4EZ+wfRVO1XRyCiFGUl8OayjV0L7Vje1l2wckOKO04qQ+MYwRQSPb+3uu5ckEf0Ijj28ilAUPHCcup08RIDcgJMyqD1slAe6rqEezEOFYQ5+cA2HwjvJJbg4Cdq8bZ1Obn2BN51sdSzliMUUcVvA3zDtsm7xvpzSpN+Qf6eD38tXn4/QNWFEfkdq/NHUxFmTPAaRkI5YsMGZO9ve0hYuVv3NK8SkYlKA/1as2UUYPyJlNc6xINc2xLJlptO8Dr+zd/2QGoXx8wCzSrW4OFvG1aO1LrE3PxWwp1ybmwSJJRtZ666nBsaDBqm/oiejYv960bD3Ah7lpapftS145VJfDtGvPMC6r+t7Jr8g7QofUiUG+B7BYLoO0oqDEt4Z9f/afsZdruddVayfWiaIRhEp4WNrd+y8GGYG/Tiu3uF7UC0f39Fa3HayIXr9JWbKNT3liPfqLtp13hLkBF6AEAaIP305S8yXQ8qOi9CG4Ck+d+knRBDg4P/zq1WaPOCMv6japNQpHYux9HCrWovscBvJxxLbtY1O+D6c8UcgtbcqvHKwdepJtKgARmHgWc383rZ7r2NFUibHAVWSI4jaDeGly5cjmcpv72YXWk5YpITcsZ370LEsenUgBG7NZzZmBho/9wnI9twXQMWRJm2I33ngafO5sWqPP8JV2fQffNyFwU0NUhIloNA4+qjUP6bpTgNnex4PtO21BfpBMLSPE5wA/y6oXu0gyl+jRllqImwz3kJHcEQAmu6N/uOorZNmMdWd6gVbpP53hQzNZbwXsQQuAWqnQUw4vgMVAN6niBgcu+DFbLOO7a0vtfDmpGMm2fVMvLF3S6SMmaXrGKUt6LMvthYMRNSu6IoDCWWU/R32sBORTSFod3Ww5cLFnleanxWfsaFK6KXUdNOCoQoo1XE5txVJ7IpASnUt63bTWI6EoKise2lW7jleo1bOtc0QyLP9GXwAqetLxL67IyCIs4KfgLzB+tx9MVkus0r5N3JfnlhNjbwmKnOC/TmGNUvx9Df3ckNGDM19t4Q31iB3CmnE+CPxvjs5COtOUGfBUCxgmXCnSkvWw91iFw56i+jrzfcBHT3+t6J3vlsiJ7xWV0J90MvY07kkcAuWi964sVfXB9fLnWZYEfMuDk2mMND7cqu3U1DyXV0GPfHTHNohbwpxgbSSspr7bJ2jdsJR5B5ldSFGy8bdfQ13jap16tREK9fMO26JgR2yPZQKdoErQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fa8d2c5-80fe-4182-bf5a-08dabc58fdaa X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2022 22:32:42.8129 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CkQ9oohsh+vj6yLqYTl/ddruHVJeBb8y5w7GYjsOnWxZ/1XaO/T/PtBHctnwXCF0dP3z2Wk7I9ePOBfMSbndL49V8zv/2Nn0GCPbHjLYfXU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR10MB6075 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-01_10,2022-11-01_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211010153 X-Proofpoint-ORIG-GUID: PrvyYc3TPCdxkyBlbsklyfp4fw8O3R4i X-Proofpoint-GUID: PrvyYc3TPCdxkyBlbsklyfp4fw8O3R4i ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667341974; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=U8GNRVdIZHDwJjSJicnPzgyXDu2AHHtDvyuYMdP+V7U=; b=xwooI1r3+aVck2z+ewmMnwiVKF2Jz6BpCZOIXu/Dyxb3pRmMGmEVHSG+W7DXgDqZxOwd9Z REcaEpr7FSKJdNfinhuHJNdihi+5hfXIaTsK+HKBungLVB2DVBoZRVl3w3BENgVnSX2XUt u9cIOscd1rpgflIDH9Lm9WQxYRN6Fe0= ARC-Authentication-Results: i=2; imf06.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=k0fhNIbQ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=c3q6WUBJ; spf=pass (imf06.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1667341974; a=rsa-sha256; cv=pass; b=aPJmcG8dwuOEtmipXW6YmyfUqf1sS9HLRXrQE6xWA2bm9Y9tp8IAlYMRwPl7JQda8hOa+w 4Xs7TzCfQiOihIAarWDOIFCAJbepo3PkDEavVuNHN1Ix+zmalnYRLrhd//gbj+px8qXG5O L9fzm8q/t/FonnKa5gci/cYs+Onopog= X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 49B7B180002 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=k0fhNIbQ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=c3q6WUBJ; spf=pass (imf06.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") X-Stat-Signature: nzrjrayod9gr6ytgbttkqp989or9xhqm X-HE-Tag: 1667341974-405432 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Convert hugetlb_cgroup_commit_charge*() to internally use folios to clean up the code after __set_hugetlb_cgroup() was changed to take a folio. Signed-off-by: Sidhartha Kumar Reviewed-by: Mike Kravetz Reviewed-by: Muchun Song --- mm/hugetlb_cgroup.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 7793401acc12..69939c233f4f 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -313,21 +313,21 @@ int hugetlb_cgroup_charge_cgroup_rsvd(int idx, unsigned long nr_pages, /* Should be called with hugetlb_lock held */ static void __hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages, struct hugetlb_cgroup *h_cg, - struct page *page, bool rsvd) + struct folio *folio, bool rsvd) { if (hugetlb_cgroup_disabled() || !h_cg) return; - __set_hugetlb_cgroup(page_folio(page), h_cg, rsvd); + __set_hugetlb_cgroup(folio, h_cg, rsvd); if (!rsvd) { unsigned long usage = - h_cg->nodeinfo[page_to_nid(page)]->usage[idx]; + h_cg->nodeinfo[folio_nid(folio)]->usage[idx]; /* * This write is not atomic due to fetching usage and writing * to it, but that's fine because we call this with * hugetlb_lock held anyway. */ - WRITE_ONCE(h_cg->nodeinfo[page_to_nid(page)]->usage[idx], + WRITE_ONCE(h_cg->nodeinfo[folio_nid(folio)]->usage[idx], usage + nr_pages); } } @@ -336,14 +336,18 @@ void hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages, struct hugetlb_cgroup *h_cg, struct page *page) { - __hugetlb_cgroup_commit_charge(idx, nr_pages, h_cg, page, false); + struct folio *folio = page_folio(page); + + __hugetlb_cgroup_commit_charge(idx, nr_pages, h_cg, folio, false); } void hugetlb_cgroup_commit_charge_rsvd(int idx, unsigned long nr_pages, struct hugetlb_cgroup *h_cg, struct page *page) { - __hugetlb_cgroup_commit_charge(idx, nr_pages, h_cg, page, true); + struct folio *folio = page_folio(page); + + __hugetlb_cgroup_commit_charge(idx, nr_pages, h_cg, folio, true); } /*