From patchwork Thu Dec 15 06:17: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: 13073914 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9663C4332F for ; Thu, 15 Dec 2022 06:18:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 271078E0005; Thu, 15 Dec 2022 01:18:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2200C8E0002; Thu, 15 Dec 2022 01:18:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 074008E0005; Thu, 15 Dec 2022 01:18:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EE0A78E0002 for ; Thu, 15 Dec 2022 01:18:15 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C87F5120843 for ; Thu, 15 Dec 2022 06:18:15 +0000 (UTC) X-FDA: 80243535750.26.D9A1329 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf07.hostedemail.com (Postfix) with ESMTP id BDB1940015 for ; Thu, 15 Dec 2022 06:18:11 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=L1UQyN9P; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=aX1HtyNO; spf=pass (imf07.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671085091; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=AuLO9/EBL3BOjYouIGAyrKOa3dcuBOE7HALsFuDpx+0=; b=F5k3u1dsicNu5j88zLnc6j5KmQGfl7/s52QcXG8dYlvkr7R4K7kybtKtvSVOegbNmDOOll GNmpQn6jHu3Hq8WtxRsEMJF/4WLBzwnmWaRScGP4Gy0LoPbNxRnifBil4KSpZigVX6ugpr IKvAAQDzJBuDqNTVALLoYze7ls44ucc= ARC-Authentication-Results: i=2; imf07.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=L1UQyN9P; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=aX1HtyNO; spf=pass (imf07.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1671085092; a=rsa-sha256; cv=pass; b=OcG/Cx5Ubl87tGW2a2k5XIH2DW7Up5NwaASj/pteZ4/t6cXLub1zzDo4CHKUqDVD5f/0V0 baNpUc00kPMlztx0PIN/qinTz0LuBCkuX6LC6N6SKfXPmG6a3utBc+M3M+sG/NugpQHkCS jNwO/amEn0Z0ZRrsXH9VJVqaXKS9bvg= Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BF2OdI0016402; Thu, 15 Dec 2022 06:18:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=AuLO9/EBL3BOjYouIGAyrKOa3dcuBOE7HALsFuDpx+0=; b=L1UQyN9Pi37WZKrFqmn3bbYeI01vx8yZ5THPRGltEoL7RiHZwLxiG20C5P4ucOIP+1pQ hmhjN2mw88/MqZMAnKZnL2VZI76d/hsp/WyR6LqrKKxdmB2vkFFj5eQE4CClPPo31Qep SEMnCEWPNkOEgVheftRt2egaTowp7PbAXkjYhBI+ZwHKbe3IcEjeeOTxzchMU5Mjs+6u ed9d7d+rJdQama9J20hz+sl2qQvFVEsXhQXFHrDFU2c/YVReKqVjDcrqjVaHVFdx/hCG lvZ6zNzV5Nz+3iD138huBOV+PN1C7w8u447fiVweazqqvNtlYDFwPgJy7/UoHraKTeSZ tg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3meyewv5n0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Dec 2022 06:18:06 +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 2BF44XMx039280; Thu, 15 Dec 2022 06:18:05 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3meyev647v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 15 Dec 2022 06:18:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UCAHrq68InHCxRszBGhsrGLNG//Md6XergQx04q9RcgHHJIhBXTMx4j4y7bWhlDtsYvJm0MAZtHbcUGEAVU3O4owbBbBAMgx4ERSF3hJ+qhe+1P+z1lfV/KWupEh2uuxTvBnakAJv3/p0HXjD2W7HX+UzCGdFB90Vi9iNm0FIY7qSrsX3hHjcLX9i8cudftqgfZdDa5wbkmH2Q8WhUHmlVaMXv0HGPm9PTPYYKMNEUJrLQty0CQrr8MEVgqxhRpLeaifwbyFuhNJnMyS8mYNWnRDtHNmD/8rSAQasV/d1ynWwt+JoGdygeXiiGRE9XBjHfKkP2+ytoARTfSPVR6cQA== 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=AuLO9/EBL3BOjYouIGAyrKOa3dcuBOE7HALsFuDpx+0=; b=EEzvSzflwEdagsexkfty3avah1Lnx+xDAMRqwNbTNj5kS7zDEeZcDcGW8nOVxeh9je/uiOjAVgM1zbHHr7SChW8KMqtx36fjYRgEn/bAG8C6nq5F/01kDac9uhNb+RordUIrQY1jNhb1RWDtwZ1Wg+ncPVfwtxitTpFWoBOb34V3PO6wALLuI8CCNxDKY3E/Mradyz2shLBw5pCk1H/YwG5VKXb3QGUB3XozTDva4GKLBzqbYIp1nBb5QIqzDaVpsd7/wCc5NMjzwTlE2DYxPCvV6LnDlY80Iv8iQTEaw1kdVlJ7le2y+s/Xr3IeuT8cfBFXQt9oVXNeWShmJkDLsA== 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=AuLO9/EBL3BOjYouIGAyrKOa3dcuBOE7HALsFuDpx+0=; b=aX1HtyNOrp6M+AsBQ11oshgcQSvotocji7KnsZVTV8idWa4j8H6NXrmzhYBrm6/J1X5Y1sBmpk7dLwqvR2piwqKmnoi67jidTrFRkx2ce3FCXUsJafu3DO+Cr2y1q9VE64H7FzKClzS8128QPQyJZ3bO0LqRyNzKhWc42TMEdS8= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by BLAPR10MB5124.namprd10.prod.outlook.com (2603:10b6:208:325::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Thu, 15 Dec 2022 06:18:03 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::51be:1301:5ec3:996f]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::51be:1301:5ec3:996f%5]) with mapi id 15.20.5924.012; Thu, 15 Dec 2022 06:18:03 +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, jhubbard@nvidia.com, Sidhartha Kumar Subject: [PATCH mm-unstable v2] mm: move folio_set_compound_order() to mm/internal.h Date: Wed, 14 Dec 2022 22:17:57 -0800 Message-Id: <20221215061757.223440-1-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.38.1 X-ClientProxiedBy: BYAPR02CA0007.namprd02.prod.outlook.com (2603:10b6:a02:ee::20) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|BLAPR10MB5124:EE_ X-MS-Office365-Filtering-Correlation-Id: 843c4b7d-2cfd-47d9-65a1-08dade641f33 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Xd2fmgQALQRmlTGsRUbnrScX4DUMsrHMb4F5RyICOoaiW3/KlGfoWP2wkFyboHejPZLUwUuuAoA4Kfv11gaX5MQkjwiEOGBlyezjuNHHyfVf5Ni3jxcBWJGeF8FEY1VWPuX4Zbiw3h+eT3T2dwut87pdIksAeruh4EJSW8NY5ENPjA+cJEz0j00199uEaGN37dQqN9WsnBmlB3mcikXoWWGjoEOVvaGXZqVZXrNuBWkFBWqv1R54vG9DFKpk9N7jIUTxzvFlst92zVDqHCf+GrAKFQIYiTgmfWvF1zfcZf0yg7Jd1pirkrNa/NfDZCq+1sv/HicNHAE36tv5AH5oLVqufJ6YO8praY1K1gup+tdsmGc5cCbSRvXgHrvNv/F5DF3kZQg/tYGz5NMFxut+Yk5F6Eoa7BqcFokqkZ7ht7aBS9Ioapz7Co2vuVSMU+DnCRegTAJB6KjKPUuysEh+71bNWG8VD3RIlsBkPTwU1JCeOHCcP/VbhAhI4cdrIXqVibRK2aP40rx5nGmYekAUJWYeeNeJlYVxXNnIEPfBluzUshituBlAtuNVoZdgy3zifsGcJLujtMRGcPK+2fW9zERoKa/0S16+e+HdoKv034MKoaw/06K891mG58gl5DNMI3MqoD2ugOTYuwprCg0VyU5JK7zGHN7guc2VOq6CKgM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR10MB5113.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(396003)(346002)(136003)(39860400002)(376002)(451199015)(478600001)(107886003)(6666004)(6486002)(26005)(966005)(186003)(6506007)(6512007)(316002)(1076003)(5660300002)(2906002)(83380400001)(36756003)(66946007)(66476007)(4326008)(8676002)(2616005)(66556008)(86362001)(44832011)(8936002)(41300700001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ftm5Vvy6PN9ta0bUMIaUhUCcW9p9mphkiO2q6zKpYkvwOnZPr/0ERAgkHVLzNzEqoCXxVBJBHgHvdwK8SE6v6vvd88DSRmwXaJGlDQsh9OdQWZDse2kITOZKNMD0+6VWqzLqn2LVzRxaCpbeIb7rbWfXfBauIASRFSOmlepfdP89Avd8Vic+KKGh5yZPZKp1ONBqLpDDmMb2gcOzQNBE4aIVcogPkkkJJrISXGo5aPLZDDYNmK51oxGHhTIrwQ6WETZNpqCI2oeOAXmYbLi9iKL7pCIrJhIkO0AzYyW8vJUh+ufijWtsCcVa3KlW6Od7oBYtpmdN4SuQvUXXh2nSOHqJLy0CBf7HyZyaekm96+cGM3Gp/Om7Mjt7xDPJCM1ZReO/FXWc39REqBrwu63NB+1IjZN5fj+57B/IlfBWM4XiCtK7URT8hebFcxbvqT1GZTdZkQbVCtt6puk/dRfHSM2ltVNDJi4nZq1hDi+SpzXzmY+EmvJxNNmiHZeKAY94TTAMgNT02AddWK/W//UgtrxZYxvMIsYaxH6rbHYISCsQ7wyD7vVj7wykuxOX5HPNnr489o81IZEYtH0uFlsB/pqEbUuV93G7ZEVlPSvfIe8W8V5PYoElt3wjf6tL/dbOKkl/D2SqllhA7d1UaCqj07w+Am8E3AtM1gTytEXEcE4cbXtTQvGkLs9+X9NYQq2wiN4U7GanrmYgj53N7kMg6/+4QriXyoHR4gWB5NS8XBQ1zL0VFT00h1oRkMUJAjb2n0PooeWFOiQ2mWc3sIr0NUtMR6HWsVVttdhFm4PVQ+bQYeQouZAAmxiQH0ndTofk0jbgAxKMkCqS5LjUnCgYIbo9iNZeFlk/xHS43+k0HnpU3M/UjUaOvXUjV5xZub4I5cOoF5kPUz/4S8yDUfiXDQB+KQSLQHOYgzrLy9j6Iw/ifRCKY6sp2QIZBhViaImYzZrctZWZ0N1NKq7WHKXsNv0Qa5KEaOsdcbey3c8gqUZ3z7/2Xrn/eJsw9/tE+GAepKpQ2pHr03iZHQSuhlqT4j074SrIykDtkEyksN5r3r/OmnFtk8tkJJ238Dx/40YOR/k3LqH6L9tk/n7v88Aymxr5ko59/0I33KBQOwUOTUCSa/s9FN/VcTJI0K518+E+2AWH8qdVerbBKW+SEr4sBcQrguhgScDcKol7kpgnvtsd/gnIN09mcB3dWO7TiC3kNTXGqvu2meSTM109U3rHflDI9nU0NhFMVmx+0rAoB/Y1roDt59DOgOkTfYB6WWvFA1V8NdAV2MQWEah6BTZduATKbmw3u+Uc69alx30x9E0+4nzeQEa4e6QSUQmQ1/oyR2+hagYdjbAnItFbH8PvJnSHuoWFnBNRSyKigaitrt3XlOA64216eYN9u9mftZEFLhsx9WiOZZ/0elO7Kj21LoHcdjCpO3yq5VYoXrcMKBwSfSA/4qv6Z/u7A/Zvux3yq/NaOwwvNVnwQNTT7/yzZtiFk8ZzEaOhxyj+FccIZfTM4JOdifvKYDs9aunZwWYbjAotF+INvIXrf7KR5kpwibevb14Cnxg1rcfllmjcpF+y4w9O2HSXCqb+A7Iz307d6xz4wxph5nhjwZZ885JOSg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 843c4b7d-2cfd-47d9-65a1-08dade641f33 X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2022 06:18:02.9779 (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: qZW5VFiKgV6VGVUQ6u83Y/sdey+z93QIvRbjqHZUAWXfii8URMoMtxx2i5okqb1tV0ivtlJPiBUaiW8xGVfa9Xo2HtPUmL2Fhdb8bpciRu0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5124 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-15_02,2022-12-14_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212150048 X-Proofpoint-GUID: XOdEpN_qEXdObNhDLpn9VXi0sF1MKPPK X-Proofpoint-ORIG-GUID: XOdEpN_qEXdObNhDLpn9VXi0sF1MKPPK X-Stat-Signature: ztatqbamut1ytjkhhotk9b5sksdr9bqs X-Rspam-User: X-Rspamd-Queue-Id: BDB1940015 X-Rspamd-Server: rspam06 X-HE-Tag: 1671085091-334222 X-HE-Meta: U2FsdGVkX1/TQGTAXl5bV1Gu01yC1YDFELMms1A5Squ0A0KY9EkjbcsgKXKwmOAd6CG4UcGez+kVH4Vvoxo8cYBEzcsxEJjoGyEOVQ8i33r19o76NZahcrUxkJUgGdAcLj0R89ClrinOhlaKeuQuNZ4zo8vrNmG8Gqi9ESttTO1i0F9tTE+Q2U+K3UFFh4TUIxnFM9zPQaWD/uXvUwXcCWtOje5qb5ZQ/l10JXakyCKN0jkHNCZR4li4Zc2LcyarhmTDkmJVfmETKgjEfy32QPSMyeMVrvLpbtioIiWyaHIh3eYjiDnTbmjo5AwM/REleVQ6qPuk9RGZRKApRxi4zlZMIT4kRlHAFK2xJfbEKVUMEWql/4aog1qSWucjxXcgz0odqnkvRGcSFiM1vwrJlGkOIxatBglsbkJOSR6ow7/mJKJ5W5RnI/se+sm9iBmAaM8MQjMRkdC53joBgeBr2OKfWVDjmTbvD8iwU8e6TRyWiTervt527Kydnbf+LI4QsfC4Q6r57smNHCZ0rI4s3JuqT/x7E/Ho+aTZQ3TqCnTAYKbxKoZSS0FZPPeie/nKWNUVmrqOuU7Rhh2N1y6gerrkFnlKNy6Snd9tpeMsO+siBGEud2nAIZX5c2ka/lwlfKQDnBiD+NnnyMhm8xhashE/f9eNDMU9rHRUYNEhMcpVmGhBxo6QecclJmvW9Z1NZwfyzXo45zv+j+4lDK0yIpQ4iMVoZjDsSLkp76Lj7WYHlRrptKSO+OdWw9p3LHVO3TZafbzcnfcUWE2cgx2F9+j0OweEN+V0IK5/e3G9VjAy2nziP4JL94WEpVjLL2XS36SBvgdir69a4/v5FHrEYJSpeB5aZniIspcmCVyZ3l1OX9+58J5VUiBrHwjqurmzVOMe6V2JrfkXumUwMJ9hv3CUqZsuQoBE6/kJFJa7QivnV1kXnu914g1JguZ7ZId2e/eK7vYukO5Zl/j9JlA FAaKZqC8 OjghweuOktECERDkfwgOYrzgl2apiLcUKO6jCPYUBbtl+0tL54y+WK3jKOMJL9Igw1DcLKUXhQyHhMDt5PCQafM3unKKauW+/6ve9lll5ZAC+zzHD5jNrBdbKIlc4v147gxA8or/Rcl62qNz2/nhgxMgU7g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: folio_set_compound_order() is moved to an mm-internal location so external folio users cannot misuse this function. Change the name of the function to folio_set_order() and use WARN_ON_ONCE() rather than BUG_ON. Also, handle the case if a non-large folio is passed and add clarifying comments to the function. Link: https://lore.kernel.org/lkml/20221207223731.32784-1-sidhartha.kumar@oracle.com/T/ Fixes: 9fd330582b2f ("mm: add folio dtor and order setter functions") Signed-off-by: Sidhartha Kumar Suggested-by: Mike Kravetz Suggested-by: Muchun Song Suggested-by: Matthew Wilcox Suggested-by: John Hubbard Reviewed-by: John Hubbard Reviewed-by: Muchun Song --- v1 -> v2: - include WARN_ON_ONCE() inside the if statement - add r-b include/linux/mm.h | 16 ---------------- mm/hugetlb.c | 6 +++--- mm/internal.h | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 7dc376052d40..300d92d2b49d 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1019,22 +1019,6 @@ static inline void set_compound_order(struct page *page, unsigned int order) #endif } -/* - * folio_set_compound_order is generally passed a non-zero order to - * initialize a large folio. However, hugetlb code abuses this by - * passing in zero when 'dissolving' a large folio. - */ -static inline void folio_set_compound_order(struct folio *folio, - unsigned int order) -{ - VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); - - folio->_folio_order = order; -#ifdef CONFIG_64BIT - folio->_folio_nr_pages = order ? 1U << order : 0; -#endif -} - /* Returns the number of pages in this potentially compound page. */ static inline unsigned long compound_nr(struct page *page) { diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 7cdbcc22587b..810e840bb4f1 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1344,7 +1344,7 @@ static void __destroy_compound_gigantic_folio(struct folio *folio, set_page_refcounted(p); } - folio_set_compound_order(folio, 0); + folio_set_order(folio, 0); __folio_clear_head(folio); } @@ -1808,7 +1808,7 @@ static bool __prep_compound_gigantic_folio(struct folio *folio, __folio_clear_reserved(folio); __folio_set_head(folio); /* we rely on prep_new_hugetlb_folio to set the destructor */ - folio_set_compound_order(folio, order); + folio_set_order(folio, order); for (i = 0; i < nr_pages; i++) { p = folio_page(folio, i); @@ -1872,7 +1872,7 @@ static bool __prep_compound_gigantic_folio(struct folio *folio, p = folio_page(folio, j); __ClearPageReserved(p); } - folio_set_compound_order(folio, 0); + folio_set_order(folio, 0); __folio_clear_head(folio); return false; } diff --git a/mm/internal.h b/mm/internal.h index bcf75a8b032d..1d6f4e168510 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -378,6 +378,25 @@ extern void *memmap_alloc(phys_addr_t size, phys_addr_t align, int split_free_page(struct page *free_page, unsigned int order, unsigned long split_pfn_offset); +/* + * This will have no effect, other than possibly generating a warning, if the + * caller passes in a non-large folio. + */ +static inline void folio_set_order(struct folio *folio, unsigned int order) +{ + if (WARN_ON_ONCE(!folio_test_large(folio))) + return; + + folio->_folio_order = order; +#ifdef CONFIG_64BIT + /* + * When hugetlb dissolves a folio, we need to clear the tail + * page, rather than setting nr_pages to 1. + */ + folio->_folio_nr_pages = order ? 1U << order : 0; +#endif +} + #if defined CONFIG_COMPACTION || defined CONFIG_CMA /*