From patchwork Tue Dec 13 21:20:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sidhartha Kumar X-Patchwork-Id: 13072428 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 18E85C4167B for ; Tue, 13 Dec 2022 21:21:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52C498E0005; Tue, 13 Dec 2022 16:21:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DC558E0002; Tue, 13 Dec 2022 16:21:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3554E8E0005; Tue, 13 Dec 2022 16:21:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 25F428E0002 for ; Tue, 13 Dec 2022 16:21:28 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id DF675120AD6 for ; Tue, 13 Dec 2022 21:21:27 +0000 (UTC) X-FDA: 80238554214.27.E05F629 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf23.hostedemail.com (Postfix) with ESMTP id C92F514000E for ; Tue, 13 Dec 2022 21:21:23 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=Y07sWXJZ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=U0j55XeH; spf=pass (imf23.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; arc=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=1670966484; 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=tbz2o372kFK52fa9A8G+DL5Zfl+sf1AKtKrlVdDAuos=; b=L/QGbTw/Cjp8kMa8rZDc/TDDj+uyxdZN5hn377LxG1IHaunbEEXyXozLpwS6T8V93G7RMY 8T5vI0WKY3jXmWIOKVMKpIxeZZ4Ctpx00ocYSY+3kEL5WiZr1tQ6OHDFyll7t8zZDQOqar amXUtSM9+Zxk+H/mjIQE7eIYPeWmJtQ= ARC-Authentication-Results: i=2; imf23.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2022-7-12 header.b=Y07sWXJZ; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=U0j55XeH; spf=pass (imf23.hostedemail.com: domain of sidhartha.kumar@oracle.com designates 205.220.165.32 as permitted sender) smtp.mailfrom=sidhartha.kumar@oracle.com; arc=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=1670966484; a=rsa-sha256; cv=pass; b=iK2ffL26DMnyXKLppfGIB8iqgBGwfWuUIFUl+F9DxC8jyic5oS+Ah/2vKmpPs3MPKyTl5d N3BBc6cMeui+gWI3NFzR3UDoXqhdZOxizrBBnAcm+9tJnpeDt6VozPf/cSduAoay2CqSfN j7J3uDLcM8WWy4BbK0K2fmve8AjxTRs= Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BDL2BXS004143; Tue, 13 Dec 2022 21:21:13 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=tbz2o372kFK52fa9A8G+DL5Zfl+sf1AKtKrlVdDAuos=; b=Y07sWXJZcXGneLr1Jo6Se+nJUlpLA374hwso0jdhBRZEvQIuBkgE+G8vWRibt4jTZ5oM tjSeQMPqRjKQTmjpKBLkVaJVteWcpSdaphL0IttBrZ+PrjXgefqL1Qqgc2rt4PwcEjt6 2hVhfg8QEOTwoLDr/DxyyL+nlWmLcdnBCMAkEuNcCnLaAkkRxe4iB20WpwKh9sxNnW/I PEaVzaeNYRvRCDPfaN/y7AnBvAN0aDF69xJX0cKfbLVRtvxgWMJ1RHkxZgIcMdDK82A2 ZirVHbTSJohGfJrq25hDm2M57bjWaKkNtC2/syPRvhPxrpkUQXKcJ20/zfkf7kzEeCwF JA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3meyewr9d1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Dec 2022 21:21:13 +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 2BDLG6sf031758; Tue, 13 Dec 2022 21:21:13 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2175.outbound.protection.outlook.com [104.47.55.175]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3meyenwpr1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Dec 2022 21:21:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TO9/J5fKvHKsUDjO/SI4jVgvq5Tdz2j+iZdz/dknV01xIYEl96iPRyDrIxa2WMSYl6hMmZFqvP3b/5BDA2Qf6U9oGhRq0HgrL+i6ONqXd68WSrFO2WFJKdbkYY/irBeZXZLk0B8UoTzyWxun5Ys/ljG2lM9LMblSj/apLBKwhkXmPgr+61eM2m73yVmrjDoMNGhV3JIvcoHWmyZYPcLbHtbWDD0xV60mpFR3k3galNKpYu/FhQQvbShEkoe45bQANSVFcqmuG30r8akNTdkI/0bUponhTUHDxGMFa4hT3ascSUexi2Yq1xrIiEwqmHVvPkREryvfo39roZpdrPa4Qw== 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=tbz2o372kFK52fa9A8G+DL5Zfl+sf1AKtKrlVdDAuos=; b=H4KB2pUieyjMPzoNsefFd2sABB0KnDFFqkox3SlEs/KuUqp0RJy0OhZIyV5L/73M1DF496KZZooE5jR/wEafcQAUzpJH7VsMWPanfZj8gJpk9Wlsu8mqF6uhBBG5TZH6XIxGRfRHoRP6CT5HI+uDDEeN7Q0BsHfeoGCblKluo5KoOYyxq7QQKFfIWVWdP2Ns+wf7PS4Oci//JSZ3zTlKADLqvbmDo4YstZmBbEuWZkfjZZOpzpt3G8z4TLxA17pF7ag5v06I8b/Jnx4QVe2u1WHG2G1Y/66VO/5r/h8UtSjOu8G7PHRdNj3Orezov08uYrsn/zdaceNMoL+ondIjSQ== 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=tbz2o372kFK52fa9A8G+DL5Zfl+sf1AKtKrlVdDAuos=; b=U0j55XeHq41CHjMSXvugia/uex0WCOwja/pBPndk3ZgaasTzfNyQ/DR9KADqoMWBKTfIm/QTsk5FAZHbyV2+IL3B5HX6lJp+MLJmaTZIZcU49JthmCSXByQUQjBJ829NHx9q1sdvEToVP8LkPmtxRDvAMPzjBzLne6YVCzfll3A= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by BL3PR10MB6235.namprd10.prod.outlook.com (2603:10b6:208:38e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Tue, 13 Dec 2022 21:21:10 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::51be:1301:5ec3:996f]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::51be:1301:5ec3:996f%4]) with mapi id 15.20.5880.019; Tue, 13 Dec 2022 21:21:10 +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] mm: move folio_set_compound_order() to mm/internal.h Date: Tue, 13 Dec 2022 13:20:53 -0800 Message-Id: <20221213212053.106058-1-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.38.1 X-ClientProxiedBy: BYAPR11CA0055.namprd11.prod.outlook.com (2603:10b6:a03:80::32) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|BL3PR10MB6235:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e489208-b4ae-460e-556a-08dadd4ff406 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nX9jV17kodSNPKDwwJeDXYCqVeQuU3AIpkqFrdqIuW3uPvwyCvJZxJS6JJayv3xzdzaeTmw1gDfobsWP9lopPRiq9aPXjncOPl/b/8gJUGVBFNyoTKFNMvsP1GQLiVmuYw+ikq9rA2oIfEnfuWbkPZ6JY9Ty41XaS9eag/gHLd0k95cMj2x0TGeXMjsAMf9QcGr+XJ6UnK8aCatxqemsDwKXQXqgocgB36r8+SZeyLnw5GQ8uLMBVAa2ARUq62Xsgr6dqra1mADk0wtxcs20vYlwplNPcx6Yf/eTBaVzfv6fn/c4By4NsVQ0y5fsC5oR0jCnfCagYpE10Ou8kJKHgGVz9TtTE97rrkjI4kD/8veKan3/LUJtKUiLU0RAD4C+Z4mSZabE5+PiwAxAOHjFR87Y+wHZML6bQRXlhz/LxAwisGhjyNVSGGrFxg6uNZFZqihCPgYrVDQdTpgcuFecXJZJcRQP+dS0aLXqefC08wQYJdlbhTIHtRqW1AmDZWftT4o0VpkleDqYcNOtg05aQfLK/lq5g66f7L0WVctOOq8rQrGN5w48hHmT6vzQSs2bHOldxwjyuSpVkDGwGp/Jj4J1dczKXGCFB8pK2o/ttYcngLQ3USyGgqP52Ha1/OBHVZZ95+cVP3gRU9lZLhmEIXnfZKNIUwZO+TSM1KI768E= 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)(376002)(39860400002)(136003)(451199015)(966005)(66946007)(86362001)(6512007)(6506007)(107886003)(478600001)(6486002)(6666004)(186003)(41300700001)(2616005)(83380400001)(44832011)(2906002)(5660300002)(8936002)(66556008)(4326008)(66476007)(38100700002)(316002)(8676002)(1076003)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +QAiiZh4+JfDHbHs3tCs0YkX3qQ61AovM4hgFqqRuP3MbA+vpFC0XZY3hCN0jjy3F4qDdJ9cc23OHPejCHSfInxTF0gHumdSpkmQIC/0ebWSceXUtDYAiAbgS3uIEe+3LVsKTWlACjfpUqOJp/uaZpBaXLNhtu1q74NA/8H1amvlNhUFaLYuA8MUgoeXWR5a65Hq2stWd2WELVH/cRsPJD63TkhAWfIPedtvtiCNv3HtV13w+TUj0/UNhLjHoN1TWRJ8LOnHwISGIn/x2rSiv4pY3ScqDwrpViY+tcMgoEfYaUDoak+CASACpquafqTOXphz9KqxWPRZphab+L+5H3J01verMhWhQctYaiLU9/lpr7UshrHsZj7KiohwjwqKuTzd0FjsFuTKj7ptm6yLitZr70BsFntxFS41f89P7wyPBB4xvyW5TB5/8TLYqJxnkmoffG0TdcOtn7OZ4g8FiXkc6QzrU/Ygx1Gyu9N80vE346AuC2dWmgVuC80SvBNtpSOidWgeVlCwrchcxpOPVZuSfqTg9PsTGHpz5r/6Ua34UioCmk7HsJgDOO2pOaLKvvNOW/yK1/QxjbWLx0/ha8hp3pYy/qHYrxgm0lFUwBw+tV+Nc4AqIooiZX6NKriSEV+nxVk+3nJamKhdlJ7I2qDH3dEhwSuuPBHsn6j2kGgEx8t55V3ToXURvfhOKJVBQLAFAUF/3knTkEvBI96z1NDw3WUkvHH2lyxUGsUD+Q5Rruuofw+7sELxUSru0+NrgjU5l6kTqy5LJmPlGvrCaEFGbvIwIfqveCd9ywMgwtj8X9pSdCwINhgN1eZ2N5r2btXAE9RuBCP1PCqry7CPHxhO0pMf0R4C1RORpU51T+a9AnLRebNuYXD82MGUfjmSx0WyKpCJvHyuupqZPAfMeBL1VDJEInbdY7UomFzdhy3RXquB3Z7bY9n3P99pR9ssn4m2ib5sSVNTDuhJ+FbNry5MSzkhOfqRqG1Qc+yj+iY8AhLd9UUeJaYIGHsMUAtJsX+lg1Dq1VgWt49VXnfJxmdL2mWxhGy7gVLL1TcN3WJoMdC3vYpaGtSsvyo7Yqzq8PKDVitJhWv3ii+TSSvrUiZTfvtVlPLOusdHqqxNaphUf2TjD7/K9Clk3npnU1GUPWyBl4DxSz+eRfofug+joXSe2c6szjcy6HOANjZnNTDV7AsvYSksKkbxH7iIUdGGu3ARpe2HDPK/Prl0rQYloDhE3ql7zjRwTzie3b5td9LWfJzsHrQX+yMEd8frizoQLcTLefNi1l/OvMKFumuKISFJb2o8HPAcVSft/mQwJBY1LFbKiUNsR3lYEPeYQ1psx22sWvxgqZ1v90KeeFtne5v03ct4XJTZQSJpAds8DodcbPjEBanJqSmFiIA2JByc+XsKqlEyOEa60XiVgcMO/xXpf9tHLwEKfU3EunTjq1AOFBwGRUZ8mtE+AfLiugOQq3HWaJGpqNnyRFV0f+VrJNY6L51jjfQW5JqVPPXMMUv5ztv2JHuB0zfOJVt86Uw4HdsMpl1EkuQKXH1qOydjiXeR6XMNyNXOhXjuC+8keGTyd8vi5WfpPjG3CDtP1epShQAP1bHz3LjOgsjYkotlUA1ncieiTpTXLr2XwYsNgQpelAyk6KufySgR5CTp6lkCz78ud75UT/kLZBGnVc9v7g== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e489208-b4ae-460e-556a-08dadd4ff406 X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2022 21:21:10.6630 (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: mHPw5sD2S+HIDazsPqn/5d9wCxmcGmSL2cst1ddDIVLE6Jlk7HxSA6EmJ17DYg0qEy08qaXRens/FgYc6yQFDKOqdGqTFmTI6i6iWf9lsVQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR10MB6235 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-13_03,2022-12-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 bulkscore=0 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212130185 X-Proofpoint-ORIG-GUID: UA0zIuPeZm9cIOBjZ5kFdcTF7SikrJZp X-Proofpoint-GUID: UA0zIuPeZm9cIOBjZ5kFdcTF7SikrJZp X-Rspamd-Queue-Id: C92F514000E X-Stat-Signature: bgdxyiczd33cs1bxado5ma7dwgjimdmo X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1670966483-666941 X-HE-Meta: U2FsdGVkX19tc6va8eJZBJXrEyPCEMl3k7smAsAO2geJlwGk0mbRxvLHkYkM74FdsXS86eQP8eJEWlWSHYBRcQ8I8AUz0ZxTTuQ8vP5GArX+H8kgDT36KbCu8OBU1mja1NsvSzH/JJlzpaZbCB8D8p8K2gM/iJ4EoCtderASATUB1+HymYXxhYvi0EYGv7GP+lK7DYTpZ3tnS3Uc/nBUnWZ+WxOe03jKKz+KCDQcG72Rueq9OXYmP5zVO3jsUPeeEgH3Dp8HuZu24w7hqEXXxDhjjDs9NKbkpbVS82DmHsrrmA55Gtecdv/e64iI+gGJ7l7Je+nti1TuW4k2v55mETYCF9J/6QMUNDvM1c9ZDO5qEAlyY2D9+4zimTx+qNIfIxgefLU9uEeHNlD4q22ITVm04YckyW/Sc4bh7OWB4/et8JXw+aXxaqiV7DloRfM/uRguK4++Pdnm0wWKS/qpwfTSBJ/ZfIxOaUvF1EW5s5Xz2dG63SKHIGX82l9siPQYIZLQWO3EjSZtkVPAJ44AO68sYNZ/h8TSuien5LAZt16ExynVwRUR9keCmLefa2stKZM2uIr/S3ri2vENmJAYCT8M4bxwwEFk3Qp/UQ15vZeYiS0TeEaEMCV7j0OWMnS2ngV+Qpu0Yzj3mqDFvN0l69B1/boW38YNzvAeVymp+mDwYEPcdfCaxWN7kaV6odaDpneMfS+u6EfX0MBDsEEQH4gdMHnGdPd0vMeXQt252nyNKIWjHC4Wz/9N5ZCir39o5r+hgCOK9e3pOx5gX/9KYMHYMfeZRQJ6wyGTwUY+G2rKECjXejEvFA/EidnFmmC8SfHGa3Sf7S30U5XtsxSAXeWadzgyXTBWojMxZ9bDgD944KmA/ayHhfsV6A3/XK/Uv2PyKBivcURi8kJnfjIECjsbkBZd1Gw5AxBOn8/0CHONIZq/LW4bDB+SCiOJlbOVLu/JQQMBNqF/b/3o07D GzV1YmUP e22mY2SDWzdQNLyUTnibdJ5IEiKMCzBMM2SN6PkgSF0GgkG1YIGfgkiz7+EfwA2o4BPaj2TRjI1VfbeotbgFj1vxUEUlqzCwMDbgwQStW+wbc1Iz1si+f3oj3R65QIgG0AA7VgL7QJlsfGYyRKqtMDxkW0Q== 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 --- include/linux/mm.h | 16 ---------------- mm/hugetlb.c | 6 +++--- mm/internal.h | 21 +++++++++++++++++++++ 3 files changed, 24 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..829b6a60ceb7 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -378,6 +378,27 @@ 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 (!folio_test_large(folio)) { + WARN_ON_ONCE(order); + 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 /*