From patchwork Thu Jan 16 21:10:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13942310 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 22E8DC02188 for ; Thu, 16 Jan 2025 21:11:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3A3D280006; Thu, 16 Jan 2025 16:11:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E748280001; Thu, 16 Jan 2025 16:11:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C42D280006; Thu, 16 Jan 2025 16:11:39 -0500 (EST) 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 5D606280001 for ; Thu, 16 Jan 2025 16:11:39 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2143F1A136A for ; Thu, 16 Jan 2025 21:11:39 +0000 (UTC) X-FDA: 83014561518.07.8EB6DE0 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2058.outbound.protection.outlook.com [40.107.237.58]) by imf12.hostedemail.com (Postfix) with ESMTP id 54FFF4000B for ; Thu, 16 Jan 2025 21:11:36 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=TbPjbINV; spf=pass (imf12.hostedemail.com: domain of ziy@nvidia.com designates 40.107.237.58 as permitted sender) smtp.mailfrom=ziy@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737061896; 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=h01OhGP49lQnm769uOiJuw7L8Wzui4j6wehMLlbisoE=; b=8cT3iDepq9hUnvRFglU+LbOoJCqlU+n16NRMCcaO1veOhUuEhUaf2ai9Uyqi+fPCDP2Q9l xIr+38LCfuoZMiOfz6sBLhXf2P3tQetLLzq0KbXE3wrLNEwaJrQLc3AdRJ4/UnHHp3cvIw gR+RKJhmcjsf1Nx+DeBHx0ASa0ItRNk= ARC-Authentication-Results: i=2; imf12.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=TbPjbINV; spf=pass (imf12.hostedemail.com: domain of ziy@nvidia.com designates 40.107.237.58 as permitted sender) smtp.mailfrom=ziy@nvidia.com; dmarc=pass (policy=reject) header.from=nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1737061896; a=rsa-sha256; cv=pass; b=rA3YJxbrSt4kQmQz98G7ElpcYLFWdmYq024dKjpADNLKi8qq9pYzT5YB9+DqM/wv/ETgll Jd28osXjtKRp2BcRHhbJNzIVotIpMzuFN4fJIUUUjs/bbtOnlWKpkMb4C9TAyLKLvbpKJc moTT8N/DYKbmksHXG7t5Z4XvCahsgXU= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Qvq98UVtYpJaRAUzrtb1kMwVA8DDp/iHBzX0GZsQ5l/NoVM4HLlKZeMWbpU1SbOZRLrBd15yVIRxl9JITcRzVvTuCDZYf+wuTqn4XZw8OUfE4Ni9K6sKTDxt97c4PhA3Dxo9k5FPzSetzuXWovuEFmUv6ANtV85wiDT5s3BzkARo4UhPhSa61MaY/Y9aHSNGyieakU+CjSWoAbLnTCGFVbq3y0zJvViXEInmttKkwjBOkPBnCiSU3LS8A6SCWW4ed1+zutiv5zFbprfbRWVN+nyNtJALMIU0WW2F82qdss2jKMj+8wueB/e72WtZMjzktOG7FijiEA8hbmnX4NxZaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=h01OhGP49lQnm769uOiJuw7L8Wzui4j6wehMLlbisoE=; b=H20IKBnl9klOvFZDz9AN5O08ym2DvMlVVMhJiB/w14/yTVg2G5aIudsAxvSLSJ4FKKaP0nCbRMB3RB6CnR/nzNP1XFmN34OicQ9b5qPzGPj/TKLzMe77pJV200j3VJE25+S0qCiJi8Yo395VUEk7x4N4qeDTLWFNYXU7SeSUAjf8kjteHvGlrIcpjIgfgSEOrlLdPeWzpdG4lR0lDkFxDkhJzg1/LpjuaBtrfWCdCUOv+lpdREDY+NAl3zbpM/0YPCouV2AJ74TqvKXr73FymqJfyeY3ke0222GOC1iePL7fMgvpdMnZ3bP0BLyk/JXTQQv+dmTshyGoJeJB4rmRXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h01OhGP49lQnm769uOiJuw7L8Wzui4j6wehMLlbisoE=; b=TbPjbINV9rOQcTfwXBtgHX10TDxVpjDksG9hWRZVXTmqk/2cpBEVUpd04N6CMnzvJHh6lxQ4g6JGtPUpLvifdtudB4+en/jkettXrnzuNfnKcpN0lKOrulsP5zlqIGcPolyyo094/VNlI22MuXi4nnY2PiNQhvQnOqLsaFk04EmpWWyTeuvI02fgnvQdNov69g1AGBe/ZkXCUGjIsG+kT4dz0PFq77uJ8gJ+anGY0iCTNpQPZjqHgLAmXYl9IIfK9AjPc2mvVRBM10dn+zB2rx6pQRBASUwI1ylqAvNDwSGS9pESZ8scCrA5QaugZ9FZSYmHxVrv0GY4TRGwY+OhFg== Received: from DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) by LV8PR12MB9232.namprd12.prod.outlook.com (2603:10b6:408:182::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.15; Thu, 16 Jan 2025 21:11:03 +0000 Received: from DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::5189:ecec:d84a:133a]) by DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::5189:ecec:d84a:133a%3]) with mapi id 15.20.8356.014; Thu, 16 Jan 2025 21:11:03 +0000 From: Zi Yan To: linux-mm@kvack.org, Andrew Morton , "Kirill A . Shutemov" , "Matthew Wilcox (Oracle)" Cc: Ryan Roberts , Hugh Dickins , David Hildenbrand , Yang Shi , Miaohe Lin , Kefeng Wang , Yu Zhao , John Hubbard , Baolin Wang , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Zi Yan Subject: [PATCH v5 08/10] mm/huge_memory: add folio_split() to debugfs testing interface. Date: Thu, 16 Jan 2025 16:10:40 -0500 Message-ID: <20250116211042.741543-9-ziy@nvidia.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250116211042.741543-1-ziy@nvidia.com> References: <20250116211042.741543-1-ziy@nvidia.com> X-ClientProxiedBy: MN0P220CA0030.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:52e::24) To DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB9473:EE_|LV8PR12MB9232:EE_ X-MS-Office365-Filtering-Correlation-Id: 755fba17-0045-4fd5-ea6c-08dd3672488f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|366016|1800799024; X-Microsoft-Antispam-Message-Info: tcO3ixMNRM75MPDvE40o2lCnuFSMYL+EUCsif9Y1qsGYu18eME+JhcY3ht6QYaa1Nc7rkmKgiGMtPtsYzqAOnwBN/mCL73aRSODE/isL+acULyRvGU1j1mGLnlW1t3bDP5wFm3u0/zso39JAN8OmB2EJPfz4lz4djf80VaSshzPzvM2Kh/e1oPIIcLcteyLCQADGsvDNAJLxFscYUo76RKo+pKeVjGDh4/LKfw60L56vz6JecGO5RLKyMdI5xJ+tkl9952D38fnJep+yjXZvWhPGOOf5bxhQ7CSzvxHBnL+kPC6Gmg0P8Yi0tDh53pwU5pgihuosA4cX/aB9uFDrc2DrFVe0Y/5QTvgMzJs3YB6CduSe33tFKghHvHpgrhBg3+khJ4WWpZeqr1YXP8wAdF0XQ3FuWCs1tra5eh0YhTZPaYAOpo7aaGoFLKwLzbDZ/7tYzzTQGco4Z8VJ6eGFaXmkiRBBr/Oo41TuiAAYyBw0LTC4YLNvpmzNZkjBQV1pqR8QABgRzazPVgZnPJlS3wGAC6fo0Q7sKeXpcP9vuPYb0Jdn6zT5aqJXdbqj0vTD2r3NOIFGeJT9UjApQWLs7kU5QhfHww63a4SabJHsPnhpGcdX7ISw6pp2QeAFDJ/Nj+CJDM6J52CfUzwcyLlS+a8dTiv2Edhz4oePpwJvxFvKpSk+aJxVqLHCAZZg3yogrp0v5T4D/I+rxC+suxdQYSFnTw7cIKYm72gKNYByGmXSqEsNEM610lf+ZGb2fOd7w40Ka9yzlgXttAuu+8YfNSiZLfPe9WuUuCPgA1abAxncG4yBcFxqQwOikBiIL6PO7+FzanujXdnoZTOT5kuNplKU/sYgDzj/L/93UckIs8bJtOMV5N534Ylmzk3C1MmS88+3NpEAXKO4xWiuYK97cpdPSed8QWQ4+7q6Q0f32YK3X1lpu3Rd/fFqec3m4kfGlBKASMTlmGv9V7nfN5MVMTizJHQIWA96rDs8g7N7hpeklskk93NPym8MYMe54jkSFjq1O5FEtQVMIuBNFrgiliOAgb7rw2QjyeIBTWd8NJ0rAVL6wZevucw2cCDtU4EIv8x/OEOXvqzt9x4OVd4umVEz9K0PyU7b19QbEb/CwEr/SSYAc8ke/OZSU7R7Hj54/pIdm3Gm/qymPWh5HvGlPKe6cuZ96cuk2ZMvEUaOlvO8vY3ZS+UdRIhyFCsMSxdSduRTi04ZgrI/8wNQsbnOYWbQ4MrJooSmIDITpn0so4U7xNPD1Shgp7OrlATxFthUXoM6N5TJUgL0Udxlxa0hHvATaSxY7k/qzXp6IFldJFnEuAq7jvbNi3Lk2Rlr0KouiPLmZ2ONLG27P34yuv8pqUWQoLQQjq/g5biEx6mYb4Bkv1ib843kwMNNvxto8bDB X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR12MB9473.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(7416014)(366016)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ty1uiS/pYo92UUx0gsdBNfg+/NU05IIRLoVbVJS4lTDFIS23PlVMpxq7kiOENCSxYAOLaknzSqYKhBJKNDHp8ggUCRcmIjVT7n03ywwhzcaaLYMf0AqVx5/GkLz3OjKaW+BNxZpZUuYhrBRlFQU0OB7yCl6HrUKj9H2lyR/0VAIk9Rg80NeFfh+K5xFblnrejpirrAyjApDQ1yq4WhJGligCFM2AWJAAtCLpLaYP0HsqIe1xtDp+ly014ZRuJnVENT5XV/4D92sOxYf1GiyVjrhQkSg9QS+FzoYiQfaMuFqBO+Kc97PflGYAGL+qlCv17ZI3Cx2vCn1HECf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yottl1HpFBFK9BZ1Szj1LCvrC9IMdtGzxNsMyKPB3eSm3J2F1a5Ljjc9JFsZYiNBayo/iHcUXkPkmP1D/4g0Od7tpwnSAZGClJqGHd/g5UU19LNbwwYnx1+zfdsdZDt5x9JEL3bHuWQYwRl7ZOmS4joYh77LuKPJUGB7rX9xj7ZXxw3UBpDngOtdNMST X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 755fba17-0045-4fd5-ea6c-08dd3672488f X-MS-Exchange-CrossTenant-AuthSource: DS7PR12MB9473.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2025 21:11:02.9270 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nZBE+N9JfeNqM3Meio58wx+0mWTBWw7tJDWMZeLwqxe9Gay6SQcNKJffVnCGol2o X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9232 X-Rspamd-Queue-Id: 54FFF4000B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 5zgd33kqxbqs1wzfxeo7pxziihw144q1 X-HE-Tag: 1737061896-904651 X-HE-Meta: U2FsdGVkX19zfxsrvQ/DkRXya3xGd3crxv80N5jiihrJyDwNwfDeMndoZsL17HFpE6kwJy1B0WAbOH45T8mQ0ItstrReAuWqeeafi7JuV18MSeu5ccA/fMzA9dJn6WWkrtGRuywsP2UNV0vExJuSRW2IBP4PKz9njo9ECNhfD2xsWTIk297v1cy6okIYlsjOOa+MO9L/HsAhVBm5cDImH07UjfLz26uCSBD5NCRnIrmY+XiiwFs2v67cDaXQvf8hAEwHnizn461wo+PW5vWKNnSCZTogJRwzVOh0zxH9Ulj9HZa/B3bvz5HIIvmjBgaV/gxo7Q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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: List-Subscribe: List-Unsubscribe: This allows to test folio_split() by specifying an additional in folio page offset parameter to split_huge_page debugfs interface. Signed-off-by: Zi Yan --- mm/huge_memory.c | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 2fead9586e34..ddba3e36b46b 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -4177,7 +4177,8 @@ static inline bool vma_not_suitable_for_thp_split(struct vm_area_struct *vma) } static int split_huge_pages_pid(int pid, unsigned long vaddr_start, - unsigned long vaddr_end, unsigned int new_order) + unsigned long vaddr_end, unsigned int new_order, + long in_folio_offset) { int ret = 0; struct task_struct *task; @@ -4261,8 +4262,16 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start, if (!folio_test_anon(folio) && folio->mapping != mapping) goto unlock; - if (!split_folio_to_order(folio, target_order)) - split++; + if (in_folio_offset < 0 || + in_folio_offset >= folio_nr_pages(folio)) { + if (!split_folio_to_order(folio, target_order)) + split++; + } else { + struct page *split_at = folio_page(folio, + in_folio_offset); + if (!folio_split(folio, target_order, split_at, NULL)) + split++; + } unlock: @@ -4285,7 +4294,8 @@ static int split_huge_pages_pid(int pid, unsigned long vaddr_start, } static int split_huge_pages_in_file(const char *file_path, pgoff_t off_start, - pgoff_t off_end, unsigned int new_order) + pgoff_t off_end, unsigned int new_order, + long in_folio_offset) { struct filename *file; struct file *candidate; @@ -4334,8 +4344,15 @@ static int split_huge_pages_in_file(const char *file_path, pgoff_t off_start, if (folio->mapping != mapping) goto unlock; - if (!split_folio_to_order(folio, target_order)) - split++; + if (in_folio_offset < 0 || in_folio_offset >= nr_pages) { + if (!split_folio_to_order(folio, target_order)) + split++; + } else { + struct page *split_at = folio_page(folio, + in_folio_offset); + if (!folio_split(folio, target_order, split_at, NULL)) + split++; + } unlock: folio_unlock(folio); @@ -4368,6 +4385,7 @@ static ssize_t split_huge_pages_write(struct file *file, const char __user *buf, int pid; unsigned long vaddr_start, vaddr_end; unsigned int new_order = 0; + long in_folio_offset = -1; ret = mutex_lock_interruptible(&split_debug_mutex); if (ret) @@ -4396,30 +4414,33 @@ static ssize_t split_huge_pages_write(struct file *file, const char __user *buf, goto out; } - ret = sscanf(tok_buf, "0x%lx,0x%lx,%d", &off_start, - &off_end, &new_order); - if (ret != 2 && ret != 3) { + ret = sscanf(tok_buf, "0x%lx,0x%lx,%d,%ld", &off_start, &off_end, + &new_order, &in_folio_offset); + if (ret != 2 && ret != 3 && ret != 4) { ret = -EINVAL; goto out; } - ret = split_huge_pages_in_file(file_path, off_start, off_end, new_order); + ret = split_huge_pages_in_file(file_path, off_start, off_end, + new_order, in_folio_offset); if (!ret) ret = input_len; goto out; } - ret = sscanf(input_buf, "%d,0x%lx,0x%lx,%d", &pid, &vaddr_start, &vaddr_end, &new_order); + ret = sscanf(input_buf, "%d,0x%lx,0x%lx,%d,%ld", &pid, &vaddr_start, + &vaddr_end, &new_order, &in_folio_offset); if (ret == 1 && pid == 1) { split_huge_pages_all(); ret = strlen(input_buf); goto out; - } else if (ret != 3 && ret != 4) { + } else if (ret != 3 && ret != 4 && ret != 5) { ret = -EINVAL; goto out; } - ret = split_huge_pages_pid(pid, vaddr_start, vaddr_end, new_order); + ret = split_huge_pages_pid(pid, vaddr_start, vaddr_end, new_order, + in_folio_offset); if (!ret) ret = strlen(input_buf); out: