From patchwork Fri Oct 6 03:20:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 13410937 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3A9EE92FDF for ; Fri, 6 Oct 2023 03:21:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4EF4594000C; Thu, 5 Oct 2023 23:21:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 472DA94000B; Thu, 5 Oct 2023 23:21:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B94B94000D; Thu, 5 Oct 2023 23:21:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 019B894000B for ; Thu, 5 Oct 2023 23:21:12 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D0921C0639 for ; Fri, 6 Oct 2023 03:21:12 +0000 (UTC) X-FDA: 81313585584.25.208A857 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf09.hostedemail.com (Postfix) with ESMTP id 9759B140008 for ; Fri, 6 Oct 2023 03:21:09 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=olpdDtdz; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=g4Tuc5vx; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf09.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1696562469; a=rsa-sha256; cv=pass; b=6HGGRrnTlF/VW581OUVs7glowmJjSG2Nmd9o4MK4EbB6nlu13mJe1Fp4rO9exrkw8YKwnk DuIY24f+RDZIVHzt18LCexGeWJgje61SSD5F4Akw8CZLPlJmsiEsGrbznXy3hU7SIpY8wB s1xApdyLripgzJ7W3FqFnSF0ZDF8gIg= ARC-Authentication-Results: i=2; imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=olpdDtdz; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=g4Tuc5vx; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com; spf=pass (imf09.hostedemail.com: domain of mike.kravetz@oracle.com designates 205.220.177.32 as permitted sender) smtp.mailfrom=mike.kravetz@oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696562469; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Tsc70UZvKWYWI+spZQiVZ3u2z8ZAo9dlRTusEOzzs6g=; b=K0bmZfWjzj4rhoLiVf5qLPiqd0SoT1/+j7zcqBfIricLBGbGwCOBSbSMWv4XLgs8FSyNYy f/gkWR5T3Z53sFNJ7BPnLFQAeistMOqLAFsmAlvUMydYStFLiiKF4NGzM753nwmZ6ZPwti UL+y951eN5CzE4DFGS1USOEBlZqh1Gk= Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3962O5IM013551; Fri, 6 Oct 2023 03:20:45 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-2023-03-30; bh=Tsc70UZvKWYWI+spZQiVZ3u2z8ZAo9dlRTusEOzzs6g=; b=olpdDtdzl/CwxMMvnqZEFjSQX+IquBx9RLp19IIjNUhzsJR7/nDQwPi7b7smEgQEl/Ew e3iaocS/eUd5VcsIAzDRPvUSyTsyrlOXPlNKO0JM666X3DQi2lS4YQpETHCMA5aod0zl O2tI3Fw5hiksBkI1Fe09JhpKPZaLDRceEtS26O7CtIIlqFnHizeHZ2MzQasgIoVi1Qo6 g5PmFCTktRdMuACOEGr8abul8hD512e6t7TL//f5SITVGRwHdai1sCzrSVElD17Cf201 rA2MKurRlVcB2piZAei1w7VmlvzgtOajt2xEs+5cnHh/VttLYGgJyfDjxvrX1VCS5WhB uw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tebqe31sn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Oct 2023 03:20:45 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 3960ZFQd000462; Fri, 6 Oct 2023 03:20:44 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2044.outbound.protection.outlook.com [104.47.56.44]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tea49xw5j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Oct 2023 03:20:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G5iPwe0XAUt0yYZMacMLd33X+fYyEigQzt+p2RCGfzPatrJjuxVbVSQ+vpjwv8Vz11SGQNECaqN+QbX01orMNPA2gDXmj1S6m/1NNYIVc6bE5uepHTFCrtI1yKrGUksq1EGCjGJK0gL3w9Dof+GRS5pcAsrqI4RiYqgSxNGQawbHeIwe/CbixTFjItoShPkELsz1GzclnkbCl2dF7Y28avBfUTESQemf/oAXRC667USw94DjBcos8Lyf5h2LIpvf1rWCukXFekRFEoANyghcGcsFpPUoZILonOS91GovU1F+h6zEpeDs2wbf+Cri8r/tVuvatsyw7Nnp1eanvIi1tQ== 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=Tsc70UZvKWYWI+spZQiVZ3u2z8ZAo9dlRTusEOzzs6g=; b=czXjKQHfK+InGMIsUV3Y2zoX6mebVFmVAqAvj4yJh06UgEHIaFdPdBqwj1AWB6IDKpamySrf5TNzNbC5ojB19a/huaetCVQjxkYX2VXdEcjCWeXL3dBCo9N6CQkaWmQgenwMzy4uiFZervuaKIhL7thZVpzaZ3irQBO6SE93qqcGmLTkjhc+LO/wPzedi6BI7AAZE7Z0hS7bjbNdPfAgQls/+n3oOWTJCBruGARtIdlXtttj3zrk3eSr0iwawV1E87AKoT78DNTAVSRmPRD/DCMRszibxoBjQT4BQruafkbaqWIjgAYYb+cb/olsFp1h1wedGwupoTS4gLem7r6Kyg== 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=Tsc70UZvKWYWI+spZQiVZ3u2z8ZAo9dlRTusEOzzs6g=; b=g4Tuc5vx5yDq6klYbhgJdI2+UdFcQdljiponoS4TzqPh8+XBKLRGHFXN8N0ShHyjJDvG/2FNbGzYFjDfSdfAZS3sKAT9P77jwtdEkTVpHlfxee2sw6+QDdXxBADpCttCRiL30xuIiVNwrVLyqiXV0lv1oyYcAG6AClqJjhj3tDE= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by DS7PR10MB5391.namprd10.prod.outlook.com (2603:10b6:5:3ac::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.38; Fri, 6 Oct 2023 03:20:41 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::59f7:ec45:eb41:d8c2]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::59f7:ec45:eb41:d8c2%6]) with mapi id 15.20.6838.033; Fri, 6 Oct 2023 03:20:41 +0000 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Muchun Song , Joao Martins , Konrad Dybcio , Oscar Salvador , David Hildenbrand , Miaohe Lin , David Rientjes , Anshuman Khandual , Naoya Horiguchi , Barry Song <21cnbao@gmail.com>, Michal Hocko , Matthew Wilcox , Xiongchun Duan , Andrew Morton , Mike Kravetz Subject: [PATCH v7 7/8] hugetlb: batch TLB flushes when freeing vmemmap Date: Thu, 5 Oct 2023 20:20:09 -0700 Message-ID: <20231006032012.296473-8-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231006032012.296473-1-mike.kravetz@oracle.com> References: <20231006032012.296473-1-mike.kravetz@oracle.com> X-ClientProxiedBy: MW4PR03CA0357.namprd03.prod.outlook.com (2603:10b6:303:dc::32) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4196:EE_|DS7PR10MB5391:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d80be4f-e16b-4ea5-1abf-08dbc61b383f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W/cYXfL1LFwvYYhs9Ds/a8TPTpSdzs0VMGXU5UsO64Oo+Dc5jyRZ4eV4ymkdLdHZ60VZhdCHWgC0DEU1JvgyAeYQqiXeOjXLV13/9IAPIhfkd/awo4qnZ/3Q51iP9vNFt7HOUcCA7UrXZWNJqqBdp+7Qcq5AkR5yiA1VLS1vXmzhfTA7PtR7/FUwgHcNd0PDIdTnatqE22nqkP08GXIKN5eUDcmQoI/N8DNuypLLyHC2/0ZwROWiX5S4SDvQfdjD6OogxinIiH/7Aa3faVDAx8kjA+HeUns34JSJcfUyUJe0t8aFACUCuB2zPdCEW2tMGbhKV0zTbOuuIEN9jUZe/yf/43SwDAD1Z8gN/03KJDfjhdJwNjG8KoF1zHT2t3jJsPoNU1Fs+jqjSuZW+crktZBZrttMDh5l39Plu/9hjNOt8WTFBwbR9vEMtBpTBeJkYFf/xj2QI6QCea2L/nYonuqDvPo1ZR+dCZzCiZehtoFgZbGZuyQl0yFm5t7UNIAuYW+7yRHcsUx3JbSJRyD3xF+ytzCtN0XL0CX/vdqRU7qJ2AOs0YjXzduGm695Z4eA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4196.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(396003)(366004)(376002)(136003)(346002)(230922051799003)(64100799003)(451199024)(186009)(1800799009)(6506007)(6666004)(6512007)(6486002)(478600001)(38100700002)(86362001)(2906002)(7416002)(316002)(41300700001)(2616005)(83380400001)(1076003)(107886003)(26005)(36756003)(44832011)(66946007)(66556008)(66476007)(5660300002)(54906003)(4326008)(8936002)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9tGa+2DSHFIMvqeG4oW3Uw3sRQ77YNnIrRFMLm7KF7KXi6PbpqP1pPUo9Zi0obEJraBICepfd4hY9jHdvl79wgs5EjKXnTe4b8mAQt9txuGskn5INTgsqM/2E222EnpK1ai/ppQAZKET3ed1OjXegZ5qXNpP3jQQrNKYgQDqUo9WQHwcrad/Oh9dfO4Wm+PUQId0xLS+OcZDI6yWli1GqA0M9mw+57Etq+J8ndeyLLymXg2RRPoMLCfwfu4zmn3ZNP8WV/QNAmrKaNaQyKs2hLBpPtkgfEXzWV3TJw2D4umzTq/Ro+5AWfrm4/L3jFfk4pJx9k0I7BihYUDmKORBi1ndLRtXa4Sh05FSQhk3UcA+lsB7rLrSWUSAQphSnTIHU5b3DY9QXMkVDsM2MF0cs/jvlocsGdbf3Ke7o+zN/J/kXcqP+EkeRd0cOI2Pifwzglre/crx+3SncpXiG2wPIxU9fVZuNMbNlbVB421SqtiG8PZUFAOVqK30jsGhrqDyiYlmULgCnP2dyyEu0YGE2BaXHD3idthMBqEFZDpQq2Uvd+HOOzBj1Cft1qoFToFG77jSXaceazxnv5NC0DJbBjSdgsMFayE1yk7ssLfkXLXw5B9OJTTv6CGrpiC7BkwrlR8PpuJRUlDqnTH6wsPPPcV6b+PQUZ8tno1ylvDXhZ5l5IcdPhvMl7L9I1yLUn4LXkVoUpevMLUPlGukqDCvnXmS3MPGZyHSSmhl6DfIvsiYSw+JyI8igpNXy/Jom8xhw5/489lN/fZ4i3bVWRQZUrLZ4UngZxb6UtIngdlBow2KZ9PoIVZ6TPLuYNpetSDseXTQ9SPQxASBjMw/RVgEFxTBJQKuQQYfM532H19+fYIcBK/QcROcmXtEGu0HvitDql4E/TIfXSLvFes16aQvaLl0ZDeGjJ594ck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/kmb4vp1YikLaF4lqSMekVn0xtzdNxmEi7snqCMM/8GGOFqt1O2UmopkPYjlrYKr6fFmqeXxvCvLXn650ShKJ1byu43a5qdku9tn6xT48ZIl1HRIX9GEMLSWmZYP8P2OJKy1og60M/cUL16p6GZEAkooF5CuTLcE/i3nv61kmyQI54tsB6Zf96gl6NidjWadh9riAHvgHUsjJ+3RfVFycQz7cvpGcfuYdIJOTawjH/F0H2VMCyh5uN8id7aYKl4ZMeNouV76yxbBMlTA5pEKOpUvBDbhs3Jyp3VNW0BOf+51dDeQ74m/6sIPEOAJ/waxDRr+QWNWSx3edP+nIhymwUXXKatviZSwHxixi4lFWop6b/TriPteI8Vor5Xutw5Vt/riBA98x18e/PuE461sYKGe7uHMj6qh+HQyWHVJtOyiy6pxNjLccqrrmKNDQxpM+D9FO6O2uA8oT/vpJxZ2JimZ0Qyn9zAszFpGJeGelqh8uGIbIPoThGH8Hv4l/wSMTwUMfsCcbOS+ebLgHCOnt/q6RdhoV5IT/JUEQv+Yas+Nv7l/FKN8pYiRSboVlEhHHKkQOO+qltyyvTqf+f+CvP4rf3t6CthYx/YKLrZ1dRCDOmjacq0kJvcIHii5fzWclR4vCksifyQKDGRgMfCVqq/IorX5MOdnF5a6lcwJ2Di3ayE5FhMtXiNJkoLuy4D4TMoqiuAmG6lE2zck8HYdUyKaeZZvC4C2WpmYZpwOB/NRqAbGWSDDFRGVrEBJpy/8OXRlOCizTcj0/lCBflHonQMNlHXCs84hh4M9KNpnlUoNfo+g/49+Rik7GfHMiSnq2iUptU52I82DCrRQVgRKw71u5O8W4k4illTmojg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d80be4f-e16b-4ea5-1abf-08dbc61b383f X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2023 03:20:41.4226 (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: D0RhtxQO8uLswloaQpO6+HggiAeSMBiUdm+T4jrIdafgVGUa4OeABoz3ZAJXTPiSz0eLDyxqGBDjuhP2FqyyUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB5391 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-05_18,2023-10-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310060024 X-Proofpoint-GUID: -47XGJ4857WhJEnnl-UfNGV4jqLyXxaq X-Proofpoint-ORIG-GUID: -47XGJ4857WhJEnnl-UfNGV4jqLyXxaq X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9759B140008 X-Stat-Signature: zxpof9t9e3aiedb7tz5f5eeeyzorkhb5 X-HE-Tag: 1696562469-225737 X-HE-Meta: U2FsdGVkX1/NGIGSs7a4JbDnyJvFU6LH91jlmHlzCPYfY7osBNaJDB14aeO9imepNarqSCMgr9HH0chQsBryz1w3e0ZftEJthERk0oCUwO4O9qKXB3BSz/GDZuJk++IAXoQ5N9GT79SvzhMwPfL2tfkkZENaKLITewxyNzmwpnr9m7Sxpi4JTaCkROIUlJK8Vt35afUcl/ECEqxeoFNR5TilysBIQ9ydRrjsHjBfs/ii9d2Nd8QZ3WoO/UB8KfFS7tmRvMin+EQJWQwRDdX6dDlJCUna1MSnKM4PENITp3YODTjmkwaA2QhZjBg50wOR8Zc8sNzAmguecL9fuGgPgpPSy115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z2XaKSG80/En1UwfTe5lzQyqDf6NL+aEhMF X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Joao Martins Now that a list of pages is deduplicated at once, the TLB flush can be batched for all vmemmap pages that got remapped. Expand the flags field value to pass whether to skip the TLB flush on remap of the PTE. The TLB flush is global as we don't have guarantees from caller that the set of folios is contiguous, or to add complexity in composing a list of kVAs to flush. Modified by Mike Kravetz to perform TLB flush on single folio if an error is encountered. Signed-off-by: Joao Martins Signed-off-by: Mike Kravetz Reviewed-by: Muchun Song --- mm/hugetlb_vmemmap.c | 49 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 10739e4285d5..9df350372046 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -40,6 +40,8 @@ struct vmemmap_remap_walk { /* Skip the TLB flush when we split the PMD */ #define VMEMMAP_SPLIT_NO_TLB_FLUSH BIT(0) +/* Skip the TLB flush when we remap the PTE */ +#define VMEMMAP_REMAP_NO_TLB_FLUSH BIT(1) unsigned long flags; }; @@ -214,7 +216,7 @@ static int vmemmap_remap_range(unsigned long start, unsigned long end, return ret; } while (pgd++, addr = next, addr != end); - if (walk->remap_pte) + if (walk->remap_pte && !(walk->flags & VMEMMAP_REMAP_NO_TLB_FLUSH)) flush_tlb_kernel_range(start, end); return 0; @@ -355,19 +357,21 @@ static int vmemmap_remap_split(unsigned long start, unsigned long end, * @reuse: reuse address. * @vmemmap_pages: list to deposit vmemmap pages to be freed. It is callers * responsibility to free pages. + * @flags: modifications to vmemmap_remap_walk flags * * Return: %0 on success, negative error code otherwise. */ static int vmemmap_remap_free(unsigned long start, unsigned long end, unsigned long reuse, - struct list_head *vmemmap_pages) + struct list_head *vmemmap_pages, + unsigned long flags) { int ret; struct vmemmap_remap_walk walk = { .remap_pte = vmemmap_remap_pte, .reuse_addr = reuse, .vmemmap_pages = vmemmap_pages, - .flags = 0, + .flags = flags, }; int nid = page_to_nid((struct page *)reuse); gfp_t gfp_mask = GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN; @@ -629,7 +633,8 @@ static bool vmemmap_should_optimize(const struct hstate *h, const struct page *h static int __hugetlb_vmemmap_optimize(const struct hstate *h, struct page *head, - struct list_head *vmemmap_pages) + struct list_head *vmemmap_pages, + unsigned long flags) { int ret = 0; unsigned long vmemmap_start = (unsigned long)head, vmemmap_end; @@ -640,6 +645,18 @@ static int __hugetlb_vmemmap_optimize(const struct hstate *h, return ret; static_branch_inc(&hugetlb_optimize_vmemmap_key); + /* + * Very Subtle + * If VMEMMAP_REMAP_NO_TLB_FLUSH is set, TLB flushing is not performed + * immediately after remapping. As a result, subsequent accesses + * and modifications to struct pages associated with the hugetlb + * page could be to the OLD struct pages. Set the vmemmap optimized + * flag here so that it is copied to the new head page. This keeps + * the old and new struct pages in sync. + * If there is an error during optimization, we will immediately FLUSH + * the TLB and clear the flag below. + */ + SetHPageVmemmapOptimized(head); vmemmap_end = vmemmap_start + hugetlb_vmemmap_size(h); vmemmap_reuse = vmemmap_start; @@ -651,11 +668,12 @@ static int __hugetlb_vmemmap_optimize(const struct hstate *h, * mapping the range to vmemmap_pages list so that they can be freed by * the caller. */ - ret = vmemmap_remap_free(vmemmap_start, vmemmap_end, vmemmap_reuse, vmemmap_pages); - if (ret) + ret = vmemmap_remap_free(vmemmap_start, vmemmap_end, vmemmap_reuse, + vmemmap_pages, flags); + if (ret) { static_branch_dec(&hugetlb_optimize_vmemmap_key); - else - SetHPageVmemmapOptimized(head); + ClearHPageVmemmapOptimized(head); + } return ret; } @@ -674,7 +692,7 @@ void hugetlb_vmemmap_optimize(const struct hstate *h, struct page *head) { LIST_HEAD(vmemmap_pages); - __hugetlb_vmemmap_optimize(h, head, &vmemmap_pages); + __hugetlb_vmemmap_optimize(h, head, &vmemmap_pages, 0); free_vmemmap_page_list(&vmemmap_pages); } @@ -719,19 +737,28 @@ void hugetlb_vmemmap_optimize_folios(struct hstate *h, struct list_head *folio_l list_for_each_entry(folio, folio_list, lru) { int ret = __hugetlb_vmemmap_optimize(h, &folio->page, - &vmemmap_pages); + &vmemmap_pages, + VMEMMAP_REMAP_NO_TLB_FLUSH); /* * Pages to be freed may have been accumulated. If we * encounter an ENOMEM, free what we have and try again. + * This can occur in the case that both spliting fails + * halfway and head page allocation also failed. In this + * case __hugetlb_vmemmap_optimize() would free memory + * allowing more vmemmap remaps to occur. */ if (ret == -ENOMEM && !list_empty(&vmemmap_pages)) { + flush_tlb_all(); free_vmemmap_page_list(&vmemmap_pages); INIT_LIST_HEAD(&vmemmap_pages); - __hugetlb_vmemmap_optimize(h, &folio->page, &vmemmap_pages); + __hugetlb_vmemmap_optimize(h, &folio->page, + &vmemmap_pages, + VMEMMAP_REMAP_NO_TLB_FLUSH); } } + flush_tlb_all(); free_vmemmap_page_list(&vmemmap_pages); }