From patchwork Fri Sep 15 22:15:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 13387790 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 B6E96CD37AE for ; Fri, 15 Sep 2023 22:16:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00EE46B0398; Fri, 15 Sep 2023 18:16:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB0A16B039B; Fri, 15 Sep 2023 18:16:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C40886B039D; Fri, 15 Sep 2023 18:16:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AE2E66B0398 for ; Fri, 15 Sep 2023 18:16:53 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 806EDA07F5 for ; Fri, 15 Sep 2023 22:16:53 +0000 (UTC) X-FDA: 81240242706.07.895202E Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf09.hostedemail.com (Postfix) with ESMTP id 34CEA140022 for ; Fri, 15 Sep 2023 22:16:49 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=yKe4AgVA; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=nzqn3FtN; 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=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694816210; 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=qMEVjuvfkFjYvAgifMfI1ykIObOzu1AqZltnchTcTjQ=; b=ibnG1qNhi6wQjTkxysOJVBwU9UH16t6pHwyiE6bwv1JA4/kMCF8tJrK5bZCihs7xthzdDx +ZcPcHOlVjDojrtqqR3yVRIrj5cWuDNVkjrGhgxx+ZKvl/ekriaGW1GV8fVF0BIDeLMml+ OiDIM5Z098Sf6fjzRuLO7+t02PqFZmw= ARC-Authentication-Results: i=2; imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2023-03-30 header.b=yKe4AgVA; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=nzqn3FtN; 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=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=oracle.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1694816210; a=rsa-sha256; cv=pass; b=cVOtlTjBhDDggELhBarG7U9V+9yJ1eksC+L7cEUbRBi0eaTDT5rIi7uzMr4PrfInM20X6V gv3NeMcM8SFwP/sSNWGGDETlKoCkR+ojh6eVbxXAJ+W/VNft+7NNzZ6Rm5qGQ1OXZ4YaB6 hotRFfSSx+/HTNdiuqoEswdZ0ZqjApA= Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38FLx9pG007419; Fri, 15 Sep 2023 22:16:23 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=qMEVjuvfkFjYvAgifMfI1ykIObOzu1AqZltnchTcTjQ=; b=yKe4AgVAeecCRxLkm8a0yu3K56ssTMsX/b1DldJY/PwJhQATjWxCktUBGqDy7YzjJljg A1nHI1mFvxrWHAeMn4tEaA4rQ323e7Pwi9K8rXgCdq1IkbqHnc3x/T/LO/ZcnbXdaSUF 1JGRa+9C5cpeHRIcifcVAjaT7wcrj8mdngjo7CX2nSnJiJ58H9VEoqdh76l5jFJza130 mPdHdUBFSje8TnFaijpWEjE4A4z3/ghspwQq+hiEN61ph+6bUzJtKcQh9L81KmpHrDUf /EvEgdJgweBsY7l7aClpjGS8GXgZVzGZ+j8s4+9mlRfNsxnD5Lcu7ThTXTWSRJen4U8m /w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3t2y7hgsw5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Sep 2023 22:16:23 +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 38FLT2W5030436; Fri, 15 Sep 2023 22:16:22 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3t0wkky7bg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Sep 2023 22:16:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XIjsB/ARC1KioLR0Lnr9fyYS8Ue+SXOCc6LxSeEqHviOsKSN4w8b0s2To9KHTxBzG8idflUTCVsZO1c5zCAU8QhH8LJ/gmOsvZh58Osj3zbct9aHi1bygXRX8I13AKtwv1DvCnJy1eLm5tuxgt2j0HU9uP2lgmDL2i96ALfoJtSK7FdSHQCKXVmqzpz0oZCo8ccyQNQNQfte2uEQHs/RDOG/McKD2aiJpqPy3iRhYeiOdwM350UEAuI5ZJqWquyXjgadPVQkVUlJ8xIHmp7X0Jj199N7JzmtnxauZox7G3UwuyluTuVvg+eYhnDokHG+bMRmzQ4DbmHNiE2gct+/kA== 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=qMEVjuvfkFjYvAgifMfI1ykIObOzu1AqZltnchTcTjQ=; b=kup2QUgVPEHlI45bkXqLlHZbB3Df+Kullt66f8pDFCHKUqu2A2HemaKA5a1hnhCLMI2VkNiySo/BFSvnSLHFzSes1+yZnlQA50tH3D3UbnKO1vwvNn58BvRo+ZBK5ntdWiltj2CXAWgWUQniQFmIaWvBCp6nuvZ+N8KSjRjW/k9p7q2iTSgRTnTAW4q9CbLFFgKsBhy/YDKed7uA0E54Q7BMqcj8I6YvBzIfQsdGT6MH71rcrTOuo50qRS++FkkMfzijl1VSR2q3c9du4L/XD3MX0BFDcFl1WexYAuPpizTrnBQaezJ2miZiQKChpUN8DbQQ/VMeN/Xqfc6gkOUPSw== 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=qMEVjuvfkFjYvAgifMfI1ykIObOzu1AqZltnchTcTjQ=; b=nzqn3FtNt88Av3X4XlmOd5b5YEuPibh/F1MOkad1ze9uMsEx6V+wlkk9VK1ZWI0ZuC1mfEG3r+2Brr7R8wZfMQcnP+7oGyCDqXgHBbNfvgs0XBrCQm8+fKhC27Sj0EHAftQYgK88dCE3eofN3eRtap/dKivQ1/i+sR5XMjpE0bE= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by MW4PR10MB5861.namprd10.prod.outlook.com (2603:10b6:303:180::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.34; Fri, 15 Sep 2023 22:16:17 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::c621:12ca:ba40:9054]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::c621:12ca:ba40:9054%5]) with mapi id 15.20.6792.021; Fri, 15 Sep 2023 22:16:17 +0000 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Muchun Song , Joao Martins , Oscar Salvador , David Hildenbrand , Miaohe Lin , David Rientjes , Anshuman Khandual , Naoya Horiguchi , Barry Song , Michal Hocko , Matthew Wilcox , Xiongchun Duan , Andrew Morton , Mike Kravetz Subject: [PATCH v3 09/12] hugetlb: batch freeing of vmemmap pages Date: Fri, 15 Sep 2023 15:15:42 -0700 Message-ID: <20230915221548.552084-10-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230915221548.552084-1-mike.kravetz@oracle.com> References: <20230915221548.552084-1-mike.kravetz@oracle.com> X-ClientProxiedBy: MW4PR03CA0063.namprd03.prod.outlook.com (2603:10b6:303:b6::8) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR10MB4196:EE_|MW4PR10MB5861:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e2c3b76-2789-44b8-2034-08dbb639618e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oSU7QTzK/v4SvSuOoilAkoV80j8viuRa1HfM1/stxBO8fGuCmRW0IYxHuYf7bIhhit9/KgTQsrHu2tb3RJ0z9HI3UpiUsbwWCtY3TXMrH+G7gmqV6QGLIISFhIDHDf/luEXtHsGuDebhmtbtoEFq8u5a1ljUMxVCHUD3OYqRtYAXTJGKiRvW3d+vMIIbCrWxENQJvs0XftujCWAYCdb4d1C27vURfOGt00+hlsSRCtHpma6OpxnaGFaHV30sNWtvbEjRDFT4h7jNr1zXTESZxQSjwxhGA5z6lVKuG1YJUV5Ln3C8dXZUaf7tLu+Ms0uJeVI66WHwSzkRJt5Fq/V+Z1wQJLx62hiM+oCiG25HzcsNNpbcpipTIEBbhH8FJ2HHRnCRM6ouhJ19SucbJ3OsodXV9OamexJKGdzdRJXfasusScg/V734XPQlcg4r5MiE0jL7Y0ywhqg4WvJWe1ETTZ8ZD5e3WV9w6CosI9bWmtP1l9QrCfMs5dyPRAxznmexh+vUQU5LKDJBR35d1vs5hwcXKQqdhDXj/YwzrM2lrnyU4mxXcjBKjYG+pwvXs3g6 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)(396003)(346002)(39860400002)(366004)(376002)(136003)(451199024)(186009)(1800799009)(44832011)(86362001)(36756003)(83380400001)(2906002)(38100700002)(478600001)(1076003)(2616005)(26005)(107886003)(4326008)(6512007)(41300700001)(5660300002)(6506007)(6486002)(8676002)(6666004)(66556008)(316002)(66946007)(8936002)(7416002)(66476007)(54906003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iFrVz4s6v4uIN5jTg6lJouiLySvuAWKJ+Rlt7377C+D469XIA0hFR4LJ6Gg9WLtnEnXU854ZFbQKWNOwLcaLCmPXr2zi0I5PeMU2NqXt+S9BY8DSOuWGv1weNFU/fH61ERr4glCFPZBvJfwO6XbBt+TQc6Wj35ARC0atva2A1PU9D8v/tTDm5/QJGGP0EZVM+odr4NG6kiSIk/nlQe5zVGCV0HHcA/PaEzWg+txLznct2iET7l3fS3xKC2Wxe2Pdba/Nsmov4slkUXs3b3BSqMJ2lnZ7+c2YW+8etaB9dJGcV8PnbOA/QZFR3ZaOjdf0l1c0ODjaz1H6+51OBMQfQeMLvIBA3gPbY2hGUhiVUfFraMe4hKbqduttUBnA0UnNK6Bv1GSVRZcRb0j2AQcDEie792kuacY4E7Tk2B/MghaN7PX4q/3WgR8LXKZUU4nQkzkpzBdgZnMfNIN/yopIVSWBltSNVyEj2PaJZIQHC52lko4eUsFQs0UUicvhSfr0229zzXtgOzrINptg11iPVB1Y5Rps1NBchThJomiDK5Oqk7q3D2qlwbTITBLP/8cN8YtAGngx+DgvRsXeOeq5s8wfuIr3Kuo1Dt+5Wc2uR7+dqYqEttXfFi+9KgKnkgm4/vrSQ+HnFUY6EALIb4arMU8Bzd8qy9sb/cGEB23IQzo70aoQUmf5N/+5UaAGbDGh5APSZsPEM543+WU3l2njXYYFoG5IuypY/w7wzqTszJJVTVLp0J5ahkSvcplx+yzCjqi+6af5i5NYVqXHVGaHqa00W1cSEa62pw6oEZMpCInV9itNxfxjAjoJCrbp+BLD56g/THqCFBA8UTbuu0C18yDFEpu4Z6JD/T8Myet6Fl33x0nTsHMWlGdZX/ABvwG6spnXWc1ZPnWvxrEVyaRv5UfDTKhxcfY1Y8M4AB1TwgZrEpbgohBffTgALh119U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SbjtheARVTmrXU7CRVQFYmo0mMLSkSb5lldTsSXNdK+da6hMylDjVCoekIkB8p/TB7k7GkjO62IiGicVyz2EtG0nY1CjkhFTV1nr9esTVGl5qbpN5PEHxAanx7ON2NtjCMJ9yjWNBjR0uhP/PZiD2BMbqVgncjCMJgHpE8ZMn38lJTGVsEpqmrOXFwCfv5fOgrQJrdvgKIj8Sy1SXzRyTQk4Tf5U7LdNWH3i8w13jU5UgnvNJAQ1GuWeLYt5lphzYIJCIK4IsBXzrQ6wKXEc7oAeeoB686aMWliXjx7RmjnCinIgpfpB8BdFsUFk02rp3TYQ2sfc3CmQsjF9xaoflaxoUwOlatgrP+IvumVYsh38qAV1L+GDNsyFFpz/XLnJR/zb9Hlw9Dnu/De5j+57YxGXoBy+peCH5KhgR/2Kw2OtmxPGSsuhWpZl3gdvK+OLl6tGxnGJQYCUJ1Ht/E2Q8Q/tDKvOvBtwZzgvv/GMY4lMK2ASrLZwPfuCJnLSNYT8n/ipEUTuWwHZbdESL7uhbExEgLI3jTSuIZPP5NdJECH5ZQWSVjK0zxzd72Ls/GYzlJ2rfpry9x7qMjhGSJM9AkSpKzEZGHa7Iq4ViWxUsnq3m3ul+AdZu47rUQapOOLoe8S3gijXo82+G2gyjNeDIM/kbFUmKIz+IlEFZehUgVnfvwt5v7s5Mf+8H82r2gyCYU+OYwZ2xnXe+CFdvSKOxnEwF+d2CwsySd4VE88nk6TAB/+dGhUrQLEl2qRstzZKuwfSSfAtUUP3NtEjkKgfx6HeGFEPQM2JZE5fM4pn X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e2c3b76-2789-44b8-2034-08dbb639618e X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2023 22:16:17.0488 (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: f+qqFJ6mvOfgJ/Vf6y2CkI3FG7KFafnmZNedrdQMI/XYzIq9JeJzWIWp0vi1ocVzWfSpvwj7YKfqz3DAgkksOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB5861 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-15_19,2023-09-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 phishscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309150200 X-Proofpoint-ORIG-GUID: GBV07K0Cu-JuI4Xj5UkNQK0it1kmM2rJ X-Proofpoint-GUID: GBV07K0Cu-JuI4Xj5UkNQK0it1kmM2rJ X-Rspamd-Queue-Id: 34CEA140022 X-Rspam-User: X-Stat-Signature: yz7eh1cz3udakt5f4hk8cw67w83t5mht X-Rspamd-Server: rspam01 X-HE-Tag: 1694816209-244608 X-HE-Meta: U2FsdGVkX19snEn+qGlm/f2d34C/q++G4yTaV5ecvfcy1AWKwP+v24TSZT065+NtZySM6sIEfpwwjILEj2tTarhY6Az3iz9iOZikGAMKWjhKfTJl8Umflcj4qpFaiMJ3kCt5upcXfrWqIZK5Ug4k3n0oyUQ6g7uqFs672IIH4tbdWOI/kx7SMn+BIq16owcpHwejCmDVSpCOqx4K1ENEiUGHpsLN4VCxYC93QMsjYcDuskaVUsOOvWdkib9yTo2lp7hsGRfXlzHzCb4xPS5vthqXG6FHs0uL0abE6iV2ERZKR2ICsqr775Q/r4LCEwFXZK6YQxEUQe21dupw9nU5IjpjivgZ1wbBXE4livPXs3dMagVWLxR5R5xVt3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ceTIVqyo5R91HUKl6cx7VXgh2rNzuX7XmsYYEHJ4 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: Now that batching of hugetlb vmemmap optimization processing is possible, batch the freeing of vmemmap pages. When freeing vmemmap pages for a hugetlb page, we add them to a list that is freed after the entire batch has been processed. This enhances the ability to return contiguous ranges of memory to the low level allocators. Signed-off-by: Mike Kravetz --- mm/hugetlb_vmemmap.c | 85 ++++++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 26 deletions(-) diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 0eeb503d8a4c..8f8a559ff6ac 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -222,6 +222,9 @@ static void free_vmemmap_page_list(struct list_head *list) { struct page *page, *next; + if (list_empty(list)) + return; + list_for_each_entry_safe(page, next, list, lru) free_vmemmap_page(page); } @@ -251,7 +254,7 @@ static void vmemmap_remap_pte(pte_t *pte, unsigned long addr, } entry = mk_pte(walk->reuse_page, pgprot); - list_add_tail(&page->lru, walk->vmemmap_pages); + list_add(&page->lru, walk->vmemmap_pages); set_pte_at(&init_mm, addr, pte, entry); } @@ -306,18 +309,20 @@ static void vmemmap_restore_pte(pte_t *pte, unsigned long addr, * @end: end address of the vmemmap virtual address range that we want to * remap. * @reuse: reuse address. + * @vmemmap_pages: list to deposit vmemmap pages to be freed. It is callers + * responsibility to free pages. * * Return: %0 on success, negative error code otherwise. */ static int vmemmap_remap_free(unsigned long start, unsigned long end, - unsigned long reuse) + unsigned long reuse, + struct list_head *vmemmap_pages) { int ret; - LIST_HEAD(vmemmap_pages); struct vmemmap_remap_walk walk = { .remap_pte = vmemmap_remap_pte, .reuse_addr = reuse, - .vmemmap_pages = &vmemmap_pages, + .vmemmap_pages = vmemmap_pages, }; int nid = page_to_nid((struct page *)start); gfp_t gfp_mask = GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN; @@ -334,7 +339,7 @@ static int vmemmap_remap_free(unsigned long start, unsigned long end, if (walk.reuse_page) { copy_page(page_to_virt(walk.reuse_page), (void *)walk.reuse_addr); - list_add(&walk.reuse_page->lru, &vmemmap_pages); + list_add(&walk.reuse_page->lru, vmemmap_pages); } /* @@ -365,15 +370,13 @@ static int vmemmap_remap_free(unsigned long start, unsigned long end, walk = (struct vmemmap_remap_walk) { .remap_pte = vmemmap_restore_pte, .reuse_addr = reuse, - .vmemmap_pages = &vmemmap_pages, + .vmemmap_pages = vmemmap_pages, }; vmemmap_remap_range(reuse, end, &walk); } mmap_read_unlock(&init_mm); - free_vmemmap_page_list(&vmemmap_pages); - return ret; } @@ -389,7 +392,7 @@ static int alloc_vmemmap_page_list(unsigned long start, unsigned long end, page = alloc_pages_node(nid, gfp_mask, 0); if (!page) goto out; - list_add_tail(&page->lru, list); + list_add(&page->lru, list); } return 0; @@ -576,24 +579,17 @@ static bool vmemmap_should_optimize(const struct hstate *h, const struct page *h return true; } -/** - * hugetlb_vmemmap_optimize - optimize @head page's vmemmap pages. - * @h: struct hstate. - * @head: the head page whose vmemmap pages will be optimized. - * - * This function only tries to optimize @head's vmemmap pages and does not - * guarantee that the optimization will succeed after it returns. The caller - * can use HPageVmemmapOptimized(@head) to detect if @head's vmemmap pages - * have been optimized. - */ -void hugetlb_vmemmap_optimize(const struct hstate *h, struct page *head) +static int __hugetlb_vmemmap_optimize(const struct hstate *h, + struct page *head, + struct list_head *vmemmap_pages) { + int ret = 0; unsigned long vmemmap_start = (unsigned long)head, vmemmap_end; unsigned long vmemmap_reuse; VM_WARN_ON_ONCE(!PageHuge(head)); if (!vmemmap_should_optimize(h, head)) - return; + return ret; static_branch_inc(&hugetlb_optimize_vmemmap_key); @@ -603,21 +599,58 @@ void hugetlb_vmemmap_optimize(const struct hstate *h, struct page *head) /* * Remap the vmemmap virtual address range [@vmemmap_start, @vmemmap_end) - * to the page which @vmemmap_reuse is mapped to, then free the pages - * which the range [@vmemmap_start, @vmemmap_end] is mapped to. + * to the page which @vmemmap_reuse is mapped to. Add pages previously + * mapping the range to vmemmap_pages list so that they can be freed by + * the caller. */ - if (vmemmap_remap_free(vmemmap_start, vmemmap_end, vmemmap_reuse)) + ret = vmemmap_remap_free(vmemmap_start, vmemmap_end, vmemmap_reuse, vmemmap_pages); + if (ret) static_branch_dec(&hugetlb_optimize_vmemmap_key); else SetHPageVmemmapOptimized(head); + + return ret; +} + +/** + * hugetlb_vmemmap_optimize - optimize @head page's vmemmap pages. + * @h: struct hstate. + * @head: the head page whose vmemmap pages will be optimized. + * + * This function only tries to optimize @head's vmemmap pages and does not + * guarantee that the optimization will succeed after it returns. The caller + * can use HPageVmemmapOptimized(@head) to detect if @head's vmemmap pages + * have been optimized. + */ +void hugetlb_vmemmap_optimize(const struct hstate *h, struct page *head) +{ + LIST_HEAD(vmemmap_pages); + + __hugetlb_vmemmap_optimize(h, head, &vmemmap_pages); + free_vmemmap_page_list(&vmemmap_pages); } void hugetlb_vmemmap_optimize_folios(struct hstate *h, struct list_head *folio_list) { struct folio *folio; + LIST_HEAD(vmemmap_pages); - list_for_each_entry(folio, folio_list, lru) - hugetlb_vmemmap_optimize(h, &folio->page); + list_for_each_entry(folio, folio_list, lru) { + int ret = __hugetlb_vmemmap_optimize(h, &folio->page, + &vmemmap_pages); + + /* + * Pages may have been accumulated, thus free what we have + * and try again. + */ + if (ret == -ENOMEM) { + free_vmemmap_page_list(&vmemmap_pages); + INIT_LIST_HEAD(&vmemmap_pages); + __hugetlb_vmemmap_optimize(h, &folio->page, &vmemmap_pages); + } + } + + free_vmemmap_page_list(&vmemmap_pages); } static struct ctl_table hugetlb_vmemmap_sysctls[] = {