From patchwork Wed Jan 22 12:40:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13947246 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 62844C02181 for ; Wed, 22 Jan 2025 12:41:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE3C3280003; Wed, 22 Jan 2025 07:41:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B6DBB280001; Wed, 22 Jan 2025 07:41:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99926280003; Wed, 22 Jan 2025 07:41:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 752A7280001 for ; Wed, 22 Jan 2025 07:41:13 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E398CA16C2 for ; Wed, 22 Jan 2025 12:41:12 +0000 (UTC) X-FDA: 83035047984.04.064ADCB Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2068.outbound.protection.outlook.com [40.107.220.68]) by imf17.hostedemail.com (Postfix) with ESMTP id 2446340004 for ; Wed, 22 Jan 2025 12:41:09 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=lswE8iwR; spf=pass (imf17.hostedemail.com: domain of ziy@nvidia.com designates 40.107.220.68 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=1737549670; 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=pBvS5FODAuYcEpPhb9iFNyPgC8a+1PAcRcRcKjUpMt4=; b=y/flPn/4OQSDyIpD7YQowQoKf4iwbPRAI3kW2tGti1zksU/Pp2rnqRvEdyEDfVziLtpwvH Kb7ikJKcAWMuX7pISKl7sCVOUYFsCHvY3zyuZIP3xfSb6xKe+WtZwnzYhWkIRZbYKG6hg6 DWUy4QEkAiqkWTeMxo8P6QnB4zqMi8U= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=lswE8iwR; spf=pass (imf17.hostedemail.com: domain of ziy@nvidia.com designates 40.107.220.68 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=1737549670; a=rsa-sha256; cv=pass; b=7YsWPSvIcEMGrE4/L5GMFPXitzvnGaWJSPWU/CQmh51qUp0piHtUt11QFAlc10tAcYkBts /RQvwIap2DhaaWo1WZFS/r5tphiGOR/2++A6bjbMVUK37HefDfK4CFVcPjwZdV2s3A+ie1 A5UzFARUsMGEOI39zoylZWclnKAOv1w= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j+hqmCvgR5tE7bKzosGHceFHXnoHxn5lCDz2+M0pV9z7eLSfS7zy5n8/gB6kpftguGeXblvOtwSFQbfZnRCshhNihR6NPkEsq1GN8YpEHb0HQW7nz2BzkKTp/QfSwmGsWVPgwFcl+o/Qz7G/+/yHPdM6CIv0C/Fftpeanz6575WxqNKnnUdFCf9JgGWoM3tOLJoSeegSVUs4m5tjsOPnnySy1SK02sH264BNuXhGYuylfzXVGIhGp+Z7Yu60DJgf7mYuGQ0DUI6X5vz6sGxOZerbDzT8NdpqAXkX6POL7VEpxX2XYQOUfEW+zk7DAN2+napPC+AoSE/Wg7tMApSsQA== 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=pBvS5FODAuYcEpPhb9iFNyPgC8a+1PAcRcRcKjUpMt4=; b=bV1x8gXcdg9FFjBF1eTssvaH/o3aeF5Nj9V6Ub3DvUhf0yfpaekTuZ3WcH+k0WDdxV2d3Q9ORW4FP2Mf+sUmbefkILAuzFANNUzXZjLsNvBGf7l4AC80iZz3xcb7vAqFtRd7BcPRBSLWZzzwCPY5tRwJa3vmp8mWwiFvu9pZ9uo74mXPIWb1JpsWO5Irs00l4lDPGCFUSZUaHZxRVp85aWwMeNxQoSd6rYfbqciKZ96NcTTkqhRpH4l0TiBfOehz+GWwPDp0+oVF5ASBCQ7aGTNGsEWh3D6MaGfQUHYpValr3DAhZU+iEBoTcVYwZ4tGJKl+WwHBBpVAIssQ7KwCbQ== 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=pBvS5FODAuYcEpPhb9iFNyPgC8a+1PAcRcRcKjUpMt4=; b=lswE8iwROIYguWToUP3+/szCFbzDQNiaYGgXtAtys3hjsqOs2JD2b+QndHW8WU6LA/e5hDwz6fTAYlqsp7lnGSOM90nzJLcoaVtUtPGhIBl7MAt2K11gJpcKCyJckEBEhyDSrUog+CmoB5zh/hFFhKL0EhsvRDaOJKfuxbchEBQreAN2v69zGdjvKGS/8APYjlsWF7BGrPQeIZcuW1WIUfNmJv/GwbT39bIq6aEpUi4jTHFWwbp3C1TA1Xv5lFlzR2giAv18yt2w6NH6GAQ/fzepLcqRR2op7NWTmOMdZOroJE0curE5EOXwvHqN3Ag5kL3R2ktVUYwAChi4wQ91fA== Received: from DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) by CH3PR12MB7619.namprd12.prod.outlook.com (2603:10b6:610:14b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.17; Wed, 22 Jan 2025 12:40:55 +0000 Received: from DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::5189:ecec:d84a:133a]) by DS7PR12MB9473.namprd12.prod.outlook.com ([fe80::5189:ecec:d84a:133a%5]) with mapi id 15.20.8377.009; Wed, 22 Jan 2025 12:40:55 +0000 From: Zi Yan To: linux-mm@kvack.org, Andrew Morton , Baolin Wang Cc: "Kirill A . Shutemov" , "Matthew Wilcox (Oracle)" , Ryan Roberts , Hugh Dickins , David Hildenbrand , Yang Shi , Miaohe Lin , Kefeng Wang , Yu Zhao , John Hubbard , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Zi Yan Subject: [PATCH 3/3] selftests/mm: test splitting file-backed THP to any lower order. Date: Wed, 22 Jan 2025 07:40:47 -0500 Message-ID: <20250122124047.1216024-3-ziy@nvidia.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250122124047.1216024-1-ziy@nvidia.com> References: <20250122124047.1216024-1-ziy@nvidia.com> X-ClientProxiedBy: MN0P220CA0019.NAMP220.PROD.OUTLOOK.COM (2603:10b6:208:52e::14) To DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB9473:EE_|CH3PR12MB7619:EE_ X-MS-Office365-Filtering-Correlation-Id: e7cfe3d7-7d59-40b0-eda9-08dd3ae2037c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014; X-Microsoft-Antispam-Message-Info: m5NaKmEKIzN+STDQGjXFo4zmwYO/2T0Nh5XHaZj9RlUtOxqLRFQ4S+YQNe8KiAsuYIR1YEYG8H8zxPTyzRT24xu+CmgpcxWy2E61cG1mWM2DLYt6jQbZGGKt5udiJvCqZPBiROVT3AL/Klt1UzVWygWdADpSagH9HJM6/jqQZPYeQJHNGSnw5jvr+K5J+Pv8/0cPdeamzac21Tin6RvP0+2cg+cmjefZkzJ0jaggLnXl1s/Fd0tnq0mUTnp939JAqV/a8hDAo7MWSKFGJhpAQzocWfw+bCaK/kaA/ZFCj4LP9W+zj2C7qAy6tSeNfT9mtkna2/SjNJaPIL2gwD6/TXB1/sUVu20bTM3jD6Nm1bNjS9/cAff8iAa3hhtW3dNQvh2ILH/7iq5DttxUoZ9NsGXpUhZJpzVDjFMaZN5KfhKw65rHwRTwWKcX0OJ6yYJrOcrFKuDq0hRDRSZn27L3LinQtV0NenhQluw2cBW9l04WmY+JkJA7ydz1WvPB1JvYmrAOxMI4SZznBGcvBxHUEBwQc1XhyammNJ/29qmOswkoAv6+uXEz5SdsNYdibo0LTgFYOC7bCGO8qmpce6pbXIHWL8aDlQMG8hTvrp0PBH6yTWBEDAhcl2l48Vrwwt8Y9oFCTqRzd15l1d2DaKaAfkl5ffIy3GLFMo18DaTT/38AigXD3YhntVOUeXX8IMTa2diaurZYBCmWTIkQhe2v0cREIumuc9xalNczMnlqXkde/EIuB33cfLIIBOYf0f90R6Fh9F3CxOUOY36MN607h8XhwnszMcSse6yrIDbr1Zp7skEeAHdiKuMnjbBvqe5PU66/39WW0xx0EjURNfAaTjwFwbDRjnrtqQgkEANTo+McgJOYef0cjTmXOFwSgXAD26h0GMzl3KivQhtP1Ze/J6aGITjItfj8LmsQk1gDXFICQcHxibYO2Q2uK3Yx16dikKapfWxkm6vcMWP+L8BGZsgNS1dvGOu9yc0RNcc5l97zkMPtPOW8VhIJtvaWIlA000frN6aA1opFi5alH2w1Qauc4A4EsfZKr/5Gm7OlM0nvM7Dm4beC0qyDLNL7FH/u0jHmMeGC7Vu+eCJNLtMG8/UfAzjriClRwHCAD7kSQeJ9p+dN2aWJ5YNo4Fd9So5QKhAlGAoETVPTBi3TG466BXq4Rlv5m82DqxmWGcZZgfuwKtsQgAoz3ZZMgEnH9XDz4sKanWO7YnPgcPAF8nIrOSFeLfXQCYRaL/IPZ74a4zYwrqORUfEadZQmDqtF20keNR7BihM9GjLh9kl5S3TFxnQelbdV1fvh9YwdjfWA1Z6LFScQBh4YrbgLoHMBL2DHwYPkGcUZ1/qHBmdK9PrY0SYDDD2guWVDUVs6vd+wiTBxRq4Eryok+5x6DBolCQ8A 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)(1800799024)(366016)(7416014)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9aax+uU1jzB3QJODOaIt56kfzmdahY8fhSrYra2sJ7it8ZhgLud1JH8XKvcGk/Wt/2hNuIj0ODQfUjrvjsAA6MBnxc/bWgOnybC5xgDL54Ok6SFUXGdhwKAWT6q+vXfBXWaWgUi8++3REaOCCsBTyk38X5mDpdtd770vfM3thyAcpfPzsxZLcZ8a5dqhmYfO+RKn0BE6pSiHt2JRIeMVIQyEzanT9K20QAgJib0WK3HITRe/HaHglXe6GnHZu8w6MYe81MapQV3xHKwDoshlH+YLp/nV0Y6wEcJmLwI4uRZHcls4a5csl2qMBrQO8BZkS4Dptir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FDxrwNbFOm7BmGYqIOwXxSAdMJLQdPftahkpDarY0w863HGaPQiGv99nBhvg/wCMWz/8Xld/6DdcVEozJLReR9tMB4sOSWytzBpgAbK7ipFJYjnfo3VvAAJ3yg6WSeVjxNpZyukpZG7PBfiW7Cqz+WdP4Xw6lttQLg70mAEbLpadk1LzJl3P X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7cfe3d7-7d59-40b0-eda9-08dd3ae2037c X-MS-Exchange-CrossTenant-AuthSource: DS7PR12MB9473.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jan 2025 12:40:55.3181 (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: JwaBEjgLeYix6VI0s94ir850c6jcLxCre7cTBDLetEiww6Rjr1W0BL2ratzXqKS2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7619 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 2446340004 X-Stat-Signature: 9g11izq8pq94femkizthh4u5s5tm9sf5 X-HE-Tag: 1737549669-616401 X-HE-Meta: U2FsdGVkX1+lKrLhJWCC6NSU3NpfYfhb0Wa8MtS+1No518pPvTOqR5azqCWkZeVrvfBh7dpvQCzw66cxv4KQ5Z3LuXi5fEa6J72BOsoaK7fQPQDbv/skXv8dOS1lQDVehxy4L5i1A3wVfZfIgWDONVO+SNMs7Fq7BddlptKmPaNb1/3/L3Ft7auxeDNo2NQ9M5Rgjid4bZaMCIWhNbNMMFLuvalu0LKiqk9kVhQ3a5hWy/yETBRh6Ri3oyA59+x6NgIpHpkxXyzhY3cfeh9ukF63mzj/2mwHT4t+FM5X11XYzFbiL9yHc/gwxXqWxfVzQP+bWQj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@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Now split_huge_page*() supports shmem THP split to any lower order. Test it. The test now reads file content out after split to check if the split corrupts the file data. Signed-off-by: Zi Yan Reviewed-by: Baolin Wang Tested-by: Baolin Wang --- .../selftests/mm/split_huge_page_test.c | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c index 8e15fc9dce3a..13ad5ac7d178 100644 --- a/tools/testing/selftests/mm/split_huge_page_test.c +++ b/tools/testing/selftests/mm/split_huge_page_test.c @@ -261,14 +261,16 @@ void split_pte_mapped_thp(void) close(kpageflags_fd); } -void split_file_backed_thp(void) +void split_file_backed_thp(int order) { int status; int fd, shmem_sysctl_fd; ssize_t num_written, num_read; char tmpfs_template[] = "/tmp/thp_split_XXXXXX"; const char *tmpfs_loc = mkdtemp(tmpfs_template); - char testfile[INPUT_MAX], sysctl_buf[INPUT_MAX] = {0}; + char testfile[INPUT_MAX]; + char sysctl_buf[INPUT_MAX] = {0}; + char file_buf[INPUT_MAX] = {0}; uint64_t pgoff_start = 0, pgoff_end = 1024; const char *shmem_sysctl = "/sys/kernel/mm/transparent_hugepage/shmem_enabled"; char *opt1, *opt2; @@ -314,7 +316,7 @@ void split_file_backed_thp(void) ksft_exit_fail_msg("Fail to create file-backed THP split testing file\n"); } - fd = open(testfile, O_CREAT|O_WRONLY, 0664); + fd = open(testfile, O_CREAT|O_RDWR, 0664); if (fd == -1) { ksft_perror("Cannot open testing file"); goto cleanup; @@ -322,7 +324,6 @@ void split_file_backed_thp(void) /* write something to the file, so a file-backed THP can be allocated */ num_written = write(fd, tmpfs_loc, strlen(tmpfs_loc) + 1); - close(fd); if (num_written < 1) { ksft_perror("Fail to write data to testing file"); @@ -330,8 +331,22 @@ void split_file_backed_thp(void) } /* split the file-backed THP */ - write_debugfs(PATH_FMT, testfile, pgoff_start, pgoff_end, 0); + write_debugfs(PATH_FMT, testfile, pgoff_start, pgoff_end, order); + + /* check file content after split */ + num_read = lseek(fd, 0, SEEK_SET); + if (num_read == -1) { + ksft_perror("Cannot lseek file"); + goto cleanup; + } + num_read = read(fd, file_buf, num_written); + if (num_read < 1 || strncmp(file_buf, tmpfs_loc, num_read)) { + ksft_print_msg("File content changed, origin: %s, now: %s\n", tmpfs_loc, file_buf); + goto cleanup; + } + + close(fd); status = unlink(testfile); if (status) { ksft_perror("Cannot remove testing file"); @@ -354,7 +369,7 @@ void split_file_backed_thp(void) close(shmem_sysctl_fd); ksft_print_msg("Please check dmesg for more information\n"); - ksft_test_result_pass("File-backed THP split test done\n"); + ksft_test_result_pass("File-backed THP split to order %d test done\n", order); return; cleanup: @@ -523,7 +538,7 @@ int main(int argc, char **argv) if (argc > 1) optional_xfs_path = argv[1]; - ksft_set_plan(1+8+2+9); + ksft_set_plan(1+8+1+9+9); pagesize = getpagesize(); pageshift = ffs(pagesize) - 1; @@ -540,7 +555,8 @@ int main(int argc, char **argv) split_pmd_thp_to_order(i); split_pte_mapped_thp(); - split_file_backed_thp(); + for (i = 0; i < 9; i++) + split_file_backed_thp(i); created_tmp = prepare_thp_fs(optional_xfs_path, fs_loc_template, &fs_loc);