Message ID | 20221207223731.32784-1-sidhartha.kumar@oracle.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp443528wrr; Wed, 7 Dec 2022 14:53:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ourmTq5SJK6GaJQuNNyqVAQWkN9OEg8JaS4igSS/+A8pmsJbe3c2H1thEBLCp38JY2jpM X-Received: by 2002:aa7:c844:0:b0:461:a130:ea3c with SMTP id g4-20020aa7c844000000b00461a130ea3cmr80359391edt.272.1670453584666; Wed, 07 Dec 2022 14:53:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1670453584; cv=pass; d=google.com; s=arc-20160816; b=IDP0r8d8e0pXm7SUo4/TWnIclCPKigij3yQxesry54FuJyYa/YdGox1wR9bP9V+hW5 bINZDBADAcQNFBq0Us8fSX5w1arokDBUFR4dMKD5p8xwZW+u4MIWW9h4RL65qvluAi78 Icbw1hsSyHKDIXEyxGuGwh5plA+88R2p31ffc4G83+1SfvmLFqbEOwLQ9D9dBQcjuSt4 414Z69rIvoyUVkwSiQwjGp2BWw1a41ugbveVfbEG9eX+Baxb9a3ZKTKvIdsx3h+nnz0Z qUS9jVEJExzvvoYp7jkLCtVnbpnUBWc5SlPgPqcndvWpcb6tEZgFHAvS1fg6aJhYSPB6 PVjg== 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 :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=mMjcFjpkGrUMbQah+4ESEDYEGowW7s7KaucTg1AiKDE=; b=j8hEtpaTBo+XdiQiG9iWj7TnNuJNH/N4JeEqrTlq+RGTZv9ONonURr9kCtJXIDA5sx 0ZuzhvuhBb5ue+1yc3pU0OdAIz7ng+oVE+I8UaQ/sETfJngVVYSdmFyETBAJUhMH1SF4 dzgn26W86SOMKMFeIx/aTGKx1snPobJKLL5OgHa8y2D/77RZUc/Lv3lKtPDnrlc5Dmp6 bkI5WhgaOaef4Wr7vGZWLbyHTyA6J5qSqVbKf4h6wg9ndju8wiPMhFXTY+qMmX/tgL4z 9/I3Il1UKNrrcaXQkIURJ4zmifw5MJuNiWknUvlbR5hllCjldZOx3BF7WnCVicSTdmNW +Rkg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=P4kfCrXC; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=nFtM4Tsv; 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 hp27-20020a1709073e1b00b007c01c6cf01dsi18868319ejc.800.2022.12.07.14.52.41; Wed, 07 Dec 2022 14:53:04 -0800 (PST) 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=P4kfCrXC; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=nFtM4Tsv; 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 S229530AbiLGWjD (ORCPT <rfc822;foxyelen666@gmail.com> + 99 others); Wed, 7 Dec 2022 17:39:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbiLGWjA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 7 Dec 2022 17:39:00 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04C5B6F0FD for <linux-kernel@vger.kernel.org>; Wed, 7 Dec 2022 14:38:56 -0800 (PST) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B7Lx9uv030858; Wed, 7 Dec 2022 22:38:44 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=mMjcFjpkGrUMbQah+4ESEDYEGowW7s7KaucTg1AiKDE=; b=P4kfCrXCgnaq8O6rN5o1c5IYWDEst3Nm8KYAaRUcvfWU9NGun1sI6p/sczbd1N/V4LYy HNwwvJWNFs8lRVIxvr+ey3c5Xa0YJ2uYhaj6yg2JgWBRVwgvxGoZ37CwMeVmErbn+FCR 3RDKUlX6H8j/NEynPn6aAxbS+SVcLCBKB3gjydHrem1jbO8uSpcShtSa2c1qTeQfY1FW vH/rdySKgcaEtfNqz1s9bxStgBv/E5HTFApECsPfgl+ZD8zu/99HPtvhWvmPPojoZYY0 U3VrACkE//cY2/Gy9ndENAQ9OJqyptjP03cKqvdvuZzrVy6NQSKQlVb0HBwZXEO6Z/TU Xg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3maudk9mrw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Dec 2022 22:38:44 +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 2B7L19AM021779; Wed, 7 Dec 2022 22:38:43 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3maa8gk7af-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Dec 2022 22:38:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QWvYqQwuppKl0tc+C90H6lC7Jl6XXM4fuZaYLb1IRxn1VOPnPF2h0HuBkYUKsSpbaJCS9sGNTVdy3bklWOFUzvKBhaoRSaPJd0o5Z38rXv5CwO0hRqgAJkUogJhvy/i/a+CHYfnNaymla6auVkBrwD/L/xC5nfXmNbult4X5Ms+Pgc38TW/Ade1MImv62FZZmmwlSjZAaSPKjHsY4mX83aHOCcAQYvpbA/D5Hobdqc6fffmZlJN5Lbtp2CiHsWwqgC7xs95QwOv6tNzRLu2R0UBu8yzMOAEyVZnJsKbfY5c32NpNTnM+mzJpRF0RlBnt8TFshiVflMIWLi6+H6sLCg== 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=mMjcFjpkGrUMbQah+4ESEDYEGowW7s7KaucTg1AiKDE=; b=mEM1lsRDYWyNiK1SJTRZo0TCW9OwV9gfg1S8fMcevNShZj8aE9eIi8IUlN0Itt1ZoxUsNwZ74uriOdvFR74fes/gE5bKe35+NMgulAyOXGY2jo8LXTNcqVDv0AW162MbMtuzPS6Xn+Lc5jSO62U3knbUmYH8uBtSx2GoMbzOiEMpDUGMFXx4FaPWF6NaBXfs22jAoY62anptTRsKi+V6g8y5une9qJngG7iVx1ay/oq8MJbLhltSz6ovgi3HQFA8WVNsalWSD8X2Q/Ochj8zHvV/CjTPHC0Ucw2k5nQ0Wq5pN1FgxM54k/V1weV/tmpybdPG+SrO+QlIL+GMo33apA== 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=mMjcFjpkGrUMbQah+4ESEDYEGowW7s7KaucTg1AiKDE=; b=nFtM4Tsvg3Wdgs8spbBe478UEl9Jz9oGwkqt98wdZlRNy2N99cqrYj13ljzO7lCAvhzWlkFrYGIQwgckAftMQhhUiyJqAyKBkTGyH52NXj26QVXhT9ntVn3JTzKMa00Gl7yla253ivn8fk9zKLAVWaRO+MH3qgUpgph0HgamaZE= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by DS7PR10MB5166.namprd10.prod.outlook.com (2603:10b6:5:3a4::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Wed, 7 Dec 2022 22:38:41 +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.5880.014; Wed, 7 Dec 2022 22:38:41 +0000 From: Sidhartha Kumar <sidhartha.kumar@oracle.com> 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, tsahu@linux.ibm.com, jhubbard@nvidia.com, david@redhat.com, Sidhartha Kumar <sidhartha.kumar@oracle.com> Subject: [PATCH mm-unstable] mm: clarify folio_set_compound_order() zero support Date: Wed, 7 Dec 2022 14:37:31 -0800 Message-Id: <20221207223731.32784-1-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.38.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BYAPR04CA0016.namprd04.prod.outlook.com (2603:10b6:a03:40::29) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|DS7PR10MB5166:EE_ X-MS-Office365-Filtering-Correlation-Id: 9eb76d05-5c03-4451-50f9-08dad8a3ca54 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BK5zlEl8h7P5ZgTHeAkALNIBxvgLbQy8TkiWYc9IXlqzTB6YXX0InJOmCqcIl5/rPtrs9W/S9ZC6+krw5Vc7yNUdZnYY/ZDWYqxR9pCVATYx9zscgm6GhUoHg9wH4s4VJ7dL7mbuU7Hf9FkeCnQB0s5u67g1ZVwelDWnaBp1LjdemUuT0lDHxKQ3C/hXX7yE/roe9OzRy+tQwHiICDFhFndHuXjZkRz8yboQF+CLko0KpNh4vU0e4WIXoswcEBNW+gYbPs+p+HLI3Q3gl6n945Dtll/Fn3j8OsuiF7dmSJlxeDfLmEvOeBPwhMDeLOoEewYUS1BrqCWZKlMSSBkhxlS0/NmbL8BdIWbv+9ya6ZUM2nIrR4AnNu3ASsUYHY7JnYlRhDCq4QOh4CwwToIby6smn/tsco2Zef57ZtOeopPIfs78DgbRubmfBcQf7H1eHXhBJFEmdbQI3acW1EuzYdmSwUJeKKUDY8uxUPjTKYJOYqLFNhDWVyJqHTNTsE7zB6YS6tpZTj5uY8kqbwDazZuR0omt2Sf3Y1vKi0nMPMQCOf4+1oZHRZ3mDQKrbVsENovTempl5CvfH4sn3gegNRbiI7n/pYi77heBiECT6AzuRqjtIx7O/HfbQSbmzuGY 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)(39860400002)(396003)(376002)(136003)(346002)(366004)(451199015)(8676002)(44832011)(2906002)(4326008)(83380400001)(5660300002)(41300700001)(8936002)(6666004)(1076003)(6506007)(6512007)(186003)(107886003)(478600001)(6486002)(2616005)(66556008)(316002)(86362001)(66476007)(66946007)(38100700002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: X0anNwI6/qYmEq6+CgRd2SAXrfZ26m1Q5sqJERWTD1ypcQOD9N/pJ6FsM78rLNTMlDce3v9NmZAvh7wsZq64Drvz8iACVyRMcdS4gP1s6PHh76IJvjurhj1OjeK9jWViLfPBcpbYhWW6Q+WVRmzmvfCq1M4xRi29RQKstQ5iyaAnVwmw3N5w85ALSME7loR/HXkvFkN6bttZaZbEv+E15Y1sxv8YZ4xiX/2hYfg1ZQj0RroVB7e2sHz14DluvCKaFfbJQz9xdj+vz+ybqWqQNVOGLNWPPyXJn3I4XP3cQP+c07UTghnK18sVioEbtzn2TyhYZQ3jtWeEtaKgGbcQtxKkpJ9XF5tVntbju8roaXyo35ea0Z+gTdBhf8rT0lJEgxVyL2lYNE1gzLAYllssuGrxRF8NEm/vMxvKZBWp+KjgZpGpf4M/z4rAZXUZlS24cVr7qMtl+oRb8/75Ec3p4adAm/mNbRt/QETe7+6ytA10dsPmDsWU3X9Sf2x+EkOzLVv7Tl7z0ETKvGG0qObVnakRTSFAAUE9nxafBQ6BJBAbXycHnS7lRwD9Bsys4rs4zmTivN7J3OyZr0Z0gDGHpxcJ4MUYK3sC3W0i8m8ZJkpHejC0A9YWjLOG7ubE6cxFpGIllAZfHDmRQGxrsJHHaWOvyaDyvTdOjFoVaDSHz41JB3QlRjroxSHdhAbAzqm6aDxf/YSGVKKSZOyzlZ41GJPChDE96YtZmeC7MDrsX1zksGuuP4Vu9k393ZCyb46N2GcgXsXJlYAfmP/vnf+gDP2Mfxdgu0Kbf7o3S/9SWVY4LOJmdoa6HzgGq9hdOilns46bpvm0pMC76RIC+CZUOjqKH/srveoQpTDlV5aEAv6BowbTyq30pd4so9Q3zu3hDNMwPhXJfTQKajRxwMegXsGB/Hj3b2Xfshdye9EmND3JaYUVgNYpoX9IBmhbQlnDhnySfvUuA9mepd2HuVGVr6l2tHBvyxAwJKh6Dt6eFZIVPA4tCjmUWRm8flqwE56ofOBx5YmAWuJHGSV9tkZ+fyiVIXpAJ5zvGR0i89UXleaBhKWtPppVARq6dIFvA/azzSE1Gm28pjeGeCXwiOHkN4ruZppCMgnxH0yiiC1xdp9Qqquk59ong2pbUzxmO1K0UuZjar8MW2W6B4DbbmJQRiz7QXQr9B3FbaF6of+/jorsi6Un9Vh+8zek1jgkXF0sctF9YulMzz9zSzq/ZkUHtMwdjER2kZs+8EWdOR7+mcjFNwGHm8SI+WC5t0zqVldNRA0RRodtLbdiaj9uBBNuXSuowKnL5z1dDHcJPB93zYzVT/i98a/rN/FVd/5/H5UkchTcSzNWORDXM63/glmg1JCz3r3UoPwICfVMNsVFNZgNl4f8JFzpZ7vFbsDVhm3hdje7nE7Sd9bEjR9vwMgunfHu7/ldRq7vdi1gBQvvSxKvah+VRhdKtQztG6pYFHOZB8g3lKGQe4cC5hXz5nichxbqRXe4+cztsMNLqnsqQ3hqI2bSMPieJ9wwSjdxkBDm393sePImPJMsk81+r+BQIlo0kwzltpeACJfY6joW6hbPNhahinDXEDXE5DgPfGrQzIkZxn6agH96/Uc4ZT99Dewzo/IBFvmmL6DSPDrICIrPB5Ymzi8ZikYrT1WLcBmNJKQcy1hxCqZSg/Ozwt/6OA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9eb76d05-5c03-4451-50f9-08dad8a3ca54 X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2022 22:38:41.4169 (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: K/IXl88UsPqYnDS5vXfn94rJSoyyHRgpi9PjWKFtCUHxGe7qighppYPg19cFckzgkI3aIBQ5/odukBcJQ9A3p790MWfzRjkbPtmKOGF6GPI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5166 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-07_11,2022-12-07_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 bulkscore=0 suspectscore=0 phishscore=0 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212070192 X-Proofpoint-GUID: qEZscxVuqPs59qN_RdmAhCBOAk3lV_5P X-Proofpoint-ORIG-GUID: qEZscxVuqPs59qN_RdmAhCBOAk3lV_5P 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751597538161376383?= X-GMAIL-MSGID: =?utf-8?q?1751597538161376383?= |
Series |
[mm-unstable] mm: clarify folio_set_compound_order() zero support
|
|
Commit Message
Sidhartha Kumar
Dec. 7, 2022, 10:37 p.m. UTC
Document hugetlb's use of a zero compound order so support for zero
orders is not removed from folio_set_compound_order().
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Suggested-by: Mike Kravetz <mike.kravetz@oracle.com>
Suggested-by: Muchun Song <songmuchun@bytedance.com>
---
This can be folded into f2b67a51d0ef6871d4fb0c3e8199f278112bd108
mm: add folio dtor and order setter functions
include/linux/mm.h | 7 +++++++
1 file changed, 7 insertions(+)
Comments
On 12/7/22 14:37, Sidhartha Kumar wrote: > Document hugetlb's use of a zero compound order so support for zero > orders is not removed from folio_set_compound_order(). > > Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> > Suggested-by: Mike Kravetz <mike.kravetz@oracle.com> > Suggested-by: Muchun Song <songmuchun@bytedance.com> > --- > This can be folded into f2b67a51d0ef6871d4fb0c3e8199f278112bd108 > mm: add folio dtor and order setter functions > > include/linux/mm.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 443d496949a8..cd8508d728f1 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -999,9 +999,16 @@ 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. > + */ Wouldn't it be better to instead just create a new function for that case, such as: dissolve_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; thanks,
On 12/7/22 4:38 PM, John Hubbard wrote: > On 12/7/22 14:37, Sidhartha Kumar wrote: >> Document hugetlb's use of a zero compound order so support for zero >> orders is not removed from folio_set_compound_order(). >> >> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> >> Suggested-by: Mike Kravetz <mike.kravetz@oracle.com> >> Suggested-by: Muchun Song <songmuchun@bytedance.com> >> --- >> This can be folded into f2b67a51d0ef6871d4fb0c3e8199f278112bd108 >> mm: add folio dtor and order setter functions >> >> include/linux/mm.h | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/include/linux/mm.h b/include/linux/mm.h >> index 443d496949a8..cd8508d728f1 100644 >> --- a/include/linux/mm.h >> +++ b/include/linux/mm.h >> @@ -999,9 +999,16 @@ 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. >> + */ > > Wouldn't it be better to instead just create a new function for that > case, such as: > > dissolve_large_folio() > Prior to the folio conversion, the helper function __destroy_compound_gigantic_page() did: set_compound_order(page, 0); #ifdef CONFIG_64BIT page[1].compound_nr = 0; #endif as part of dissolving the page. My goal for this patch was to create a function that would encapsulate that segment of code with a single call of folio_set_compound_order(folio, 0). set_compound_order() does not set compound_nr to 0 when 0 is passed in to the order argument so explicitly setting it is required. I don't think a separate dissolve_large_folio() function for the hugetlb case is needed as __destroy_compound_gigantic_folio() is pretty concise as it is. > ? > >> 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; > > thanks,
On 12/7/22 17:42, Sidhartha Kumar wrote: >> Wouldn't it be better to instead just create a new function for that >> case, such as: >> >> dissolve_large_folio() >> > > Prior to the folio conversion, the helper function __destroy_compound_gigantic_page() did: > > set_compound_order(page, 0); > #ifdef CONFIG_64BIT > page[1].compound_nr = 0; > #endif > > as part of dissolving the page. My goal for this patch was to create a function that would encapsulate that segment of code with a single call of folio_set_compound_order(folio, 0). set_compound_order() does not set compound_nr to 0 when 0 is passed in to the order argument so explicitly setting it is required. I don't think a separate dissolve_large_folio() function for the hugetlb case is needed as __destroy_compound_gigantic_folio() is pretty concise as it is. > Instead of "this is abusing function X()" comments, we should prefer well-named functions that do something understandable. And you can get that by noticing that folio_set_compound_order() collapses down to nearly nothing in the special "order 0" case. So just inline that code directly into __destroy_compound_gigantic_folio(), taking a moment to fill in and consolidate the CONFIG_64BIT missing parts in mm.h. And now you can get rid of this cruft and "abuse" comment, and instead just end up with two simple lines of code that are crystal clear--as they should be, in a "__destroy" function. Like this: diff --git a/include/linux/mm.h b/include/linux/mm.h index 105878936485..cf227ed00945 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1754,6 +1754,7 @@ static inline void set_page_links(struct page *page, enum zone_type zone, #endif } +#ifdef CONFIG_64BIT /** * folio_nr_pages - The number of pages in the folio. * @folio: The folio. @@ -1764,13 +1765,32 @@ static inline long folio_nr_pages(struct folio *folio) { if (!folio_test_large(folio)) return 1; -#ifdef CONFIG_64BIT return folio->_folio_nr_pages; +} + +static inline void folio_set_nr_pages(struct folio *folio, long nr_pages) +{ + folio->_folio_nr_pages = nr_pages; +} #else +/** + * folio_nr_pages - The number of pages in the folio. + * @folio: The folio. + * + * Return: A positive power of two. + */ +static inline long folio_nr_pages(struct folio *folio) +{ + if (!folio_test_large(folio)) + return 1; return 1L << folio->_folio_order; -#endif } +static inline void folio_set_nr_pages(struct folio *folio, long nr_pages) +{ +} +#endif + /** * folio_next - Move to the next physical folio. * @folio: The folio we're currently operating on. diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e3500c087893..b507a98063e6 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1344,7 +1344,8 @@ static void __destroy_compound_gigantic_folio(struct folio *folio, set_page_refcounted(p); } - folio_set_compound_order(folio, 0); + folio->_folio_order = 0; + folio_set_nr_pages(folio, 0); __folio_clear_head(folio); } Yes? thanks,
On Thu, Dec 8, 2022 at 10:27 AM John Hubbard <jhubbard@nvidia.com> wrote: > > On 12/7/22 17:42, Sidhartha Kumar wrote: > >> Wouldn't it be better to instead just create a new function for that > >> case, such as: > >> > >> dissolve_large_folio() > >> > > > > Prior to the folio conversion, the helper function __destroy_compound_gigantic_page() did: > > > > set_compound_order(page, 0); > > #ifdef CONFIG_64BIT > > page[1].compound_nr = 0; > > #endif > > > > as part of dissolving the page. My goal for this patch was to create a function that would encapsulate that segment of code with a single call of folio_set_compound_order(folio, 0). set_compound_order() does not set compound_nr to 0 when 0 is passed in to the order argument so explicitly setting it is required. I don't think a separate dissolve_large_folio() function for the hugetlb case is needed as __destroy_compound_gigantic_folio() is pretty concise as it is. > > > > Instead of "this is abusing function X()" comments, we should prefer > well-named functions that do something understandable. And you can get > that by noticing that folio_set_compound_order() collapses down to > nearly nothing in the special "order 0" case. So just inline that code > directly into __destroy_compound_gigantic_folio(), taking a moment to > fill in and consolidate the CONFIG_64BIT missing parts in mm.h. > > And now you can get rid of this cruft and "abuse" comment, and instead > just end up with two simple lines of code that are crystal clear--as > they should be, in a "__destroy" function. Like this: > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 105878936485..cf227ed00945 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1754,6 +1754,7 @@ static inline void set_page_links(struct page *page, enum zone_type zone, > #endif > } > > +#ifdef CONFIG_64BIT > /** > * folio_nr_pages - The number of pages in the folio. > * @folio: The folio. > @@ -1764,13 +1765,32 @@ static inline long folio_nr_pages(struct folio *folio) > { > if (!folio_test_large(folio)) > return 1; > -#ifdef CONFIG_64BIT > return folio->_folio_nr_pages; > +} > + > +static inline void folio_set_nr_pages(struct folio *folio, long nr_pages) I like this approach and helper name since it is more consistent with folio_nr_pages. > +{ > + folio->_folio_nr_pages = nr_pages; > +} > #else > +/** > + * folio_nr_pages - The number of pages in the folio. > + * @folio: The folio. > + * > + * Return: A positive power of two. > + */ > +static inline long folio_nr_pages(struct folio *folio) > +{ > + if (!folio_test_large(folio)) > + return 1; > return 1L << folio->_folio_order; > -#endif > } > > +static inline void folio_set_nr_pages(struct folio *folio, long nr_pages) > +{ > +} > +#endif > + > /** > * folio_next - Move to the next physical folio. > * @folio: The folio we're currently operating on. > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index e3500c087893..b507a98063e6 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1344,7 +1344,8 @@ static void __destroy_compound_gigantic_folio(struct folio *folio, > set_page_refcounted(p); > } > > - folio_set_compound_order(folio, 0); > + folio->_folio_order = 0; I suggest not touch _folio_order directly, we can introduce another helper like folio_sert_order to set -> _folio_order pairing with folio_order. Thanks. > + folio_set_nr_pages(folio, 0); > __folio_clear_head(folio); > } > > > Yes? > > thanks, > -- > John Hubbard > NVIDIA
On 12/7/22 6:27 PM, John Hubbard wrote: > On 12/7/22 17:42, Sidhartha Kumar wrote: >>> Wouldn't it be better to instead just create a new function for that >>> case, such as: >>> >>> dissolve_large_folio() >>> >> >> Prior to the folio conversion, the helper function >> __destroy_compound_gigantic_page() did: >> >> set_compound_order(page, 0); >> #ifdef CONFIG_64BIT >> page[1].compound_nr = 0; >> #endif >> >> as part of dissolving the page. My goal for this patch was to create a >> function that would encapsulate that segment of code with a single >> call of folio_set_compound_order(folio, 0). set_compound_order() does >> not set compound_nr to 0 when 0 is passed in to the order argument so >> explicitly setting it is required. I don't think a separate >> dissolve_large_folio() function for the hugetlb case is needed as >> __destroy_compound_gigantic_folio() is pretty concise as it is. >> > > Instead of "this is abusing function X()" comments, we should prefer > well-named functions that do something understandable. And you can get > that by noticing that folio_set_compound_order() collapses down to > nearly nothing in the special "order 0" case. So just inline that code > directly into __destroy_compound_gigantic_folio(), taking a moment to > fill in and consolidate the CONFIG_64BIT missing parts in mm.h. > > And now you can get rid of this cruft and "abuse" comment, and instead > just end up with two simple lines of code that are crystal clear--as > they should be, in a "__destroy" function. Like this: > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 105878936485..cf227ed00945 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -1754,6 +1754,7 @@ static inline void set_page_links(struct page > *page, enum zone_type zone, > #endif > } > > +#ifdef CONFIG_64BIT > /** > * folio_nr_pages - The number of pages in the folio. > * @folio: The folio. > @@ -1764,13 +1765,32 @@ static inline long folio_nr_pages(struct folio > *folio) > { > if (!folio_test_large(folio)) > return 1; > -#ifdef CONFIG_64BIT > return folio->_folio_nr_pages; > +} > + > +static inline void folio_set_nr_pages(struct folio *folio, long nr_pages) > +{ > + folio->_folio_nr_pages = nr_pages; > +} > #else > +/** > + * folio_nr_pages - The number of pages in the folio. > + * @folio: The folio. > + * > + * Return: A positive power of two. > + */ > +static inline long folio_nr_pages(struct folio *folio) > +{ > + if (!folio_test_large(folio)) > + return 1; > return 1L << folio->_folio_order; > -#endif > } > > +static inline void folio_set_nr_pages(struct folio *folio, long nr_pages) > +{ > +} > +#endif > + > /** > * folio_next - Move to the next physical folio. > * @folio: The folio we're currently operating on. > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index e3500c087893..b507a98063e6 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1344,7 +1344,8 @@ static void > __destroy_compound_gigantic_folio(struct folio *folio, > set_page_refcounted(p); > } > > - folio_set_compound_order(folio, 0); > + folio->_folio_order = 0; > + folio_set_nr_pages(folio, 0); > __folio_clear_head(folio); > } > > > Yes? This works for me, I will take this approach along with Muchun's feedback about a wrapper function so as not to touch _folio_order directly and send out a new version. One question I have is if I should then get rid of folio_set_compound_order() as hugetlb is the only compound page user I've converted to folios so far and its use can be replaced by the suggested folio_set_nr_pages() and folio_set_order(). Hugetlb also has one has one call to folio_set_compound_order() with a non-zero order, should I replace this with a call to folio_set_order() and folio_set_nr_pages() as well, or keep folio_set_compound_order() and remove zero order support and the comment. Please let me know which approach you would prefer. Thanks, Sidhartha Kumar > thanks,
On 12/08/22 10:06, Sidhartha Kumar wrote: > On 12/7/22 6:27 PM, John Hubbard wrote: > > On 12/7/22 17:42, Sidhartha Kumar wrote: > > > > Wouldn't it be better to instead just create a new function for that > > > > case, such as: > > > > > > > > dissolve_large_folio() > > > > > > > > > > Prior to the folio conversion, the helper function > > > __destroy_compound_gigantic_page() did: > > > > > > set_compound_order(page, 0); > > > #ifdef CONFIG_64BIT > > > page[1].compound_nr = 0; > > > #endif > > > > > > as part of dissolving the page. My goal for this patch was to create > > > a function that would encapsulate that segment of code with a single > > > call of folio_set_compound_order(folio, 0). set_compound_order() > > > does not set compound_nr to 0 when 0 is passed in to the order > > > argument so explicitly setting it is required. I don't think a > > > separate dissolve_large_folio() function for the hugetlb case is > > > needed as __destroy_compound_gigantic_folio() is pretty concise as > > > it is. > > > > > > > Instead of "this is abusing function X()" comments, we should prefer > > well-named functions that do something understandable. And you can get > > that by noticing that folio_set_compound_order() collapses down to > > nearly nothing in the special "order 0" case. So just inline that code > > directly into __destroy_compound_gigantic_folio(), taking a moment to > > fill in and consolidate the CONFIG_64BIT missing parts in mm.h. > > > > And now you can get rid of this cruft and "abuse" comment, and instead > > just end up with two simple lines of code that are crystal clear--as > > they should be, in a "__destroy" function. Like this: > > > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 105878936485..cf227ed00945 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -1754,6 +1754,7 @@ static inline void set_page_links(struct page > > *page, enum zone_type zone, > > #endif > > } > > > > +#ifdef CONFIG_64BIT > > /** > > * folio_nr_pages - The number of pages in the folio. > > * @folio: The folio. > > @@ -1764,13 +1765,32 @@ static inline long folio_nr_pages(struct folio > > *folio) > > { > > if (!folio_test_large(folio)) > > return 1; > > -#ifdef CONFIG_64BIT > > return folio->_folio_nr_pages; > > +} > > + > > +static inline void folio_set_nr_pages(struct folio *folio, long nr_pages) > > +{ > > + folio->_folio_nr_pages = nr_pages; > > +} > > #else > > +/** > > + * folio_nr_pages - The number of pages in the folio. > > + * @folio: The folio. > > + * > > + * Return: A positive power of two. > > + */ > > +static inline long folio_nr_pages(struct folio *folio) > > +{ > > + if (!folio_test_large(folio)) > > + return 1; > > return 1L << folio->_folio_order; > > -#endif > > } > > > > +static inline void folio_set_nr_pages(struct folio *folio, long nr_pages) > > +{ > > +} > > +#endif > > + > > /** > > * folio_next - Move to the next physical folio. > > * @folio: The folio we're currently operating on. > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > index e3500c087893..b507a98063e6 100644 > > --- a/mm/hugetlb.c > > +++ b/mm/hugetlb.c > > @@ -1344,7 +1344,8 @@ static void > > __destroy_compound_gigantic_folio(struct folio *folio, > > set_page_refcounted(p); > > } > > > > - folio_set_compound_order(folio, 0); > > + folio->_folio_order = 0; > > + folio_set_nr_pages(folio, 0); > > __folio_clear_head(folio); > > } > > > > > > Yes? > > This works for me, I will take this approach along with Muchun's feedback > about a wrapper function so as not to touch _folio_order directly and send > out a new version. > > One question I have is if I should then get rid of > folio_set_compound_order() as hugetlb is the only compound page user I've > converted to folios so far and its use can be replaced by the suggested > folio_set_nr_pages() and folio_set_order(). > > Hugetlb also has one has one call to folio_set_compound_order() with a > non-zero order, should I replace this with a call to folio_set_order() and > folio_set_nr_pages() as well, or keep folio_set_compound_order() and remove > zero order support and the comment. Please let me know which approach you > would prefer. My opinion ... which is often wrong :) I agree 100% with John about these being clear and understandable routines, as well as Muchun's comment about the need for an interface for setting _folio_order instead of accessing directly. However, I do have some concern about two independent interfaces for setting _folio_order and _folio_nr_pages. These two fields really do need to be "in sync" and having two interfaces to modify independently may lead to errors. Any thoughts Matthew? You introduced folios as well as the somewhat redundant compound_nr/_folio_nr_pages fields. Here is another thought. Since this discussion started with a question about "Can/should you really pass a zero order to folio_set_compound_order?", what about a separate "folio_clear_order" interface? We would then have: folio_set_order() /* passed non-zero order when creating large folio */ folio_clear_order() /* zero order is implied */ Note that I did drop 'compound' from the names. The more I think about the folio direction we really should not use compound in the same. Both of these could wrap a renamed version of Sidhartha's routine folio_set_compound_order(). In this way the two fields are automatically kept in sync. Again, just my thoughts/opinion.
On Thu, Dec 08, 2022 at 10:06:07AM -0800, Sidhartha Kumar wrote: > On 12/7/22 6:27 PM, John Hubbard wrote: > > On 12/7/22 17:42, Sidhartha Kumar wrote: > > > > Wouldn't it be better to instead just create a new function for that > > > > case, such as: > > > > > > > > dissolve_large_folio() > > > > > > > > > > Prior to the folio conversion, the helper function > > > __destroy_compound_gigantic_page() did: > > > > > > set_compound_order(page, 0); > > > #ifdef CONFIG_64BIT > > > page[1].compound_nr = 0; > > > #endif > > > > > > as part of dissolving the page. My goal for this patch was to create > > > a function that would encapsulate that segment of code with a single > > > call of folio_set_compound_order(folio, 0). set_compound_order() > > > does not set compound_nr to 0 when 0 is passed in to the order > > > argument so explicitly setting it is required. I don't think a > > > separate dissolve_large_folio() function for the hugetlb case is > > > needed as __destroy_compound_gigantic_folio() is pretty concise as > > > it is. > > > > > > > Instead of "this is abusing function X()" comments, we should prefer > > well-named functions that do something understandable. And you can get > > that by noticing that folio_set_compound_order() collapses down to > > nearly nothing in the special "order 0" case. So just inline that code > > directly into __destroy_compound_gigantic_folio(), taking a moment to > > fill in and consolidate the CONFIG_64BIT missing parts in mm.h. > > > > And now you can get rid of this cruft and "abuse" comment, and instead > > just end up with two simple lines of code that are crystal clear--as > > they should be, in a "__destroy" function. Like this: > > > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 105878936485..cf227ed00945 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -1754,6 +1754,7 @@ static inline void set_page_links(struct page > > *page, enum zone_type zone, > > #endif > > } > > > > +#ifdef CONFIG_64BIT > > /** > > * folio_nr_pages - The number of pages in the folio. > > * @folio: The folio. > > @@ -1764,13 +1765,32 @@ static inline long folio_nr_pages(struct folio > > *folio) > > { > > if (!folio_test_large(folio)) > > return 1; > > -#ifdef CONFIG_64BIT > > return folio->_folio_nr_pages; > > +} > > + > > +static inline void folio_set_nr_pages(struct folio *folio, long nr_pages) > > +{ > > + folio->_folio_nr_pages = nr_pages; > > +} > > #else > > +/** > > + * folio_nr_pages - The number of pages in the folio. > > + * @folio: The folio. > > + * > > + * Return: A positive power of two. > > + */ > > +static inline long folio_nr_pages(struct folio *folio) > > +{ > > + if (!folio_test_large(folio)) > > + return 1; > > return 1L << folio->_folio_order; > > -#endif > > } > > > > +static inline void folio_set_nr_pages(struct folio *folio, long nr_pages) > > +{ > > +} > > +#endif > > + > > /** > > * folio_next - Move to the next physical folio. > > * @folio: The folio we're currently operating on. > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > index e3500c087893..b507a98063e6 100644 > > --- a/mm/hugetlb.c > > +++ b/mm/hugetlb.c > > @@ -1344,7 +1344,8 @@ static void > > __destroy_compound_gigantic_folio(struct folio *folio, > > set_page_refcounted(p); > > } > > > > - folio_set_compound_order(folio, 0); > > + folio->_folio_order = 0; > > + folio_set_nr_pages(folio, 0); > > __folio_clear_head(folio); > > } > > > > > > Yes? > > This works for me, I will take this approach along with Muchun's feedback > about a wrapper function so as not to touch _folio_order directly and send > out a new version. > > One question I have is if I should then get rid of > folio_set_compound_order() as hugetlb is the only compound page user I've > converted to folios so far and its use can be replaced by the suggested > folio_set_nr_pages() and folio_set_order(). > > Hugetlb also has one has one call to folio_set_compound_order() with a > non-zero order, should I replace this with a call to folio_set_order() and > folio_set_nr_pages() as well, or keep folio_set_compound_order() and remove > zero order support and the comment. Please let me know which approach you > would prefer. None of the above! Whatever we're calling this function *it does not belong* in mm.h. Anything outside the MM calling it is going to be a disaster -- can you imagine what will happen if a filesystem or device driver is handed a folio and decides "Oh, I'll just change the size of this folio"? It is an attractive nuisance and should be confined to mm/internal.h *at best*. Equally, we *must not have* separate folio_set_order() and folio_set_nr_pages(). These are the same thing! They must be kept in sync! If we are to have a folio_set_order() instead of open-coding it, then it should also update nr_pages. So, given that this is now an internal-to-mm, if not internal-to-hugetlb function, I see no reason that it should not handle the case of 0. I haven't studied what hugetlb_dissolve does, or why it can't use the standard split_folio(), but I'm sure there's a good reason.
On 12/8/22 11:33, Matthew Wilcox wrote: > None of the above! > > Whatever we're calling this function *it does not belong* in mm.h. > Anything outside the MM calling it is going to be a disaster -- can you > imagine what will happen if a filesystem or device driver is handed a > folio and decides "Oh, I'll just change the size of this folio"? It is > an attractive nuisance and should be confined to mm/internal.h *at best*. > > Equally, we *must not have* separate folio_set_order() and > folio_set_nr_pages(). These are the same thing! They must be kept > in sync! If we are to have a folio_set_order() instead of open-coding > it, then it should also update nr_pages. > > So, given that this is now an internal-to-mm, if not internal-to-hugetlb > function, I see no reason that it should not handle the case of 0. > I haven't studied what hugetlb_dissolve does, or why it can't use the > standard split_folio(), but I'm sure there's a good reason. Sure, perhaps I overreacted to the "abuse of this function" comment, and the whole thing could be fixed up with a clean name, hiding it from the public mm.h API, and...removing comments about abuse! haha :) thanks,
On 12/08/22 19:33, Matthew Wilcox wrote: > On Thu, Dec 08, 2022 at 10:06:07AM -0800, Sidhartha Kumar wrote: > > On 12/7/22 6:27 PM, John Hubbard wrote: > > > On 12/7/22 17:42, Sidhartha Kumar wrote: > > This works for me, I will take this approach along with Muchun's feedback > > about a wrapper function so as not to touch _folio_order directly and send > > out a new version. > > > > One question I have is if I should then get rid of > > folio_set_compound_order() as hugetlb is the only compound page user I've > > converted to folios so far and its use can be replaced by the suggested > > folio_set_nr_pages() and folio_set_order(). > > > > Hugetlb also has one has one call to folio_set_compound_order() with a > > non-zero order, should I replace this with a call to folio_set_order() and > > folio_set_nr_pages() as well, or keep folio_set_compound_order() and remove > > zero order support and the comment. Please let me know which approach you > > would prefer. > > None of the above! > > Whatever we're calling this function *it does not belong* in mm.h. > Anything outside the MM calling it is going to be a disaster -- can you > imagine what will happen if a filesystem or device driver is handed a > folio and decides "Oh, I'll just change the size of this folio"? It is > an attractive nuisance and should be confined to mm/internal.h *at best*. I suspect it was placed in mm.h as it is the 'folio version' of set_compound_order which resides in mm.h. But, no need to repeat that unfortunate placement. > > Equally, we *must not have* separate folio_set_order() and > folio_set_nr_pages(). These are the same thing! They must be kept > in sync! If we are to have a folio_set_order() instead of open-coding > it, then it should also update nr_pages. Ok. Agree. > So, given that this is now an internal-to-mm, if not internal-to-hugetlb > function, I see no reason that it should not handle the case of 0. > I haven't studied what hugetlb_dissolve does, or why it can't use the > standard split_folio(), but I'm sure there's a good reason. The hugetlb code is changing the compound page/folio it created from a set of individual pages back to individual pages so they can be returned to the low level allocator. Somewhat like what page_alloc/page_free do. split_folio is overkill. split_page would be a closer match. It makes perfect sense to put the function in mm internal.h. Thanks,
On 12/8/22 12:01 PM, Mike Kravetz wrote: > On 12/08/22 19:33, Matthew Wilcox wrote: >> On Thu, Dec 08, 2022 at 10:06:07AM -0800, Sidhartha Kumar wrote: >>> On 12/7/22 6:27 PM, John Hubbard wrote: >>>> On 12/7/22 17:42, Sidhartha Kumar wrote: >>> This works for me, I will take this approach along with Muchun's feedback >>> about a wrapper function so as not to touch _folio_order directly and send >>> out a new version. >>> >>> One question I have is if I should then get rid of >>> folio_set_compound_order() as hugetlb is the only compound page user I've >>> converted to folios so far and its use can be replaced by the suggested >>> folio_set_nr_pages() and folio_set_order(). >>> >>> Hugetlb also has one has one call to folio_set_compound_order() with a >>> non-zero order, should I replace this with a call to folio_set_order() and >>> folio_set_nr_pages() as well, or keep folio_set_compound_order() and remove >>> zero order support and the comment. Please let me know which approach you >>> would prefer. >> >> None of the above! >> >> Whatever we're calling this function *it does not belong* in mm.h. >> Anything outside the MM calling it is going to be a disaster -- can you >> imagine what will happen if a filesystem or device driver is handed a >> folio and decides "Oh, I'll just change the size of this folio"? It is >> an attractive nuisance and should be confined to mm/internal.h *at best*. > > I suspect it was placed in mm.h as it is the 'folio version' of > set_compound_order which resides in mm.h. But, no need to repeat that > unfortunate placement. > >> >> Equally, we *must not have* separate folio_set_order() and >> folio_set_nr_pages(). These are the same thing! They must be kept >> in sync! If we are to have a folio_set_order() instead of open-coding >> it, then it should also update nr_pages. > > Ok. Agree. > >> So, given that this is now an internal-to-mm, if not internal-to-hugetlb >> function, I see no reason that it should not handle the case of 0. >> I haven't studied what hugetlb_dissolve does, or why it can't use the >> standard split_folio(), but I'm sure there's a good reason. > > The hugetlb code is changing the compound page/folio it created from a set of > individual pages back to individual pages so they can be returned to the > low level allocator. Somewhat like what page_alloc/page_free do. split_folio > is overkill. split_page would be a closer match. > > It makes perfect sense to put the function in mm internal.h. > Thanks John, Mike, Matthew, and Muchun for the feedback. To summarize this discussion and outline the next version of this patch, the changes I'll make include: 1) change the name of folio_set_compound_order() to folio_set_order() 2) change the placement of this function from mm.h to mm/internal.h 3) folio_set_order() will set both _folio_order and _folio_nr_pages and handle the zero order case correctly. 4) remove the comment about hugetlb's specific use for zero orders 5) improve the style of folio_set_order() by removing ifdefs from inside the function to doing #ifdef CONFIG_64BIT static inline void folio_set_order(struct folio *folio, unsigned int order) { VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); folio->_folio_order = order; folio->_folio_nr_pages = order ? 1U << order : 0; } #else static inline void folio_set_order(struct folio *folio, unsigned int order) { VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); folio->_folio_order = order; } #endif Please let me know if I missing something. Thanks, Sidhartha Kumar > Thanks,
On 12/8/22 13:58, Sidhartha Kumar wrote: > Thanks John, Mike, Matthew, and Muchun for the feedback. > > To summarize this discussion and outline the next version of this patch, the changes I'll make include: > > 1) change the name of folio_set_compound_order() to folio_set_order() > 2) change the placement of this function from mm.h to mm/internal.h > 3) folio_set_order() will set both _folio_order and _folio_nr_pages and handle the zero order case correctly. > 4) remove the comment about hugetlb's specific use for zero orders > 5) improve the style of folio_set_order() by removing ifdefs from inside the function to doing > > #ifdef CONFIG_64BIT > static inline void folio_set_order(struct folio *folio, > unsigned int order) > { > VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); Sounds good, except for this part: why is a function named folio_set_order() BUG-ing on a non-large folio? The naming is still wrong, perhaps? > > folio->_folio_order = order; > folio->_folio_nr_pages = order ? 1U << order : 0; > } > #else > static inline void folio_set_order(struct folio *folio, > unsigned int order) > { > VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); > > folio->_folio_order = order; > } > #endif > > Please let me know if I missing something. > Thanks, > Sidhartha Kumar >> Thanks, > thanks,
On Thu, Dec 08, 2022 at 01:58:20PM -0800, Sidhartha Kumar wrote: > 5) improve the style of folio_set_order() by removing ifdefs from inside the > function to doing > > #ifdef CONFIG_64BIT > static inline void folio_set_order(struct folio *folio, > unsigned int order) > { > VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); > > folio->_folio_order = order; > folio->_folio_nr_pages = order ? 1U << order : 0; > } > #else > static inline void folio_set_order(struct folio *folio, > unsigned int order) > { > VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); > > folio->_folio_order = order; > } > #endif While we usually prefer to put ifdefs outside the function, I don't think that's justified in this case. I'd rather see a comment inside the function like: static inline void folio_set_order(struct folio *folio, unsigned int order) { VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); 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 }
On 12/8/22 2:01 PM, John Hubbard wrote: > On 12/8/22 13:58, Sidhartha Kumar wrote: >> Thanks John, Mike, Matthew, and Muchun for the feedback. >> >> To summarize this discussion and outline the next version of this >> patch, the changes I'll make include: >> >> 1) change the name of folio_set_compound_order() to folio_set_order() >> 2) change the placement of this function from mm.h to mm/internal.h >> 3) folio_set_order() will set both _folio_order and _folio_nr_pages >> and handle the zero order case correctly. >> 4) remove the comment about hugetlb's specific use for zero orders >> 5) improve the style of folio_set_order() by removing ifdefs from >> inside the function to doing >> >> #ifdef CONFIG_64BIT >> static inline void folio_set_order(struct folio *folio, >> unsigned int order) >> { >> VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); > > Sounds good, except for this part: why is a function named > folio_set_order() BUG-ing on a non-large folio? The naming > is still wrong, perhaps? > This is because the _folio_nr_pages and _folio_order fields are part of the first tail page in the folio. folio_test_large returns if the folio is larger than one page which would be required for setting the fields. >> >> folio->_folio_order = order; >> folio->_folio_nr_pages = order ? 1U << order : 0; >> } >> #else >> static inline void folio_set_order(struct folio *folio, >> unsigned int order) >> { >> VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); >> >> folio->_folio_order = order; >> } >> #endif >> >> Please let me know if I missing something. >> Thanks, >> Sidhartha Kumar >>> Thanks, >> > > thanks,
On 12/8/22 14:12, Sidhartha Kumar wrote: > On 12/8/22 2:01 PM, John Hubbard wrote: >> On 12/8/22 13:58, Sidhartha Kumar wrote: >>> Thanks John, Mike, Matthew, and Muchun for the feedback. >>> >>> To summarize this discussion and outline the next version of this patch, the changes I'll make include: >>> >>> 1) change the name of folio_set_compound_order() to folio_set_order() >>> 2) change the placement of this function from mm.h to mm/internal.h >>> 3) folio_set_order() will set both _folio_order and _folio_nr_pages and handle the zero order case correctly. >>> 4) remove the comment about hugetlb's specific use for zero orders >>> 5) improve the style of folio_set_order() by removing ifdefs from inside the function to doing >>> >>> #ifdef CONFIG_64BIT >>> static inline void folio_set_order(struct folio *folio, >>> unsigned int order) >>> { >>> VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); >> >> Sounds good, except for this part: why is a function named >> folio_set_order() BUG-ing on a non-large folio? The naming >> is still wrong, perhaps? >> > > This is because the _folio_nr_pages and _folio_order fields are part of the first tail page in the folio. folio_test_large returns if the folio is larger than one page which would be required for setting the fields. OK, but then as I said, the name is wrong. One can either: a) handle the non-large case, or b) rename the function to indicate that it only works on large folios. thanks,
On 12/8/22 2:14 PM, John Hubbard wrote: > On 12/8/22 14:12, Sidhartha Kumar wrote: >> On 12/8/22 2:01 PM, John Hubbard wrote: >>> On 12/8/22 13:58, Sidhartha Kumar wrote: >>>> Thanks John, Mike, Matthew, and Muchun for the feedback. >>>> >>>> To summarize this discussion and outline the next version of this >>>> patch, the changes I'll make include: >>>> >>>> 1) change the name of folio_set_compound_order() to folio_set_order() >>>> 2) change the placement of this function from mm.h to mm/internal.h >>>> 3) folio_set_order() will set both _folio_order and _folio_nr_pages >>>> and handle the zero order case correctly. >>>> 4) remove the comment about hugetlb's specific use for zero orders >>>> 5) improve the style of folio_set_order() by removing ifdefs from >>>> inside the function to doing >>>> >>>> #ifdef CONFIG_64BIT >>>> static inline void folio_set_order(struct folio *folio, >>>> unsigned int order) >>>> { >>>> VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); >>> >>> Sounds good, except for this part: why is a function named >>> folio_set_order() BUG-ing on a non-large folio? The naming >>> is still wrong, perhaps? >>> >> >> This is because the _folio_nr_pages and _folio_order fields are part >> of the first tail page in the folio. folio_test_large returns if the >> folio is larger than one page which would be required for setting the >> fields. > > OK, but then as I said, the name is wrong. One can either: > > a) handle the non-large case, or > > b) rename the function to indicate that it only works on large folios. > Discussed here[1], the BUG_ON line seemed more appropriate over if (!folio_test_large(folio)) return; as the misuse would not be silent. I think I would be against renaming the function as I don't see any large folio specific function names for other accessors of tail page fields. Would both the BUG_ON and return on non-large folio be included then? [1]: https://lore.kernel.org/linux-mm/20221129225039.82257-1-sidhartha.kumar@oracle.com/T/#m98cf80bb21ae533b7385f2e363c602e2c9e2802d > > thanks,
On 12/8/22 14:33, Sidhartha Kumar wrote: > On 12/8/22 2:14 PM, John Hubbard wrote: >> On 12/8/22 14:12, Sidhartha Kumar wrote: >>> On 12/8/22 2:01 PM, John Hubbard wrote: >>>> On 12/8/22 13:58, Sidhartha Kumar wrote: >>>>> Thanks John, Mike, Matthew, and Muchun for the feedback. >>>>> >>>>> To summarize this discussion and outline the next version of this patch, the changes I'll make include: >>>>> >>>>> 1) change the name of folio_set_compound_order() to folio_set_order() >>>>> 2) change the placement of this function from mm.h to mm/internal.h >>>>> 3) folio_set_order() will set both _folio_order and _folio_nr_pages and handle the zero order case correctly. >>>>> 4) remove the comment about hugetlb's specific use for zero orders >>>>> 5) improve the style of folio_set_order() by removing ifdefs from inside the function to doing >>>>> >>>>> #ifdef CONFIG_64BIT >>>>> static inline void folio_set_order(struct folio *folio, >>>>> unsigned int order) >>>>> { >>>>> VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); >>>> >>>> Sounds good, except for this part: why is a function named >>>> folio_set_order() BUG-ing on a non-large folio? The naming >>>> is still wrong, perhaps? >>>> >>> >>> This is because the _folio_nr_pages and _folio_order fields are part of the first tail page in the folio. folio_test_large returns if the folio is larger than one page which would be required for setting the fields. >> >> OK, but then as I said, the name is wrong. One can either: >> >> a) handle the non-large case, or >> >> b) rename the function to indicate that it only works on large folios. >> > > Discussed here[1], the BUG_ON line seemed more appropriate over > > if (!folio_test_large(folio)) > return; > > as the misuse would not be silent. I think I would be against renaming the function as I don't see any large folio specific function names for other accessors of tail page fields. Would both the BUG_ON and return on non-large folio be included then? Actually, if you want the "misuse to not be silent", today's guidelines would point more toward WARN and return, instead of BUG, btw. I don't think that a survey of existing names is really the final word on what to name this. Names should be accurate, even if other names are less so. How about something like: large_folio_set_order() ? > > > [1]: https://lore.kernel.org/linux-mm/20221129225039.82257-1-sidhartha.kumar@oracle.com/T/#m98cf80bb21ae533b7385f2e363c602e2c9e2802d >> >> thanks, > > thanks,
> On Dec 9, 2022, at 06:39, John Hubbard <jhubbard@nvidia.com> wrote: > > On 12/8/22 14:33, Sidhartha Kumar wrote: >> On 12/8/22 2:14 PM, John Hubbard wrote: >>> On 12/8/22 14:12, Sidhartha Kumar wrote: >>>> On 12/8/22 2:01 PM, John Hubbard wrote: >>>>> On 12/8/22 13:58, Sidhartha Kumar wrote: >>>>>> Thanks John, Mike, Matthew, and Muchun for the feedback. >>>>>> >>>>>> To summarize this discussion and outline the next version of this patch, the changes I'll make include: >>>>>> >>>>>> 1) change the name of folio_set_compound_order() to folio_set_order() >>>>>> 2) change the placement of this function from mm.h to mm/internal.h >>>>>> 3) folio_set_order() will set both _folio_order and _folio_nr_pages and handle the zero order case correctly. >>>>>> 4) remove the comment about hugetlb's specific use for zero orders >>>>>> 5) improve the style of folio_set_order() by removing ifdefs from inside the function to doing >>>>>> >>>>>> #ifdef CONFIG_64BIT >>>>>> static inline void folio_set_order(struct folio *folio, >>>>>> unsigned int order) >>>>>> { >>>>>> VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); >>>>> >>>>> Sounds good, except for this part: why is a function named >>>>> folio_set_order() BUG-ing on a non-large folio? The naming >>>>> is still wrong, perhaps? >>>>> >>>> >>>> This is because the _folio_nr_pages and _folio_order fields are part of the first tail page in the folio. folio_test_large returns if the folio is larger than one page which would be required for setting the fields. >>> >>> OK, but then as I said, the name is wrong. One can either: >>> >>> a) handle the non-large case, or >>> >>> b) rename the function to indicate that it only works on large folios. >>> >> Discussed here[1], the BUG_ON line seemed more appropriate over >> if (!folio_test_large(folio)) >> return; >> as the misuse would not be silent. I think I would be against renaming the function as I don't see any large folio specific function names for other accessors of tail page fields. Would both the BUG_ON and return on non-large folio be included then? > > Actually, if you want the "misuse to not be silent", today's guidelines > would point more toward WARN and return, instead of BUG, btw. From you advise, I think we can remove VM_BUG_ON and handle non-zero order page, something like: static inline void folio_set_order(struct folio *folio, unsigned int order) { if (!folio_test_large(folio)) { WARN_ON(order); return; } folio->_folio_order = order; #ifdef CONFIG_64BIT folio->_folio_nr_pages = order ? 1U << order : 0; #endif } In this case, 1) we can handle both non-zero and zero (folio_order() works as well for this case) order page. 2) it can prevent OOB for non-large folio and warn unexpected users. 3) Do not BUG. 4) No need to rename folio_set_order. What do you think? Thanks. > > I don't think that a survey of existing names is really the final word on what > to name this. Names should be accurate, even if other names are less so. How > about something like: > > large_folio_set_order() > > ? > >> [1]: https://lore.kernel.org/linux-mm/20221129225039.82257-1-sidhartha.kumar@oracle.com/T/#m98cf80bb21ae533b7385f2e363c602e2c9e2802d >>> >>> thanks, > > thanks, > -- > John Hubbard > NVIDIA
On 12/9/22 06:27, Muchun Song wrote: > From you advise, I think we can remove VM_BUG_ON and handle non-zero > order page, something like: Yes, and thanks for summarizing all the individual feedback into a proposed solution. If we go this route, then I'd suggest a little note above the function, such as: /* * For non-large folios, this will have no effect, other than possibly * generating a warning, if the caller attempts to set a non-zero folio order * for a non-large folio. */ > static inline void folio_set_order(struct folio *folio, > unsigned int order) > { > if (!folio_test_large(folio)) { > WARN_ON(order); Better make that a WARN_ON_ONCE(), to avoid taking the machine down with excessive warnings in the log. > return; > } > > folio->_folio_order = order; > #ifdef CONFIG_64BIT > folio->_folio_nr_pages = order ? 1U << order : 0; > #endif > } > > In this case, > > 1) we can handle both non-zero and zero (folio_order() works as well > for this case) order page. > 2) it can prevent OOB for non-large folio and warn unexpected users. > 3) Do not BUG. > 4) No need to rename folio_set_order. > > What do you think? If the new behavior is OK with everyone, it seems good to me. thanks,
On 12/9/22 13:10, John Hubbard wrote: > On 12/9/22 06:27, Muchun Song wrote: >> From you advise, I think we can remove VM_BUG_ON and handle non-zero >> order page, something like: > > Yes, and thanks for summarizing all the individual feedback into a > proposed solution. > > If we go this route, then I'd suggest a little note above the function, > such as: > > /* > * For non-large folios, this will have no effect, other than possibly > * generating a warning, if the caller attempts to set a non-zero folio order > * for a non-large folio. > */ > >> static inline void folio_set_order(struct folio *folio, >> unsigned int order) >> { >> if (!folio_test_large(folio)) { >> WARN_ON(order); Although, on second thought...I'm still a little confused about why keeping the same name is so important? A very direct approach that has more accurate naming (and therefore no need for a strange comment explaining the behavior) would be: static inline void large_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 folio->_folio_nr_pages = order ? 1U << order : 0; #endif } thanks,
> On Dec 10, 2022, at 05:20, John Hubbard <jhubbard@nvidia.com> wrote: > > On 12/9/22 13:10, John Hubbard wrote: >> On 12/9/22 06:27, Muchun Song wrote: >>> From you advise, I think we can remove VM_BUG_ON and handle non-zero >>> order page, something like: >> Yes, and thanks for summarizing all the individual feedback into a >> proposed solution. >> If we go this route, then I'd suggest a little note above the function, >> such as: >> /* >> * For non-large folios, this will have no effect, other than possibly >> * generating a warning, if the caller attempts to set a non-zero folio order >> * for a non-large folio. >> */ >>> static inline void folio_set_order(struct folio *folio, >>> unsigned int order) >>> { >>> if (!folio_test_large(folio)) { >>> WARN_ON(order); > > Although, on second thought...I'm still a little confused about why > keeping the same name is so important? Just my personal preference. I like its simplicity. I'm not against large_folio_set_order, but suggest folio_set_order. Thanks. > > A very direct approach that has more accurate naming (and therefore no > need for a strange comment explaining the behavior) would be: > > > static inline void large_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 > folio->_folio_nr_pages = order ? 1U << order : 0; > #endif > } > > > thanks, > -- > John Hubbard > NVIDIA
diff --git a/include/linux/mm.h b/include/linux/mm.h index 443d496949a8..cd8508d728f1 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -999,9 +999,16 @@ 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;