Message ID | 20221129225039.82257-2-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 q4csp607451wrr; Tue, 29 Nov 2022 14:52:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf4ao90bRAuCZy3uH+T0p2JXom12JAjrY9mVCC5uuYDzNZVOj1sYc+r/uVs6FJ9+1MIyiz2L X-Received: by 2002:a62:4e06:0:b0:575:4ab0:f360 with SMTP id c6-20020a624e06000000b005754ab0f360mr9956280pfb.2.1669762343141; Tue, 29 Nov 2022 14:52:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669762343; cv=pass; d=google.com; s=arc-20160816; b=dJ/3ax3H60lxGvV5UFsIbLw+rzHmmllIANLDmYybEUywSzUgCw88S8e1oXvHs34cWa 8w9sGwHemwt5rxVP84xbVZj/IPtx+i1miZv4CcYXp57J5rR7yBBCeRqYDkFv+wxe2t/q rnpSipXPX4lTx7/slfPkNn+Q9lz1BDmCKpX1YVgTq43hczv20HtTzrk5ho3vInZIYyoQ mVfnfc2QHk4IKm64SjYmJMcaNKo8VYKFI/0Gw2B2N+KJvVq3OEvV/YR6loCAceObeO4U YvFufajBpXTyadKKpO/RJ2cGUzMJgdwz8+UUyNyZdPp5XorYXBECFL9aPQEgQcXBtTkR 2iyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=tGmuZTBNbre96NHUK8JjH0uovdu0VRYw1Si/RwfIyuI=; b=LcqGBxX/kAlJ5ZIsDxgJWPPR5SYeoem3+wGlQnYQIC4e4FUtUsK1D1jYZlbl/WeRPL lXjOF7J8eoZzM1mDYKVOqc5rZX/L0aUvVfvOqMmZ1sbQtQSXtZur824+9ila6uDy31Dn DjdB52BoVtburaBpU+hEDFPm59uDTpPh+pT4ibk+ip2Q4z9ey1CLqeVeML0mQZvakDMr FP7IwTcOAafzG2NUtEVLGMdMpo4zIGpGyrucBcI3ihg4Vl9tfSMo6rZk16MfSFWLaUjq Z4zcgSdaUaB2Wu7j+P5I0SNMWjh0YllRKyE8K/T6smZdqTTKigsIu6saIA04OiZNKM4k n3DQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2022-7-12 header.b=mq0c2fsL; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=btFQdzpr; 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 z5-20020a170903018500b00179c921918esi17873251plg.17.2022.11.29.14.52.10; Tue, 29 Nov 2022 14:52:23 -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=mq0c2fsL; dkim=pass header.i=@oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=btFQdzpr; 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 S236962AbiK2WvP (ORCPT <rfc822;rbbytesnap@gmail.com> + 99 others); Tue, 29 Nov 2022 17:51:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235957AbiK2WvK (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 29 Nov 2022 17:51:10 -0500 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DFFC1EEC3 for <linux-kernel@vger.kernel.org>; Tue, 29 Nov 2022 14:51:08 -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 2ATMDsOP015137; Tue, 29 Nov 2022 22:50:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2022-7-12; bh=tGmuZTBNbre96NHUK8JjH0uovdu0VRYw1Si/RwfIyuI=; b=mq0c2fsLy5cLmwupFkkaJnXjfa9zYMBaPrg9037SbEnDUQm5rgzI2/7j5eNjp/MHBPiz hKih/AB/PB2+3P06ke4/tKubolti4/ej10YLGGc1UxBuye0eLkv1qscxo5ZFmYCoZY/c bqLyyPf7dT/9WxPRU/p8wf1c2giUrVviXdyKDX+1b0mu7M7K9Nbd6DvrpdFV7f7MKODP V7Os2IPnOpkRB8Mp7JrBcJmlWz8Y2DYXrPKsf5ivZ1mp2T5j5d4H2MOp5KHb1JOvDX8M YrUUJ2eZH0ZE4LzrSp8L5w22L8owWxO1orgjkwuxNg0NCcs3ZR4++QTpI86PokU6wySA XQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3m4aemepjm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Nov 2022 22:50:46 +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 2ATLF0FH027905; Tue, 29 Nov 2022 22:50:46 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3m39881gmu-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Nov 2022 22:50:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U26riPB8rzpZD/mVj7xcQmCmmSme7gVs69ABJoz1+o4R3aGcIu+MQAWe3AhA0Jhb6BiwoCL+dB++cLpwj63JUes3P5oCh7OR1MHyd+ynco/o3btc85rVbt4PS1ub/qZ3/n3tWKw7i7CG+0XEjsn0WE/zkPJz3s89UVPHxKTvZqUPdWUoxVnH9WRUlsAoi4uSm6KU/stYb48HbsZTx3kBxOXCbSfet8iy6qPKLrSxnQNbkFRWCIE2hGgQPFZToXYBn0PbSaRGQiyVv+pJqN8+HzDCPz32rcyvltKVGeCx9Upg6JS+fArGEOUh4mlMLvJF+ngFof1TjNRrie3G29lzow== 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=tGmuZTBNbre96NHUK8JjH0uovdu0VRYw1Si/RwfIyuI=; b=krEfZmyNKJ4y+YokliQLhMoy4CU8y8x2XxulJtlPdxz8zo3eyCHBJKTqt4aR+EhN4Ox2dD6QhERmODSWCUce3RuGJRcOMBQouCXpaEd+q1mP3BK4N9TcLiY6x/5Zcv0MnKXsmLv6iFc5XmxVdRctrX8UNFn2xA4dw59YIcdMzG3x+qZe2BUwYAR42Zv8Zd5iiUnRazk5slUIlDI0HNKBYxRlglDm45aJhw1lgyyN528WWueOWLEW0ra22w/2PTvpbkzHL4XMEucn9Qwv7pIjv8RgOP2I7NrM0bQ5VHJ9NKH8Rb2b0ZV29YVUiLwX7QSUkWkLl+KSVu0JYJ3FMEFjqg== 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=tGmuZTBNbre96NHUK8JjH0uovdu0VRYw1Si/RwfIyuI=; b=btFQdzpreugE1+lrF25lSUv340mhxEHm9tpb512aC8S0k1OadUrQ5014mIQeTYgcKPW7KqiaE6KMnqbiUuKWLTg1uTZS6eg1TvfV19fYu2+caURdxoXE1lZavY00nvarju9C21O5cN5m/+RdJTk8LCdCGVDgRrq5NeTEzPvlOao= Received: from CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) by CO6PR10MB5586.namprd10.prod.outlook.com (2603:10b6:303:145::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.23; Tue, 29 Nov 2022 22:50:44 +0000 Received: from CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954]) by CH0PR10MB5113.namprd10.prod.outlook.com ([fe80::3702:7db0:8917:9954%5]) with mapi id 15.20.5857.023; Tue, 29 Nov 2022 22:50:44 +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, almasrymina@google.com, linmiaohe@huawei.com, hughd@google.com, tsahu@linux.ibm.com, jhubbard@nvidia.com, david@redhat.com, Sidhartha Kumar <sidhartha.kumar@oracle.com> Subject: [PATCH mm-unstable v5 01/10] mm: add folio dtor and order setter functions Date: Tue, 29 Nov 2022 14:50:30 -0800 Message-Id: <20221129225039.82257-2-sidhartha.kumar@oracle.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221129225039.82257-1-sidhartha.kumar@oracle.com> References: <20221129225039.82257-1-sidhartha.kumar@oracle.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: CH0PR03CA0397.namprd03.prod.outlook.com (2603:10b6:610:11b::30) To CH0PR10MB5113.namprd10.prod.outlook.com (2603:10b6:610:c9::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR10MB5113:EE_|CO6PR10MB5586:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c488c91-f80a-409b-e44f-08dad25c25c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4tVBZRxKrWWNI02ikFOjc22TlbxwdcGSSV8d+RCfoqU2sMGnUcWiO9ceXTvmzjHZ8AsGevv2FlXUuFkSIpuaP8cvvvEBFdjkzPEy415g65KHjN45v8kOdeSnb0hBWJuRDsjIWoitIyqZSWbYV0hrSVpm94iZu90rh/9i5giSB/EEtQACElPL8gcJJfybjiUCs4htToDQFETRcuyKYPJtVSIqUscfozxjxEzyBOwbpuJHjd6oQF1jt3hhvY84ZB2tackTbXbzZxuaaLbZRxIUE+eRcGcEUwcLqZ5Iuetaa69WeaAzorWOZoFv9ERTgX1UoZQpcT5w3WXP57pwMsjnZWf3LA2Ifl2kBYfQXe64itfmDCqY0K2FNz3oxsicEsdWN5sANGolyCJEskz1OtNwUHiyX197Pk0ZyDhVK94YHzZl0G94M7iUG3aVCwHt0FD7xEV31QLJ+hW5EmZ+V/qkpdq8nSZLxBT8aJ//M36M+GW0lTQgvZMwcqserY8zokKOWFm/pZPFNcH78lQ/MIAgAlcZ38owgT0GcSM+vsj0EbusggBvEzyOun3y80uNuxj0hlQVdPqRQH2rT8wgqif7icKFL1RzMBtADB+9QAIn81T+Z8zQMXBlxkRld8Xw2qig 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)(376002)(346002)(366004)(39860400002)(136003)(396003)(451199015)(2906002)(2616005)(6486002)(186003)(41300700001)(1076003)(478600001)(36756003)(6512007)(86362001)(26005)(7416002)(83380400001)(38100700002)(6506007)(8676002)(66556008)(66476007)(4326008)(6666004)(107886003)(44832011)(316002)(66946007)(5660300002)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hSrcKvGfsyqr07KCR4Jld6R0dVwsBaAsOpwsEPxk7jgFZctCHnJFdMpaZRyIPsm6IklvnDr1HhakFHrV/TlVS01JdWk6dOLI7QOQftMHygGjK8mKMkHUpAisAvXHUGggah2XnfDpqnm0YvO5rgdoNv+o6AANO7Z4eY4da0RuxwxgiwvvKD3pM3Y9Rjk1MIFFEJp7HiaaSaSDMg9ciRyeIUoyXMVYDKhnKREBLHLlH4qnmTTBGMb7CA7vB+jHpgILQyzSwpha9rC7yG7VnTTIte1j2PzPQE+IZX7PlGzSTVtQYetwbS7NvZ7ReOM7xYEQmdFP+OsZLt939JnfUtU99KS2PzWanDiP9WvldyoehwCPNLxomemH7/HPGQ4l80cbL3YS06Ps6hSn+0LllYt377+uRma4a43JIsdo8IgqiqS3EY/8wb4KcmEr2Y0s+P8CAhgqZiuQ5ykiU7gkj7rYNIyJ9mqV84C9TeWw+x1WeEFw/H1ItkFCmRPbKy08vryUxcKD8f5u8v3bKeShXO48+4a3PnLwIu8ZzSMXwHcVWFUgZIZ7z5LKYHkjlxghxN0PiKO/bova4Pey4da4jIbZRMtnJ3xM1LMK1omAGSq+EocBO04wJrfTuOZACkYOchk5x2deifL6OX6XgwilqiPw9JKD9QuhcqMfHUGZhXNzQuVT+UW34afjPNbC+pFQbOn1g4/qBBPsBJHDsaGUhpaZoycZcTX7PqMf0wjCQZJdOmmuReutVLcAlbB0UOQ6oGoNh6qUC5WLDboYTi+FRNmV2FI+5QHfcWVJmiIt09XmQqL13/aFEL+/Y3WViO747faTENb+JjByDtcPnOUZ8wLgIoBehfhNhj2iVRX96nREf8wSaC1cElQ+jDKYq9OzSfCPUilYGGfNX8OUo9HnGW8ZSUJ6nlvtWznMtDp6Fk73c9Ax14cPRM6dZKR0BV9tT9YHnUx1Xc71/jzB2DxO+2J0wFk+UzC+AS0MskqHpsI7NaP+xURfCmEN0DZkTZsfVLx1WHps+Q0cixd4R82J7tBqZkZLDst44up1i5yQ3bHddf+aikGGleJ543lvxybCE0RRBP6JOfxCp85MbS0S10IXfYImYQP1Vy8xRRHrmzStQGRf3L6OSTBY6tY3T8HHmAskHa+GvBe9GUN0YMume7V4lVlzoKjTmKmpF6FXh8oZfmHDsrSq1BI52u6lrTorYqHy/hFeWcM16BWVsh6L2yOu6ViSkS5W2xR/N9XWqEBAeyAm21BVNN4pV8EOHrAoXIqR+pgihMcmr6XNXkJx85JLQnPzPUvym4UTidN+mnH+nrnb1xlzq72Gs0QaQV/3FLiYPOtDWy8hOaGk3AjRfmoDdZE4E1hchuCkwS/f1cu0OWzcpd7or5+Q3rv1CBqBBk2hcTWZASY9x7AxsXEOmD5UrBlIVtd1/+6Cah3lEtL6d/SJJZYc7gZL6z5RLwG6YL1tFF23WJm+YPA2LDHfcEPy8MkzWaqdvDfmONG+yBSgwzEQIGbPBfKUZKHy9tyzvTPUpNUmcd1H3rj8O11Z8ld5dvV93p0mSejDLLyPy4SiqEMstNlxXDPRr6QmZsczhZlX1sr6HB6U7jxs0X9t8BgEtg== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: zw5eKEqYUMj5vYO9d0dKyNUC4BnQ9HaLHzRJXHZziK2VdGLnl/lnIoNLol+tO55ihEIurlhh5F8nMwhdX27OT8azvTHnWPxYCH+zQmbFZDADoFFMWWytzuqEfy8QxcPB2UJXKrA00EsHhhdKocc0uJiVNW9aKPduDwPhFJo3BeQ5TKSLNPmZIQS0t53m+TOs9/iLvzWhtDFwvuYyNiKALWUfKy6gXODSyOUmDn1izE+7L5cUOTjlXPo3hR+43zxTRksJ9nnFA27UnunMMTkjUy8cfwwKGZqG6hhm/2cslcaBE3SHvf7ZAUUkGP1vUdBJYhA6IdM5FR3cKgzSrimfJGaVMw3BLDnGVEClzFNaN5H44ayvOq/PM8PJ9UIOHIiBL+7fWYE4AkHMNCCNJOOzprDgfJaTHZDQXffIh0W4Rsol8Z19Ouh1TTg7yUgeF5xwoOTxR1YXYwiScJZ/SfKq85/UjJx/1FVGdx88ep4lrsG4NqFRVaxeu2dSOOAo9PfJFsRpk5Cof+0yVo0l/WOpIy9UTTgEW23N8HA8kg1KirAI3UCdkMohAxx2appQxgx9TnopnEv4rSuzvgrF9wikhdd0KKvOj2tvu/wuwnxI8+s8cz3m2nVmflw6Bi2wRfm3KQcHyeoM76T4zoy2BvSvYGCJwSl9ye4FufMGTjBwldv40Ll7n5qUyCYcTCSJNVH2hkRb/7maHIeh2KgM6mxvdN60/ydDnfuNkXE0AiJaR7hjFRVyPwjPJMhtvzN+p+cdLaHPGCje0lfIsaxCjFXLHqGSrIjPhYACPf1+WC2ywW1i9jeksFfATS0EGhE9vTl5sj3/mdoO+PU5wsmDCqlMd2AzvnGp0zs/Ys359p9jWen75+hUfxd/zZFavtblTZRSCEl1I+QpH5ZyAydGh1dEwSO4PBwBOEuIyNgk/yaqHnmGIkltbnpAhwT5LNqWZrnSuytJXAJoEU737I1fIMx3lnvs4i4BuCEBgt0R0ZqxhQEy/E+xrmNVZ4uS+uSVS0YzVqaJ/g0lSFZ7+bRIh0T2kydYh9QODXi7WqWYSkkI5xsiVeziyeRoWJd0v7bb0+RZAR3YpN4tilTEEsarx2nQk8C8c+QWZorDiZCn0gZ+8Ec= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c488c91-f80a-409b-e44f-08dad25c25c0 X-MS-Exchange-CrossTenant-AuthSource: CH0PR10MB5113.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2022 22:50:44.0130 (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: ykDOd7EDrmXoFetYWuu43ynh5LPKcPZ9mg+D/axNHBDvQNopxDWiJNjJzsQae4sDhuadQlKnIsnfnYk0tIKQgtE1ElX1RZ/hrfiCIfPUNYA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR10MB5586 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-29_13,2022-11-29_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 suspectscore=0 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211290137 X-Proofpoint-ORIG-GUID: VufT3BYM0vTRovhzMkprFtWtqClY2Vd3 X-Proofpoint-GUID: VufT3BYM0vTRovhzMkprFtWtqClY2Vd3 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?1750872718482590373?= X-GMAIL-MSGID: =?utf-8?q?1750872718482590373?= |
Series |
convert core hugetlb functions to folios
|
|
Commit Message
Sidhartha Kumar
Nov. 29, 2022, 10:50 p.m. UTC
Add folio equivalents for set_compound_order() and set_compound_page_dtor().
Also remove extra new-lines introduced by mm/hugetlb: convert
move_hugetlb_state() to folios and mm/hugetlb_cgroup: convert
hugetlb_cgroup_uncharge_page() to folios.
Suggested-by: Mike Kravetz <mike.kravetz@oracle.com>
Suggested-by: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
include/linux/mm.h | 16 ++++++++++++++++
mm/hugetlb.c | 4 +---
2 files changed, 17 insertions(+), 3 deletions(-)
Comments
On 11/29/22 14:50, Sidhartha Kumar wrote: > Add folio equivalents for set_compound_order() and set_compound_page_dtor(). > > Also remove extra new-lines introduced by mm/hugetlb: convert > move_hugetlb_state() to folios and mm/hugetlb_cgroup: convert > hugetlb_cgroup_uncharge_page() to folios. > > Suggested-by: Mike Kravetz <mike.kravetz@oracle.com> > Suggested-by: Muchun Song <songmuchun@bytedance.com> > Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> > --- > include/linux/mm.h | 16 ++++++++++++++++ > mm/hugetlb.c | 4 +--- > 2 files changed, 17 insertions(+), 3 deletions(-) Sorry, for the delay, Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
> On Nov 30, 2022, at 06:50, Sidhartha Kumar <sidhartha.kumar@oracle.com> wrote: > > Add folio equivalents for set_compound_order() and set_compound_page_dtor(). > > Also remove extra new-lines introduced by mm/hugetlb: convert > move_hugetlb_state() to folios and mm/hugetlb_cgroup: convert > hugetlb_cgroup_uncharge_page() to folios. > > Suggested-by: Mike Kravetz <mike.kravetz@oracle.com> > Suggested-by: Muchun Song <songmuchun@bytedance.com> > Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> > --- > include/linux/mm.h | 16 ++++++++++++++++ > mm/hugetlb.c | 4 +--- > 2 files changed, 17 insertions(+), 3 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index a48c5ad16a5e..2bdef8a5298a 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -972,6 +972,13 @@ static inline void set_compound_page_dtor(struct page *page, > page[1].compound_dtor = compound_dtor; > } > > +static inline void folio_set_compound_dtor(struct folio *folio, > + enum compound_dtor_id compound_dtor) > +{ > + VM_BUG_ON_FOLIO(compound_dtor >= NR_COMPOUND_DTORS, folio); > + folio->_folio_dtor = compound_dtor; > +} > + > void destroy_large_folio(struct folio *folio); > > static inline int head_compound_pincount(struct page *head) > @@ -987,6 +994,15 @@ static inline void set_compound_order(struct page *page, unsigned int order) > #endif > } > > +static inline void folio_set_compound_order(struct folio *folio, > + unsigned int order) > +{ > + folio->_folio_order = order; > +#ifdef CONFIG_64BIT > + folio->_folio_nr_pages = order ? 1U << order : 0; It seems that you think the user could pass 0 to order. However, ->_folio_nr_pages and ->_folio_order fields are invalid for order-0 pages. You should not touch it. So this should be: static inline void folio_set_compound_order(struct folio *folio, unsigned int order) { if (!folio_test_large(folio)) return; folio->_folio_order = order; #ifdef CONFIG_64BIT folio->_folio_nr_pages = 1U << order; #endif } If we can make sure all the users of folio_set_compound_order() should pass a non-order-0 page (it is true for now), then I suggest adding a VM_BUG_ON() here to catch unexpected users. 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 = 1U << order; #endif } Thanks. > +#endif > +} > +
On 12/07/22 11:34, Muchun Song wrote: > > > > On Nov 30, 2022, at 06:50, Sidhartha Kumar <sidhartha.kumar@oracle.com> wrote: > > > > Add folio equivalents for set_compound_order() and set_compound_page_dtor(). > > > > Also remove extra new-lines introduced by mm/hugetlb: convert > > move_hugetlb_state() to folios and mm/hugetlb_cgroup: convert > > hugetlb_cgroup_uncharge_page() to folios. > > > > Suggested-by: Mike Kravetz <mike.kravetz@oracle.com> > > Suggested-by: Muchun Song <songmuchun@bytedance.com> > > Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> > > --- > > include/linux/mm.h | 16 ++++++++++++++++ > > mm/hugetlb.c | 4 +--- > > 2 files changed, 17 insertions(+), 3 deletions(-) > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index a48c5ad16a5e..2bdef8a5298a 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -972,6 +972,13 @@ static inline void set_compound_page_dtor(struct page *page, > > page[1].compound_dtor = compound_dtor; > > } > > > > +static inline void folio_set_compound_dtor(struct folio *folio, > > + enum compound_dtor_id compound_dtor) > > +{ > > + VM_BUG_ON_FOLIO(compound_dtor >= NR_COMPOUND_DTORS, folio); > > + folio->_folio_dtor = compound_dtor; > > +} > > + > > void destroy_large_folio(struct folio *folio); > > > > static inline int head_compound_pincount(struct page *head) > > @@ -987,6 +994,15 @@ static inline void set_compound_order(struct page *page, unsigned int order) > > #endif > > } > > > > +static inline void folio_set_compound_order(struct folio *folio, > > + unsigned int order) > > +{ > > + folio->_folio_order = order; > > +#ifdef CONFIG_64BIT > > + folio->_folio_nr_pages = order ? 1U << order : 0; > > It seems that you think the user could pass 0 to order. However, > ->_folio_nr_pages and ->_folio_order fields are invalid for order-0 pages. > You should not touch it. So this should be: > > static inline void folio_set_compound_order(struct folio *folio, > unsigned int order) > { > if (!folio_test_large(folio)) > return; > > folio->_folio_order = order; > #ifdef CONFIG_64BIT > folio->_folio_nr_pages = 1U << order; > #endif > } I believe this was changed to accommodate the code in __destroy_compound_gigantic_page(). It is used in a subsequent patch. Here is the v6.0 version of the routine. static void __destroy_compound_gigantic_page(struct page *page, unsigned int order, bool demote) { int i; int nr_pages = 1 << order; struct page *p = page + 1; atomic_set(compound_mapcount_ptr(page), 0); atomic_set(compound_pincount_ptr(page), 0); for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { p->mapping = NULL; clear_compound_head(p); if (!demote) set_page_refcounted(p); } set_compound_order(page, 0); #ifdef CONFIG_64BIT page[1].compound_nr = 0; #endif __ClearPageHead(page); } Might have been better to change this set_compound_order call to folio_set_compound_order in this patch.
> On Dec 7, 2022, at 11:42, Mike Kravetz <mike.kravetz@oracle.com> wrote: > > On 12/07/22 11:34, Muchun Song wrote: >> >> >>> On Nov 30, 2022, at 06:50, Sidhartha Kumar <sidhartha.kumar@oracle.com> wrote: >>> >>> Add folio equivalents for set_compound_order() and set_compound_page_dtor(). >>> >>> Also remove extra new-lines introduced by mm/hugetlb: convert >>> move_hugetlb_state() to folios and mm/hugetlb_cgroup: convert >>> hugetlb_cgroup_uncharge_page() to folios. >>> >>> Suggested-by: Mike Kravetz <mike.kravetz@oracle.com> >>> Suggested-by: Muchun Song <songmuchun@bytedance.com> >>> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> >>> --- >>> include/linux/mm.h | 16 ++++++++++++++++ >>> mm/hugetlb.c | 4 +--- >>> 2 files changed, 17 insertions(+), 3 deletions(-) >>> >>> diff --git a/include/linux/mm.h b/include/linux/mm.h >>> index a48c5ad16a5e..2bdef8a5298a 100644 >>> --- a/include/linux/mm.h >>> +++ b/include/linux/mm.h >>> @@ -972,6 +972,13 @@ static inline void set_compound_page_dtor(struct page *page, >>> page[1].compound_dtor = compound_dtor; >>> } >>> >>> +static inline void folio_set_compound_dtor(struct folio *folio, >>> + enum compound_dtor_id compound_dtor) >>> +{ >>> + VM_BUG_ON_FOLIO(compound_dtor >= NR_COMPOUND_DTORS, folio); >>> + folio->_folio_dtor = compound_dtor; >>> +} >>> + >>> void destroy_large_folio(struct folio *folio); >>> >>> static inline int head_compound_pincount(struct page *head) >>> @@ -987,6 +994,15 @@ static inline void set_compound_order(struct page *page, unsigned int order) >>> #endif >>> } >>> >>> +static inline void folio_set_compound_order(struct folio *folio, >>> + unsigned int order) >>> +{ >>> + folio->_folio_order = order; >>> +#ifdef CONFIG_64BIT >>> + folio->_folio_nr_pages = order ? 1U << order : 0; >> >> It seems that you think the user could pass 0 to order. However, >> ->_folio_nr_pages and ->_folio_order fields are invalid for order-0 pages. >> You should not touch it. So this should be: >> >> static inline void folio_set_compound_order(struct folio *folio, >> unsigned int order) >> { >> if (!folio_test_large(folio)) >> return; >> >> folio->_folio_order = order; >> #ifdef CONFIG_64BIT >> folio->_folio_nr_pages = 1U << order; >> #endif >> } > > I believe this was changed to accommodate the code in > __destroy_compound_gigantic_page(). It is used in a subsequent patch. > Here is the v6.0 version of the routine. Thanks for your clarification. > > static void __destroy_compound_gigantic_page(struct page *page, > unsigned int order, bool demote) > { > int i; > int nr_pages = 1 << order; > struct page *p = page + 1; > > atomic_set(compound_mapcount_ptr(page), 0); > atomic_set(compound_pincount_ptr(page), 0); > > for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { > p->mapping = NULL; > clear_compound_head(p); > if (!demote) > set_page_refcounted(p); > } > > set_compound_order(page, 0); > #ifdef CONFIG_64BIT > page[1].compound_nr = 0; > #endif > __ClearPageHead(page); > } > > > Might have been better to change this set_compound_order call to > folio_set_compound_order in this patch. > Agree. It has confused me a lot. I suggest changing the code to the followings. The folio_test_large() check is still to avoid unexpected users for OOB. static inline void folio_set_compound_order(struct folio *folio, unsigned int order) { VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); // or // if (!folio_test_large(folio)) // return; folio->_folio_order = order; #ifdef CONFIG_64BIT folio->_folio_nr_pages = order ? 1U << order : 0; #endif } Thanks.
On 12/07/22 12:11, Muchun Song wrote: > > > > On Dec 7, 2022, at 11:42, Mike Kravetz <mike.kravetz@oracle.com> wrote: > > > > On 12/07/22 11:34, Muchun Song wrote: > >> > >> > >>> On Nov 30, 2022, at 06:50, Sidhartha Kumar <sidhartha.kumar@oracle.com> wrote: > >>> > >>> Add folio equivalents for set_compound_order() and set_compound_page_dtor(). > >>> > >>> Also remove extra new-lines introduced by mm/hugetlb: convert > >>> move_hugetlb_state() to folios and mm/hugetlb_cgroup: convert > >>> hugetlb_cgroup_uncharge_page() to folios. > >>> > >>> Suggested-by: Mike Kravetz <mike.kravetz@oracle.com> > >>> Suggested-by: Muchun Song <songmuchun@bytedance.com> > >>> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> > >>> --- > >>> include/linux/mm.h | 16 ++++++++++++++++ > >>> mm/hugetlb.c | 4 +--- > >>> 2 files changed, 17 insertions(+), 3 deletions(-) > >>> > >>> diff --git a/include/linux/mm.h b/include/linux/mm.h > >>> index a48c5ad16a5e..2bdef8a5298a 100644 > >>> --- a/include/linux/mm.h > >>> +++ b/include/linux/mm.h > >>> @@ -972,6 +972,13 @@ static inline void set_compound_page_dtor(struct page *page, > >>> page[1].compound_dtor = compound_dtor; > >>> } > >>> > >>> +static inline void folio_set_compound_dtor(struct folio *folio, > >>> + enum compound_dtor_id compound_dtor) > >>> +{ > >>> + VM_BUG_ON_FOLIO(compound_dtor >= NR_COMPOUND_DTORS, folio); > >>> + folio->_folio_dtor = compound_dtor; > >>> +} > >>> + > >>> void destroy_large_folio(struct folio *folio); > >>> > >>> static inline int head_compound_pincount(struct page *head) > >>> @@ -987,6 +994,15 @@ static inline void set_compound_order(struct page *page, unsigned int order) > >>> #endif > >>> } > >>> > >>> +static inline void folio_set_compound_order(struct folio *folio, > >>> + unsigned int order) > >>> +{ > >>> + folio->_folio_order = order; > >>> +#ifdef CONFIG_64BIT > >>> + folio->_folio_nr_pages = order ? 1U << order : 0; > >> > >> It seems that you think the user could pass 0 to order. However, > >> ->_folio_nr_pages and ->_folio_order fields are invalid for order-0 pages. > >> You should not touch it. So this should be: > >> > >> static inline void folio_set_compound_order(struct folio *folio, > >> unsigned int order) > >> { > >> if (!folio_test_large(folio)) > >> return; > >> > >> folio->_folio_order = order; > >> #ifdef CONFIG_64BIT > >> folio->_folio_nr_pages = 1U << order; > >> #endif > >> } > > > > I believe this was changed to accommodate the code in > > __destroy_compound_gigantic_page(). It is used in a subsequent patch. > > Here is the v6.0 version of the routine. > > Thanks for your clarification. > > > > > static void __destroy_compound_gigantic_page(struct page *page, > > unsigned int order, bool demote) > > { > > int i; > > int nr_pages = 1 << order; > > struct page *p = page + 1; > > > > atomic_set(compound_mapcount_ptr(page), 0); > > atomic_set(compound_pincount_ptr(page), 0); > > > > for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { > > p->mapping = NULL; > > clear_compound_head(p); > > if (!demote) > > set_page_refcounted(p); > > } > > > > set_compound_order(page, 0); > > #ifdef CONFIG_64BIT > > page[1].compound_nr = 0; > > #endif > > __ClearPageHead(page); > > } > > > > > > Might have been better to change this set_compound_order call to > > folio_set_compound_order in this patch. > > > > Agree. It has confused me a lot. I suggest changing the code to the > followings. The folio_test_large() check is still to avoid unexpected > users for OOB. > > static inline void folio_set_compound_order(struct folio *folio, > unsigned int order) > { > VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); > // or > // if (!folio_test_large(folio)) > // return; > > folio->_folio_order = order; > #ifdef CONFIG_64BIT > folio->_folio_nr_pages = order ? 1U << order : 0; > #endif > } I think the VM_BUG_ON_FOLIO is appropriate as it would at least flag data corruption. Thinking about this some more, it seems that hugetlb is the only caller that abuses folio_set_compound_order (and previously set_compound_order) by passing in a zero order. Since it is unlikely that anyone knows of this abuse, it might be good to add a comment to the routine to note why it handles the zero case. This might help prevent changes which would potentially break hugetlb.
On 12/7/22 10:12 AM, Mike Kravetz wrote: > On 12/07/22 12:11, Muchun Song wrote: >> >> >>> On Dec 7, 2022, at 11:42, Mike Kravetz <mike.kravetz@oracle.com> wrote: >>> >>> On 12/07/22 11:34, Muchun Song wrote: >>>> >>>> >>>>> On Nov 30, 2022, at 06:50, Sidhartha Kumar <sidhartha.kumar@oracle.com> wrote: >>>>> >>>>> Add folio equivalents for set_compound_order() and set_compound_page_dtor(). >>>>> >>>>> Also remove extra new-lines introduced by mm/hugetlb: convert >>>>> move_hugetlb_state() to folios and mm/hugetlb_cgroup: convert >>>>> hugetlb_cgroup_uncharge_page() to folios. >>>>> >>>>> Suggested-by: Mike Kravetz <mike.kravetz@oracle.com> >>>>> Suggested-by: Muchun Song <songmuchun@bytedance.com> >>>>> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> >>>>> --- >>>>> include/linux/mm.h | 16 ++++++++++++++++ >>>>> mm/hugetlb.c | 4 +--- >>>>> 2 files changed, 17 insertions(+), 3 deletions(-) >>>>> >>>>> diff --git a/include/linux/mm.h b/include/linux/mm.h >>>>> index a48c5ad16a5e..2bdef8a5298a 100644 >>>>> --- a/include/linux/mm.h >>>>> +++ b/include/linux/mm.h >>>>> @@ -972,6 +972,13 @@ static inline void set_compound_page_dtor(struct page *page, >>>>> page[1].compound_dtor = compound_dtor; >>>>> } >>>>> >>>>> +static inline void folio_set_compound_dtor(struct folio *folio, >>>>> + enum compound_dtor_id compound_dtor) >>>>> +{ >>>>> + VM_BUG_ON_FOLIO(compound_dtor >= NR_COMPOUND_DTORS, folio); >>>>> + folio->_folio_dtor = compound_dtor; >>>>> +} >>>>> + >>>>> void destroy_large_folio(struct folio *folio); >>>>> >>>>> static inline int head_compound_pincount(struct page *head) >>>>> @@ -987,6 +994,15 @@ static inline void set_compound_order(struct page *page, unsigned int order) >>>>> #endif >>>>> } >>>>> >>>>> +static inline void folio_set_compound_order(struct folio *folio, >>>>> + unsigned int order) >>>>> +{ >>>>> + folio->_folio_order = order; >>>>> +#ifdef CONFIG_64BIT >>>>> + folio->_folio_nr_pages = order ? 1U << order : 0; >>>> >>>> It seems that you think the user could pass 0 to order. However, >>>> ->_folio_nr_pages and ->_folio_order fields are invalid for order-0 pages. >>>> You should not touch it. So this should be: >>>> >>>> static inline void folio_set_compound_order(struct folio *folio, >>>> unsigned int order) >>>> { >>>> if (!folio_test_large(folio)) >>>> return; >>>> >>>> folio->_folio_order = order; >>>> #ifdef CONFIG_64BIT >>>> folio->_folio_nr_pages = 1U << order; >>>> #endif >>>> } >>> >>> I believe this was changed to accommodate the code in >>> __destroy_compound_gigantic_page(). It is used in a subsequent patch. >>> Here is the v6.0 version of the routine. >> >> Thanks for your clarification. >> >>> >>> static void __destroy_compound_gigantic_page(struct page *page, >>> unsigned int order, bool demote) >>> { >>> int i; >>> int nr_pages = 1 << order; >>> struct page *p = page + 1; >>> >>> atomic_set(compound_mapcount_ptr(page), 0); >>> atomic_set(compound_pincount_ptr(page), 0); >>> >>> for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { >>> p->mapping = NULL; >>> clear_compound_head(p); >>> if (!demote) >>> set_page_refcounted(p); >>> } >>> >>> set_compound_order(page, 0); >>> #ifdef CONFIG_64BIT >>> page[1].compound_nr = 0; >>> #endif >>> __ClearPageHead(page); >>> } >>> >>> >>> Might have been better to change this set_compound_order call to >>> folio_set_compound_order in this patch. >>> >> >> Agree. It has confused me a lot. I suggest changing the code to the >> followings. The folio_test_large() check is still to avoid unexpected >> users for OOB. >> >> static inline void folio_set_compound_order(struct folio *folio, >> unsigned int order) >> { >> VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); >> // or >> // if (!folio_test_large(folio)) >> // return; >> >> folio->_folio_order = order; >> #ifdef CONFIG_64BIT >> folio->_folio_nr_pages = order ? 1U << order : 0; >> #endif >> } > > I think the VM_BUG_ON_FOLIO is appropriate as it would at least flag > data corruption. > As Mike pointed out, my intention with supporting the 0 case was to cleanup the __destroy_compound_gigantic_page code by moving the ifdef CONFIG_64BIT lines to folio_set_compound_order(). I'll add the VM_BUG_ON_FOLIO line as well as a comment to make it clear it is not normally supported. > Thinking about this some more, it seems that hugetlb is the only caller > that abuses folio_set_compound_order (and previously set_compound_order) > by passing in a zero order. Since it is unlikely that anyone knows of > this abuse, it might be good to add a comment to the routine to note > why it handles the zero case. This might help prevent changes which > would potentially break hugetlb. +/* + * _folio_nr_pages and _folio_order are invalid for + * order-zero pages. An exception is hugetlb, which passes + * in a zero order in __destroy_compound_gigantic_page(). + */ 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; Does this comment work?
On 12/7/22 10:49 AM, Sidhartha Kumar wrote: > On 12/7/22 10:12 AM, Mike Kravetz wrote: >> On 12/07/22 12:11, Muchun Song wrote: >>> >>> >>>> On Dec 7, 2022, at 11:42, Mike Kravetz <mike.kravetz@oracle.com> wrote: >>>> >>>> On 12/07/22 11:34, Muchun Song wrote: >>>>> >>>>> >>>>>> On Nov 30, 2022, at 06:50, Sidhartha Kumar >>>>>> <sidhartha.kumar@oracle.com> wrote: >>>>>> >>>>>> Add folio equivalents for set_compound_order() and >>>>>> set_compound_page_dtor(). >>>>>> >>>>>> Also remove extra new-lines introduced by mm/hugetlb: convert >>>>>> move_hugetlb_state() to folios and mm/hugetlb_cgroup: convert >>>>>> hugetlb_cgroup_uncharge_page() to folios. >>>>>> >>>>>> Suggested-by: Mike Kravetz <mike.kravetz@oracle.com> >>>>>> Suggested-by: Muchun Song <songmuchun@bytedance.com> >>>>>> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> >>>>>> --- >>>>>> include/linux/mm.h | 16 ++++++++++++++++ >>>>>> mm/hugetlb.c | 4 +--- >>>>>> 2 files changed, 17 insertions(+), 3 deletions(-) >>>>>> >>>>>> diff --git a/include/linux/mm.h b/include/linux/mm.h >>>>>> index a48c5ad16a5e..2bdef8a5298a 100644 >>>>>> --- a/include/linux/mm.h >>>>>> +++ b/include/linux/mm.h >>>>>> @@ -972,6 +972,13 @@ static inline void >>>>>> set_compound_page_dtor(struct page *page, >>>>>> page[1].compound_dtor = compound_dtor; >>>>>> } >>>>>> >>>>>> +static inline void folio_set_compound_dtor(struct folio *folio, >>>>>> + enum compound_dtor_id compound_dtor) >>>>>> +{ >>>>>> + VM_BUG_ON_FOLIO(compound_dtor >= NR_COMPOUND_DTORS, folio); >>>>>> + folio->_folio_dtor = compound_dtor; >>>>>> +} >>>>>> + >>>>>> void destroy_large_folio(struct folio *folio); >>>>>> >>>>>> static inline int head_compound_pincount(struct page *head) >>>>>> @@ -987,6 +994,15 @@ static inline void set_compound_order(struct >>>>>> page *page, unsigned int order) >>>>>> #endif >>>>>> } >>>>>> >>>>>> +static inline void folio_set_compound_order(struct folio *folio, >>>>>> + unsigned int order) >>>>>> +{ >>>>>> + folio->_folio_order = order; >>>>>> +#ifdef CONFIG_64BIT >>>>>> + folio->_folio_nr_pages = order ? 1U << order : 0; >>>>> >>>>> It seems that you think the user could pass 0 to order. However, >>>>> ->_folio_nr_pages and ->_folio_order fields are invalid for order-0 >>>>> pages. >>>>> You should not touch it. So this should be: >>>>> >>>>> static inline void folio_set_compound_order(struct folio *folio, >>>>> unsigned int order) >>>>> { >>>>> if (!folio_test_large(folio)) >>>>> return; >>>>> >>>>> folio->_folio_order = order; >>>>> #ifdef CONFIG_64BIT >>>>> folio->_folio_nr_pages = 1U << order; >>>>> #endif >>>>> } >>>> >>>> I believe this was changed to accommodate the code in >>>> __destroy_compound_gigantic_page(). It is used in a subsequent patch. >>>> Here is the v6.0 version of the routine. >>> >>> Thanks for your clarification. >>> >>>> >>>> static void __destroy_compound_gigantic_page(struct page *page, >>>> unsigned int order, bool demote) >>>> { >>>> int i; >>>> int nr_pages = 1 << order; >>>> struct page *p = page + 1; >>>> >>>> atomic_set(compound_mapcount_ptr(page), 0); >>>> atomic_set(compound_pincount_ptr(page), 0); >>>> >>>> for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { >>>> p->mapping = NULL; >>>> clear_compound_head(p); >>>> if (!demote) >>>> set_page_refcounted(p); >>>> } >>>> >>>> set_compound_order(page, 0); >>>> #ifdef CONFIG_64BIT >>>> page[1].compound_nr = 0; >>>> #endif >>>> __ClearPageHead(page); >>>> } >>>> >>>> >>>> Might have been better to change this set_compound_order call to >>>> folio_set_compound_order in this patch. >>>> >>> >>> Agree. It has confused me a lot. I suggest changing the code to the >>> followings. The folio_test_large() check is still to avoid unexpected >>> users for OOB. >>> >>> static inline void folio_set_compound_order(struct folio *folio, >>> unsigned int order) >>> { >>> VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); >>> // or >>> // if (!folio_test_large(folio)) >>> // return; >>> >>> folio->_folio_order = order; >>> #ifdef CONFIG_64BIT >>> folio->_folio_nr_pages = order ? 1U << order : 0; >>> #endif >>> } >> >> I think the VM_BUG_ON_FOLIO is appropriate as it would at least flag >> data corruption. >> > As Mike pointed out, my intention with supporting the 0 case was to > cleanup the __destroy_compound_gigantic_page code by moving the ifdef > CONFIG_64BIT lines to folio_set_compound_order(). I'll add the > VM_BUG_ON_FOLIO line as well as a comment to make it clear it is not > normally supported. > >> Thinking about this some more, it seems that hugetlb is the only caller >> that abuses folio_set_compound_order (and previously set_compound_order) >> by passing in a zero order. Since it is unlikely that anyone knows of >> this abuse, it might be good to add a comment to the routine to note >> why it handles the zero case. This might help prevent changes which >> would potentially break hugetlb. > > +/* > + * _folio_nr_pages and _folio_order are invalid for > + * order-zero pages. An exception is hugetlb, which passes > + * in a zero order in __destroy_compound_gigantic_page(). > + */ > 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; > > Does this comment work? > > I will change the comment from referencing __destory_compound_gigantic_page() to __destroy_compound_gigantic_folio, although __prep_compound_gigantic_folio() is another user of folio_set_compound_order(folio, 0). Should the sentence just be "An exception is hugetlb, which passes in a zero order"?
On 12/07/22 11:05, Sidhartha Kumar wrote: > On 12/7/22 10:49 AM, Sidhartha Kumar wrote: > > On 12/7/22 10:12 AM, Mike Kravetz wrote: > > > On 12/07/22 12:11, Muchun Song wrote: > > > > > On Dec 7, 2022, at 11:42, Mike Kravetz <mike.kravetz@oracle.com> wrote: > > > > > On 12/07/22 11:34, Muchun Song wrote: > > > > > > > > Agree. It has confused me a lot. I suggest changing the code to the > > > > followings. The folio_test_large() check is still to avoid unexpected > > > > users for OOB. > > > > > > > > static inline void folio_set_compound_order(struct folio *folio, > > > > unsigned int order) > > > > { > > > > VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); > > > > // or > > > > // if (!folio_test_large(folio)) > > > > // return; > > > > > > > > folio->_folio_order = order; > > > > #ifdef CONFIG_64BIT > > > > folio->_folio_nr_pages = order ? 1U << order : 0; > > > > #endif > > > > } > > > > > > I think the VM_BUG_ON_FOLIO is appropriate as it would at least flag > > > data corruption. > > > > > As Mike pointed out, my intention with supporting the 0 case was to > > cleanup the __destroy_compound_gigantic_page code by moving the ifdef > > CONFIG_64BIT lines to folio_set_compound_order(). I'll add the > > VM_BUG_ON_FOLIO line as well as a comment to make it clear it is not > > normally supported. > > > > > Thinking about this some more, it seems that hugetlb is the only caller > > > that abuses folio_set_compound_order (and previously set_compound_order) > > > by passing in a zero order. Since it is unlikely that anyone knows of > > > this abuse, it might be good to add a comment to the routine to note > > > why it handles the zero case. This might help prevent changes which > > > would potentially break hugetlb. > > > > +/* > > + * _folio_nr_pages and _folio_order are invalid for > > + * order-zero pages. An exception is hugetlb, which passes > > + * in a zero order in __destroy_compound_gigantic_page(). > > + */ > > 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; > > > > Does this comment work? > > > > > > I will change the comment from referencing > __destory_compound_gigantic_page() > to __destroy_compound_gigantic_folio, although > __prep_compound_gigantic_folio() is another user of > folio_set_compound_order(folio, 0). Should the sentence just be "An > exception is hugetlb, which passes in a zero order"? How about a comment like this? /* * folio_set_compound_order is generally passed a non-zero order to * set up/create a large folio. However, hugetlb code abuses this by * passing in zero when 'dissolving' a large folio. */ My only concern is that someone may modify the routine such that it no longer works when passed zero order. It is not likely as anyone should notice the special case for zero, and look for callers.
> On Dec 8, 2022, at 03:25, Mike Kravetz <mike.kravetz@oracle.com> wrote: > > On 12/07/22 11:05, Sidhartha Kumar wrote: >> On 12/7/22 10:49 AM, Sidhartha Kumar wrote: >>> On 12/7/22 10:12 AM, Mike Kravetz wrote: >>>> On 12/07/22 12:11, Muchun Song wrote: >>>>>> On Dec 7, 2022, at 11:42, Mike Kravetz <mike.kravetz@oracle.com> wrote: >>>>>> On 12/07/22 11:34, Muchun Song wrote: >>>>> >>>>> Agree. It has confused me a lot. I suggest changing the code to the >>>>> followings. The folio_test_large() check is still to avoid unexpected >>>>> users for OOB. >>>>> >>>>> static inline void folio_set_compound_order(struct folio *folio, >>>>> unsigned int order) >>>>> { >>>>> VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); >>>>> // or >>>>> // if (!folio_test_large(folio)) >>>>> // return; >>>>> >>>>> folio->_folio_order = order; >>>>> #ifdef CONFIG_64BIT >>>>> folio->_folio_nr_pages = order ? 1U << order : 0; >>>>> #endif >>>>> } >>>> >>>> I think the VM_BUG_ON_FOLIO is appropriate as it would at least flag >>>> data corruption. >>>> >>> As Mike pointed out, my intention with supporting the 0 case was to >>> cleanup the __destroy_compound_gigantic_page code by moving the ifdef >>> CONFIG_64BIT lines to folio_set_compound_order(). I'll add the >>> VM_BUG_ON_FOLIO line as well as a comment to make it clear it is not >>> normally supported. >>> >>>> Thinking about this some more, it seems that hugetlb is the only caller >>>> that abuses folio_set_compound_order (and previously set_compound_order) >>>> by passing in a zero order. Since it is unlikely that anyone knows of >>>> this abuse, it might be good to add a comment to the routine to note >>>> why it handles the zero case. This might help prevent changes which >>>> would potentially break hugetlb. >>> >>> +/* >>> + * _folio_nr_pages and _folio_order are invalid for >>> + * order-zero pages. An exception is hugetlb, which passes >>> + * in a zero order in __destroy_compound_gigantic_page(). >>> + */ >>> 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; >>> >>> Does this comment work? >>> >>> >> >> I will change the comment from referencing >> __destory_compound_gigantic_page() >> to __destroy_compound_gigantic_folio, although >> __prep_compound_gigantic_folio() is another user of >> folio_set_compound_order(folio, 0). Should the sentence just be "An >> exception is hugetlb, which passes in a zero order"? > > How about a comment like this? > > /* > * folio_set_compound_order is generally passed a non-zero order to > * set up/create a large folio. However, hugetlb code abuses this by > * passing in zero when 'dissolving' a large folio. > */ How about adding a new helper like "folio_dissolve_compound(struct folio *folio)"? then it may be unnecessary to add a comment. Thanks. > > My only concern is that someone may modify the routine such that it no > longer works when passed zero order. It is not likely as anyone should > notice the special case for zero, and look for callers. > -- > Mike Kravetz
On 12/7/22 18:19, Muchun Song wrote: > How about adding a new helper like "folio_dissolve_compound(struct folio *folio)"? > then it may be unnecessary to add a comment. > Yes, and in fact, I just finished spelling out exactly how to do that, in [1]. [1] https://lore.kernel.org/all/d17530ad-8e12-8069-d619-a2d72fe80e15@nvidia.com/ thanks,
> On Dec 8, 2022, at 10:31, John Hubbard <jhubbard@nvidia.com> wrote: > > On 12/7/22 18:19, Muchun Song wrote: >> How about adding a new helper like "folio_dissolve_compound(struct folio *folio)"? >> then it may be unnecessary to add a comment. > > Yes, and in fact, I just finished spelling out exactly how to do that, in [1]. Thanks for your guidance. I have replied in thread [1]. > > > [1] https://lore.kernel.org/all/d17530ad-8e12-8069-d619-a2d72fe80e15@nvidia.com/ > > > thanks, > -- > John Hubbard > NVIDIA
On 07.12.22 05:11, Muchun Song wrote: > > >> On Dec 7, 2022, at 11:42, Mike Kravetz <mike.kravetz@oracle.com> wrote: >> >> On 12/07/22 11:34, Muchun Song wrote: >>> >>> >>>> On Nov 30, 2022, at 06:50, Sidhartha Kumar <sidhartha.kumar@oracle.com> wrote: >>>> >>>> Add folio equivalents for set_compound_order() and set_compound_page_dtor(). >>>> >>>> Also remove extra new-lines introduced by mm/hugetlb: convert >>>> move_hugetlb_state() to folios and mm/hugetlb_cgroup: convert >>>> hugetlb_cgroup_uncharge_page() to folios. >>>> >>>> Suggested-by: Mike Kravetz <mike.kravetz@oracle.com> >>>> Suggested-by: Muchun Song <songmuchun@bytedance.com> >>>> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> >>>> --- >>>> include/linux/mm.h | 16 ++++++++++++++++ >>>> mm/hugetlb.c | 4 +--- >>>> 2 files changed, 17 insertions(+), 3 deletions(-) >>>> >>>> diff --git a/include/linux/mm.h b/include/linux/mm.h >>>> index a48c5ad16a5e..2bdef8a5298a 100644 >>>> --- a/include/linux/mm.h >>>> +++ b/include/linux/mm.h >>>> @@ -972,6 +972,13 @@ static inline void set_compound_page_dtor(struct page *page, >>>> page[1].compound_dtor = compound_dtor; >>>> } >>>> >>>> +static inline void folio_set_compound_dtor(struct folio *folio, >>>> + enum compound_dtor_id compound_dtor) >>>> +{ >>>> + VM_BUG_ON_FOLIO(compound_dtor >= NR_COMPOUND_DTORS, folio); >>>> + folio->_folio_dtor = compound_dtor; >>>> +} >>>> + >>>> void destroy_large_folio(struct folio *folio); >>>> >>>> static inline int head_compound_pincount(struct page *head) >>>> @@ -987,6 +994,15 @@ static inline void set_compound_order(struct page *page, unsigned int order) >>>> #endif >>>> } >>>> >>>> +static inline void folio_set_compound_order(struct folio *folio, >>>> + unsigned int order) >>>> +{ >>>> + folio->_folio_order = order; >>>> +#ifdef CONFIG_64BIT >>>> + folio->_folio_nr_pages = order ? 1U << order : 0; >>> >>> It seems that you think the user could pass 0 to order. However, >>> ->_folio_nr_pages and ->_folio_order fields are invalid for order-0 pages. >>> You should not touch it. So this should be: >>> >>> static inline void folio_set_compound_order(struct folio *folio, >>> unsigned int order) >>> { >>> if (!folio_test_large(folio)) >>> return; >>> >>> folio->_folio_order = order; >>> #ifdef CONFIG_64BIT >>> folio->_folio_nr_pages = 1U << order; >>> #endif >>> } >> >> I believe this was changed to accommodate the code in >> __destroy_compound_gigantic_page(). It is used in a subsequent patch. >> Here is the v6.0 version of the routine. > > Thanks for your clarification. > >> >> static void __destroy_compound_gigantic_page(struct page *page, >> unsigned int order, bool demote) >> { >> int i; >> int nr_pages = 1 << order; >> struct page *p = page + 1; >> >> atomic_set(compound_mapcount_ptr(page), 0); >> atomic_set(compound_pincount_ptr(page), 0); >> >> for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { >> p->mapping = NULL; >> clear_compound_head(p); >> if (!demote) >> set_page_refcounted(p); >> } >> >> set_compound_order(page, 0); >> #ifdef CONFIG_64BIT >> page[1].compound_nr = 0; >> #endif >> __ClearPageHead(page); >> } >> >> >> Might have been better to change this set_compound_order call to >> folio_set_compound_order in this patch. >> > > Agree. It has confused me a lot. I suggest changing the code to the > followings. The folio_test_large() check is still to avoid unexpected > users for OOB. > > static inline void folio_set_compound_order(struct folio *folio, > unsigned int order) > { > VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); > // or > // if (!folio_test_large(folio)) > // return; > > folio->_folio_order = order; > #ifdef CONFIG_64BIT > folio->_folio_nr_pages = order ? 1U << order : 0; > #endif > } > > Thanks. On mm-stable, dynamically allocating gigantic pages gives me: [ 23.625105] page:00000000ae27bd2a refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1800 [ 23.635117] flags: 0x17fffc00000000(node=0|zone=2|lastcpupid=0x1ffff) [ 23.641969] raw: 0017fffc00000000 ffffa4edc489bb58 fffff784c6000048 0000000000000000 [ 23.650141] raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000 [ 23.657907] page dumped because: VM_BUG_ON_FOLIO(!folio_test_large(folio)) [ 23.663955] ------------[ cut here ]------------ [ 23.667680] kernel BUG at include/linux/mm.h:1030! [ 23.673378] invalid opcode: 0000 [#1] PREEMPT SMP PTI [ 23.681610] CPU: 3 PID: 1220 Comm: bash Not tainted 6.1.0-rc4+ #13 [ 23.690281] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.0-1.fc36 04/01/2014 [ 23.699837] RIP: 0010:__prep_compound_gigantic_folio+0x115/0x120 [ 23.706587] Code: c7 44 24 5c 00 00 00 00 5b 44 89 d0 5d 41 5c 41 5d 41 5e c3 cc cc cc cc 48 83 e8 09 [ 23.725954] RSP: 0018:ffffa4edc489bc90 EFLAGS: 00010296 [ 23.731001] RAX: 000000000000003e RBX: ffffffffae39a720 RCX: 0000000000000000 [ 23.736065] RDX: 0000000000000001 RSI: ffffffffad522c25 RDI: 00000000ffffffff [ 23.740866] RBP: 0000000000040000 R08: 0000000000000000 R09: ffffa4edc489bb58 [ 23.745385] R10: 0000000000000003 R11: ffff926d7ff4b028 R12: fffff784c6000000 [ 23.749464] R13: 0000000000040000 R14: fffff784c6000000 R15: ffff9266039fb900 [ 23.753176] FS: 00007f69a9703740(0000) GS:ffff92696f8c0000(0000) knlGS:0000000000000000 [ 23.758299] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 23.761275] CR2: 0000556789080640 CR3: 0000000105568005 CR4: 0000000000770ee0 [ 23.764929] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 23.768572] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 23.772221] PKRU: 55555554 [ 23.773696] Call Trace: [ 23.776170] <TASK> [ 23.777258] alloc_fresh_hugetlb_folio+0x14b/0x220 [ 23.779406] alloc_pool_huge_page+0x7c/0x110 [ 23.781273] __nr_hugepages_store_common+0x191/0x400 [ 23.783369] ? __mod_memcg_lruvec_state+0x93/0x110 [ 23.785343] ? __mod_lruvec_page_state+0xa6/0x1a0 [ 23.787223] ? _copy_from_iter+0x8c/0x540 [ 23.788788] ? __kmem_cache_alloc_node+0x13b/0x2a0 [ 23.790577] ? kernfs_fop_write_iter+0x174/0x1f0 [ 23.792313] nr_hugepages_store+0x57/0x70 [ 23.793754] kernfs_fop_write_iter+0x11b/0x1f0 [ 23.795337] vfs_write+0x1e1/0x3a0 [ 23.796531] ksys_write+0x53/0xd0 [ 23.797690] do_syscall_64+0x37/0x90 [ 23.798947] entry_SYSCALL_64_after_hwframe+0x63/0xcd [ 23.800602] RIP: 0033:0x7f69a9501977 [ 23.801798] Code: 0f 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 64 8b 04 25 14 [ 23.807322] RSP: 002b:00007ffce87f3338 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 23.809460] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: 00007f69a9501977 [ 23.811485] RDX: 0000000000000002 RSI: 00005652a970e5e0 RDI: 0000000000000001 [ 23.813443] RBP: 00005652a970e5e0 R08: 0000000000000000 R09: 0000000000000073 [ 23.815385] R10: 0000000000001000 R11: 0000000000000246 R12: 0000000000000002 [ 23.817289] R13: 00007f69a95f9780 R14: 0000000000000002 R15: 00007f69a95f49e0 [ 23.819176] </TASK> [ 23.819792] Modules linked in: intel_rapl_msr intel_rapl_common intel_uncore_frequency_common isst_ir [ 23.829056] ---[ end trace 0000000000000000 ]--- [ 23.830413] RIP: 0010:__prep_compound_gigantic_folio+0x115/0x120 [ 23.832390] Code: c7 44 24 5c 00 00 00 00 5b 44 89 d0 5d 41 5c 41 5d 41 5e c3 cc cc cc cc 48 83 e8 09 [ 23.836787] RSP: 0018:ffffa4edc489bc90 EFLAGS: 00010296 [ 23.838083] RAX: 000000000000003e RBX: ffffffffae39a720 RCX: 0000000000000000 [ 23.839764] RDX: 0000000000000001 RSI: ffffffffad522c25 RDI: 00000000ffffffff [ 23.841456] RBP: 0000000000040000 R08: 0000000000000000 R09: ffffa4edc489bb58 [ 23.843150] R10: 0000000000000003 R11: ffff926d7ff4b028 R12: fffff784c6000000 [ 23.844836] R13: 0000000000040000 R14: fffff784c6000000 R15: ffff9266039fb900 [ 23.846521] FS: 00007f69a9703740(0000) GS:ffff92696f8c0000(0000) knlGS:0000000000000000 [ 23.848417] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 23.849797] CR2: 0000556789080640 CR3: 0000000105568005 CR4: 0000000000770ee0 [ 23.851491] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 23.853181] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 23.854861] PKRU: 55555554 Something's broken.
On 12/12/22 10:34 AM, David Hildenbrand wrote: > On 07.12.22 05:11, Muchun Song wrote: >> >> >>> On Dec 7, 2022, at 11:42, Mike Kravetz <mike.kravetz@oracle.com> wrote: >>> >>> On 12/07/22 11:34, Muchun Song wrote: >>>> >>>> >>>>> On Nov 30, 2022, at 06:50, Sidhartha Kumar >>>>> <sidhartha.kumar@oracle.com> wrote: >>>>> >>>>> Add folio equivalents for set_compound_order() and >>>>> set_compound_page_dtor(). >>>>> >>>>> Also remove extra new-lines introduced by mm/hugetlb: convert >>>>> move_hugetlb_state() to folios and mm/hugetlb_cgroup: convert >>>>> hugetlb_cgroup_uncharge_page() to folios. >>>>> >>>>> Suggested-by: Mike Kravetz <mike.kravetz@oracle.com> >>>>> Suggested-by: Muchun Song <songmuchun@bytedance.com> >>>>> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com> >>>>> --- >>>>> include/linux/mm.h | 16 ++++++++++++++++ >>>>> mm/hugetlb.c | 4 +--- >>>>> 2 files changed, 17 insertions(+), 3 deletions(-) >>>>> >>>>> diff --git a/include/linux/mm.h b/include/linux/mm.h >>>>> index a48c5ad16a5e..2bdef8a5298a 100644 >>>>> --- a/include/linux/mm.h >>>>> +++ b/include/linux/mm.h >>>>> @@ -972,6 +972,13 @@ static inline void >>>>> set_compound_page_dtor(struct page *page, >>>>> page[1].compound_dtor = compound_dtor; >>>>> } >>>>> >>>>> +static inline void folio_set_compound_dtor(struct folio *folio, >>>>> + enum compound_dtor_id compound_dtor) >>>>> +{ >>>>> + VM_BUG_ON_FOLIO(compound_dtor >= NR_COMPOUND_DTORS, folio); >>>>> + folio->_folio_dtor = compound_dtor; >>>>> +} >>>>> + >>>>> void destroy_large_folio(struct folio *folio); >>>>> >>>>> static inline int head_compound_pincount(struct page *head) >>>>> @@ -987,6 +994,15 @@ static inline void set_compound_order(struct >>>>> page *page, unsigned int order) >>>>> #endif >>>>> } >>>>> >>>>> +static inline void folio_set_compound_order(struct folio *folio, >>>>> + unsigned int order) >>>>> +{ >>>>> + folio->_folio_order = order; >>>>> +#ifdef CONFIG_64BIT >>>>> + folio->_folio_nr_pages = order ? 1U << order : 0; >>>> >>>> It seems that you think the user could pass 0 to order. However, >>>> ->_folio_nr_pages and ->_folio_order fields are invalid for order-0 >>>> pages. >>>> You should not touch it. So this should be: >>>> >>>> static inline void folio_set_compound_order(struct folio *folio, >>>> unsigned int order) >>>> { >>>> if (!folio_test_large(folio)) >>>> return; >>>> >>>> folio->_folio_order = order; >>>> #ifdef CONFIG_64BIT >>>> folio->_folio_nr_pages = 1U << order; >>>> #endif >>>> } >>> >>> I believe this was changed to accommodate the code in >>> __destroy_compound_gigantic_page(). It is used in a subsequent patch. >>> Here is the v6.0 version of the routine. >> >> Thanks for your clarification. >> >>> >>> static void __destroy_compound_gigantic_page(struct page *page, >>> unsigned int order, bool demote) >>> { >>> int i; >>> int nr_pages = 1 << order; >>> struct page *p = page + 1; >>> >>> atomic_set(compound_mapcount_ptr(page), 0); >>> atomic_set(compound_pincount_ptr(page), 0); >>> >>> for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { >>> p->mapping = NULL; >>> clear_compound_head(p); >>> if (!demote) >>> set_page_refcounted(p); >>> } >>> >>> set_compound_order(page, 0); >>> #ifdef CONFIG_64BIT >>> page[1].compound_nr = 0; >>> #endif >>> __ClearPageHead(page); >>> } >>> >>> >>> Might have been better to change this set_compound_order call to >>> folio_set_compound_order in this patch. >>> >> >> Agree. It has confused me a lot. I suggest changing the code to the >> followings. The folio_test_large() check is still to avoid unexpected >> users for OOB. >> >> static inline void folio_set_compound_order(struct folio *folio, >> unsigned int order) >> { >> VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); >> // or >> // if (!folio_test_large(folio)) >> // return; >> >> folio->_folio_order = order; >> #ifdef CONFIG_64BIT >> folio->_folio_nr_pages = order ? 1U << order : 0; >> #endif >> } >> >> Thanks. > > On mm-stable, dynamically allocating gigantic pages gives me: > > [ 23.625105] page:00000000ae27bd2a refcount:1 mapcount:0 > mapping:0000000000000000 index:0x0 pfn:0x1800 > [ 23.635117] flags: 0x17fffc00000000(node=0|zone=2|lastcpupid=0x1ffff) > [ 23.641969] raw: 0017fffc00000000 ffffa4edc489bb58 fffff784c6000048 > 0000000000000000 > [ 23.650141] raw: 0000000000000000 0000000000000000 00000001ffffffff > 0000000000000000 > [ 23.657907] page dumped because: > VM_BUG_ON_FOLIO(!folio_test_large(folio)) static bool __prep_compound_gigantic_folio(struct folio *folio, unsigned int order, bool demote) { int i, j; int nr_pages = 1 << order; struct page *p; /* we rely on prep_new_hugetlb_folio to set the destructor */ folio_set_compound_order(folio, order); __folio_clear_reserved(folio); __folio_set_head(folio); The problem looks to be because the head flag is set after the call to folio_set_compound_order() which looks for PG_head. I will test the fix of moving folio_set_compound_order() to after the __folio_set_head() call. > [ 23.663955] ------------[ cut here ]------------ > [ 23.667680] kernel BUG at include/linux/mm.h:1030! > [ 23.673378] invalid opcode: 0000 [#1] PREEMPT SMP PTI > [ 23.681610] CPU: 3 PID: 1220 Comm: bash Not tainted 6.1.0-rc4+ #13 > [ 23.690281] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS > 1.16.0-1.fc36 04/01/2014 > [ 23.699837] RIP: 0010:__prep_compound_gigantic_folio+0x115/0x120 > [ 23.706587] Code: c7 44 24 5c 00 00 00 00 5b 44 89 d0 5d 41 5c 41 5d > 41 5e c3 cc cc cc cc 48 83 e8 09 > [ 23.725954] RSP: 0018:ffffa4edc489bc90 EFLAGS: 00010296 > [ 23.731001] RAX: 000000000000003e RBX: ffffffffae39a720 RCX: > 0000000000000000 > [ 23.736065] RDX: 0000000000000001 RSI: ffffffffad522c25 RDI: > 00000000ffffffff > [ 23.740866] RBP: 0000000000040000 R08: 0000000000000000 R09: > ffffa4edc489bb58 > [ 23.745385] R10: 0000000000000003 R11: ffff926d7ff4b028 R12: > fffff784c6000000 > [ 23.749464] R13: 0000000000040000 R14: fffff784c6000000 R15: > ffff9266039fb900 > [ 23.753176] FS: 00007f69a9703740(0000) GS:ffff92696f8c0000(0000) > knlGS:0000000000000000 > [ 23.758299] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > [ 23.761275] CR2: 0000556789080640 CR3: 0000000105568005 CR4: > 0000000000770ee0 > [ 23.764929] DR0: 0000000000000000 DR1: 0000000000000000 DR2: > 0000000000000000 > [ 23.768572] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: > 0000000000000400 > [ 23.772221] PKRU: 55555554 > [ 23.773696] Call Trace: > [ 23.776170] <TASK> > [ 23.777258] alloc_fresh_hugetlb_folio+0x14b/0x220 > [ 23.779406] alloc_pool_huge_page+0x7c/0x110 > [ 23.781273] __nr_hugepages_store_common+0x191/0x400 > [ 23.783369] ? __mod_memcg_lruvec_state+0x93/0x110 > [ 23.785343] ? __mod_lruvec_page_state+0xa6/0x1a0 > [ 23.787223] ? _copy_from_iter+0x8c/0x540 > [ 23.788788] ? __kmem_cache_alloc_node+0x13b/0x2a0 > [ 23.790577] ? kernfs_fop_write_iter+0x174/0x1f0 > [ 23.792313] nr_hugepages_store+0x57/0x70 > [ 23.793754] kernfs_fop_write_iter+0x11b/0x1f0 > [ 23.795337] vfs_write+0x1e1/0x3a0 > [ 23.796531] ksys_write+0x53/0xd0 > [ 23.797690] do_syscall_64+0x37/0x90 > [ 23.798947] entry_SYSCALL_64_after_hwframe+0x63/0xcd > [ 23.800602] RIP: 0033:0x7f69a9501977 > [ 23.801798] Code: 0f 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f > 1f 00 f3 0f 1e fa 64 8b 04 25 14 > [ 23.807322] RSP: 002b:00007ffce87f3338 EFLAGS: 00000246 ORIG_RAX: > 0000000000000001 > [ 23.809460] RAX: ffffffffffffffda RBX: 0000000000000002 RCX: > 00007f69a9501977 > [ 23.811485] RDX: 0000000000000002 RSI: 00005652a970e5e0 RDI: > 0000000000000001 > [ 23.813443] RBP: 00005652a970e5e0 R08: 0000000000000000 R09: > 0000000000000073 > [ 23.815385] R10: 0000000000001000 R11: 0000000000000246 R12: > 0000000000000002 > [ 23.817289] R13: 00007f69a95f9780 R14: 0000000000000002 R15: > 00007f69a95f49e0 > [ 23.819176] </TASK> > [ 23.819792] Modules linked in: intel_rapl_msr intel_rapl_common > intel_uncore_frequency_common isst_ir > [ 23.829056] ---[ end trace 0000000000000000 ]--- > [ 23.830413] RIP: 0010:__prep_compound_gigantic_folio+0x115/0x120 > [ 23.832390] Code: c7 44 24 5c 00 00 00 00 5b 44 89 d0 5d 41 5c 41 5d > 41 5e c3 cc cc cc cc 48 83 e8 09 > [ 23.836787] RSP: 0018:ffffa4edc489bc90 EFLAGS: 00010296 > [ 23.838083] RAX: 000000000000003e RBX: ffffffffae39a720 RCX: > 0000000000000000 > [ 23.839764] RDX: 0000000000000001 RSI: ffffffffad522c25 RDI: > 00000000ffffffff > [ 23.841456] RBP: 0000000000040000 R08: 0000000000000000 R09: > ffffa4edc489bb58 > [ 23.843150] R10: 0000000000000003 R11: ffff926d7ff4b028 R12: > fffff784c6000000 > [ 23.844836] R13: 0000000000040000 R14: fffff784c6000000 R15: > ffff9266039fb900 > [ 23.846521] FS: 00007f69a9703740(0000) GS:ffff92696f8c0000(0000) > knlGS:0000000000000000 > [ 23.848417] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > [ 23.849797] CR2: 0000556789080640 CR3: 0000000105568005 CR4: > 0000000000770ee0 > [ 23.851491] DR0: 0000000000000000 DR1: 0000000000000000 DR2: > 0000000000000000 > [ 23.853181] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: > 0000000000000400 > [ 23.854861] PKRU: 55555554 > > > Something's broken. >
diff --git a/include/linux/mm.h b/include/linux/mm.h index a48c5ad16a5e..2bdef8a5298a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -972,6 +972,13 @@ static inline void set_compound_page_dtor(struct page *page, page[1].compound_dtor = compound_dtor; } +static inline void folio_set_compound_dtor(struct folio *folio, + enum compound_dtor_id compound_dtor) +{ + VM_BUG_ON_FOLIO(compound_dtor >= NR_COMPOUND_DTORS, folio); + folio->_folio_dtor = compound_dtor; +} + void destroy_large_folio(struct folio *folio); static inline int head_compound_pincount(struct page *head) @@ -987,6 +994,15 @@ static inline void set_compound_order(struct page *page, unsigned int order) #endif } +static inline void folio_set_compound_order(struct folio *folio, + unsigned int order) +{ + 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 4c2fe7fec475..6390de8975c5 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1780,7 +1780,7 @@ static void __prep_new_hugetlb_folio(struct hstate *h, struct folio *folio) { hugetlb_vmemmap_optimize(h, &folio->page); INIT_LIST_HEAD(&folio->lru); - folio->_folio_dtor = HUGETLB_PAGE_DTOR; + folio_set_compound_dtor(folio, HUGETLB_PAGE_DTOR); hugetlb_set_folio_subpool(folio, NULL); set_hugetlb_cgroup(folio, NULL); set_hugetlb_cgroup_rsvd(folio, NULL); @@ -2938,7 +2938,6 @@ struct page *alloc_huge_page(struct vm_area_struct *vma, * a reservation exists for the allocation. */ page = dequeue_huge_page_vma(h, vma, addr, avoid_reserve, gbl_chg); - if (!page) { spin_unlock_irq(&hugetlb_lock); page = alloc_buddy_huge_page_with_mpol(h, vma, addr); @@ -7351,7 +7350,6 @@ void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio, int re int old_nid = folio_nid(old_folio); int new_nid = folio_nid(new_folio); - folio_set_hugetlb_temporary(old_folio); folio_clear_hugetlb_temporary(new_folio);