From patchwork Wed Jan 22 12:40:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13947242 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2082.outbound.protection.outlook.com [40.107.236.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1148C212B0F; Wed, 22 Jan 2025 12:40:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737549657; cv=fail; b=gZnOzHVf+So8oPseoW6UAlakOCt3STBfaPwMbTsN5KCwfFVvQGU7P8xogJd/1gZ99VVdH23JeKIvOpYf8LTBcFQd8cklLDNqDWYkpR7rtnB0xzfBmH51BK1DoB8gu7sJPnKjYl8JjXC5K8h8c2BSo2u3RetTRdv1UN21UkHJRJk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737549657; c=relaxed/simple; bh=wUFnTKG729nZKg8+j3eHppmqfGTj7Ei1k8L01C7vE+A=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=PgXA0uFxzH//vZFc9ujOQZr7vKMAaZMke8glEtRqwwv6qB1OJUiCDeF0lFaE3/PAuxFC99OEHAWD2Xa+WzlwdaDpK8nHgZOQVhu6TCmvlmSP12XXDmICkO4w7Vb/VN1sQV1H1rirVrrNY9nbGt1KF7dks+TY+XxK/Rt6yAgo0Ks= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=gbtKqrR/; arc=fail smtp.client-ip=40.107.236.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="gbtKqrR/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=P+CV+b0bqVKOHjAPFbE6GwE3iudURE7m5lrrDdRDWyyI6GIQ0oJirBTtMirU06dBdLGIsQ+CopzMGlq9l2+0S8P5pzwqndWxAMm1r1DNE/kJXc+Ptwtia7OVnKhfqSOO0GkWynJhsGuhE9LrMyWX7ydirE9Lmv/u9S7qR0aQJis5lPIa532S7SZM7pK1YAjzuJsyN/RUicfcQ0VVEVbMDOouzrQdQTAw+cmwFVkmQXHHQ75vI2O5/BTwgBkzuPwlSWU4UMeFwAXmhb5JUYh8FXvLJg2LBeKND8gmOdfh6rc3L51TEWAZ3v/WVi4EcEpEHhZmRfL0t7geSHihGiJRwA== 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=WyURrOf1NUHmAiMEXV1zetxPd9i+upU8gYqrWH1keF4=; b=ucFpYO+lgdbrZt/pNCL4AdkzUAtI0BoycYlKfygWR4kU/pLe4+jTLBAx8jJY4LFrIlSCtZkuyxNHPXN3DjhAnNWUYznLt/PxsRFuTfkr5V0st4PkK6LOAQQWLpDICH0s5tqO9RyDV//ofpjmfM+jNkXAgO85NAqkUVzLNK9BmWjNhGcuGbGAkENcuxcggjpPSLWWaX0ajrsk/RYwrWK16LhwZ9+rwLMZKVv79Vzpjh+r4Y2Qmsdy0qT2FTSK8QFuGtFWS0/Sl0aNm96HT+fKxNXafjmQ2mo+qRdsYYLNuSmNMUCLpT0tGdk3yaRHjSwhzdkl3L4449MU13+yXvcsqA== 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=WyURrOf1NUHmAiMEXV1zetxPd9i+upU8gYqrWH1keF4=; b=gbtKqrR/utN1ep2ezFPB8tdml107yDUcDiMrHIFIIhYw05ctSF/3VwpUhC1KBp/mHCYe7PDnQPNN/5wx7+h6Ovz1gQ/6pf7d4YUI+vM+Cw9cOcYD/R2BMsQgcXIk2NpHha2dxjQ4/shdtS4bqLXv0ar3/5hWgsy49BpNmb8UUjRSUJuWXTMSNeHUfSSHv/mnK8/dJ0jyaWN3VPrilb9dEO7CpCUw5q73lm9Ia/vsj9ePPhd/HpetGZQwWaJEdNnG6b/swDVmMwFv1sAYgn6Q59002d+qkMr8LKryULwAxnNhUSOGTbwUjC0OG+e/2c0tlfLEDB3m4JtKk4DrdvE8RA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; 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:53 +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:52 +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 1/3] selftests/mm: make file-backed THP split work by setting force option Date: Wed, 22 Jan 2025 07:40:45 -0500 Message-ID: <20250122124047.1216024-1-ziy@nvidia.com> X-Mailer: git-send-email 2.45.2 X-ClientProxiedBy: BN9PR03CA0490.namprd03.prod.outlook.com (2603:10b6:408:130::15) To DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB9473:EE_|CH3PR12MB7619:EE_ X-MS-Office365-Filtering-Correlation-Id: c1a31416-b117-417b-0378-08dd3ae201b7 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: JSE1nfKHrCkvFn/3VBHwSxzgl8YYck/ReP8Z4GmnOsMwxdhw8QDhyZDhlqacDgSYvnb9SNoBJRBfGpBYvydgEdNd6WWdrLBveh5ZTXMvqcW+ErSsOPREXpfGSVLk/FQ5n7D/n2KJDrQ8yIy90d9VM7Yo9zSQwUBtkcXwlMidll0lMO6PsgAsMVMLRvBgqSZ2+JH4Rnoj++1JlfROwQHbL6mgL+JkShkf7nnUo7hfdQER9vMF8HsceKljgzuyo+YMTHvlnxXj/UfErGsc+Ba9PtbM59KHEFtXEIuXNWabLG2TuBno+dTkPCyYONyu3/h1Qwln55ZqOYhJgv/kjOOD6oijRdHPPXegZ0foM6D+J7SGwpYlwVgWf/myY3RnUlajbtPJkWwuQDIaNsMGxHK7ga0HxcaHjDcEs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12.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: BdlTob2Weuc1qnmUq//OcDPUsL4zICq3PQAMSBRGVcZn02JCUwEYNY98U+MHTXnXmfQxa74ejV0JQrFnnaA7d0bVtVkqwikxQeHTDiriBXKxhGzAps4cba4lutS5Otwqd9H+TPvWnDh4V4Ijrmzj28I4q3AkderFA6q148ePHFukOx1om2+ZeA0DfZylQa2j3YukStGNdv9FZWG4jr6/EP6eLxi9GMcyquqcmWtIJtZJuZdpoC6E3FJdTTcBXKq4uARwOUPmWyEFp779r0c6BsdmdX2H59m+t1AbHc7pdOMi0UBq7LAOGPsKe37JV4HvICytr55FsJB2UE2hpEBrhANPU03a5Rnoz8QplXTcGlasK1TOhmzTjMjnb8CRvkD/NIywP+0kd7YBym/RXV23MIs8Ilgj3I4LmO/gPZxQWi0p7cOeop0Epo4XwvbhtuLt9bdaSbqDk/e2RrtrLA4VFDF4SW9e/DU9IGPDQUETgWa0zeIoVN+Udko+eo1d7vh0IsDtl1PX/DOtD2QCOlLNInsBGnMO2oa8Rwss27PkKcnNjtF0B0Tr/8yniQLW8luTzZ0RNC3abTuVN83fLtXTsyvYsR+bbSsdlLsZhIhbab6I+GietZjq2mb79IYfQMGU6D1D0XrPI5woxCTWBvwoWAdFiTyHnvwIR9VcQtXhZ9oIhXk4whnM/5bwNIAlEqiDemisCtcTOJLqwircpK/Mtceb6AnQxs97+P9AMBrOePjZFgUbfvPnK11X9dNeDeMKPu7LlMy9Ap1Jne027GSJZbybJQYDDlQ4HvdyPS00FceCtCXiLl7XMIqv630salgxNAwPwSfYnH8jY3mLV0XcDwNug+RtcVy8LgVYrStiUJcv6Tjy/rGERMHRmabRJvRk3RIFEW8YLl8M0z10c9x+laPvtCj8CRKWBvYBPMwOd5gSDQ0AHNaozDmlMThLwHvjTchrsTSwTk8llrzD+/9JuB1i79wYKoT2H0a59I8kzZTA6W+kpQ3sWIUIFp0gFBWGwZSuulBZhBZtEDY9aetjbhjl4DgF3RpQAluU++6WbkK2Oe/+iuTmqW1xwFk4qsN1K7uGeg3I2ZFIFtB7fuhFnQ7+I68glVrdRefg2Y8pDhCV17iUSLdetWSGnwYN5PG2TxThfuKrmErL8TJCMMpEEH2KLSPjxp9hkrPQ3+MT7F/rKhdI9TrXLjQ/PdIHn8rym7BMGTHHzVW222NmUkkYpZd2vCfYkyBvSx4cq2hCzVKpWxrYdNRFqaWvoqH4rMQNLBQwqTu/CoONuA8JWwClX1Y+cDhm3J1K1A90xAOiS6tOY7Iuj+fbp41yLmWYb/lEonNIqjKDZkTjAB6zdOzng86b+BSwMMlts2FYRVUEg5Wr8wW/SAvfUYX4fgsh+JM1os2acd/mKTer1ySUAuUu+63EYFPkl6dpeut3W3V3naIWSRkwI665zZFtXrTF3DytmTAQNfyX3+ONPYaDxIUXq+70BzKk+872iq/lI4mK/yjQLELsHxvpVwhSpq9Lx2QbKZ6PWoLKFOpgC9+iUyVy38DKGQcsrcD7WR1aspspHYAr4/32GxoNGxGauIvmBbAl X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1a31416-b117-417b-0378-08dd3ae201b7 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:52.8889 (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: 0sBG6c5Fpq95lOh2O0QnmO0zfbPF+xS1ivhvd/jpJ4cJwcK2Ulc7ppL4UGPHFsRX X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7619 Commit acd7ccb284b8 ("mm: shmem: add large folio support for tmpfs") changes huge=always to allocate THP/mTHP based on write size and split_huge_page_test does not write PMD size data, so file-back THP is not created during the test. Set /sys/kernel/mm/transparent_hugepage/shmem_enabled to "force" to force THP allocation. Signed-off-by: Zi Yan Reviewed-by: Baolin Wang Tested-by: Baolin Wang --- .../selftests/mm/split_huge_page_test.c | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c index 3f353f3d070f..8e15fc9dce3a 100644 --- a/tools/testing/selftests/mm/split_huge_page_test.c +++ b/tools/testing/selftests/mm/split_huge_page_test.c @@ -264,15 +264,46 @@ void split_pte_mapped_thp(void) void split_file_backed_thp(void) { int status; - int fd; - ssize_t num_written; + 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]; + char testfile[INPUT_MAX], sysctl_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; ksft_print_msg("Please enable pr_debug in split_huge_pages_in_file() for more info.\n"); + shmem_sysctl_fd = open(shmem_sysctl, O_RDWR); + if (shmem_sysctl_fd == -1) { + ksft_perror("cannot open shmem sysctl"); + goto out; + } + + num_read = read(shmem_sysctl_fd, sysctl_buf, INPUT_MAX); + if (num_read < 1) { + ksft_perror("Failed to read shmem sysctl"); + goto cleanup_sysctl; + } + + opt1 = strchr(sysctl_buf, '['); + opt2 = strchr(sysctl_buf, ']'); + if (!opt1 || !opt2) { + ksft_perror("cannot read shmem sysctl config"); + goto cleanup_sysctl; + } + + /* get existing shmem sysctl config into sysctl_buf */ + strncpy(sysctl_buf, opt1 + 1, opt2 - opt1 - 1); + memset(sysctl_buf + (opt2 - opt1 - 1), 0, INPUT_MAX); + + num_written = write(shmem_sysctl_fd, "force", sizeof("force")); + if (num_written < 1) { + ksft_perror("Fail to write force to shmem sysctl"); + goto cleanup_sysctl; + } + status = mount("tmpfs", tmpfs_loc, "tmpfs", 0, "huge=always,size=4m"); if (status) @@ -317,13 +348,24 @@ void split_file_backed_thp(void) if (status) ksft_exit_fail_msg("cannot remove tmp dir: %s\n", strerror(errno)); + num_written = write(shmem_sysctl_fd, sysctl_buf, strlen(sysctl_buf) + 1); + if (num_written < 1) + ksft_perror("Fail to restore shmem sysctl"); + + 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"); return; cleanup: + num_written = write(shmem_sysctl_fd, sysctl_buf, strlen(sysctl_buf) + 1); + if (num_written < 1) + ksft_perror("Fail to restore shmem sysctl"); umount(tmpfs_loc); rmdir(tmpfs_loc); +cleanup_sysctl: + close(shmem_sysctl_fd); +out: ksft_exit_fail_msg("Error occurred\n"); } From patchwork Wed Jan 22 12:40:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13947243 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2082.outbound.protection.outlook.com [40.107.236.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5073212D7A; Wed, 22 Jan 2025 12:40:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737549659; cv=fail; b=khCHoaY8oeNF8NG2+YRYR1JExvlx+sO/JyS4NwxWD272Yz0onZRa4T4zhHNrlKFJoWqPR1Seb+m7zz0eorL1ITSFW+2WJWyKs4FMeIhhfjhI1MCwAtk0xrmSB4MIRf2U0Sdw4FZPg22TYT57h94aALiA2Q1PlLmG0+6aC/gTZ1w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737549659; c=relaxed/simple; bh=uMqI+2tqCXQabaHOMMNEdO0SRwfWh7bxHJBeeh1700Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=o+Z0Dkbn6v0z5+KD1W8yH2vWw/XW+iiDLXgBh1WzVy+3bqeQbUMkeN0RJyAIoYta71h9dldlZwLgpLbUiQrMtMnTWcz0+7xt9g2O6gWSrNMbAr7LN0HFuQA2yfWFpHdjHJXDGhH2ARPOi4WPDZXIwOkhB7l4d6w64wuGMChVUWU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=caM5M2rO; arc=fail smtp.client-ip=40.107.236.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="caM5M2rO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ywzzy9mW3yp3/nFWmmEHVBlo94fsivfiROuso4Xu7Wu4gHf7DmUtboo/x3AYsNjwSlHbwvT4SD+VoRrmgwt3PzrPJKmtWFl2AlBoEj2TaxGUAt+a/R1SaFsgh2bpLezRmmcT7WvOTNddqdOLGnriaxfTPbRr2qxx1KNVDgUUM09x9mYvahLfhUC20aDWiEfsm1kV8/Eagmyz8m3BMVWvwj5+Ax/VVYPaH/kNHqu8tuN2PvZ4nRkMeaJ5pyedf0YsDA0BDWUOhDmmVgFY2gmeAtwVDUn0RlcCmOo/K27Cxb1pnTkm/tSu6Kh+0gxad8MH1o5vt5a3MZHWVsmJuOiKWg== 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=WmKa+b07ci/+SigIR8tnvRx0W0zt+6m9eZpwmObzkqI=; b=vFxpVfR5Qx7GeZmbXyOgbRhQRR+ZWDRqgRZBSjlARCApFkwI/jKDlZGrBvMCB3KOLMq6zOrYhuyfO8oCnr5s24ZWpQWPgk8Dvax/v+RqagZYylOg2jSwnUcCrMax0V3dpF2w4PQhAc6JlrYpziT6aCzWBxFbxq4tHzVH4bmlDBtKr4EUol5lpkhXE1JMDepFTeV95o9prCenbvORC6ICfAa0r9DOuYZL4zjEnt+IvsG40+yM9M6NwWNtRn1UknSkegK0xQlGrBtvh3NRhtKOzGp6M3vXJhnbebjBJqUvJrCw3S4OvbHxohidlsVID8Il204KB63NY71sX9fWRtU9MQ== 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=WmKa+b07ci/+SigIR8tnvRx0W0zt+6m9eZpwmObzkqI=; b=caM5M2rOSh4vH7qTnba99IagSCqTCc/NgJvPV1zXDfJ8AZ+5kMYY6wowI6zsaKdZWraVFqGoaYTUh2BvhRy6yYYp5PLxtrND9LMlRu5vcKTOLHl1w1PSlSTo+4Tlo7ttQkO5ULD9idcLV88ERTqc3lKLIXf6FRr5QFpFC/XF8bIdENYNemN5OCgh9fThNeJkJMzjR7zTlBxX4IYc0/p/JYvcguo+xGgthP4YHtQCsCMBN5ZFYoS+IWFY0wVzqIyskDh3ZAv2EuaxtTej9gnoSsQsiljFUtasLzm8zEQ9mqrdJdAOF/FTm/0XTVe7J5SMTtmhKq48FuIY7+zf3mdtDA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; 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:54 +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:54 +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 2/3] mm/huge_memory: allow split shmem large folio to any lower order Date: Wed, 22 Jan 2025 07:40:46 -0500 Message-ID: <20250122124047.1216024-2-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: BN9PR03CA0501.namprd03.prod.outlook.com (2603:10b6:408:130::26) To DS7PR12MB9473.namprd12.prod.outlook.com (2603:10b6:8:252::5) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB9473:EE_|CH3PR12MB7619:EE_ X-MS-Office365-Filtering-Correlation-Id: 2bb2722f-ff9e-40b7-e83c-08dd3ae202bf 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: GmM8jSgGpBY9dqfpfWB0alb1EP48V17wok85A72z5NvKakx+xXcU9a2uluMr838izS20mUjxU+DnDVNkt3KdjkQwRAJMla1kBKJhWM0SzAO5Z73LClv2xsVjGAhw4IfRfoLVVSnmK+tpWabS6nuMB3xUsOKMO8a9OI+08RYolkfllDH/doZAEAgErUw5UIn8XBdeGcS6IzIbeuMSdae6aK26rHiGp8JlveRO4HIC+XCD0kRl4djWaCGbHMqFrvFB7RnuxSxB006NnMBYlbWswoy7TJiPbvotd+iGhMl18V7Y5h1WWiiBgefw2BJAA401zXGqdMIy4vUkwKxocNeH8fMAVgk+nsrEItUTe1RyYJo5SeU972nR4nSqRgCxeV4I413Dmf1jP0+2b3kOHs7MxyZqxfzMwsxOZWFUTY7aF4+6yrJe9rtwTzP5Cx/oicvyQ5p8l4yWFvKo9vS8a0YTDyHegEpI5ZfVGNbokb7U/SiUajH0iX3sBpm8pCSl1xa8alEszmx5oHeOgtgc6havjMMS6MRUo1fAAjD1zBilnXNzGLWnOb/LH7EWW3CX5jHnhyLl+zTzRGBQL2GcKnDwKJy/Cn7TObBjf+UzCJnX7qHN/+MFpXIekbLCPoFsLatS/5h5UwW3frkDrDmbRxklTaP2fCCR99DAfzkQ9CDI6eC0ewKCwP6bljRNZTsWDJhMzn3xEDXxw7bomfAadHnYMcf8j4HXZCVAfZjky5dx43ZfiXyDvORnY0u2D/KMskTM/HhJY/CMc/K3FSicbDtghu1v4L9rcXDHMTpy3RdopxUoHhF6UglqjHxyKvMeRcu1VScv0w9puplao5r/dEi5AhmwZvBHtKoyO5C7HYdylwyyfT7D882d+RQBG+NxXNIUxMx+UR+/IIzsdcCg8tI/cOKCkgxpJusY+7rj+XtLgDRDK5YcIUge29OsVx0QCkfD0bepOO2ct6sYHJPPEDJpGn3oRruI8OWXB3D0jHCs6vySsEKn3dgebqXL/Tk1w2rNSWL9pGeiX3Jr7u4FcegKph7fp4d+2OgRcOauIoSZIWEPMEi4KscTlkLq5EXrWZy7Cu4ci/gBbJvsje2V5DDyhMY8EcSOElSqGzaLG/DZ5Vfeg+IuFJDyQ4E0HzvvtTPyWNB8epEnKjIMZg75Yv8HfDPITk84qEc+nUXwnnFmUFNR1DRt3wzklRj1IgmP6csX5zFTlxqOvFvJHun1YkV0PHM9e1bAdvZkhOzbA/r4bX6Y15J72HgVen8vDmOxYv+VcI680wZZoss41pjglj7Y5WRhUKHNUQDOGbiWKxwFrQXVxMTIzXIqINs68HSdpgDnIMlRSnyGpGJ27QVuobjM5lO51VWZjb1U3b+vOaBSLXgVumrizBKdY6XN7wynwK+Q 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: kxVih0iVeFDRdlBSB1m/STBAbIkiovNt22WHhQzU+9bkWdb8cscYji/M8A7+smdChSXAFhma3Lmt1YmWqbdwnzdsscDwY3BZhH6vwj/shNYpUkFkL/kmar0g2OyBB3DpumcrqIDbZSW3NHNRIa5a2f0DDrMC3Oa7UM86hW0DtxsZOhox7iGnjR4Ig5jmyDwFfiOO5hzk3KR+0tLQmD+DJog/CGVas68Glc9mNDHw8PcPkjqtxYTROUBuir6ZrXJKtQK5xnnkcOvlstF1gcn649mGHSBHfHj1PLXJ1ve9WfnLoSRvpqbvQAQv2eErmPWqoNeRfZjQeRZR4vkkhFQP0l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TIdwjTYiW9rKnijGWAIthMgLQeLmH21NFs7oGl+Q9uX5VCbTnp3qK34Ao3hu53xJ7jGqbHIWER1azsUPMbEDdo/GnBfeykMBM6Ehp1AQWqyXIrLpFVSg/NTSZJ7gUibhHloSyCVZysUdPeVQ/RXlMnffo2a9/jtrOX7yCOujLz8y4W5 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2bb2722f-ff9e-40b7-e83c-08dd3ae202bf 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:54.0741 (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: qSZoVvTDqyOm/1lXJ7VDPGG5xzuVE1n5C/grwYft5An4NqsSx85MbUqmZt16L1sd X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7619 Commit 4d684b5f92ba ("mm: shmem: add large folio support for tmpfs") has added large folio support to shmem. Remove the restriction in split_huge_page*(). Signed-off-by: Zi Yan Reviewed-by: Baolin Wang Acked-by: David Hildenbrand --- mm/huge_memory.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 3d3ebdc002d5..deb4e72daeb9 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3299,7 +3299,7 @@ static void __split_huge_page(struct page *page, struct list_head *list, /* Some pages can be beyond EOF: drop them from page cache */ if (tail->index >= end) { if (shmem_mapping(folio->mapping)) - nr_dropped++; + nr_dropped += new_nr; else if (folio_test_clear_dirty(tail)) folio_account_cleaned(tail, inode_to_wb(folio->mapping->host)); @@ -3465,12 +3465,6 @@ int split_huge_page_to_list_to_order(struct page *page, struct list_head *list, return -EINVAL; } } else if (new_order) { - /* Split shmem folio to non-zero order not supported */ - if (shmem_mapping(folio->mapping)) { - VM_WARN_ONCE(1, - "Cannot split shmem folio to non-0 order"); - return -EINVAL; - } /* * No split if the file system does not support large folio. * Note that we might still have THPs in such mappings due to 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: 13947244 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2082.outbound.protection.outlook.com [40.107.236.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 980D8212F94; Wed, 22 Jan 2025 12:40:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737549661; cv=fail; b=aqToA1o2Oovj+YUWqNjXaRJ0cTZlibu8+saM1ZgihcC3Tyr6gARaHQt8JvyOIv2wPr5Zboa3vdEuDf3bcGovc5mHTKFPxX0Sa2Heo5mYJqSu2UWTo5ffeXH9M8ft+N7QJodwi0ue4j1RYJGkFQjJHzXccHja1fcDmZVB/wHuWiw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737549661; c=relaxed/simple; bh=IpXh0wgj+LVp4JNJ3SjMTCCzT+fgSKr+4zSn97xhNb8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=IUhNx5RoG07hvMcu05za/hgU2Og1wX19TC/gnn2ATeetCzfnja/DaBFzkMJ0Kn/vrV9uO22IovkFT7+ERNKTtiiChWO9c+AzJwAXjdsDYIMGzIUnUxsBbo60nngvDM7M8g93Krwt9qH8nNOz7B4vcdiKm9SYbDvOGOP1qIHOPuc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=lswE8iwR; arc=fail smtp.client-ip=40.107.236.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="lswE8iwR" 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== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; 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) Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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/jqQZPY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L/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/nV0Y6wEcJmLwI4uRZHcls4a5csl2qMBrQO8BZkS4DptirgH87tCb4+zqWg833DNddujkGBSt7rhbjoj4rC1tT/DIlIk33HyJXxl8TRG5pwv94NNA3JWOkwd2DcPOpzXADSQ/TUda0sB4qoh3Mb+p2GV+p1IShHom8fPmFUZS6vv6yGtJgUbV0pTR6UjIuKnnwnTyRGorGI0qZPUM3Ht/eehboW/HdnI+8N3mWtI9kzb38oKoKLvAUoBk+kN47XlA8nX/NfvsGRCckUxjCgIvQdl758bUUZYIvO5q2WLetN7TpomgP2eJDrdmON+TzZl6f4pr00dYvnKb9echqps/t8FkeZTUbj1ImxHE2HfrDXChK1TuBUFcAB0buC+sTwOe3G6ynICMZdNqszC/B3nqDpvNaxorQdbM79ig+8FI9Pl1w4YrvcnO/YMgFMZU/q3SC0F2Amfl1L6biX8TBO1CuSsV0mg88Gx1iB68X37yeE584Ii51v8uYK2zZN1v+/gKk27b82ZIgfzjmst32c9M8VtoIuQf2138CC6QIStdQ2d8bQ2nd10wTfB99x+8oicqC1foXDoNLAAB/liGnwI4Vz9AZPe8b67wxvMj8uBz+Y6mtrn8iEaJBEbVd46/QHc+ci6xyRwOCol4j9+yL59uWZa+QdENZ6I23kKBhZYz3IcCVbXiKY+wFdLanrS7u0GXJUNXX/kR7u1uZAoMQRIDieCM70hL6ujFgX8IaMuB647uDRGxcYUhAC+Kzw/dMxREhZJYrfBk16uGp4LqFu68bbYFg4FL8HulRoYx53vChLK5wgB4t5lYCZ2l04/BT1nytFmTKViHQM8ujhbIwBdTohiJ8tAqRYuZCDUa8C490x9yJsj/Pbcw437iEjWNvnj/tfJGPtoPewhLFGvfCDLpQWvo+l+pa7WWApvAn3cFloSlsdkPiPpfeKFesv1KaGFoGb1PoC5ksr9vM9Li85MOmwXO4+/AEH9cGdEV9brq1B9LxBVlKCBMwd7yX6ZvMusKfDKDW0EtX88kt0MUmaS1l9wxsiI5QhUu6kKoO0ZOLyh/6oy8haudCL3Q2t8cpOiJgnNlnRHpkpVNmaZeOHprrWkeszxL7wd9W4n2O2lyg3a+uZM5DMFDxrwNbFOm7BmGYqIOwXxSAdMJLQdPftahkpDarY0w863HGaPQiGv99nBhvg/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 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);