From patchwork Fri Oct 14 03:12: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: 2483 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp596889wrs; Thu, 13 Oct 2022 20:34:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7CU+Rd0hcMY9i6i4gREm4JajIZd9RZOb5KAV7LPbLLydQ5HKHkHOTWzUEzmJhATSOG5XbF X-Received: by 2002:a17:906:9bca:b0:78d:bc5a:9137 with SMTP id de10-20020a1709069bca00b0078dbc5a9137mr2154064ejc.25.1665718471998; Thu, 13 Oct 2022 20:34:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665718471; cv=pass; d=google.com; s=arc-20160816; b=puvCC71nh+eQIqfEv+mGkL5KcyT6zLoZmbkIsMCP2wun7GmiNcBeRv+SWejoFQEq30 KskLfotrt+CRipGAPBirKG59qkrTTSBbrVn3Ti11telNdG9GKW9tDko+FwHElCJaBlqT ze2xExphtasf33pGIO86kouakZSh3g4j8oVJSxjgMz6hPcf+Q141WUTdG8YCHky7nY5c EqJkigf9R5GAnRf+Ppei/VthbjrCoRflYMuzZLEzfWDKSwC0DR2tLApyMJFJKyNq2WG/ hOrEXaGHDZ5MILhovqADTWCxOidyZz0yLawqifjOLxQKTxJ98ZmxWQyqE8KPN6ZrTh+W bQhA== 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=/ecZZqbF1xzPcqYuCvFEI6guW/DtEAVXatJHoDqN5qw=; b=A8VmxcgtjLruRQpYdH3jQsJ/Hk9rJ7jpJ+gczSO6GFCkHk6t3kmcIDQdX1lxbM97LL seAvK4MyrLcyPF2PhfV1PriLEh8OfHwLYvmweTAE4mfloJH9vIMxWjOzx1q/OK1eEjGX vIYVWD5kbZcnO7c4c8AZImKgU2CR3PpwKVNXbenv/k7nJstuNUPVV7m1350B0SOMjoYa SVB0cIQayQ/go8IxoJlT7hmJ0u8qYLsjOqRWrkdxIkPB0Q1nDjNZ+I1rvw80EPLl7WFy //AaNVb/FLAb1nFNg2xtNBFht8d8F4o5J1dJSyT1JFXM52zcQcB7rIJm6wICbEDlkwEG fkNg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=SM1cJ5jm; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WepxlrKu; 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 by26-20020a0564021b1a00b004533149e228si1183038edb.618.2022.10.13.20.34.03; Thu, 13 Oct 2022 20:34:31 -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=SM1cJ5jm; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=WepxlrKu; 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 S229717AbiJNDO0 (ORCPT + 99 others); Thu, 13 Oct 2022 23:14:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230047AbiJNDN4 (ORCPT ); Thu, 13 Oct 2022 23:13:56 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF0AB5F7CF for ; Thu, 13 Oct 2022 20:13:55 -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 29E1Txkf026322; Fri, 14 Oct 2022 03:13:43 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=/ecZZqbF1xzPcqYuCvFEI6guW/DtEAVXatJHoDqN5qw=; b=SM1cJ5jm9wlvT7sSxkI8ePH5XilUFMHpqGD41b1M0uMR1MmpqxV3Al1Cera2zgsJNclf MfJnT1ZMb/EP240L1Ygh4vR3bVu4xw+S0/GG16wjdXM0ai8DTkjYPlzt0dXNDJsqs5io 4Z/t/K0F7MxKrC3usjLZc5aBd1uaZEHD5l+bPNV71Wvcp0J18CzELQxkRjc2Wkajm8Zd 6Vnpe9AlSTT6NHgLrV6kZD+fHhe945ibcpLwt0ShdtirOeXSb4cbCTStK49CoeBXeZGj tunFT6nRZGat08SaBhK/uZ5C1wLuOPWn74FvjUK01P9uvubQcFs5hwsYv3iOIdG3ESf4 7g== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k6kgmsv76-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:13:43 +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 29E2fbtg017587; Fri, 14 Oct 2022 03:13:42 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2105.outbound.protection.outlook.com [104.47.55.105]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3k2yn71658-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:13:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OQ0GgOYTromkX2SCyKCFL6D6IUCKlDOVy9Opad+NReyfOwrObBmoejwyTEQC2GxVZAIvDuNtHDQw564Ax1KGqQMP87qb/1XVXRKyQagb7wQx5C9TzyItZDU2gqkfaVw/bH2MkI+XBLAcxxi2bMFIBt6ejUR/t9GYJKGipYUDfP56X8aGVPOK/FgalIvb5cgG+17P8uXcBsH9yEpR5XXVSaPwWFLaz7mk6cfpS3NU2UrQBywvmikCxgtbIlWaE6xEFfoNt/XqKLd3EPLBM5xhdpJm0EZbzBuYt4mYmD3xkUHNE2we5hPtvW38YjZ79j2KQPCvKIbaS4Wn7+K2SyQ2MQ== 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=/ecZZqbF1xzPcqYuCvFEI6guW/DtEAVXatJHoDqN5qw=; b=mK82J92kn2kTrGZagcfKiVbl5YKcemuZTMtUqoxhAUxtZW4UMwJGsxd1yGURp3nOF0GWzUr0rOo3nykbn963KnrmVEWTZ+gcrC/c1AAXLSnoZWM85eKxwnykqSjF4zltF6LmD6bYGevG2329zfLG35wLwpylxRcARCcws5cqGlR/cyr8rAr8d4Kr1mRlhE/D8wMFmhQ4LTpr5OuYoVLpVoGNKH9AUfPrvaaKJ2B1H3sLqkN8WfmkGRtg6NH/LOpYz/p180CQRZ/Nah16T/QQ+rVi1+AdvgLVQ6jo9YTe6l96QRbKRudAIFhOLDPosiLZetD2Lkbkp/+ly8mrT3x+Fg== 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=/ecZZqbF1xzPcqYuCvFEI6guW/DtEAVXatJHoDqN5qw=; b=WepxlrKuunNDAlX+/ZQizwmhBkBORJjuBrxA+BjfI+kbimCfUcSCIgEeMEXixxzmiwEGRU8SSysoF/9kxtR69Jv90fBomhuXZWxNkVxJI+ihNrLjKgSEWk/u8R79+zJN9t/f7HOoeEYwlo53AAKbyvzoP3XaT8vbiIR/H8gtH6U= Received: from DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) by CH2PR10MB4182.namprd10.prod.outlook.com (2603:10b6:610:7a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Fri, 14 Oct 2022 03:13:40 +0000 Received: from DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8]) by DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8%3]) with mapi id 15.20.5723.026; Fri, 14 Oct 2022 03:13:39 +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 1/9] mm/hugetlb_cgroup: convert __set_hugetlb_cgroup() to folios Date: Thu, 13 Oct 2022 20:12:55 -0700 Message-Id: <20221014031303.231740-2-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014031303.231740-1-sidhartha.kumar@oracle.com> References: <20221014031303.231740-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BYAPR01CA0004.prod.exchangelabs.com (2603:10b6:a02:80::17) To DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR10MB5117:EE_|CH2PR10MB4182:EE_ X-MS-Office365-Filtering-Correlation-Id: dc6527f4-dc10-4b9e-55c3-08daad92175f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H6MvUdOWb/7tPEo8k9n2GM9FqSwYkcBlUr6Kclffek+wI/zerZRg+/JPzqTmpDTkM1NtDoL1arB4CqE0Tpcd0wksNUKjQcuGOVdnZQdUdIIMLeVQcUl7N25oEyYzDtkfB4sSmRFGgV2YvHcBHdCyltZjzhdZ+efbtOSW7RT0AMW/k1b2yX1owfXg+X86NIT8JxRePlREvyBMe2VpT4u2QawZnosFOTD9eKfP3ahttoNDz7c54G7mPt7Iun8SYM6qmys+pNxFO9PHlp43SdnY+tuDm4ZsHzBe/seQLL8XIwvMsls7fxQjS5m6cXSDhKX6P2u/8K24UQrtvu87DUv0joPUvjQJhFMOe8G9Kz9IMZehZqzFWorwz1eCNKDGZ5y7J3RPloAtu0djlAYh0mQ1LfNKRIcLo9m8/4zOgS3NAl5dGFR+eiPWtTfjDWVmzJsI5vjrHkFxnLsPTh5gBOycfTvao5Lp2Gk6H1eCCi/O0RzJExdWW5WszYw2DgoCTuDxtylmoX1Ike/2yrRw5qXWE+8Q/icxMxROZHt5JvnSciFeUuPG1AHslfkRvQBIsRzyc9cFsF45scK53jllZvJuSe8YrmWaB8owhsVuaVNiEkcmsuWBHsJlYUQu79Rquqlj05UXmQZqcQb4rqz/JQkAblpZBiRv7sb9xJFD5Gk8gxv6+2ekvLW5+EJRunC1PPKktu9aG5kWl2GRbeSxkYHhbw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR10MB5117.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39860400002)(376002)(346002)(396003)(136003)(451199015)(478600001)(6486002)(8936002)(66556008)(66476007)(41300700001)(6512007)(5660300002)(26005)(36756003)(2906002)(4326008)(8676002)(66946007)(83380400001)(44832011)(316002)(38100700002)(6506007)(86362001)(2616005)(186003)(6666004)(107886003)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: K5maBpsnqwsu6LZfrt4CdqJbeaqz7QeP/1SiUVcFqc/2UDma01rdMq7L8pYRjMRQunHVf/atVyahcFqMW7bUnWgCWrrAAtE5b6VVMrqBGeaIFdqdoG2iWB6JLDkg/Z14KzCABDoz/f3kVyMgVmCaV7yN67NjhZxPfRmsXq/s4SBx9jAjQVKayPRGMeCIZMC5JmKXYJl1I94eKuz/EeMo6S0FnEdsISmyKq6HnbNEcmlR0fn17ItjjsZX9Qa6RFAYagdi+VYWhw9XWofWRgeHBlyaHOSLOJdsLlnWzAO1tH3M9OfWdEzfH5MChWWw/P/mb7GG7zilauHTAXAf4N8qWCB7ZcDdoPJPy/3me9FzgOm4t1/0g3t95zVIk/JaiqOXhEzk2Rny3JWWjtGgWE3T5iIpcmXYJxbuYdHBxpQ4bh3lXMzjOUfwkh+RnXbUPHD0ce2kc/xyQodTGDE3iwPjwl6oUUQGk3UpT/IXpONQ9CKsaTho5QQcRAvghbBaYsFfRaPfKoNLXmGNahiQyzEh00WStYuQum3XdPhh2zx69ycabP//vn7r1kIEbnOA4GIi5l4WRrxLxb/Gi9YZ2ZB2k3x2qF7g5cdFWODRW+CHo+ZiyhgHPlzDO4cu4mtyzIz6abzwGx+3QUVAlL97vKuRXCV/Eq/0EJhnA2Js3HnW3QkPV2rad1BJOYuH2TYyJ/uACb6/JBgHImrzLEF0gTzanaylQDUgtP6CLTbsg5/34VL3V3nfFzoTLrtRuNWjcsnoDwqmq0UydB75DIAgnK9XP+XmLH3J/hgs/LfdfzECtII4SNQqyimbV9CUQvQo6DY84ZEYfZu4EGtHDyiarmC430+nLdAbDjeqazAUIG9EBISEyZ+0Ft50rt+5LLLbBrHanjZOcDKDEhUxIs5AgfEyPK+d2FRGlC70IJ11YVl0tJypkdNAEr89qMTgZo3Kl1nlPb9FpFwx6SyvS1aA+4js8iedmZMua2dUOwTFogxRE0XwaAOJiyFMgVTY5OlwyDgEYi/xMOhCEt49gfKlCfItV0Cjk/X4e1CnYYCh+oFHb0UeP6TkFWLqLe5jX3cPdB0hImJp7ps14V1bdb+FT17GqnPulmFzYqKKPHmmL5Nb4tJwY0LzHsB2qum6fJonpbYVj+SiyQno7ESuw4NCcHGq+KIkTQgxZFTQ16L2jYuhlBf7ImA6dGvc+qiYO9AQSn35f6JLq7khxk5uk7N5ZiXifRYrdoSBiZUAjLbmdWh47s3bXZ9e3kAK8vbbjK43v61NusFC9/+qbPVni//b3iuxBaBRLfs61xZ5Z+IOonaatOsfhEkH194umyROTov+1PVCANQEGKaRGGoEKt1aTobbWuA++PP+fQ5Jx4n7Vat/X7YlNw1OF8Vu+pVu8rRd6liADZ2h4YVOvRiuA7bF1VhA0rnPneGHGixaf83fUmQQk1CNiD8Mmr5mLWVaia6H4/ShomUB0mfzk0eJ6l57fIxRm0+ein5Xbe6mudpD5MCqXSdmz7KURjS+H5TkSpCD2HAwnzk7o8UbhjesvJiRQWnLbO5RMT/rjSo/X2iUdPG2StYsHieU8Q6yvG/oZL57YQRM+zE7ZT/EEq2+EWoPjPZZog== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc6527f4-dc10-4b9e-55c3-08daad92175f X-MS-Exchange-CrossTenant-AuthSource: DS7PR10MB5117.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 03:13:39.6863 (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: U5+5rgtEhhFwdglgSfZd2vo/wipHUO7UkfIIb1W9zEtLycFpcNfUpTpQUw9+1aUvjEEDZGfuAWDGhDVbdARNXwUN4cfcBK0Cor7yXn7fGBg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4182 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-14_01,2022-10-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210140017 X-Proofpoint-ORIG-GUID: TCL30Dq5anAP7kFUCiHMkhxv5C36wRiW X-Proofpoint-GUID: TCL30Dq5anAP7kFUCiHMkhxv5C36wRiW 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?1746632412210323346?= X-GMAIL-MSGID: =?utf-8?q?1746632412210323346?= 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 --- 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 Fri Oct 14 03:12: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: 2484 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp596987wrs; Thu, 13 Oct 2022 20:34:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4f2I7w2ahKHklWDAnGgecIyWxdnYkA56L3cGPbyGmNJ1t55qDBdDsbBxwDDpPPXrSI3//t X-Received: by 2002:a17:906:5dcc:b0:78d:fb98:6f85 with SMTP id p12-20020a1709065dcc00b0078dfb986f85mr2071461ejv.123.1665718490198; Thu, 13 Oct 2022 20:34:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665718490; cv=pass; d=google.com; s=arc-20160816; b=zib8VElI2nOOvW50q50DerGSGi++p4EoGXaiS90OU947q+Z5/Km21CsOgcrLlB5Aim OXgKTuf3u6WbaimoTUntDlIIiP2aJQrCPNVLMmUkKZ22rEGqgy3CRbqfzUbGI4XhkAk4 hhzwi49e8gZRjV6k/7up13JC/qRGKNpRs7dlfjtUkOjutgJNCvq1U8Zbx5/iWhNCC28i qO5mDxkxRdivvsQT9Vj3CQe8HB+chMZv99EwKzgf4PJ7MPNjeChiZlY8Fzl56//1Ui0f LE633BSx93VayLhMdGpVAhkVIKBmVdeP8JO0bNI4Wpmw0PKfOjIoi6VXxR/j9JqN1YKi 7r+Q== 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=JmGIt3Tl013Plbg0tYdWooZLBzr8VHykld6KHkpJ/Gw=; b=Nw9sSOplxQc9HlDj2iQRQGqWtrkVgYDgFnTdBATC5YpOyzD/BcjH0a5ECU/1XsobT8 dd6yjM3qtClTpHuI4n8Fu3IQ2kLospNZkNccUfppkRRdiGKFDZns+G7u1Lwnv4js0UJz 7gsZcIdVMWbqs4sA+1fp5QDXcGI/X14NrrrUKUO9oD9Wjx6PWcdf51iKBDTr7liOcWTb 9RmPxzVJLqeEhBw5uas1Yx3pxaX0MU/SkpIRKZa8lqfEpWgWoBNwM8T9Azb7WYe95BEy A9z2K+2s1jst8eEuhKIxTmilvloTz37j+0TFHhxzSfnH81Y1qhUY2dH4nsxB0/zMg74I CtlQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=dNbR+bLL; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qQhuDwsl; 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 z21-20020a05640235d500b0045d073d7ca5si1294799edc.339.2022.10.13.20.34.25; Thu, 13 Oct 2022 20: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=dNbR+bLL; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=qQhuDwsl; 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 S229791AbiJNDOa (ORCPT + 99 others); Thu, 13 Oct 2022 23:14:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbiJNDOI (ORCPT ); Thu, 13 Oct 2022 23:14:08 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D3D310FB for ; Thu, 13 Oct 2022 20:14:07 -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 29E34A8t006784; Fri, 14 Oct 2022 03:13:54 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=JmGIt3Tl013Plbg0tYdWooZLBzr8VHykld6KHkpJ/Gw=; b=dNbR+bLLZ8vuZzujnNq0dIM4F3oIOyvAvun42+FLyby+hO9MpoPa92XhttZkr4YmGuH/ W/mPWqf89Yc4vv9lP6XqpkuO2LPKgLzasdTDJ/u4M66ejI+x6uxf7xxynDMJAkcICOGr umseTJ4sGDEyVpNc26qNnt+VpwYASlruOT0PkaumoQciaC/ooO7YSrSNsE3RbuzvSZ7X 7GQe9Z8tesmcbCeJ1GRQyWCBcdsbLClgVoUuwC+Z43Pjao11XxEyh664N58ZNqb++pbV XYmU/oBmsCW3b76X3v+lPKxwqN7U/qoZFxi3vSt9fJMeGSz0Dsoxlf0FJ44l+TUNf51B Uw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k6mr29k0u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:13:53 +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 29E0Se7e040328; Fri, 14 Oct 2022 03:13:53 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3k2ynddam5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:13:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NXoZkzHpoPJNxD637ugUFu+U6pg//AU8z7cyW5PsoM6+kr3udb53O30pxKN3Wk+q2STIjCwOlDR9RXCfJYr1CB7p2QSRGfjP1mDGUpZFSWq9VkyRmDNhKyms7mAparDOTSWbuytDX+dj0niWLJ4Iy7Ky1xZQDIt7A/6oT+ziv2CZG/wjzQra1yZHGMCq/JSXSHFltKo80Qvj9kSq6WNGHnRDZCGziTnschuBWH9j7p4tUIdBqs4nwxDfdzlz/zmUTf8gqwobAktY3E08sZAcWzmCkHu+f70HeKrKMSnm8H4I7w3GYOhxIBaWZ4C58rwUsVhUo/2rRyIK6XowhWNlXw== 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=JmGIt3Tl013Plbg0tYdWooZLBzr8VHykld6KHkpJ/Gw=; b=H88dikQHMIayqDCmqsD9rqPhbP4TRdivpCJapImKOjVGUkkcQ94TXoGZWDv1c6/uhDptC5unCfcpi/Fl1bgAmASpUTQdzuG/WXp45PjoTUu/CsL1VmDIbyuhoQ6FVgC3sNjZKIzdf5W5tVTH0c5Tiggq/hn2EnW+Ap7hULrv5hZZtx5JXV1b8kjh8HKWGFxS1g1xLhzPEqyIrmK2s00VBSIBKbli6JBVxwF/BeLpNuoi1RNTkOaHhWJeTT/K/Q2edFlmZstKhmw8qaiE02lSqfLZLV47APsbsW1gbUwE/W+euq32EmGZ7JefiNxlh5oZrXKXW6iHkLZh6xId0q5XAA== 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=JmGIt3Tl013Plbg0tYdWooZLBzr8VHykld6KHkpJ/Gw=; b=qQhuDwsltZeJKmXufwbMyXszyeJ8ps9QVFZta6JMl1GBSQRfVwkskFKUL2I+fnirKIhUn5FKtRmgAxWTjNdCOjUDcENNazNqGsUK3LHm/RkCbJT4YuHLyWW41FzqQ5BmwPggLY5Rluk0D3pjcKlRWzFMegal5U43wzUOfJ6RNHk= Received: from DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) by CH2PR10MB4182.namprd10.prod.outlook.com (2603:10b6:610:7a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Fri, 14 Oct 2022 03:13:51 +0000 Received: from DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8]) by DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8%3]) with mapi id 15.20.5723.026; Fri, 14 Oct 2022 03:13:49 +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 2/9] mm/hugetlb_cgroup: convert hugetlb_cgroup_from_page() to folios Date: Thu, 13 Oct 2022 20:12:56 -0700 Message-Id: <20221014031303.231740-3-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014031303.231740-1-sidhartha.kumar@oracle.com> References: <20221014031303.231740-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BY3PR04CA0012.namprd04.prod.outlook.com (2603:10b6:a03:217::17) To DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR10MB5117:EE_|CH2PR10MB4182:EE_ X-MS-Office365-Filtering-Correlation-Id: 30ac85bb-b9c4-41ed-af92-08daad921d61 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vdhOnA6KRN2YfQIgJaufFxOvo3l3uPE1cBWSmrQfVdivfQNCeKERPFHRbvPqt7omySufVJURCHY34/ziAaCKR67wOp5eqjaqS0Lti+BLdixm3DtPcKFVKdl1aGYuwhaT6om1eely/6vatUuvkJd5pIdgS9aBc8DGV/FeaP/2JufGdeHRPScS/r1eXgTctH3xntcw3JPkKonTBw9jqjA+SFOlmMkbEqI6POgwvO95C9cje8ubRPzhawHqkdw5G9cx8V5V/qpgJpkchqKtERLS04X8naCMuufqsCSEc5HlNqRToK/+tma4jadGvvGmUC7ehc+8gHEADuPskACohKW4CCQuaxVsALUXY1XSJVgn0CKWWLGNnXvee7nnUlq7AEmmXpM2GTGva5XYW2cWwNzNHCoczLXuKCDfp5q8GgXz5IdREDR+9jH7EcO76hB8W1c7wdvqsfxTcNUxN+oW0giYc+bobP4OOwVCmK6lHHyEgIFb9ntbMAk9lK0ZUKAWJy0gdyDtBxWu48kWl96cBbpp8b1VMqYTHrak0Gw9gtxKo730toEBhzcwnmwBXW6rTcYCVbE2aZMQmQJF2oIC66aYOZR7q80unbNe3LwofdnU8One14cYtFLpFNzqBSO9uK8JqbNYm3hUu+nay3nb/nW9i/4YbZWl1ZI/srPtRsctC7kKaxpS3ONSgfkYgwEGH/BVgDBBKW8+2BfPJ1PuK3ztLQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR10MB5117.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39860400002)(376002)(346002)(396003)(136003)(451199015)(478600001)(6486002)(8936002)(66556008)(66476007)(41300700001)(6512007)(5660300002)(26005)(36756003)(2906002)(4326008)(8676002)(66946007)(83380400001)(44832011)(316002)(38100700002)(6506007)(86362001)(2616005)(186003)(6666004)(107886003)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A/FoYYz8IMVnM83IGAwCpnHZa0MrnEGO45Vrbd7OlsrppL3dPhnlfPrLaz/DQsebwqcVUll5PjfMOTTNqyIRwup9ZHSXcHxwJig3alnQyrOI9wSadCfOLnCkDfKcw3kLow1UKw6riyurNb7L2aKvRBTjs8H/6zmeP28r/ql1M/QfntFBtuEHPIyILO6bl/k35R1w66uHSTB9kabSOqrssSyoFZoH1+rLFPhx8ola0tPhsJ09G1mojg6+aZ5Dv9h55+DprkHMdz5eeN1cmMWpYxy0tAX2MzYBnhdQo+aJbmqpevDy/p1YDJMIxJXMDDQDpuvxYpA6G8DVfedPwEz9wgS3FeTQQhodHHcAeI9eN5A9Gd6qVvgPNWRdWbTnqUBNNOoJo+8Hbm4wL+0UOCxz1m+JDFpjaCJOZSW9OlahaPaRTSdNUCoFWvXn4Loe8oeuz9kJHj60MtCIvQZ4Dxdfhd53obKsBopo4tzcZ6Pe/2tx+BIToiVlwfsfQS/i3+99p6tOcHgGshSNizu7x+07Z2akNd4iZ9B+J4tvjbeB1SbFiqrenlilXaEBl609o5VdSl+Pq5apo0vMBrKG+ZijjQt6F1NUccQevlG21LeT9R5sdzpNYDNqQt5e/m+Hsv9O4W26+KJh4OwHvSB5/BWjSK1GMh/Cv+2macpn/rl57Thp/++y1g+S3GLvayyopRUhcp590T4+aiEcg59JXQkWn00Lrf3csKDybENUcrkVT8fX3GNnUxIciwPSnRltMOKXEQO3cq/nFPyQMbQ9UyRlD+DBC6zT/tx+E0egixu7+UYrNysmaQP8wan9rEzueztUSsgSfuAmyjDZMv+Is+udqTY0sSSMwGEuaAbaxXsEFilWlijwi9YUqgC3LoSsNwaao2HD08/OSFO2tDY230m+yR8/lOLJ1T2RazvKrO9xHpo+MwgfOZPazB4ZaP080GgO2mt5PyQKbD8s3c124aPXlOYaNifxluJFQRGpTIjA69S7n9sk7fq3eQOoikJxhoAvEYZdjcvLP2tfLdeJhFLstyNoT4IYpAjrPrzkmFXjFW+iQD8dguibhpbvbxpW4m515mO5xg1xmOlbBCEdFYkzca36+qiLqkOEUNIyWYub0vgJzKRfPwBisC2ttAJceW8+8iMBo1VhXXbYsY2IFtQXE4vTEiZTxUqGs7xCq+xLujLrhdwwvGlVvGYvPJHX5ymikjNE6GNNDexZ7a/aNbjxxd948GkaDhawr3lw4CdI2D3VjCnGgLkHvO9vz2jkQD2+9kclaFAaFGLUjBEAUDYr/1y53A3fYulPVGoFkwPD1zop1yKwPbbAbPr++CxDoQDPZ4+G6eIZrq0y+976xixE6F2FRsGnphAKZbMifiydnAuGaBaPQScoWmPY8GLqJSYM1sCj2M68lwf0AqvPsTr2FCJ9PeTRVqZ9aAV+N9qem4iGoAScUrg5S9a1GPkpzS9NkNYH5otQNFBVMhDDS5cOWq27Sp4ItVVe+U0+hEwISEYO2deOCbgfVNwhFOf9hV+OBO22PU44S/GpzCEKsssNlwPt8jH45hPN5h9tyOWITprt/Ap1V740zMQ17+TPsjs7H7yaJtI1m8l1uuupLvhchg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30ac85bb-b9c4-41ed-af92-08daad921d61 X-MS-Exchange-CrossTenant-AuthSource: DS7PR10MB5117.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 03:13:49.7524 (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: njRMgr3Vzcy5mr2BrQdr2oxnbUFmSJs3njciWcHlgAODZzGJJO77Urm8LzllUMdIrkNmOV3sh3TtiZZcB+dN5IsoVSawpua/+YwOhV5Bqws= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4182 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-14_01,2022-10-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210140017 X-Proofpoint-ORIG-GUID: 51biPprJqisMaHiT_z5g2AkJAxiTTztY X-Proofpoint-GUID: 51biPprJqisMaHiT_z5g2AkJAxiTTztY 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?1746632431979786917?= X-GMAIL-MSGID: =?utf-8?q?1746632431979786917?= 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 --- 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 4133ffbbeb50..bcb9bfce32ee 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 Fri Oct 14 03:12:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 2491 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp601767wrs; Thu, 13 Oct 2022 20:52:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4aEGGKF6FK2k2pYtOR1TP3cv0RLCm8cLVnOUXOLvzTxeHiXk/oKyUJgvm7VBwvx3TJ8Phn X-Received: by 2002:a17:90b:3502:b0:20c:e1ce:46d6 with SMTP id ls2-20020a17090b350200b0020ce1ce46d6mr14909722pjb.94.1665719548334; Thu, 13 Oct 2022 20:52:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665719548; cv=pass; d=google.com; s=arc-20160816; b=FlFYxkIAtfjJEeFLzgdZHg2686AhXgwEwe5qZZyhogIg+Mb5DNTf7+qYF6sTdz88Po kX7ekuhqHEYsDVsuOC9F2iwlYiSvnyc4o6gnOPq4MphoECfT+JDI4GDgJfXa+A+AK3oY EJKY7QL50x3hQa5KzkpLDsRXEPowrAk4ePgdUUjHlP/t6C58U9L3Ayaf8K8/SVxXD/KN Fp8yPz4bb/xkOY8s4hYjx+hZ56n9VfSecLAIt0bMi1YZ40uSCzoCBk6gxlMu58TGQG4w /ZMAZklUOemgSEuWeH+66pdnKPtY3tw72IP6QzL49n5mYEy9MJVkJiTAgZK9AEg1MQQT N94Q== 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=1b2Agnqraxu+oJn88SnZ5zrHf4rJCayWbQEFBe9+MkU=; b=rFFls47VyDT/x+kYpfg40+vTjnQQB4A7Oj2H3ZDxA4KMCXKiWeL5eeer3aFy2s79TY PXhkM5v7gBHhGa9WTrEoTzZFInvP/+qfq7JpneMbjCF9M7o7idPmVlm3D/bInANR4T+j djaSfIYvBSeP9F0tH3uxVMvPspN4Pjfpm2VwRA8nJknZ1k4CbzagaJtcSsOjDb3qpC6Z KOVuyt8cfjyfa0Th58FTEZzj0jJVx/dZGXnaWulflWu6YSdiIXC6okvHfgw1n4tnLje8 TYRBw0+HLDjfxZupi5XoeZtYC4zSyOYRawyv+n+geF0nNRLEGl2V8qq32o4gkWhWTJkn krIA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=WSlTCLG5; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZfFI8mUb; 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 mh8-20020a17090b4ac800b00200435da17asi8765301pjb.128.2022.10.13.20.52.16; Thu, 13 Oct 2022 20:52:28 -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=WSlTCLG5; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=ZfFI8mUb; 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 S229771AbiJNDO6 (ORCPT + 99 others); Thu, 13 Oct 2022 23:14:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229884AbiJNDOT (ORCPT ); Thu, 13 Oct 2022 23:14:19 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A46D013F11 for ; Thu, 13 Oct 2022 20:14:17 -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 29E0HvRI025579; Fri, 14 Oct 2022 03:14:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=1b2Agnqraxu+oJn88SnZ5zrHf4rJCayWbQEFBe9+MkU=; b=WSlTCLG5ruakkQSnrgZjNgZhoI7yK8xPwuMNWZfoSXO2+B0utuvkxP2onlzN8/QgNEGB gKHm6LQZd44VJGDzKk/mDhnBVVB5EZNHjGZKd4pD4r2gAc3kTpE4RywTdIefOf3cXgCY 9AGlP3NEJnTy5XdXenCyFwaDyVpiuPV2hkKYvRZlbGIaxtBww/iqgxuOrtMgtiGZ+32+ ZdAUT/ufT8zcunu6PpmnTnn4zTWggsD/wMlBy39qSDGrmi1CEXcw9LFFeTQ/4S1tNdvj KOVJSwjGCUvtXHVkfxNwtzdPGmiHKujc1KvcFzaNN9bOch0yT+QY1l7KpwEB5XaE0lr5 uA== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k6r4v8tm6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:03 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29E31XVp033961; Fri, 14 Oct 2022 03:14:02 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2107.outbound.protection.outlook.com [104.47.55.107]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3k2yn6j1jp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KHJRPJnTwZQbFMv8PNMvUxM7wanjawELicy31RDc4fVRpkgIScRkVqKgxjJb1jCDED3uJgJQ2hwyRKUuGBAXoL3OWqFwGNq7UoDfYT5f0/5vllWKbLi8JdOKNsbU2NA9AdvsRP3/TFQvrvaVjQZrB2lqk1f6dSuqCW3tbpxFKRPYFFr70ZXB2cNHavonjGgyfYCL/Uni21YVDD5YxgCYZl0JU9E+gvlvKhpu6qyVMAT7tCoBnv6z8hXDS6gWrVW4k/z/rhXYiM/Xit7c9r68yyHdvvp6ygQ3A3p6vrhZc3RGx53Wfozdl6OYajCr9mkyFYHNwq3nPj8k6K8ZJwW7Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1b2Agnqraxu+oJn88SnZ5zrHf4rJCayWbQEFBe9+MkU=; b=ByV1ZhdS81/YYw6nHRePJfOccMQfKo96yzKshyeZOuXAqOGyPd85vNIZqFeE5vBWtLWjpc31Pj3fSJ0N4jpvNsSVL6nQU6J80HSeh2BBCBxoKk42dHMc7ta3x2w5nQfnCCWbTQp6JNIsExFsl2u/awsLOoLRcG4ej92bkUY/ALvOZuwYFWF3Ucgkgqa8dUWqO8FjytKBkX1VvSsrzBe9BP8gml7eVYJO1TKJap1FlB66TzejuVo3ge2J23rneBemrW629JvwkDOXASj+flYvJeZ0KDuzuTifMcmAVjikSvNTEcXPtO7PDvTe2Kyj8q2/8XXktQ63dc5dw89/ln95qQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1b2Agnqraxu+oJn88SnZ5zrHf4rJCayWbQEFBe9+MkU=; b=ZfFI8mUb0b2tp4tMgKExrghM+p6p+rx8uboLoRrydnM58qSVsh6KOpJTbxiK/ptgqMo4uyMjDeX3ev+GLt/vz/6kmlnPiYrc6QeQsikeKwvmr9BifaInbaAvrAoF1yraKVRbtNpH6rYXMgOHejYHMeUnj3oSxb2imeJtqiktJrQ= Received: from DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) by CH2PR10MB4182.namprd10.prod.outlook.com (2603:10b6:610:7a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Fri, 14 Oct 2022 03:14:00 +0000 Received: from DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8]) by DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8%3]) with mapi id 15.20.5723.026; Fri, 14 Oct 2022 03:13:59 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: akpm@linux-foundation.org, songmuchun@bytedance.com, mike.kravetz@oracle.com, willy@infradead.org, almasrymina@google.com, linmiaohe@huawei.com, minhquangbui99@gmail.com, aneesh.kumar@linux.ibm.com, Sidhartha Kumar Subject: [PATCH 3/9] mm/hugetlb_cgroup: convert set_hugetlb_cgroup*() to folios Date: Thu, 13 Oct 2022 20:12:57 -0700 Message-Id: <20221014031303.231740-4-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014031303.231740-1-sidhartha.kumar@oracle.com> References: <20221014031303.231740-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BY5PR20CA0014.namprd20.prod.outlook.com (2603:10b6:a03:1f4::27) To DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR10MB5117:EE_|CH2PR10MB4182:EE_ X-MS-Office365-Filtering-Correlation-Id: b5c46b78-2333-499d-39ed-08daad922340 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tc1JQMK5n/omnoZkDGChU/t2XQsWPrOHyQbbYF3PxiUCW3GnI7VDdvldY/F/FBycLdY49lg6tKUgvzXbNXFQhza6cVkTGRvkj0KffJAcDPALGoBsNPyb9kdPupONwr1tsXY6g+dNyQSgK7aUelJ76w/5Uo/zZy0Oh3adV8fJC6aU+HqM7GLs3vVgfgWWOCEVloX1jU4k6O0ZuWYt7r3W4iwTq2Z2IOx356ASzm6Stf2ef01pSWOzmB15a3i/G9HFWYj9Z5FgsiRGeLtO322EasJXv8+VT5O2EQwppyYo12R3XZsGynaT3dquAoJ7eojagw0eUbGbFBpnMnBHgY57N26Ef2GGBig43cEuBrgshPK73lHB/MPCWcb+GrzkSwGsc5Ivclg8dqZGIn4kobntpmd+KfVFSVi1Df9M5d2a5Lz5++jDduLuYVnyChH768Q2tfD2nfZGCiOMVzKpVu3qsZo6LTdumndBwqX/XIgDSnLfPKKnJG2ixcOzSHJOcxg017ggCzE62Gs8zhsPdXbNKISiDsZARH6SoRIdLTS1GXO8HvauYLfaYPQcPj4eSD5Z6e/P6iG2ms0ZvlJzsPhFm866U451M/02pgrg/eBlnxAqyD8XtBVdwbB7ThmYFX1a2UjuGm16gq+6hvRvR7C9lqKNdTgB/6UJ+3o7sXVjexESdVM2WnLU+4G14CMKl/iP2ILKvovpcy9WS+bUtTGB1w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR10MB5117.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39860400002)(376002)(346002)(396003)(136003)(451199015)(478600001)(6486002)(8936002)(66556008)(66476007)(41300700001)(6512007)(5660300002)(26005)(36756003)(2906002)(4326008)(8676002)(66946007)(83380400001)(44832011)(316002)(38100700002)(6506007)(86362001)(2616005)(186003)(107886003)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fJx0UHXk3LbwlDu+fvLVbWC+YijCFoV8pMsMZ0KwiXuQESgOexuRTx8Wf4oBQDQMFAbnj89lePwFAz8IkQoA0MzB0LHbdDWCuuu3ARwjaoj/VFvoNAp5Y3Dmr8TSYTFTKryezKhsFcCcuGGptOz5lP3+KdPm7uhhZyB/fp0D+JPhFQBoarxW3BSYWAp+6JGdPiQSG87JxLi/7S1BTN6GfBl7r2Etb8/ykfY5cVJMveyN3bThlf2wtdZM1vIorPTL5U+rUiZBf7T64r9ROw+bkzqyTaa+Q44xTy9Up5D4vA9D06wqtPJ17h8dPusnNM8fV5ReiT0iqhltMtJ0SBdvG2GO0GFwjKIfeXngTLJTiA55KqsAAyrYelp8TLy/gD9guYIJfTPrZOlerxBQPvaxmVlEhRWLrrHW2ynX9WAwOpwcRt3JQclbmQzEepeUOi1kyuwOg/FbR5WStelzqs9eR2E+MMuqWWeBfwGhijncSEiUhS6xieLLRyndM29Vj6hb8VjIU/lb/dchd5B3emxPbgcoa70rOkhB8WzAC7DMzw4jvA6r0tVy3UQdjgwNFcs2kycNoie4W1ZbsNQ+QPyI2hFgHoCr1wmNwuhU6008+d8Dm3GIuQICgL/0lfN2XcEDPCU23JCiIytyYTGwsEDNa+TMAAl6jRmWcJ98KHkqihzu+ZOA5PmjvsU2imOUBRM4H5TazIDD/gSiADK3+FyesCdUyUXgBaOJmkYaM1Ms7yGCQ2bdZgjoyC5bMbNqyrYAGs5WyKdFs8WNrxFg0nv7JJTCfBIKy8VB64ngzTFzMUo/XYp8tOyoVgqThlA4VuxLXVkNE/GeVOCnvuRUBodEwk0KwFaqzXQzLAZ04rukzXw+Wjw12RP8PXeGynE7YskMbllrFfvyXcKv3dj/WaiM2Ebtal2BL5evIjk4eVepYlRo549cHJX7MahTBWiYIRPBu3UMUQhZ8Sqy5z3XmsT70046wgg305m9Kgq+gkeI9Bu+iwcqCOG4IH4ubwyOV6o+qVxzAGV5gPMweSt6JQ6B5NosqxGz2t7d5KxXVjEWpvaZf5ZWAnetMd226YCbRfwSv0DCukOS++G1pdZbzacWKfcoDkbGNgh8ZKdLX505ebgT7mDSuNgsOCiAkykIulfQyp1PkbZAxR0obgyZVG/nN7UTbi4V75xoJSOA89d81E8WdL7CfkcsZUl3NoZllSvrF1YKKYR1XSKjPTtQ/g0Lnx6B7SdMANmdWBTUiH/r1UC8mWQVpY5KDotKdYv2teNdg3gQieuzgQv6szVP6KwAnbzdLi2VLt+VVJxT+CAuVUZS2DTEpARCS5Yw1tV0CjyAknm42mjXzjQ4DnP+lUHJ0RKjoKCfkLJ/bozbmq0/lwKGvLB+u5IvdO0hsyaOK1AWqqCQM60TVWCiJN71c7q3uH7ln1/+vcjwRwRS+dWh8L7SbXtaWOQte0JczVc0tMdhhoBdW8BIMKMt476eDhGrfxQ3SE5IT2iHvq/m3Pwowyq6Z1e1I4p1hFW8Y3zwMMtVdQ1MKxs9aFJvS7A4aYLBoAj2W14h3kX42+z9am9cyL8iPugiH1mv485+k8tLzRufTWEFdL+4DJAB66dtN+k7BQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b5c46b78-2333-499d-39ed-08daad922340 X-MS-Exchange-CrossTenant-AuthSource: DS7PR10MB5117.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 03:13:59.5526 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dTb4ZCoJ4TY6vq/f/oAIc9vWv+GxnKA3+F2MW4/YRlrRcOaWnMjc6K2BjG1gbQ4J25F+Yu8IbUURc47gonQLpXiAQ438249tvaKJ8ZdFbyI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4182 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-14_01,2022-10-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210140017 X-Proofpoint-ORIG-GUID: VgCWlwDxQRs6oks54bePRwP_a7ha_Usw X-Proofpoint-GUID: VgCWlwDxQRs6oks54bePRwP_a7ha_Usw 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?1746633540896032144?= X-GMAIL-MSGID: =?utf-8?q?1746633540896032144?= Allows __prep_new_huge_page() to operate on a folio by converting set_hugetlb_cgroup*() to take in a folio. Signed-off-by: Sidhartha Kumar --- include/linux/hugetlb_cgroup.h | 12 ++++++------ mm/hugetlb.c | 33 +++++++++++++++++++-------------- mm/hugetlb_cgroup.c | 11 ++++++----- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h index feb2edafc8b6..a7e3540f7f38 100644 --- a/include/linux/hugetlb_cgroup.h +++ b/include/linux/hugetlb_cgroup.h @@ -112,16 +112,16 @@ static inline void __set_hugetlb_cgroup(struct folio *folio, (unsigned long)h_cg); } -static inline void set_hugetlb_cgroup(struct page *page, +static inline void set_hugetlb_cgroup(struct folio *folio, struct hugetlb_cgroup *h_cg) { - __set_hugetlb_cgroup(page_folio(page), h_cg, false); + __set_hugetlb_cgroup(folio, h_cg, false); } -static inline void set_hugetlb_cgroup_rsvd(struct page *page, +static inline void set_hugetlb_cgroup_rsvd(struct folio *folio, struct hugetlb_cgroup *h_cg) { - __set_hugetlb_cgroup(page_folio(page), h_cg, true); + __set_hugetlb_cgroup(folio, h_cg, true); } static inline bool hugetlb_cgroup_disabled(void) @@ -199,12 +199,12 @@ hugetlb_cgroup_from_folio_rsvd(struct folio *folio) return NULL; } -static inline void set_hugetlb_cgroup(struct page *page, +static inline void set_hugetlb_cgroup(struct folio *folio, struct hugetlb_cgroup *h_cg) { } -static inline void set_hugetlb_cgroup_rsvd(struct page *page, +static inline void set_hugetlb_cgroup_rsvd(struct folio *folio, struct hugetlb_cgroup *h_cg) { } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index bcb9bfce32ee..4d98bf7ba81c 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1758,19 +1758,21 @@ static void __prep_account_new_huge_page(struct hstate *h, int nid) h->nr_huge_pages_node[nid]++; } -static void __prep_new_huge_page(struct hstate *h, struct page *page) +static void __prep_new_hugetlb_folio(struct hstate *h, struct folio *folio) { - hugetlb_vmemmap_optimize(h, page); - INIT_LIST_HEAD(&page->lru); - set_compound_page_dtor(page, HUGETLB_PAGE_DTOR); - hugetlb_set_page_subpool(page, NULL); - set_hugetlb_cgroup(page, NULL); - set_hugetlb_cgroup_rsvd(page, NULL); + hugetlb_vmemmap_optimize(h, &folio->page); + INIT_LIST_HEAD(&folio->lru); + folio->_folio_dtor = HUGETLB_PAGE_DTOR; + hugetlb_set_folio_subpool(folio, NULL); + set_hugetlb_cgroup(folio, NULL); + set_hugetlb_cgroup_rsvd(folio, NULL); } static void prep_new_huge_page(struct hstate *h, struct page *page, int nid) { - __prep_new_huge_page(h, page); + struct folio *folio = page_folio(page); + + __prep_new_hugetlb_folio(h, folio); spin_lock_irq(&hugetlb_lock); __prep_account_new_huge_page(h, nid); spin_unlock_irq(&hugetlb_lock); @@ -2731,8 +2733,10 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, struct list_head *list) { gfp_t gfp_mask = htlb_alloc_mask(h) | __GFP_THISNODE; - int nid = page_to_nid(old_page); + struct folio *old_folio = page_folio(old_page); + int nid = folio_nid(old_folio); struct page *new_page; + struct folio *new_folio; int ret = 0; /* @@ -2745,16 +2749,17 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, new_page = alloc_buddy_huge_page(h, gfp_mask, nid, NULL, NULL); if (!new_page) return -ENOMEM; - __prep_new_huge_page(h, new_page); + new_folio = page_folio(new_page); + __prep_new_hugetlb_folio(h, new_folio); retry: spin_lock_irq(&hugetlb_lock); - if (!PageHuge(old_page)) { + if (!folio_test_hugetlb(old_folio)) { /* * Freed from under us. Drop new_page too. */ goto free_new; - } else if (page_count(old_page)) { + } else if (folio_ref_count(old_folio)) { /* * Someone has grabbed the page, try to isolate it here. * Fail with -EBUSY if not possible. @@ -2763,7 +2768,7 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, ret = isolate_hugetlb(old_page, list); spin_lock_irq(&hugetlb_lock); goto free_new; - } else if (!HPageFreed(old_page)) { + } else if (!folio_test_hugetlb(old_folio)) { /* * Page's refcount is 0 but it has not been enqueued in the * freelist yet. Race window is small, so we can succeed here if @@ -2801,7 +2806,7 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, free_new: spin_unlock_irq(&hugetlb_lock); /* Page has a zero ref count, but needs a ref to be freed */ - set_page_refcounted(new_page); + folio_ref_unfreeze(new_folio, 1); update_and_free_page(h, new_page, false); return ret; diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 600c98560a0f..692b23b5d423 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c @@ -212,7 +212,7 @@ static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg, /* Take the pages off the local counter */ page_counter_cancel(counter, nr_pages); - set_hugetlb_cgroup(page, parent); + set_hugetlb_cgroup(folio, parent); out: return; } @@ -894,6 +894,7 @@ void hugetlb_cgroup_migrate(struct page *oldhpage, struct page *newhpage) struct hugetlb_cgroup *h_cg_rsvd; struct hstate *h = page_hstate(oldhpage); struct folio *old_folio = page_folio(oldhpage); + struct folio *new_folio = page_folio(newhpage); if (hugetlb_cgroup_disabled()) return; @@ -901,12 +902,12 @@ void hugetlb_cgroup_migrate(struct page *oldhpage, struct page *newhpage) spin_lock_irq(&hugetlb_lock); h_cg = hugetlb_cgroup_from_folio(old_folio); h_cg_rsvd = hugetlb_cgroup_from_folio_rsvd(old_folio); - set_hugetlb_cgroup(oldhpage, NULL); - set_hugetlb_cgroup_rsvd(oldhpage, NULL); + set_hugetlb_cgroup(old_folio, NULL); + set_hugetlb_cgroup_rsvd(old_folio, NULL); /* move the h_cg details to new cgroup */ - set_hugetlb_cgroup(newhpage, h_cg); - set_hugetlb_cgroup_rsvd(newhpage, h_cg_rsvd); + set_hugetlb_cgroup(new_folio, h_cg); + set_hugetlb_cgroup_rsvd(new_folio, h_cg_rsvd); list_move(&newhpage->lru, &h->hugepage_activelist); spin_unlock_irq(&hugetlb_lock); return; From patchwork Fri Oct 14 03:12: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: 2481 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp595153wrs; Thu, 13 Oct 2022 20:27:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM57F5yhE7ANG5PNIGgEghIZPLUKT9CBLtTZ+AorhH73RK+5+3BR5cnqgyUVfFj07da12urj X-Received: by 2002:a17:907:8a23:b0:78d:a24e:a9aa with SMTP id sc35-20020a1709078a2300b0078da24ea9aamr2069778ejc.404.1665718063050; Thu, 13 Oct 2022 20:27:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665718063; cv=pass; d=google.com; s=arc-20160816; b=ph/3jNbju+QeB7C/7QW/ZuoMRMgWNlN1wR38nzq4LtL2OFDC1XbM/A/mvVNW+EfapI ZQ2xG+57XAHAaEENO5IHEvaNFZiCYhV80Sun2y/jysg99nPlgAF7Z2cpk+uueQNmDmrr cYe938TvMMXSTdwkHfswMx/8s9+EQY2O7W8ixxZCJSar9IUVYIi4BwcvzxtRT/zsq2J7 j8wjQa4rDoj6y0bUOyTcUDJx66umTXXojUxkl3dgIGl5N1cZandxD++VGpvedTmBTW9l SvUfOhJ5LuHUpvoL7Q4NYSE0Ihp+wSYdGyBM9Oq0PN9BKLZPj88KnM8k+X8HV7JfOlN1 o+Mg== 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=YwOiu07DhwM1iywJ5BTRvmCQY83wPPOpkpjDxWRM/bk=; b=oEkLQrUcqB+qdvXqRWH1bB0oSgRhC8K208SrMcWZCgbOK71giEk/Dpczows7NO20B1 neVCflOvtlhmRKCy0JNhhMLwRxikiAIdl38a4h9n0QoHUgOwYWoyRahPT6AtlIdV5vGV Y+Xht4JJY5JMBJoOTbnX9BE0pmgE1JMcfnvX8UrC5AUmALBz+5jyZZdtlL2KqvVQo+uu Q9h9oM31vjTozyY3sUJEyQk+wa///tK2lMu8X9jNQUW4mLmwYia+4LiTnVn1Q0il+GHa EBmIFXrNeZ5E0+ySRj4V3FMBxXbe+2BcWGFxFUPSiZyYQ7JMPXthHzyi18vJnkwHo+Is 0d4g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=0D0zkiWa; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VaM1WJii; 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 i22-20020a056402055600b00459101ecc5esi1039264edx.468.2022.10.13.20.26.26; Thu, 13 Oct 2022 20:27:43 -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=0D0zkiWa; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=VaM1WJii; 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 S229897AbiJNDPE (ORCPT + 99 others); Thu, 13 Oct 2022 23:15:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229710AbiJNDO0 (ORCPT ); Thu, 13 Oct 2022 23:14:26 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F23F205DF for ; Thu, 13 Oct 2022 20:14:25 -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 29E1kIlx007683; Fri, 14 Oct 2022 03:14:15 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=YwOiu07DhwM1iywJ5BTRvmCQY83wPPOpkpjDxWRM/bk=; b=0D0zkiWafRtlqKX4JxAnAa/PJAPIHFUTacS290z2mvAtYfNIv8o7DGmwqExeqg7IYtD8 kW8wD6izfjvwSDKdZVs7rDbIRszAVbZTIDt4pEs3tX5cDJtbHEdmGFN0Rs4VcpH6tWXF 0tWp2b/OTA9Dh8iNY6yGL+w76MM8WEBTdilfUqe3JI7Od/p5pBJoSjcDVj87cyNp6Y6V rRqsyXsuiU7A9wr7NNrbTlipiUeO4FTeO7bCh0nW4rw707EkiIyXDRQCECG/PM3a1pTW HQMNda5ZUvlV4g8605mm1kvudNbOq/WV/9E38GvrYXnoLNEu99mfZGyrn6AiE9956wwk Ug== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k6r4v8tmf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:14 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29E0IiGT003847; Fri, 14 Oct 2022 03:14:13 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2105.outbound.protection.outlook.com [104.47.55.105]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3k2ynd5qme-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I8D0eMVm8BVuz5YqRLdkPghyhzwse6L6VY/4geUrpL28dtOugHWYyvPt/n6Y/VNpr5kyH247VSh08daHF/i7/ufR1L+08GfbUemsHfJ7SrKf4Z3rBJAPBYbMFG+YknGv3zgRXxL7Mfm0V0UrnNnVWVV2uno6Z9uYPJL1TChqilbsdfWtnrx+hqREOUwjvkP3UbuzeFqdv7vR/ny7KUlfb3pkVeTBU+zDElNEuRxQyGsaDRiEx0B7/00WC0Iwck39tvrCzW83paNC+SooEchGuG5PuMfh0GqeFrf9JRENDA6oMjNhEEbFG70WAYA3aC+1aMxiBKl8gM6oK/1cg27QMw== 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=YwOiu07DhwM1iywJ5BTRvmCQY83wPPOpkpjDxWRM/bk=; b=hpyIFzH3B5+y17+U+LjdhgH73IDRlg33IR3N83XjdWqr5AnpBM00GRNBDp1+QMtjFeQ/6K+lSrS8Ib3qomUOxlLhBAT1YX0hznb4CiD4wIPTCLQShmkC1TCUBc2HaYRFO6Ww/pGSlFVpXLT1yU3laR+rbvVeg/d/EvT+P2um+jTFsSmL2CIkG65Zh4DuSJOWvu45KVNcuvMXJfCu4iVBdbu+BP917Z8Uj7rj1czxVy1V1eoopolLyBlaMTPC/GXWh/EQOFWXNILclWCTkJgpBxYEGV/Os+tLqyWHojPKIjAc0gqUbHsTzrjop/lkrusP14/csKRazqd+27I9qK2nfg== 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=YwOiu07DhwM1iywJ5BTRvmCQY83wPPOpkpjDxWRM/bk=; b=VaM1WJiiFZcGSFZKshISexMYKmUFx1CodyALEOFZe0+W395oL9vrxmnwabupkJfpV5HVe3Zkol+wLZ4m5EraZetDKXolcQLA2paoZs38Edvh9FvTwk49LfAQMqEIOCNfOcSDgZsT7XXJeA0kccI8n77r6TQxpB18eWM1/9Qv2Sg= Received: from DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) by CH2PR10MB4182.namprd10.prod.outlook.com (2603:10b6:610:7a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Fri, 14 Oct 2022 03:14:10 +0000 Received: from DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8]) by DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8%3]) with mapi id 15.20.5723.026; Fri, 14 Oct 2022 03:14:09 +0000 From: Sidhartha Kumar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: akpm@linux-foundation.org, songmuchun@bytedance.com, mike.kravetz@oracle.com, willy@infradead.org, almasrymina@google.com, linmiaohe@huawei.com, minhquangbui99@gmail.com, aneesh.kumar@linux.ibm.com, Sidhartha Kumar Subject: [PATCH 4/9] mm/hugetlb_cgroup: convert hugetlb_cgroup_migrate to folios Date: Thu, 13 Oct 2022 20:12:58 -0700 Message-Id: <20221014031303.231740-5-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014031303.231740-1-sidhartha.kumar@oracle.com> References: <20221014031303.231740-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: SJ0PR13CA0001.namprd13.prod.outlook.com (2603:10b6:a03:2c0::6) To DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR10MB5117:EE_|CH2PR10MB4182:EE_ X-MS-Office365-Filtering-Correlation-Id: 748f0995-e5a2-4a1b-e145-08daad922950 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LgHImaNHMGSga3CR11Thk2yV8s7ScpQpUDWh3lWIpQQLPM1Aax8yzS87ehDn52xnW647+02m6lTDE7yXeJybYQAFAso2G1cp3g65BDKoq0J/aOldPc/DCnE4zXCkLAay42kuUt+NVNWuDd2hnA5qI3pA+af3Qt7kpa6lyLeNcAcdff7FVqd/uuefuxf5FIBoD3DCDewux8ry0VW7dA5Vo/7lJMe6vtgUufAjJ4avaURdqXOhtVVMihR5kYtwg+oStjI3MCg90UjJW1uUY3u9FdebwhlnUH6fjo62Wku748W7pgx4hwcFb2axuFXyiickqxfg/QmvEuwxw/YZRCl1ePHpJ0O8cnTuwj+8ksnULZvAekrJ4kIqUj1dehyoFx6dbUWaniiTn1k5ukOVMEa9oCEcCpMNkf4ITRLrquZXty95hczsz8k2w6xAIQp7vXUZpr/fzO9spnipVwz0TrRGj7UnHjLXiGADn/Rzv4uEpquG5gU67w8zPfWccSXRxrd5sI1K6O9sVNDE6lJ1tV7ahNXian8OsGb2mnbNr86LeyG2wWGFUkzLUrsLnDA3p1Mj78aaVd/PnfS7b+0g8xMCJO3sklw3nyiFSRMRIGbfaFQLumhn27p63v2uzpzXOsXElOLDTxeJcH5R8keovnJPs5M3uTUsR2NZVDY4h8iyqxdntdeS7oOndqPJYQaEvjsYf+Ny8nTNJdC7vsVyAI0O0w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR10MB5117.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39860400002)(376002)(346002)(396003)(136003)(451199015)(478600001)(6486002)(8936002)(66556008)(66476007)(41300700001)(6512007)(5660300002)(26005)(36756003)(2906002)(4326008)(8676002)(66946007)(83380400001)(44832011)(316002)(38100700002)(6506007)(86362001)(2616005)(186003)(6666004)(107886003)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Mcf9Bnd+bsbuN8GK+h/PbtHwdf2S1NVZ2zdynb4JlzrMQvDM0pSCKlIfoatsd/z1IJHi1OTz5LVRdJXBLu3lTseZt5SDA1oioEu9nN7C6vArxxBd7Zn0WLgWHYWFJhggQI1jocmHe/WJVZfv1mFvaI1EyBiwakY3DLPP49kgqrU+5NJtTxBqKmMzJ8mooCUwblZPLhP8yg4wpldeMw24JpoPYFrKRh2wvs3DuXXYj7bd37/U7xKV0Knw+OQyG+YpzFwhvwj0Meoq3d0PShz4NW3pV0Ko9ZhJXu3cptKLwHuWcAJBdZMnqKUW1mzL5Fob7oYt0RIO0eDBaEDohCvD59cy1ooAqA1ipiDIepN8dbYOQAGaBphnKTkw+jkLciZHYRdEEP5GI8ADbAI8zPPDPOnk8ZnvBLm0atTKlZ/nI3oKHC+JqKUTL2vRUzYWir01Oc829YAPIiU1I+nQdB5B71C4jAT1091hOB1Bjn3cAn3bqVPqhCgbdfwgs1hBxWmM3osEA0XpZ16DIieYmzyUwcbub1LCpocyCBVsC3GRQi+RzpuaVGAGScSfYjgBOy4PxJiOMx97f1NCJpkW9vqe/tyl/efzFO/bnfTR+uPOq3PVDTR41kjdIbJ1lSppCnDDKqxt1yxX5Yo/HugS2vkBsg/uB2Ezjz3F5bYdrlWNfjMQ6FwoSKg9FDubeuUGa+7DdcMh5yrAe3e/dDoGo05TzzHK0WUwBRwgKlBwCxt6QODJ7aofurdLsjm9ACatP+VmLwf0ABuUOafJG8af8NJgkoO/PkJavCl+mw0iqN5PYg1EBwfqA/Vswa9I3XJBSlWcYFRBa1F6xeyi78oa9wEfV2oe9/hQE41dSjiC3HpBGPbBpZMrozPiLUSXCNGVGMYRjmLCGmCt/5WdpzTwsO4QgnOXU5p9tLXuTvNofPrJ1P1DIgOc2w8vMFQoaqY/8EwhfO8K8OrNVKPAP/djggaxRi94gNojD4jFmFvp8gkE2Huw+XOhSF1DPdip9mn9ioP29MPUrflJfA3t7QdqvdYeImK16AEpIDcEduOwHV7ojCXzdvnGbIr198klQifNcMgHRE6hT7z1D4q+2XjL0aJRXRmme9TpIBm2iYn9oR4xHz/ZfM7a1o6yhU9cdAOCRhKEunllEvRFGgIiC83OYmSarJj6Ut136GLnqOEEdQtHKIhiHNSiQlwF0fLPzZYnebo1I5wGFMO02GtIn7chFexQvyhmYOCROYxDlOeB/6Cn/BF+87s0LlGAJdvtrTBWyMapfDVQVLvDSn0WhBEmIkMWw0AD1TsYXcWn0pzn4XEZkkt/krqmw7m4U5KvJv4t+unJQfCqyD3sHY9rtdvXFgz+0nMKVErbdaAP0fdHzKS49RnY6S66POo13ydx0UAERWNkR7zZMPrcWrPzXg5UlwuU0J8nQyTAPX39tTUMs4l0cMKrtJXoj1IwiYij38kGPkzTO2DM+4x+mKLEDX/myue9BG/Gl3Hyr5PdxlAi3XsQXkkZ5e02KctlfFfB7UdXGRgWL2uokmVdm+97YJhfSusBe0ZU3pZGlZC3o5rawvvjyGnBKWWChj59xP/anKOe4mcFUGptkSIzk7PGUKLNNXRojw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 748f0995-e5a2-4a1b-e145-08daad922950 X-MS-Exchange-CrossTenant-AuthSource: DS7PR10MB5117.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 03:14:09.7280 (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: 997jn/dhCaFUJQgOxgze+cJp1AZc77da6JtNTEZf8TkR3PwlJDqApnBOc8fHsYLioinZVBB0OLT8RaIRYi3g47IaBYKDG2xw3Z3aYs449Hc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4182 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-14_01,2022-10-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 adultscore=0 mlxscore=0 bulkscore=0 malwarescore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210140017 X-Proofpoint-ORIG-GUID: sotljtfVBdFULi6CehXL45UcHx8xALbD X-Proofpoint-GUID: sotljtfVBdFULi6CehXL45UcHx8xALbD 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?1746631983275181987?= X-GMAIL-MSGID: =?utf-8?q?1746631983275181987?= 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 --- 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 4d98bf7ba81c..e2dcc9cffb2b 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7289,7 +7289,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 Fri Oct 14 03:12: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: 2487 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp599168wrs; Thu, 13 Oct 2022 20:42:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7JgpyR/12PWdskdBT8gdPQ7vEX7DDWH1PiS2Ht581Qkd8RF+n2Z/2CpqF2ENl9Tss8J9gD X-Received: by 2002:a05:6402:2706:b0:459:788a:355b with SMTP id y6-20020a056402270600b00459788a355bmr2410391edd.315.1665718975206; Thu, 13 Oct 2022 20:42:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665718975; cv=pass; d=google.com; s=arc-20160816; b=wPjju8t569yNWkuiKjJ3YptnfxRW9oQ3z+jd5pECPRsJQ7a19KB94ZSq7E4EtE/HZR WZt4CBN35PZeO5XVCYrPpEdYsDzquluMBvv3EgPqqZAGBS5D8oYpy6wLStz7iOBoZVoe pyi+1lznsBNAn1sS//rKOmwEcEdBWVye1FFF8y4fB6GUri/Zs4nLguuJSmwblBM9UkMH LS/Xt08BN5pc+ZGG8ivP1jas2eB0z+uUWiUBIIXjWoYRBSjRPB8N9iHJe66woPI278Oq f2zlAfNB772GwbZJ24gSmxmKueEzfC7FJEVaSBOkWWBdgQMazgmBxVP2su93ge15j2ST /v7Q== 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=4r0kBUhUUQoyOllhANKTHwaqm7Sl8FIuHUpB7uEibbg=; b=FicMOBNPvDSNOtHngrbxuWSPBhY1XUiUwD62Rrgvxj5JcmtPhQKedb6ar833aucT0x /flvFh0vMmMPhyeF7vD57AxSqvLtA6xvPbao1XxBvqt0/9js8NnZiLFOEYvJqJ5vOrhW rZFI4Yp5RMK3afWgr65yhwvRbEG5oTz2doqN7+vA63oTVCRfLg0TcaAs8nblMZ+oIzrZ AsG5POQCIDcHyo7uF0B5p+538m/yBFOQo9yEYdBqkEliQHh4hs70NQ9Dwfdlsk/cZnZA u2+HV1Bd6aK9Jt7wx0kyq8KGfiZ60blzWEbZZMDgD6ntULw07aZMwN2io0/bj/Z+XRS8 CY/A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=FjeGlljg; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=G5p0nr92; 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 qa43-20020a17090786ab00b007826e727aeasi1350025ejc.44.2022.10.13.20.42.28; Thu, 13 Oct 2022 20:42:55 -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=FjeGlljg; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=G5p0nr92; 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 S229907AbiJNDPO (ORCPT + 99 others); Thu, 13 Oct 2022 23:15:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbiJNDOh (ORCPT ); Thu, 13 Oct 2022 23:14:37 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74BD53687C for ; Thu, 13 Oct 2022 20:14:33 -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 29E386Qc000494; Fri, 14 Oct 2022 03:14:24 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=4r0kBUhUUQoyOllhANKTHwaqm7Sl8FIuHUpB7uEibbg=; b=FjeGlljgeM5zXr/CtGEw/yWRMAmtV/TpJKyxmykdQlbSsDqbVWcMs1GA9Z6XlJoWVOQn b+V8WG8MhAik1tvap2DBgQI/tzCuBzO4ZH0fBrsEGm40P4PBtlNpamrS+QrB25TEA0Ip hLpCYhhP1hsNPWOuSHuPQI9S8fXAoY9b/PPVsFGWF6bRgvxfogrNlfGnPpk72b0TuqtZ +Jn28Lx1RgTo3Sme6fxh3RPhgROygoVbt6ZaLrr57n6+H4MwQBF46vDpTDAVFZTD/NrH YtaQKUdyrQgJsks8qu/ehracGiIvov1NBH2jDlD3Nvg4LQCcpGBx1SIAVSqIcckaI1/w QQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k6qw7gwvr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:24 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29DNg1XF009730; Fri, 14 Oct 2022 03:14:23 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3k2ynddber-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TTZXAwGeQDmBCTvncmLKfZNXZpvgtpMqzooj+qm3XthGZZ3tDyxNJApmqw5CB130ndHPrPj2/pl5kiqb2HTemoqqICA03GtPk+abvBKCijU6Uz7D9p2fcgtKLoSBGF3W29GajXlewcExm6EENe4NtaLdvUmiXjLq4VJCXkoW67H2aPb09nb74Et9ppTOKGha57Jy7d5vTb5DEkvAu2XmnWocpDjcGmiuOxn3advel5bPOXBC418OIPCk8VnAn0Vn4blTuRvfK/c6k/ahbxtf3HDLQpTi9dVzZqJj87NrkJ8meIGm1jVk8IPpWEVP7/iQCnqlwoFPUMeQE9MnBOc7Dw== 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=4r0kBUhUUQoyOllhANKTHwaqm7Sl8FIuHUpB7uEibbg=; b=e+jGCe4t3X/kH4+aTPmbd+JiCConFQdkHw3fi5uQWMJbIFjigAUETXlhF5/mUVXkZ4aaOvo0zGKDC/roz9WLgmhIYMWacHTtarmY+K3Jev5AgPd+34ajgPGafaN7HvvD+kWnoNSE6HuV2FzWmWW+T/rMgtDw/EHgFbRuQzsS4vzj8KQrzLbgov+nUVqWHW+f1JXfCEr1yoMWaqA4kzDvMXpFhJAlwALB+h98fJRPFXcrV441i7vWqFsvkB796ALctqdMVOG7iJwjcJZbSPwKA52qN3sqF3X6jMtkb2BrfPF0etozfu0XnW8zky4JsVpVecoTl1zOHl2NE9m6roQn3A== 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=4r0kBUhUUQoyOllhANKTHwaqm7Sl8FIuHUpB7uEibbg=; b=G5p0nr92j3ZyxAhOFggW2qGYdokAvufz6gVvxaD3SbwF57bbRp/8yeCP6mWeX6dQgQv0D4qLv7rc4EZaaWUhP9YwOj56RhvCycqw0kBZgyb9ttYurvsoRdDcF1axjQR4fUYbiDBVqPNrtTWQgEAsK/G7J8SqJn4iABcKpkP0VRo= Received: from DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) by CH2PR10MB4182.namprd10.prod.outlook.com (2603:10b6:610:7a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Fri, 14 Oct 2022 03:14:20 +0000 Received: from DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8]) by DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8%3]) with mapi id 15.20.5723.026; Fri, 14 Oct 2022 03:14:19 +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 5/9] mm/hugetlb: convert isolate_or_dissolve_huge_page to folios Date: Thu, 13 Oct 2022 20:12:59 -0700 Message-Id: <20221014031303.231740-6-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014031303.231740-1-sidhartha.kumar@oracle.com> References: <20221014031303.231740-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BY5PR04CA0025.namprd04.prod.outlook.com (2603:10b6:a03:1d0::35) To DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR10MB5117:EE_|CH2PR10MB4182:EE_ X-MS-Office365-Filtering-Correlation-Id: 2ef9c240-2fbc-4d54-4427-08daad922f45 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bM34Bz9noFPvv4Sw4dpfbhVG/t4UfUbHvRqF4I8e13OxsaU/6ou2XJxmBDGwnySqrF+/RZz5+I0ewE+F2yjDcEIJjIG2VGK1a/U8W+raaBirkb+RvNzysdRTnlPkwEGA4cCrbCCtiWbQOuSexGQH0P6m0f11E78LSRU16KMaEYuu/LA2dONI6B+975PW539FcP4r+Vqh3Bpi6KFOCFCwOuMkgtApb51OyckeXtZBr4MYWemT417emxJwixU2fblIC1d393Y2kWHDCjcnUePNnualVJ7mOcwvK8e+YKvozlKdoGVr+N7cNt0ze3KFdSvaQFE4rJwGiEfHTr21qKunWnuc+iwvXSQRjqo8rTxA7KRcRoD6gHjFCjbaegKKawJC4bxHyhHtw/HBLKebjr/iIDdjmN2/tU5Qb0lutCxadX5wLUHPerZfprKZ6BgK+Ms7CzgGhKiRJAWQRbSHvvTYUjLibFKFbydzczvFR/wEF9VeIQTg+j+4BxgPOYvZkaIU4LoYzXWtLqN/i06fugeCO2oVG/U160xKAJQ11oI8Uy0PwXuS3i5jymFJjVOlnZFnPlU0EdDpO5mRo7saWM1c8n+hwbBLJ73WVr5HGLcFxIVWjHHwatL837K3sm4gea0I1yM+p3DpIdovSSDYqnQhN8AB4s4s4stGryIZhrWAD+3AksRbUMUSP5c0Z76ACRipf0RhtXeSfb7doWesjbXUn+osT9JIBdnjqk8UNo9zUJTqswF1xVvvyEk5mB1ljyRb X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR10MB5117.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39860400002)(376002)(346002)(396003)(136003)(451199015)(478600001)(6486002)(8936002)(66556008)(66476007)(41300700001)(6512007)(5660300002)(26005)(36756003)(2906002)(4326008)(8676002)(66946007)(83380400001)(44832011)(316002)(38100700002)(6506007)(86362001)(2616005)(186003)(6666004)(107886003)(1076003)(14583001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PIyqcFD1kPm2Psf4TUPHab96WU9cijJlKGGGjyKsvWVYzWyrucAoxTwX/wekpRTQtIjH0oxK6vK4l5aewHGrW7czaFsVtaENRB1uu98tdsBuWyYGfiTSadHwW7DsLy0YU6XNJt4ifGWSgavQ0IFjoKjd+hNfJltRyVZif04EKG3lodDyDXoCapzZpKw11rZ2dy+TazThqH8WlWRHUCMjbvq269LkS6YDcnu8gqJ6K+rDVUBjhBVt6/PNLI1Rji6vKnSi5DaWgDXEf1HqHA5XCIvW04Ap79nPCjBbqHg4eTfg2UTbnsb7RZxGt6RMee8GtmXAwoSdl7kuMnZLg1TA7WDPnMhNwVv6/s/lnOF1Jn6+dFa4eyw7Br5d7l9P5lUmmtRyo1W3XGiT1LhQXgMKuGp6wF8vnajg2SY0GigiVmBOuraLqOXM/F+hcc5LU/SVwMTissVR3yVK8S0Jw9xPDOiUX9i13XKAJhKkrbgSEuczCPGbUipM03MfoNrFjyJ2X/PQxNKxSyOC5GMlWIYPjXcwUn4Asy0m3yoUIkQLW4U4k7LeNipmMiofRBzF/c4fS6i3f+92QfbvrrIB7gaFc+L/UzZ/or8ouAorqBvuBScuxvSHzSr+/fWjzknyZPb0ZHSeaWY1iP31mjS8/mzNq8n7UxMLDW/3RQu3qcWY6lal+P8HQCN7gA0PhYyfegZM3CY8jkjAkun/5g4XyUbgaq0p7WLeE7oj5VPQ3yMJSkGLgjKMMck1DctI0KebdaAI+Yb6oMm7dnFK8ZCC7xgp6ccQjh0/6Wduubd3cm++T9Il29bqsZxDDOSVfb1XBQ/DmMreWa7JvWZWr8547XktMsmOJCYs/mei6c/g+CQh8lWz7L6j5h//VEEO3k1Dij//i4Vv1zh6zW+Y1NVSBgPXlhyNrXNJLkz/NlBBg/7WfrDdhpxF0mZAiWFeHxgyRP90rTzwRUMDeUYvMi14J3IxaE99yP2+c/fw26JA/PS2FhjWyWc++8h7kWMF0+qvD4jWA2r6rdK69aF5LN6rPAldfn0JdSjMf3e1FYlRXo32Ys7zcZ2iBGW8YC7OzhxTECNeFUknmNXR2aEOQWoIx/Qj/HErJQBkriPzk7mVTGBhZHlFntNRcZO6+aJDoTa5j+NT0sTW7ehVK31BysKCBuioQ7b6zfE/cWJUKOnZ2udix9aewHzlstiYrGSPNyAlAiyiipNy5PxS0sRWrDYXFyu5VDHbcFEQ+SXFm28RvqmVyLHkkjicx+l7APQkqJX832UOBQk4qMruE5EiFJ/wJol1wrJjdOmQF0zVsVbBBw+h9fL1Jf2X/T9rhZD+JxWTl++xJRCpHZmaTE3ECkxOjH4k24qlceeLn+QazZTfaMskwczK/vyKWnuOy4fuBOAq3lpZiVZsARhrgh8gf/UIhYYNfab/p+8WMDyXeN2qPosqBj3ueXUQ0StXx4FfIGNR4ZzejSKHffo9989NT2WxJhJrvH5n17sZhYdDh3mciTPPxunT1IH1WXZSdZ6wkqGOJoJfnCUqcVXJUtEHRHaqG2yAn9JiEcOX7mtGhq6AbxEWoHZk24uZ5c1a0Gb/nYTdP65C64zGBfCAoKsKZCeglVoufg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ef9c240-2fbc-4d54-4427-08daad922f45 X-MS-Exchange-CrossTenant-AuthSource: DS7PR10MB5117.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 03:14:19.7339 (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: 5y6t2LN7fvIGvLipJqZJRqPOTNSaasJta+BozytKrxX93J8c7nv3OrN0bLSDwRWN+cLzWQUB3R9vI1OEWow7ufqjA0XUPLY35q8E8Bj066w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4182 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-14_01,2022-10-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210140017 X-Proofpoint-ORIG-GUID: f7SNV-cu7ldKIF1UQtAN0QgtMpE-0b9U X-Proofpoint-GUID: f7SNV-cu7ldKIF1UQtAN0QgtMpE-0b9U 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?1746632940177860586?= X-GMAIL-MSGID: =?utf-8?q?1746632940177860586?= 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 --- mm/hugetlb.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e2dcc9cffb2b..44a9a6072c58 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 Fri Oct 14 03:13:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 2488 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp601068wrs; Thu, 13 Oct 2022 20:50:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4tlnf3nvXp44P3NiqwBlvEcoduDeONlxY3NJSgluQKVIM/bhuKMhMLK6Jrax5I4XmgtZAa X-Received: by 2002:a63:1349:0:b0:44b:2240:b311 with SMTP id 9-20020a631349000000b0044b2240b311mr2766275pgt.405.1665719401452; Thu, 13 Oct 2022 20:50:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665719401; cv=pass; d=google.com; s=arc-20160816; b=X+7aYp4FLYISsu64J6nbFr+HU1LRU+mpBrf7Ls40jR2qNOVAMSknPknfWKFfZ+ixM6 vEjXH/8E2a88QKscqVQWZ/9AB1yRVZ0P1E/RhIYylcYjtICLiCMQ5u62xbgu/9iFDgDD 2nD8r84ZseZSoC0RljI8mKHtOvxzGbfo6s1BTjGPlB4/u9eSEd0QTI/iYsIZF5MpLkCd itGnCqt0kLjPOlsoTNGg4OFibGHDAQOXNQ93NrbZtURWFbHRs07fUhIedEtZp+WfO7AG ElDRRkhZWZ8MfpYuyKTiK1pP+W7sivlr9pcRzPTIRtdtXq0NEhrkpkSiHH0piyFAMAnj Z0VQ== 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=9UkqaIPxVIAGRp4AHqMGFSJkoHo7vYoVRFk1XahV5z8=; b=ifny0xGF/kuxikeAJZBguUa4HRCU+yde4EOUTyncxZnYcfLIFT5HdedeMd5X6XMyFN 2mehzCQOLMIYpFEA7fVmOHZjPl64+FZgnw0xA1AdfEUhAPCYEq+CM02L5fcSLEGmR3HI 1yH9DYvZIqsErKL7FI7akbHimj1Fse3EEOFol65ZM6GtSrE312t+oDu+AjHBCBvEl+k2 4D2ObklTbo1q4ab2+Yux0tshQWgSDVleYyqx/tE3zsehxQeCltQwLIEaLsf6Iijq5Rx0 aY8meZYgvki8ZjmWqoJFbl7YFSjvAObMNnF/6TezvaEzQ3zie8ltR54YX27K+qXl0aZO O44Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=beoHE4A2; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=r0nbVOZj; 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 bk13-20020a056a02028d00b0046271a622cfsi1327844pgb.550.2022.10.13.20.49.49; Thu, 13 Oct 2022 20:50:01 -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=beoHE4A2; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=r0nbVOZj; 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 S229700AbiJNDPn (ORCPT + 99 others); Thu, 13 Oct 2022 23:15:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229936AbiJNDOy (ORCPT ); Thu, 13 Oct 2022 23:14:54 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 721C61F2E5 for ; Thu, 13 Oct 2022 20:14:46 -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 29E33nZo006589; Fri, 14 Oct 2022 03:14:33 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=9UkqaIPxVIAGRp4AHqMGFSJkoHo7vYoVRFk1XahV5z8=; b=beoHE4A2zZR1WHmaRroXAfVJ84/y+nX3mM19BJaZPuwdbwwwnBdnDnN6eSbq/4tAm6qp qslX3F4Q+S3PyG3j9yl1r5q45zkYHxCL2pc2sqRTrFtdNHSLbjl/eOPl1XQ9V3FcrhlE eR9qcMFX32ogB/4v4NVga9kn083N1WrkKw1OpMgghmLxqFbh8cuc6hPgPVl23rs2SMPB 0ZzgXSdvLF7ffuTYr+qzKKUyldg9oxqY+yTcP7ysXmH9slNyqbj2VQ+t5qjI/++16zhJ sAIJ+1XaTusEQ6zkdMvEumQJQgq1O2rA/Vuv5cXvtfQf0POv8ToiNGedszYs2H9ON2Vc XA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k6mr29k1b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:33 +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 29E1eWcv025311; Fri, 14 Oct 2022 03:14:32 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2108.outbound.protection.outlook.com [104.47.55.108]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3k2yn716v9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YUXRyubV9hzkGbXEOMsJL/tUns2elKAOdl8GnZJ1JTXeFXxBbL4r4Lv1JPo1r92R6L55uFR5vlgTdwG9NLXFZ3uCHv98qjLXUXTHu0jliH28BZ2blRLmv0hoxv9x3c55sscT+TnIeRRz5+Az4KfRVhVkz+fwmoClVPpJp19QV/ueeBnpnumvLPASZ14NV1b5LXO4l+3W0SFWDPrTVb/M0EC7Vv5ZBaqhVDolqO6w3SSvLBe2OCdSOTdE5q18thHBQGBCk5a0TKiIT2qUOTJnyFIlZAvOLia/e4Nw+JJ9aHUpsszlaCRWjEA/6lGgryrFmx9f/S3z4Y1CuyetPvkNrg== 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=9UkqaIPxVIAGRp4AHqMGFSJkoHo7vYoVRFk1XahV5z8=; b=V8cWKj3vsFr6GaYB/CJc+R8CiVZ++h2xDY2xjcTxJljmJBVlWkED1YXvGKTqxJHp/GuRkv7MBdaBBFjLjvSXT2CLblStUOuEMjUL+z4nASKy4a5yCshcruKeknZouxl2FMWdED8ae/aVJmxQ1x8OHjrBk/+B5BZ1UJiPZbzFFmm8qUsYDRCm+mZk1eaWAQeQFbUbNNlGMeW0o2t6UQxfwM9YsQxrSSYkn/EQhBO4CjyWNmx8yuNyHGEAeJ6OW5j/xbbMZE4YxCoFvlViKjTiJsvJG8R+C/Q8Psy+ctCkGhuqwzQQl98w50mbmMbl4zw6zEjOBCqLJpD7177V55NvWA== 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=9UkqaIPxVIAGRp4AHqMGFSJkoHo7vYoVRFk1XahV5z8=; b=r0nbVOZjxFge0ealZRjq8naKYXXwx4R8HRngtvZ4iXEpf06L14AJoJ564gh0Z2qE2EdZtMIS2U7QzWpvmoEdGsqb2+ZwzYcfjMsw3O0GREdl1qwPQdn6LwssdDDHhD5ItbDW9P//0d3NbSu4NTCITz+nKH0zwilOhf4ZsD2xHqc= Received: from DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) by CH2PR10MB4182.namprd10.prod.outlook.com (2603:10b6:610:7a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Fri, 14 Oct 2022 03:14:30 +0000 Received: from DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8]) by DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8%3]) with mapi id 15.20.5723.026; Fri, 14 Oct 2022 03:14:29 +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 6/9] mm/hugetlb: convert free_huge_page to folios Date: Thu, 13 Oct 2022 20:13:00 -0700 Message-Id: <20221014031303.231740-7-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014031303.231740-1-sidhartha.kumar@oracle.com> References: <20221014031303.231740-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: SJ0PR05CA0140.namprd05.prod.outlook.com (2603:10b6:a03:33d::25) To DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR10MB5117:EE_|CH2PR10MB4182:EE_ X-MS-Office365-Filtering-Correlation-Id: 5572897b-ca4c-4c65-afb2-08daad92351a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0Lax5pIOuAsvxvnALBUIxTDdvu9n9gubIEOnO7Oh2sbxA4kJgPMNV2NUd7E+pEUh09owDvVF6LB/aq2MDDdYp9eet8yihifK/NE77sUeEzb/MCJZpwA5yGczqkeXqpfCSyUaHm+5ADcnKZ2nHK+kDYAa7mbju/70ZsD3ZfS0L4aPz5YXkzjc9rueEQWyt1xP9Mb1fhqccPPkMtXXqG2OEYo/tjRWNXeK9jXGKVRLTwkun+nf60gPMmm+1xWqSL0uv5I3YVecJiFpO+r6wAkWb9SP+7H+UzGvpQdPRwRLfiXy52SSrTPSry/8QmB2IZ2WsLBdwuAS6Z/c6KstFYYWL9VY46tdJNIYX6MrGrggh/teHGwZCH+amIv1vyzyViX2zKZxeIOjlQq/6YqLDIGLYpAgPs+ph/TEQpEMX7ISGB4uhQVzAykM1zKiMstS+LBUjfP7n9yEEOLRy4EAEdQh0Yoh71Xpz4bVHOGGVL40khtJMS43M8GYrJbr2ns2fgOM2AwyVLfiBJHKMR/2IW9aBfpsjCWzBAwXqcU+H4NZuE1Qkt9mvWdKRlUwKqolB4xXchLn+PyUQWoNyldtM1T6g4d/pcftW7a9x1si0gRmqk5SrwSqtKaew2jU5tBmBYtOjgVSkWWrpsG58TPC5cpMSdK5BuGR3DVJDkrawJ7LRHrtqly8FWr/Azi09g0JW3FIK3bgDfP7JIG67Z4oMTBVKdMiij6LaWnf51Ax+4N90PtCn6TPe5kFtdivatip+p+E X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR10MB5117.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(39860400002)(376002)(346002)(396003)(136003)(451199015)(478600001)(6486002)(8936002)(66556008)(66476007)(41300700001)(6512007)(5660300002)(26005)(36756003)(2906002)(4326008)(8676002)(66946007)(83380400001)(44832011)(316002)(38100700002)(6506007)(86362001)(2616005)(186003)(6666004)(107886003)(1076003)(14583001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xzXqxjnh5aLIAYnUh4Eqv8X75jfrXiDeyXi42J2mreHcgLAKCrAbLg5ureRxn6kE5XVPXP6NGnJz4c3DTcN/CHC+KiVP4n5FZW2ddpYHgT6W5X9Oj4DoP/6KXmwCTn3ZVUrLnlB0utINnGcATfo6RPYL7wjx3rH7XDzdJ5QZQZqf0WnI1etsQK/vzMqQLrpN6c5vZotfYIlEEyvo/t+gWPB/PfklLuhc7mtSy4FvlLZWpAAU1sOAbZb1NKj86IISPE8Yd/aBQSnHR59RbrovENcU4KDk6KXdRsIkuIboG1yPegx1yCmGENWxxx2AfEo+wp4e2hOiBQUiG4hhVz3wsJ6K+ZGowQjA1/MaQjDZbHdbiLgqFgSWGYZwNJrKHKEX/CO+8Je3J4xCQ9WtGOd2G9kpP/4LRTnaTLrQntqyjFPD90hXNvkp3xbKm77GQph6QRmPnDFXVtTKl1K+RgPLTJsTYR3QCw1hltGkYC9Ny3ENVxFG/T1C9uKeg3/A5sde2K8chWuRzb3ybdrLKobwjukA/zigf3WEAITXcuMfV9ODoBVnr8C0Avp3hD2KRCXpayvkjgWFviSsezUcgfoSpkud3OwZ3udmLij6swN54OMT2pwDF3YjnmogErrAL43jpo/T2kpI0zCe1V4jniYKH4iawqiMr2gpFQ3gIYGjFzhruu/myeQvmJHExFUQDF+TG327upwxxR8PYtXM2npgl5yMvV8Kb7Nmo4TWXwND7L4kJj7Rj5wkprohbO7Z5ctxOmmTNooTzWIpFPCRD8QU07semBMWHsmppfmTOyJSYxyGfRt2yuOJB8IskWQfyEJphvldwsMckNaDpzBgjKN4iLUCLBg7SHpHrP0UdPL75b1rGvSZnNkMQ06Dch/WoeNRZZthVk68tm/Ha4X4KQ5o+1XKqlTMHyR4L0Q01ixYnZMi+r4PARJA+ThppxZSHApR4J+iUcDgZoY1+d7vuvLPE3znqZJhTKxx2Bu+dh/y3PJzxcWZLIOKl1QIrDW3ZbYwtwThcgj/zZCXrn82nxc9Cav9KiW9pcR/qleYx+QqJh6NvS2e1ZiSNCpauPEkHCBle6bLVWxBUskDMDXBtDdcjAeyRF1tpa+1fBIvsL49xo6OwLfXMWnydNvb7BNkDHHA2Vwg2/gQjLxVkigXzXWktDXAFgh1WFXLojM2WhYtsMGUUUbr33k78CrqpAbpBQccZpYotp6VG/aw8klk4L3oGx21PlR6b5H/165PNUwz8rh35yXWCGpPEzyVYPiqLMhDffzjU4E+9S885o2Wa7TqY2lAIc/ffdw2jBjPs0aXVF5tUMZs4e9LshK8iTwDy17cuBvSaHZP6Rlp4vEzSab+9X4QvMBidL2RsMdoy/2rBJT+szkpEWatMPnCV6Qirm5TLRhYnqoSNooK9tMu7bjYktvVP+Qc/Hsk28aX46k7Gskq3c0kOm/pnTf8HgE91R2dysic5cFxhKaz+zlrjWs3xdSe1ZIDqLaJ6LFyJsDVjHbExzGGR4SKXKXGUPKviwCO0PYLpgjlyVwuxq3BsUbiZw9P+uucsg3UBUhJlSGmkIkrTzU6joay19uXfwKe3otlurYDqQHC1UQn/4bkwHFKSA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5572897b-ca4c-4c65-afb2-08daad92351a X-MS-Exchange-CrossTenant-AuthSource: DS7PR10MB5117.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 03:14:29.4903 (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: JGEP8qh9oHCHSwynRrDGAkyrjIkMizaXEJi5Q8TUvhHJKmWVmHb1pJZv9FnoWyKVFHYq3lKMDV0k3iT7Ab3VIy8GUqlwyjCvxYBEBNo8YOs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4182 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-14_01,2022-10-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 phishscore=0 mlxscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210140017 X-Proofpoint-ORIG-GUID: GmNl-L8uOwKaYqJ_n1erL4C-6NSAQnAz X-Proofpoint-GUID: GmNl-L8uOwKaYqJ_n1erL4C-6NSAQnAz 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?1746633387096691967?= X-GMAIL-MSGID: =?utf-8?q?1746633387096691967?= 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 --- mm/hugetlb.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 44a9a6072c58..5228c2b805d2 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_PAGE(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 Fri Oct 14 03:13:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 2482 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp595516wrs; Thu, 13 Oct 2022 20:29:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Vkg8oATobC2o0EVCak6xhhm1vHinEJ6DYg9kOg15WRwHYLDgZ1hyKJsXY04Z3C1dE/mVu X-Received: by 2002:a05:6402:3705:b0:454:e006:82 with SMTP id ek5-20020a056402370500b00454e0060082mr2417822edb.360.1665718149055; Thu, 13 Oct 2022 20:29:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665718149; cv=pass; d=google.com; s=arc-20160816; b=TtqPM8OZ2ss69WmH7asMVEK7ygX6Pd0oCAnY72m7ndeVoqpD2XE3klvnE1qheDs1nK DgIXZHuyMlkV7DxojPBIx2djNDLXi/weGdqfmIkys+tAcozSydOoKOG4HsaZs8y/SLoj qGTatCkH2JJm72DwTQKfwltVMKwVMLyqrAM5HafOheR+pBp2DID0MO+dUTbxxGbTg1XD uwmb9iPljbpMdnNfW4f1iV/9C7c6WaBr2i38e85LV8Bnbd5YzeCr1jrDTw2ie0GCFYkt 64Wn1vANzUdeaxSQWpWvCIjOOYmn7uTOFs9en2DUMoeg+ykMCRRGlb8tIQIth9FgO2pB XXIw== 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=BSmQMWtOsOQUlCDLLHdXQwox8wfT3/Dgx95AOUTYQoQ=; b=mwDwcIcHw8SqfUey0yUtnd1gkc9ueVtYb/mnN1tMRHCSlo2NL17SvxGwtsbZ7xizcN A3RhLjFqXq6DoAoUmtRX8u/Xt+C1qAiEPIAJiwu4uGhbC1EYl6Hz87tl3vsCtDmCbc0d 3PJHGS6BwU4LRqqBGvkPZMIuchjFtuQfPCk6EFsqBZ8MrI6392c4iSEMLa8gLat/0iQr Bc+CHad7lCswU6jN8sW/5aDee8pxlidzvYPs5X1vDxwH4flzb+HjrZhF+yKCYAB9Rwfg OmVDGqFPsp2uetIdJo1C36NdPND+kL3wFQ04oolruyC9lgFJrnnKtnNADv+rY+BHCeci 03ag== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=RDc48+5Z; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=kWffB5G9; 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 z21-20020a05640235d500b0045d073d7ca5si1284147edc.339.2022.10.13.20.28.44; Thu, 13 Oct 2022 20:29:09 -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=RDc48+5Z; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=kWffB5G9; 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 S229739AbiJNDPy (ORCPT + 99 others); Thu, 13 Oct 2022 23:15:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229883AbiJNDO6 (ORCPT ); Thu, 13 Oct 2022 23:14:58 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDD732FC33 for ; Thu, 13 Oct 2022 20:14:55 -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 29E2hdXx000655; Fri, 14 Oct 2022 03:14: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=BSmQMWtOsOQUlCDLLHdXQwox8wfT3/Dgx95AOUTYQoQ=; b=RDc48+5ZSbe3A2hf1ZFX/OexCkXL8ZnYs7+bQAUg6SIfU7jnjeMBotfeD3zTAxVzHb0w 5eu2GRARH8tDkUHgC98LjF5qvxcpd0c9rjy9Vf6mB+xPCnKX8+yzMMynXM1YCikDt/g2 crXcxiNFaBAx1v3d72MQj1qhviOm7yRKtjNuR23Nv2cBgx+7zHHa1U3ivNDi4VDdDI8c 9AABaXKX5xPt5EWkIjTtcXNB8fho9kzlWZ6evjU0DkXfofkb+OzrqiDi5NVRP7A6zOiV d9k6CvhKjK0kJXg4+u/J9zQltjxihjdeQfqDeG5QUpduvY7Qbn5lt2/h9nHSp+ESM+ZE Pg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k30ttf35f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:44 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29E0MWPP018229; Fri, 14 Oct 2022 03:14:43 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2049.outbound.protection.outlook.com [104.47.73.49]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3k2yn6t0up-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V6ae5n4+0X1SoiKP2CKee7mOnHUV+6h3jDvIukG2hTg+igExKJ1xXK1cr+ava3XmpLCypsIjJoysCAfmhnqIWHI8kIW6/n2wC6eri1KfAU2TiwSZ3labL6D57MBsoHIXJcAnZezmhVvQf0penmXqLcocbOO6BgW7ChCjPfoq7BlLVXNAUfe4yPcY1ZgitpwGiiRkcWeI/qNiL3bpNcwxypELwm5PpbRUF+4s1/Zg5mhnzJpezoh1OHAI9eAFS0rCasMlNTPG3YQypEatWswoUPhe6MYe8hVBJwBudohqjhhEoQrCAua8Sri6wJKDDbvhyVCHIskvbuKbZ3ApcHyIYg== 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=BSmQMWtOsOQUlCDLLHdXQwox8wfT3/Dgx95AOUTYQoQ=; b=YdsMXWU0LDNMyrQRfGa/plKp6RqjFCgzXDgO5hKLW/AFFAqzwk26Hk0Lov6Pj5wpeAunltaJUxcwNBU4wLnVYOAiRV4UhPBMg0sZC2cdzlp8gXfwNUUXW/1qxDxd0RWFKsoqXTkeQKShpDJUBsxV74HU37xvM8YfZ5FxzcG4jLmG21CQAIXG6DRqzl3N3FlY96v0iFnWByo1GM219fbY2kYZgclJXzy/etUCwiJoPiCENsZOgx2keNv4QHEDC4lqLlF2lITZo5oLwrnO8bKwYEl9/Q5zS/+4yWvD6byNP2cpcol0YTX0IUIGY/EZpLGEKK4UbasXOBNCx4H0KavByA== 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=BSmQMWtOsOQUlCDLLHdXQwox8wfT3/Dgx95AOUTYQoQ=; b=kWffB5G9Gp1dXT4vgKnNl+ioUnH2u1kv7zP9jDRSExRaLlkvcCyYQCzpIG63vUatciyc3yfh+hhcy7+ax9nENjiIsPHZjXwtOi4DvSMcjTAv1cCez88kCwlqqXxmXqGv+mRedmAw3N07S+cgxKgYrtAVpZ2jYb9jco/nhgI1Ysk= Received: from DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) by DS0PR10MB6750.namprd10.prod.outlook.com (2603:10b6:8:133::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.26; Fri, 14 Oct 2022 03:14:41 +0000 Received: from DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8]) by DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8%3]) with mapi id 15.20.5723.026; Fri, 14 Oct 2022 03:14:40 +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 7/9] mm/hugetlb_cgroup: convert hugetlb_cgroup_uncharge_page() to folios Date: Thu, 13 Oct 2022 20:13:01 -0700 Message-Id: <20221014031303.231740-8-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014031303.231740-1-sidhartha.kumar@oracle.com> References: <20221014031303.231740-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BYAPR06CA0064.namprd06.prod.outlook.com (2603:10b6:a03:14b::41) To DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR10MB5117:EE_|DS0PR10MB6750:EE_ X-MS-Office365-Filtering-Correlation-Id: c9ac0c45-a099-4ce8-bf4a-08daad923b4e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HgmKRxFb2smrcmp5PonCS1vj6qjYqoz2voBcm52Nak++KK8G88q90ph7gu2q/hFjMtd8jhYg1cvAGshQAyY3f3xKEgwzLpk6z6qk0gNSrSc6QA++hcbPbcr011a97Lj82xMbltcT/axO7I7mxeQjDmXaFWF+J9A2PszcIGCDs5vjQ/nOyag3nSb1oTiUBSZ7EwOQOLGelq0h4jpLa8y0ncX9N/Cz7llLlE03lVOvAjlW1Bl+5T4buo8wlbkNEH/HelxXJLRmUBWX7s38IMOQtM6CrXp6L+n4guc+dECGYYa9jZ0IbiaT9t9KrLqjY4UOQl7v9Cd2t1u+dCSFALUOZbgNOcXpIMdM3OoxUyBmPT1vyMqRhytFLg6Y2vbFsYUrScbQGD5vOoLzwhJ8WUluGXRfDoiB7syYGhuktcgOsY0qvzJkqUHYjwLlbBYzgskIcqyHjUdCebRU6uE1pWwbALI0I2B/gOWvuCcGi7HgfuIdfw9rTfXOX9zo2wvNj6B6x5W2GOW22MS3mh7s9oTlieuVF8WFYGSAkFHc1TSAs8dzpYzttRuUvZFtgVCDDu8xb+yySNriuoV35ZuFchKjU6b1OYMiYCW255LFY1E+YxhLBUN2rejn08T/fCztjUNmniJZuHe/CL6Zw6hMLPI0W8srIT8KDViTVlzxXH9BTVLIpipobj4/FPz31JEtwKqMEMvFQDwbNrYGg23Ix5IKvQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR10MB5117.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(396003)(366004)(376002)(39860400002)(136003)(451199015)(83380400001)(2906002)(86362001)(26005)(6512007)(38100700002)(316002)(478600001)(186003)(41300700001)(8676002)(6486002)(44832011)(4326008)(5660300002)(66476007)(1076003)(2616005)(107886003)(66946007)(66556008)(36756003)(6506007)(6666004)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hy3tMw8em/E6Nvm4wYNkhbJl5IO0IeU9kZtKHDuBOGKDiditeKEAnbKEx9x8ckpImFqqDERsSbVdpBsE3OXya1A1k0OIq7K5Cz9SdHw8BaqYpnQuX4yXCyaiNQJZmYqdhK7QSlvy9cQ6zdmAVbJtDsgVRQPvzNR8f+jPe35mP8+1/vnF9vc8u4BnJfxmpslKFTMQdFMiQ6KCcSlo5s1uH+cYBi30KIo7trAysEHSutTmzYshtGWi9gWQgopVOgpuFkfZv0qJyZJtKKN30Iv+qD8F/7CeOzt9RGxoh4aYAcMFBlvUwZjxOiy2pC673IHWVL4W0FksJVjJ+Cc+AFczL1rSYh+OaggOuxzzEqjIjRdwzTbC0AeF3k22WeC/muXjTvYw0GKRqN82YE5JGG6ae0Tkz+CmmotEdRR9dnRlzYzJElBMST8Z/JCCJa3BYvGoBG/jc7cuL1DTeLrgsCBH57qJHth45UundkcUnWXZU/ru39oUypMTaQhanBv/Ty2ve0WcJ8wmvWrUaZbVp8BnOj8vU9OUFzKWkM+VI17cK/OiRVSvTirHlD/G0jtFRhb9CNR2saKMkhSowiYR6lReh0UMn5i+ubN7PtG2i3AaKl3TLsnySc8HIB4kByMMUNjLR7HULSHOHmm4zMO3o6ckD4SXadJCOd7yLC4RdBMnjMb2aXmLAysdXkFhYkuOqtZgROxT1hD//IEZZKiOFgrUeF5M0NjblJFPrE6UzcTkJZEK871c9GWzSfQf6kvOth4jFp0NHpJ+3wHK6XXFaaKVsmXNpsPwhNT8Q0uZX85h9g8wBwnq0qpEECtpD+JVQ34h+LtX8k25BRKO0RVS3uQc4rZvf/ziEPiVrRuYvFHK+z0j8k/gf9LxEtB94WE+HJ8Kfp6pPqhcJaTD1haX+GW2neR5e6r6fxd7ypZV4hKsSs0NHLdS8BagRcHnou+5jFVA2/knhgMhc7A2RNgzQDa2+sPNeS2ff0+gTBB/ccfbV1Zq/+TIzcYyw2VtP1+HGqQgyB28HAJ4StGm56rzVi8rT/xKgzrD1JzPCi8BQ1OUyEbIgxPsv62dGLqrhAVj1XenhdNIhW9iZgV1AhBAaSClrPqZkwxjYs+sUgFn8IehtkOWG3SEwVA75qV6UA6rs/6JW5HhSSOz6rJXh6Yo4eJDYlFjIj7GdstxPbaN0wG64OxgRtGHMs3Lgz8cZNEQkfdvViM8afwz8McszRzz5CLCPMMxqglaaOdDYT8yDiPcfJfUzh5UK6KNZVM0jA9Yx0l2bKbnNs7miJrtwHKS7t6hrVu6OJbFgmKbTW1NuUvx3wx/9oRQQuurDuEwq9IuQ6xGG4GWAErPBoQn7eB7iuyGMqE3u6gkqIjWYFbUzYpBWlPo1g+I7vl133qONQ17RL4rJ/1yUsKUowyuAX+Q6gJjd/swBYiCa5x/zzYw9ZpsqNrKOJ9w3WgvRozMUFF2/h/meEAn5973vxs1cZsKUBWEoM2QAJfLpCQ7ZmAuX3Ygud4I4KULG2to9r7M+W1JCU2D/j3+aCrFP6gyOwI2KrGkkuLtEswswWuJKr0ptLzKlwegwznf0Hro/eyJkKc2gEvJ0NY5IVHNjjW2p4oDYEkLJw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9ac0c45-a099-4ce8-bf4a-08daad923b4e X-MS-Exchange-CrossTenant-AuthSource: DS7PR10MB5117.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 03:14:39.9130 (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: Az2xqJkpd1nksfJFDKGlZf0bNjjNb1ssUC5uRGup16NySQacrk9wn1meIpGUs7cZfa5pC+OafDBk1/PIGasBuTsbtH6doWGb8T+ZdR88Vgk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6750 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-14_01,2022-10-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210140017 X-Proofpoint-GUID: H4ZpfE_l9dEB1_i2hyjL4tZXrNhjrGkI X-Proofpoint-ORIG-GUID: H4ZpfE_l9dEB1_i2hyjL4tZXrNhjrGkI 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?1746632073707495322?= X-GMAIL-MSGID: =?utf-8?q?1746632073707495322?= 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 --- 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 5228c2b805d2..d44ee677e8ec 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 Fri Oct 14 03:13:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 2486 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp597403wrs; Thu, 13 Oct 2022 20:36:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7i/dpVeffBLGrfmEqLQb1FeiieeJIQh/OGHf/8Q0oYkYMHoFPr4eNJ9OGNND/GbWjALITz X-Received: by 2002:a17:907:2cf5:b0:78d:f9cc:794a with SMTP id hz21-20020a1709072cf500b0078df9cc794amr1944495ejc.577.1665718582177; Thu, 13 Oct 2022 20:36:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665718582; cv=pass; d=google.com; s=arc-20160816; b=NUQ86JSI4co77PIxFhg88JJVXQis4OBAPzbDEk9ibJvLyGnpEFFcmfqjLkppyastVF B/flyxHh9d2vsEP7SXLQJTkmM+2whZrVXg2Gz+6FsTY6JIqULu6i6NXFVkC2w/c5u2OF 8nwLxHf+gSgqfPaEfLYZyBHb65Q56dbidVemnvw+472RtI4dM89Y7JkF9dc6P6sNUqiU VVU2fazLyZSc/tpAhukjfb83wK9k9BVJG5oXoEGyhsWb6C20DZxcmuEd673z9oFg1brf QL1C1ptqjt2sPXrN2seuuMFZEdtWlBVnYmeVHnkBqcZH6nMtg0UL4V11X/F80VFeusV/ 66cA== 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=acRyPjuqLPSR4zKveinzMUspL/hbEcXs3/pnXWlB/7k=; b=uqctTk+Mlur3Y6qljQdleOqNifS7tY3erKeHDuRjuRES2DV8Dw97mxEDGgYykSR5Tp PqHBPjZU5jg7Cg6uz7HKxt9Do0hvFr1O/+RSfxnoCkNNoDi31XI30yupGz7RYys3OggZ W3WUE+R/WUM+/C5OeKtcNZuMhVVrk+xL0VO4ldsst4dsTjvp6490mzBZfSI4OnsYOg46 8YU1Bh9XpI4jk2N1SkOjjOydzUy2N7YJLpPvzHjarvUIDyTU8cEtQdbu5zuYyod4MZxR MleTv4k2511whpNGSDFrL23ETAXgcrfWGe1ptlyuZ7misJx2cLl56bzp0eucdQrDdgll rkTQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=QYjxsLER; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=p+pF0e3p; 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 c22-20020aa7d616000000b00451a9bc10casi1170032edr.196.2022.10.13.20.35.56; Thu, 13 Oct 2022 20:36: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=QYjxsLER; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=p+pF0e3p; 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 S229916AbiJNDQJ (ORCPT + 99 others); Thu, 13 Oct 2022 23:16:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbiJNDPZ (ORCPT ); Thu, 13 Oct 2022 23:15:25 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E6E33DBE9 for ; Thu, 13 Oct 2022 20:15:05 -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 29E1TqPq026262; Fri, 14 Oct 2022 03:14: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=acRyPjuqLPSR4zKveinzMUspL/hbEcXs3/pnXWlB/7k=; b=QYjxsLER206aFIgr0nV9f5qTYEAn71KjFuAR8NwXHIClLM5DokM6h84IxWFoh428lz/N Uz4V+kaV358N2l874XKSivZnx9RtGOHa06X3AWPL3qtI+Sxx8Oc1NjiMOj1C25C8Dzs7 ntCBmWYBs3fmnljRR3FfsSqdJ91ejBIs3Cd0x2waUrvzQpQ/CzPFH7nyQPioPxNQHpr6 ZEl6CwroL41Wov9zRKWifd8CVlrn2eM+I2RvNJiINqQX4qxGFyMFUuxf8kt+CT0Ji6wd 0gL7I4JHqMVqifR0zjiTYIu5yzeWkZXTb/Z5cWyVs2pHwnqFVJin8e0zOmjskdiGbvNn qw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k6kgmsv89-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:55 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 29DNTev3009827; Fri, 14 Oct 2022 03:14:53 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3k2ynddbsx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:14:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ai3wZxgUXeUmyRm0GRC+Z9C1tZLnRF4BQCcAaMa0vyC1f3YWsHUkS3kcJYntO4y4LlxCcxL0ygClgq24cJKqe5QwVKwDLHWP3tOC4Nnclum6tu3cOrTdjzkJGKes7RsoOAvjFFX09K3hDsG79nSwTJ3J4TfPBQ7jBGUGTWpnlTjcw++QihAY5aRF85a4JviOB++DnzAVALSC8TOJFloHNF2vu19sFdM7zZogM8NYIzbjyaZiEdZiwjzfkdywvK5FYn1qH3bXgct5wHxDgeSFQGDZ+J2gZaKq5ZFuCYAkTI3G6JfJf0fn6CeNdfvSAw53aSdCSKxRy0oaaJHfMOcBwA== 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=acRyPjuqLPSR4zKveinzMUspL/hbEcXs3/pnXWlB/7k=; b=gHWE14+94/b4If9BrrDk9XdCjrHGBL7ROR2fj32/SedXQshnAo29ptd30tNhzwzexKOPrY/pvwhZnhCs0IDb9HcuONRQBOBXGXH+a7PLpG39wjX5oHoGJXAhGQyCjvnpdYvD6sY3FIZVsx2RjjdTC+cEwHK5uyTxVGsUCokbMzYTPiWmztDShx2NzUxjwdXEBitkIvTbJj0CpyVJbNwEmIB7Et2+BxGOyVXPDok3hdcjZ2u0YG+bHmBehP9gWiOYlxxdz6JUDS2N/VM4+lBK2DmrIGIMHOPrp97cm0LRMXKP1HVPbpn6HKkzeJje63RuS3cWS96Q65HtigxZ6v2sRg== 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=acRyPjuqLPSR4zKveinzMUspL/hbEcXs3/pnXWlB/7k=; b=p+pF0e3pOtoaaL1kQBdq+3pZ+Zvnd9+U9mqalLRe/ZlAtp7MCM0+34Ke+bnDilEm0MNQAxXgHLGE9glE+hMxvHZT7DU/qXzNMjfoSzwIS3DUp3+L8jsAMh1RGtaBb/KD9OjCUuEXT1gK2T5qi57LVyzML923KIZ1PwgYN3UhdzI= Received: from DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) by DS0PR10MB6750.namprd10.prod.outlook.com (2603:10b6:8:133::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.26; Fri, 14 Oct 2022 03:14:51 +0000 Received: from DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8]) by DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8%3]) with mapi id 15.20.5723.026; Fri, 14 Oct 2022 03:14:50 +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 8/9] mm/hugeltb_cgroup: convert hugetlb_cgroup_commit_charge*() to folios Date: Thu, 13 Oct 2022 20:13:02 -0700 Message-Id: <20221014031303.231740-9-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014031303.231740-1-sidhartha.kumar@oracle.com> References: <20221014031303.231740-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: SJ0PR03CA0097.namprd03.prod.outlook.com (2603:10b6:a03:333::12) To DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR10MB5117:EE_|DS0PR10MB6750:EE_ X-MS-Office365-Filtering-Correlation-Id: 5e93baa6-74f0-48f2-2e05-08daad924164 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f6D0IsgLhrJughfin1Wu73W9us5lUi3Oq1m9J1iOedOv9qu4sYIiboFa088DBsJTwXu87gS3XDF/uOYeEVdLdYCdf7yDqZsOFZ7vvsc2kVf6CepVoDRqylpTmn7UBzetdOgJ+fHVgIpMqnVGFZ48cc0Pl92TeOCAAbrgI5DxVGecWVXbzM/sB9ga3NISpv1EPU9Qjw9hRnEchPb29vZcU/Gw40HsddJoqms8qDEDsHDxyephzFnjdo2bd9UjKJOV+wfZ9VPag64MI7XfSCNRCUyfjRdkXv1gmthcoKTJs2wlxSgdv1L70IoZQmUa0mtGHh+HJMrhB9s1FMMOvCiCcNVNgarG7KeDIWFQd/CVmTQ8TD/AHP+sM/eoWZak/4K5PKh/E1mr9dzTx5i7tZ5JpOKbUBYhFRfcgIEAErWytDkVQm487hjnjBCBo6ZFoAAn+XPE8Q2rMZWr7HWOr+oJ+buSf4JgTE4nGuiUM1/h5ZHqF2i/ta35TxIiEmq3cClVyrF/fsnil5abEgFmqyIu3te79wEhqf3oE+4FNkSLU0oGE+DCeh2O3WFJYLsuOgMRxcC/S1JA8y2yDgpUqs/z8E/mVVeGEJAwRuaJbyDjhZ7H7dKJNhmEsPS0xxUAAeQ9oW0IlvOiRPE5ZvoJqGPI1F60FIQXWZoMo32rTdLa2nRDFc2S6Jn7gNKpxG8a85mFGDgu2r7HnO6tn8V8IF19/Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR10MB5117.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(396003)(366004)(376002)(39860400002)(136003)(451199015)(83380400001)(2906002)(86362001)(26005)(6512007)(38100700002)(316002)(478600001)(186003)(41300700001)(8676002)(6486002)(44832011)(4326008)(5660300002)(66476007)(1076003)(2616005)(107886003)(66946007)(66556008)(36756003)(6506007)(6666004)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4gHWK9DhOCbYgkDfP5mt0FYRQ7peUrlA7auNQ+Cv1TnA4UKRgZhpLCr3Qwk2NZxYslBlHQvu9rD7kO7nWOFEFSg58ndZwq3c8kqxVrc7StIOorB/6IAU6y4lpY1gqQf02d6ztdfdyCreLfWQDc7b93k+6G41e4VUKAH6FhJC12ys/DpJAPPzifr/+KbUBwOyIPJNhWdvUTV0gwgmIMUQCxB5dJ8PRedkbiLhtl4Ztx6We/f+dWRm9L3BYJ9wFU68N0x3fSk5aQ8dPY8bJhzGSn0Qzj4KyEUGz89Ywg8GRu1NLYn9yyCMmTmlyi5I+1e3RoopefLkS24jt74Co7HZugbMV5oEtJz1dQb+P38inB9gKhs4HOc6Jpqd7LZjU7oxV5Np7j6wDVlaagbto1WwFaLPlS6m0+4/qEvoayTIF6TBIVb5hrrh6+/2b+pyTlQRMaf7MJlx2W8hcqa7jJz3j/vo/FSHsgQrXENPAIFcN7sRWy3R7pFvRfNAbDhXY34+gf574+oRhSNaoDHI2b8nvd9OFOvc6YX9XyYJ+L4Lyhebby4rgkaxK3M9u/KadK8it++npr1zNQntINhNezGB7051QpVVWE0vIBHlrarDJM5rWSSDW35/uDgGgmY3mBo0YgPqW/rCDTW3KTOcRkBPPaZGn7w4d+/d1HZ4bJrED43yQOsfFLYoLDVEecxBZPsAd8jdzGpV5snuJ5F8BdyzpbaPRziDJrG5FnRoh45scTq9IcUGV73MgbGuGrm9glQq4WnN0ZXPhYwqaAWoEDAr1Jy54mdGnGiNTCJnfa4lAo6+HBwSrbQnTmS9YfV2bVIShF4tHUKIu1nHpYVew8P4r5dQCyAbof1hIcR8cLNxfyUjZCs7OnDeYB+CIy8moCQkRV8fJrDD6rUQcm2FgB4MdrR/zU3E27+125EY58dSGq2Yc2h7LS5/jtPp7cVBmzYB4WoIqFE+q0jX2WBE7XodCwVxLGylm+0VE19uCnj+qspxcYBuY/LGpbug+e41TdNnGoTZCvY+U3C/5s243ToYF6L3LrEYlZ4JE1+q9QPDQSIhY5Y/iF/dRaF6YUpP8oV2GIsDCJpV5U4ewLXXWkCpEy+xraP9I46QBJ9BX5fwBaUjJznGpX4INtgCMEczIyyHYFNaAuI/TEdz3SA5mwMIQfhdnzz7bN/WPK+tWSV81MwZ5Y4ZoZRiklbQzpWLkhTiAq712bYvaz0CAGZOEDwojJK9bEkaSQs7QHGjqVIhnc+QFf7daoNdTMBqMpzoxtOEXjHyyOrlEa154WGNTDC695DyZpv9ksFJomg+43rImco1+gKijKHvk6weiHV+ZPg94uvzpi7eRoX8rSFnEl6abXYhMuP9ycX6zd1JD/FrRmiRRqTEC749e5xuenbQelUUqEwV4fFY9nWvayR2xPth3JuIR2dFbbdHzeg6ST5msmuZ3agHZYK/8Bm9IaqduUgq5pRArwncjZyj8h8vAMLbFpUEQ7pz27t7JAPkYrvtAS3pFgsn8sMmik5xeTQTpww/69EYPVfIKLAWFCaOnjLxaptyOfdeaqW4xKNIU6JxdnsDlEHVefkaoqgNuwtLsDU3DpP2LqFhnR4i3H/JuONx3A== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e93baa6-74f0-48f2-2e05-08daad924164 X-MS-Exchange-CrossTenant-AuthSource: DS7PR10MB5117.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 03:14:50.1510 (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: o+4T3B6El7tpAgQ6U42mUqSB89p1WXALF9bXAsElcOi9p6UC24Yd9e9nh0eU5mWTuXQQg3WN8Nd61BigE6EAhpru4dGeGjeLna15dXiCI1k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6750 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-14_01,2022-10-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210140017 X-Proofpoint-ORIG-GUID: pPwva1lBgqkQBwVpuC9D3uMQufBsCTjB X-Proofpoint-GUID: pPwva1lBgqkQBwVpuC9D3uMQufBsCTjB 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?1746632527976024580?= X-GMAIL-MSGID: =?utf-8?q?1746632527976024580?= 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 --- 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 Fri Oct 14 03:13:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 2489 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp601241wrs; Thu, 13 Oct 2022 20:50:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5e89Vmb4iM5JrIJKnNU8b5fJbTob+YZZKio4RvcmZU4Iu96njUJNIHBx2lfvTGa6Yuna8h X-Received: by 2002:a17:902:748b:b0:181:3fae:9b95 with SMTP id h11-20020a170902748b00b001813fae9b95mr2919543pll.24.1665719423538; Thu, 13 Oct 2022 20:50:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665719423; cv=pass; d=google.com; s=arc-20160816; b=LsWvjP1GuF6TaIYi9pxmiDgZmP+EyV4pVI2Y48gruMVQ8czzI4p7Isngp2LOcahdqP VEKzKynNlPq81WaDqRejsZw5t7wXxkiKKhQA0xpvZeqNW8m7szOzvHsTJgEL5sMa0wMe 0KG20YG60Fd485Nlo2gnP5FUAqY9sA0KGxpIyRdXvvJeAXAZBScL44aWVf44bkSB3YNh fTT0CW0sHCZ72TgEoYW8srHd3ddETrNphD/SzhUJ3IULiVFiHhQTofEIWsY5NdnqETLK zUF9jiLMHGk1SxoJVPG873GGuqx4iOrztuqMbdwZNiTGoOFVilFCBM2qtnNdeuBSghYy CuHg== 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=ISMhie7jByGxhiOgIqWmSQOUNT5Ar7QdCS2YsPKVfQc=; b=xAjHMq8wIQbQl+zh+b/+eURiWVLWRZwBe4b8j4cc4+1qoWqTir2mXCLPbj+or3WsW3 vNaGetR+SyXly0CHXT+/p1JE/QS1Oa+W4Xub60N92jJPEFwt5fRa4zgO29pyxhXdbYbr n8DupX5xcifzc/o/w2U7GoD4Sp/6LgRtMOFsxGX+5/XZaZeNeeGthWcqgHbPf78y0A0D ikPmJ4o5I6jmOQMXlV/gvMPVt3dfH4hE6ljMpACpCbaBZbsoersCXMQGWwkfeepnRBD2 MBO07Zi93/MZaEgBMCdSG253e5SNuyr4cXcIpdmEuEoPqrreareBZqAEUbYsyl9Y7BPK N91w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=A5lMSoUI; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=cAwoyvcp; 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 a16-20020a17090abe1000b0020d5c7ae3cbsi1328591pjs.38.2022.10.13.20.50.11; Thu, 13 Oct 2022 20:50:23 -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=A5lMSoUI; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=cAwoyvcp; 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 S229729AbiJNDQe (ORCPT + 99 others); Thu, 13 Oct 2022 23:16:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229958AbiJNDPk (ORCPT ); Thu, 13 Oct 2022 23:15:40 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C2C57CE1C for ; Thu, 13 Oct 2022 20:15:17 -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 29E33xiP006651; Fri, 14 Oct 2022 03:15: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=ISMhie7jByGxhiOgIqWmSQOUNT5Ar7QdCS2YsPKVfQc=; b=A5lMSoUICiVAJLhjTUhEO0TBol4Nhh3DU7O8WMdt3aUEjjU6wa5wG9d/Fd8BBs1H+5Vu bzayVRDURv1YEXN9AEMg7kZZQi434ZINhL761MwMdIqqLfgAvSCnlnc+Mmv1oMPABygt dI6l/nufQCsibZ39oO5W7U42TtB7DuKWX04fl/BzsSj6Y2j5d1LFuaEpjpXSpk4Pupb6 tsF9mgAZzSO+PrwWj8v+4tpS59+HVsEHAdl6XdcVcUu/VYK5x1P6Q2Z0c/589E0nIUjU fnoSGRZU9t4iu9wcxdmuCC0PcWBsMjhmnC42sTpjN3gPbPgXPuDAtoNU5vhMiy56Z5if SQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3k6mr29k2a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:15:04 +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 29E2I8UM020773; Fri, 14 Oct 2022 03:15:03 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2044.outbound.protection.outlook.com [104.47.73.44]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3k2yn6j2af-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Oct 2022 03:15:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E08VCO7VlCl9Ty6zyh2DDEcdFbsR3npv7PqAUGswypvE3fgxKgtClMUmUJ19uNN30xfWVZ08flVeT0Pwn33NkUJcI5Gdy+XuvM0OZ4Gstgqd6UxWmpfibhbXbOs3VGN+WNk/JX/uZ8D0zHCcAyUAjhbspvzVVOgNl+C95IIxE6yP4g47SiOF6XYS3nGfIDcPgKy78nW0PtFMQJSUPo0apUyixzYfWD/LFZytR3M2Ik9QTdj0P8HzU7x60o1C0t2KvjuiZ+cS+Muw0Q0tmCjNxyzLPKogZY1fFTsDwjddHVBwdwo7UnB/aostfseOQXz3Q0wFM3R/f7lXFINm4N4PLQ== 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=ISMhie7jByGxhiOgIqWmSQOUNT5Ar7QdCS2YsPKVfQc=; b=fhDbdI034ceX+vIHjl1pz1qTMTmKrTl2WMxbMkVGcNydYJBfcNVilWyxLEZtvVXCwB4bsUza6SX4kUCJpzKwRlOjltgswF2cZpW1j6B4C2TL9H+cHmMMz+XdDg4OaSsAYJ9lquUo0Cv3qk8oS/1h7/FsnLTSWoeeDzVVjO5TqIPcKv7FPrsZt1taMLyJNpFPmOKxsHRd2+bcZSORPP2O5YesYtmkRJk8U6xxj54cLCLreFUuMNZmWh19L1YmhifYguT+8t+W8MT3moSSG0rz0D1tQDzhEXoFKFLbmV0xr7t0COSgoBk7p1LESKxTucT6oQQfuug8fw7dBYG8t2Tgvg== 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=ISMhie7jByGxhiOgIqWmSQOUNT5Ar7QdCS2YsPKVfQc=; b=cAwoyvcpIYEpq2bK0qoThgR3DqmP5Zd9qzvFEAFvSwVYw/yhlKCu20WEnKQOwCKUgwHKa1i1Gty7yfgjpj7cZm2B5CXXSQU5HylWtFk+SVonPFJ84Oyvov9UcRQFK0FFosaxv/VsnkPkkUsnjclNMr34G2BKVhQVix+nzN4xJYA= Received: from DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) by DS0PR10MB6750.namprd10.prod.outlook.com (2603:10b6:8:133::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.26; Fri, 14 Oct 2022 03:15:02 +0000 Received: from DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8]) by DS7PR10MB5117.namprd10.prod.outlook.com ([fe80::c026:d7f9:58f6:a5e8%3]) with mapi id 15.20.5723.026; Fri, 14 Oct 2022 03:15:00 +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 9/9] mm/hugetlb: convert move_hugetlb_state() to folios Date: Thu, 13 Oct 2022 20:13:03 -0700 Message-Id: <20221014031303.231740-10-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221014031303.231740-1-sidhartha.kumar@oracle.com> References: <20221014031303.231740-1-sidhartha.kumar@oracle.com> X-ClientProxiedBy: BY3PR05CA0033.namprd05.prod.outlook.com (2603:10b6:a03:39b::8) To DS7PR10MB5117.namprd10.prod.outlook.com (2603:10b6:5:3a6::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR10MB5117:EE_|DS0PR10MB6750:EE_ X-MS-Office365-Filtering-Correlation-Id: c52a8082-5bd3-4783-39a8-08daad9247ac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lrV+FqnSwXYO50CZ8TSn/FAH9BbkeL3ycKKuD4N2J/Td9fHMLc27XMhlaNbCQlXae+PyaxsXSxkCupFxXRXRGR6dfxb/vJpEzqkTOcZm/fWmjhGZLylhzstoH4U+U1V9FnP7reKI2aZ6Smnj2ogWlD//94RK4kpmobB3SpNOKtMreTx9p87hqfKi3OjW12N5avS5jnT/rTmUF3/H5TWgbFEDzmKi6Ovx9u8ucAgMRNRQQA11OgyufFg5gs5KsE6doT+5EDKLfrDznVCn9DctcCp7HvjAMiV4M//u/FsolqBOtjmZUI0jX3OaotmAuCMTtqY+n9qJ50Oaxkry/ZKeCEdxZF6WIxt4d4VdCtlT7cTR5NKSYiSvUaHR/F8ap79d0XamghNQB54nKqwiBqAHcjGCTGZmoJsTQohh7tCHtTVFs67HnQh2KJnq3hOtOu6VdGzrPzBaNjL4W5YnVL7rvnWTbpz+dKX/Sr/pueryV/RFxa8LXnO2jUTVF0AkBUyPpXj5Y89tRp/hmE4eA/e5exL1prkOPTPQdp9bPcivkRX7XuBWUepcqLNbBMImuw086KH5s6slUyTe1Cdr5ZFns3k2pKUxO+BgQ53xFQ4APxPk4vGQwoJuUyGKZ13CxzILi5tEMjmpMCiAoauMxIljgA3eDMP2/yXYpITbwkUpJrsIIqiWrvMIK3dySB1iv9t3gCujrOkGcJVwYkKgKcP3JQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR10MB5117.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(346002)(396003)(366004)(376002)(39860400002)(136003)(451199015)(83380400001)(2906002)(86362001)(26005)(6512007)(38100700002)(316002)(478600001)(186003)(41300700001)(8676002)(6486002)(44832011)(4326008)(5660300002)(66476007)(1076003)(2616005)(107886003)(66946007)(66556008)(36756003)(6506007)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aqnwsmW4gpkm2D8e4XTRyJZIaqiAd+F0W4WTw92AR4C/S88HwoK9qRTAC/RebOJvtLxyL9GVv7TFe+PKP6gg4aL/A9n1QwR5n2SK8kIpYMSfjrYAFs6q0DboLqlyOpciYiEWLGfoUZyu9gSsSGLFdsdjwjkB2dUr9GZXs9Y6HvvU++mBzx4QxMytpWEVR0KeTimi3F/eA0SSTG/Bbzz91j8oGc1wJgojqMWpJUSZzhzDB/qrJPGB6mjJsHmls127dgRfugNDinVzhRRT5XHI7ZstZJkZD0BVAbX7H5yjYViqOIDTELwOhav31Zi7a7BeOIXjWcTj0O09/2dSuKtPUAVnYucb3/rK0aK6G4aGyTYcLG3zgAxB4OklmMkZCsuhcvbZilf9st+896tMcBUSZVD4zlt2EqJsMFRvCTKtBQcmQiXuLVwhJg/MF+ci4ohNC+ErUF3dWkdOZuqQu7kcpD4g6V6P7Zy6HiBHOfb/UwAJ43XooDWagEgOOWzKlbWWad8MnuSgFTmSG+cdNmh4b0igvNy3DibjZygmpow/VWocxFXuXSYsLP6l5q0/blsmTQkc1Pbmt/YmMjiO2MliYPK4qvvQ3PeO9QcBVcyMLnTH06g0g7h6noH5/tdNhfdn2pLn5L4LAEcU4JaoAKf1OS/Mis4MsrL2VOTUx92SOugV+EC7U6rLrqPPz0p56gKPM+tNqY1ru7SNTmvaJA3pfNUSQ6zTSZgB9LIjCKRlX2nBW0SA0Fk7jq6WKNsfEccRTlC1sHa5WV44zKMuOv9RRnlmNIclV7aKJCOXpAeF4cPsjVKLeFtvEhvkb5aclXg0KWT5L/B2hgPny/g+qJc/4lpzYWbeATwmWiXmsi7Z1UfH2+FK4fXFEI4DQO6f4Sy7gt0qr+87NAg6CNLcDFPQOmkoRuuP0v9e8snOk1sLM9H/PEyBj4JXI0/AaUAQ0MdK0MQz17fPEedqx65oG4vWecgbETbXKgWPdj1/dT3T21P8yae3fel5Otr1acc/BS/QCVDzvHiRLFXZoffTdDxMR2Fcgt0f06j+QDVTp18zyVg3l6a1yWrZMzI7l8JXAeZ3UVwQoUYaQIk4Im+q3G/LzWjegY3aQlVnI06Kp6i8cIKU4AxvT0drFQ3+7EZLEG/203ylhCChKrF7VAGwELivThAsdVXTxKw9f5SgZIrqcGw96ZIEBoo11UNBmdGVxLkSAH8eHnu8uHRHG9nPc/fpBdqMV8rZe4QeYQIjCMEFagBrkLj6JTT9GthamiIjbDF0FRsmzaFPVy/kX443mG8tv63eXJakV9B+7w6yUtNiSfYXIjhVnsaMjmu3zpXFIkw9FXeyhZpKw99XLWKSjOZs/k5tZRA8ekcMnkLqBT4ryNEfCtGi/XviIYOGR4HDZVBDKkrhetlUKEfQZhvjApWyoH984a4zuescRWNxDKyWdwh0nWmZ46hi7R/jBzGkg3dH6VwAQ3qaYWqnqKh/3K6CFLJI3M6zysK/oakQ2oHRytCCGFWCo+XGduAA/oSND//vUpoq7LHmqZ9nebVWyzzrx6p2txtIsFyGSEb/DjlGxMppYKP8wcN23g7NLZvSsT4NCciqEo0pwoqp1Lqg4O193g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c52a8082-5bd3-4783-39a8-08daad9247ac X-MS-Exchange-CrossTenant-AuthSource: DS7PR10MB5117.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 03:15:00.6271 (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: IKFWBqwmJ2ZMwneJzAq5aH5q4ehVQGp0SUXWUN41ugaYbau6niLd9wWoiQfdXNwoqY6eQV0nPPgCXDgpFTsy1gSSy3M1FYg8QfTKi+DkbUo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR10MB6750 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-14_01,2022-10-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 adultscore=0 malwarescore=0 phishscore=0 suspectscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210140017 X-Proofpoint-ORIG-GUID: dHjXz6wSVy1VdDHsqPk669P7pF6F__cB X-Proofpoint-GUID: dHjXz6wSVy1VdDHsqPk669P7pF6F__cB 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?1746633410374814667?= X-GMAIL-MSGID: =?utf-8?q?1746633410374814667?= 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 --- include/linux/hugetlb.h | 6 +++--- mm/hugetlb.c | 22 ++++++++++++---------- mm/migrate.c | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 8cd8854f41d4..bfce1b48fbaa 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -183,7 +183,7 @@ int isolate_hugetlb(struct page *page, struct list_head *list); int get_hwpoison_huge_page(struct page *page, bool *hugetlb); int get_huge_page_for_hwpoison(unsigned long pfn, int flags); 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; @@ -438,8 +438,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 d44ee677e8ec..351e7c8a585d 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -7288,15 +7288,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. @@ -7305,12 +7305,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 55392a706493..ff4256758447 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -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; }