From nobody Sun Nov 24 23:51:51 2024 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2050.outbound.protection.outlook.com [40.107.236.50]) (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 896571DE2A6 for ; Thu, 21 Nov 2024 18:52:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732215178; cv=fail; b=crvbiSKd8M5IFAsOTTqpdfHda7yVqPBh2cOelMqXGj8344Rz0Q80weTnv7O3wf4YVA7wILU0na9xlW9+8KfOC1sT0EobmHkQblWaq300sxur/ken6Z1zOSMhyrTpaYlovHH2KdAyFP9avW4r2GRpmL913xfiUsM9Za7JpgouO/A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732215178; c=relaxed/simple; bh=zPGR7jKRPB6tJMDs2QTqlQCPHl5sLzjWxqmoVUkf1Co=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=D46/9FjqzjZwnAKVkccY1PbIEUMO5nFV2srzZdZ3RRq6UUZ6o0Y+itUekJxLFXvbviSbGiFM/lo4QgyLGSjxbOu3/Rlgxxgs3YpwlnUr05tGVrdPlVCtMnN87lwPrcEwuESKyAUWaSoS3yq11Z6K+NWpP0An694f+zUtxblp5lU= 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=OAdKuTM1; arc=fail smtp.client-ip=40.107.236.50 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="OAdKuTM1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DFHo8moea7rlV4/8uZlcbNdEjHwR57YXRxfF+RtCGWOQlOGeEcdpJ4rY2EH2XHhKjHEXJv5lAkRg2eNhl2G76j7GBCl7AUMwkXUjX99BjuPcN9LnmXDMIY39VanpfMCM82lfiqpJpUhyGF8lDAj77PNwE0AFA62bxi8ZuNy+ogtL6XVvN4wDvHqdN7U4WYMxTwdgrO81/uhHPWLSaqTNReyAZBg68ylM6BZJ+TZLKrQGKFzfWseaXNLrEoc4QyGeRNJiAvwC3cX7s/M/Wwv6TLrnvQ2fo0zuGw9hkihC4KidV8idj/pCjSE5iLCWUlglGHfLr/q7RubryQns5ykfCw== 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=7vfodItUcrcyLrOMU+QPVr1fQyMNwn6ddi+gcaz99x8=; b=sVt4O3NoNqV3IY+VnRRuMNM5/TGte3foB9mw5cauoXH4ahwvJonR44TaOkSLqOLHhqFyhN80QQKXzHTy+r5Isva5Sm0Z+oZsFhkIPC75XCgjnXtOHYEa6K16kc7/Fg9P7kjfE1BpjSmoZ4iEXldS9TkyuStYCQH/8MPOWgjF9sa8umE9dXTQShV3FWbMECq5fyj7oJJVucUHMyfsbxFbtYPRZpKbFrm9G/u09H+CWXE3cPb7gqGH91EcQVcCrHhepO+wBJR1WoneNMEFqkgOn/6OH5PQvM090oId/RbhUcualaZW9Xd1q7mLsTuwWUpI8E2CbmMfQsgmIoJu0FN3+A== 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=7vfodItUcrcyLrOMU+QPVr1fQyMNwn6ddi+gcaz99x8=; b=OAdKuTM1Ig4jZxUJ69RH0ro9okn4s52IRcJw7+HaNeIXFLfooXlmUJmCRGWaQyBcDNTCaEcbccSxFjyverIj9q6t86jEi3ueQXBAvT+SJxbbTsCnMzQqEA9425yOhFas0WOElaJJfhptsuKclxoJzDStHfoIeTYh5WJX1X40zb2tVbnqX+Or9kOnEB6uvUucDsFNCtGNna6EuiQjAEY/KpWatoc4doDlyYcT2KAJUI8E3v61hd4PkFDMz7PFBhoyuWJIX6HB4oBm59p0yGwHgPJKBEdbHKIIqjzztsOrWrGHiq+8mfo1RZssrgB42qUq+b//uj+KYkrlXwUfOehILQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BL4PR12MB9478.namprd12.prod.outlook.com (2603:10b6:208:58e::9) by MW6PR12MB8834.namprd12.prod.outlook.com (2603:10b6:303:23c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.17; Thu, 21 Nov 2024 18:52:44 +0000 Received: from BL4PR12MB9478.namprd12.prod.outlook.com ([fe80::b90:212f:996:6eb9]) by BL4PR12MB9478.namprd12.prod.outlook.com ([fe80::b90:212f:996:6eb9%5]) with mapi id 15.20.8158.024; Thu, 21 Nov 2024 18:52:44 +0000 From: Zi Yan To: linux-mm@kvack.org, "Kirill A . Shutemov" , "Matthew Wilcox (Oracle)" Cc: Ryan Roberts , Hugh Dickins , David Hildenbrand , Yang Shi , Miaohe Lin , Kefeng Wang , Yu Zhao , John Hubbard , linux-kernel@vger.kernel.org, Zi Yan Subject: [PATCH v3 9/9] selftests/mm: add tests for folio_split(), buddy allocator like split. Date: Thu, 21 Nov 2024 13:52:20 -0500 Message-ID: <20241121185220.2271520-10-ziy@nvidia.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241121185220.2271520-1-ziy@nvidia.com> References: <20241121185220.2271520-1-ziy@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: BL1PR13CA0216.namprd13.prod.outlook.com (2603:10b6:208:2bf::11) To BL4PR12MB9478.namprd12.prod.outlook.com (2603:10b6:208:58e::9) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL4PR12MB9478:EE_|MW6PR12MB8834:EE_ X-MS-Office365-Filtering-Correlation-Id: 0634ce88-ba82-4fd0-13c7-08dd0a5dad2e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ao6xM8paWj8W1BV6BMlXhk3QhR/VThr8iEKeDACvc9Y7fOoBPjN2A2xfG6Px?= =?us-ascii?Q?7mw//1i3mMpVEvRC48S1NBHGrCa1DyvjemfUPnNGSEkxZb/Vhscdb9ARX8ck?= =?us-ascii?Q?Rki5H2IWW+miJiyhvkAQC9VbmpLAMZuJM6E7BZJ4J40g7LHssvuTk8iWRdoK?= =?us-ascii?Q?rlkMeqZTtkhSInBcQJJWTabZDW3kvzI7BxpTK7Xhi1FV/X+cGiZsTUbPIsbf?= =?us-ascii?Q?xCOoHfgQTsAgmlrIbsC6vKUJFYH4dS57ICsa+4JpbOdmF6QHSvoptWHOElNZ?= =?us-ascii?Q?SK4IzNoyVZdPwkwaQ1u4ogkeWDOwwn/mLE0lkW2B8z80S1x728DyqvnhmeUL?= =?us-ascii?Q?oXnBtA1UPGk8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= =?us-ascii?Q?o6zyTgmyXkALj2xACtS3CFeyUFtXXXqpTlKhOqaeSzi35Cx2aSKJIyuObfMn?= =?us-ascii?Q?liC22+rlsYJidiiKy3efv2Ip?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL4PR12MB9478.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?S3AWpXHLvR8V8016XN5gZXJsu6xOaAvvlS5qjELxYLjsFR5JjRilojyEal2o?= =?us-ascii?Q?+5UQ4O+fd4zTERhTPbm+/GBeblw5GOY6LtWtFNSttakcQL6rRWY5RhZFecK+?= =?us-ascii?Q?y7umaC0BoyjhemVXulbzxmo4HACzunrhMKjLPIAAeDX/rPdi0L8zXCDLU5rZ?= =?us-ascii?Q?KQ7fr+zcgj8d0yAj5NbBN2QlQayRyYlg7nOdOY695Jaa0YNE4VJftJVEn5/9?= =?us-ascii?Q?7NpbLDRCJiCUis0Wrghx83slWFOOh/RcHWM6a6YneX1HtY3AunNmtuAetQDC?= =?us-ascii?Q?478tlK2XVQc/FNKlODiYUt5ZAIttYom1U3NlcZuu/SeFsQ07C9Lkm8N47bey?= =?us-ascii?Q?FGH1W7/dKS2blT/4MBlEmV7IVq718RCjF+YsMRbGq+QisWveWWr9kB4YxZvR?= =?us-ascii?Q?KVtMsvG8FcgankrNKEZ/FzAMIqbH60EyDLS8wVX7kHqk1ZI98UIAlNwWgwR5?= =?us-ascii?Q?H6ytz3tNPdKEUWoYU7xLHOAbqhG1m+n1bmBHb3mzXGTRqN+mmV4tMAUwRecy?= =?us-ascii?Q?KIOIhJwm3+orC9b7OMYrIjJN3SFtzsRCWjaafra/xnuNYGzSObxqFi7bYdkh?= =?us-ascii?Q?5d4tTI1jLpY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Skr4gTFRuFRuz?= =?us-ascii?Q?LFgSOHsBC+PVaxBdCcORQictG4/vmoxzPRxyndDSbk6t7yk/rBKSE3BHS8Zt?= =?us-ascii?Q?O5HN8tLWddhYk3mbvnERYvc0aermuqDNP3HSEHE1?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0634ce88-ba82-4fd0-13c7-08dd0a5dad2e X-MS-Exchange-CrossTenant-AuthSource: BL4PR12MB9478.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 18:52:41.0986 (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: nQOjIULsQyyZeQzt+x8v5MCa/siBtpoh/RBWlZ+0crFxtyYE4wAd15VwwXj3/G6n X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8834 Content-Type: text/plain; charset="utf-8" It splits page cache folios to orders from 0 to 8 at different in-folio offset. Signed-off-by: Zi Yan --- .../selftests/mm/split_huge_page_test.c | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/test= ing/selftests/mm/split_huge_page_test.c index 5bb159ebc83d..1af8d6fa4465 100644 --- a/tools/testing/selftests/mm/split_huge_page_test.c +++ b/tools/testing/selftests/mm/split_huge_page_test.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -420,7 +421,8 @@ int create_pagecache_thp_and_fd(const char *testfile, s= ize_t fd_size, int *fd, return -1; } =20 -void split_thp_in_pagecache_to_order(size_t fd_size, int order, const char= *fs_loc) +void split_thp_in_pagecache_to_order_at(size_t fd_size, const char *fs_loc, + int order, int offset) { int fd; char *addr; @@ -438,7 +440,12 @@ void split_thp_in_pagecache_to_order(size_t fd_size, i= nt order, const char *fs_l return; err =3D 0; =20 - write_debugfs(PID_FMT, getpid(), (uint64_t)addr, (uint64_t)addr + fd_size= , order); + if (offset =3D=3D -1) + write_debugfs(PID_FMT, getpid(), (uint64_t)addr, + (uint64_t)addr + fd_size, order); + else + write_debugfs(PID_FMT, getpid(), (uint64_t)addr, + (uint64_t)addr + fd_size, order, offset); =20 for (i =3D 0; i < fd_size; i++) if (*(addr + i) !=3D (char)i) { @@ -458,8 +465,8 @@ void split_thp_in_pagecache_to_order(size_t fd_size, in= t order, const char *fs_l close(fd); unlink(testfile); if (err) - ksft_exit_fail_msg("Split PMD-mapped pagecache folio to order %d failed\= n", order); - ksft_test_result_pass("Split PMD-mapped pagecache folio to order %d passe= d\n", order); + ksft_exit_fail_msg("Split PMD-mapped pagecache folio to order %d at in-f= olio offset %d failed\n", order, offset); + ksft_test_result_pass("Split PMD-mapped pagecache folio to order %d at in= -folio offset %d passed\n", order, offset); } =20 int main(int argc, char **argv) @@ -470,6 +477,7 @@ int main(int argc, char **argv) char fs_loc_template[] =3D "/tmp/thp_fs_XXXXXX"; const char *fs_loc; bool created_tmp; + int offset; =20 ksft_print_header(); =20 @@ -481,7 +489,7 @@ int main(int argc, char **argv) if (argc > 1) optional_xfs_path =3D argv[1]; =20 - ksft_set_plan(1+9+2+9); + ksft_set_plan(1+8+2+9+8*4+2); =20 pagesize =3D getpagesize(); pageshift =3D ffs(pagesize) - 1; @@ -494,7 +502,8 @@ int main(int argc, char **argv) split_pmd_zero_pages(); =20 for (i =3D 0; i < 9; i++) - split_pmd_thp_to_order(i); + if (i !=3D 1) + split_pmd_thp_to_order(i); =20 split_pte_mapped_thp(); split_file_backed_thp(); @@ -502,7 +511,13 @@ int main(int argc, char **argv) created_tmp =3D prepare_thp_fs(optional_xfs_path, fs_loc_template, &fs_loc); for (i =3D 8; i >=3D 0; i--) - split_thp_in_pagecache_to_order(fd_size, i, fs_loc); + split_thp_in_pagecache_to_order_at(fd_size, fs_loc, i, -1); + + for (i =3D 0; i < 9; i++) + for (offset =3D 0; + offset < pmd_pagesize / pagesize; + offset +=3D MAX(pmd_pagesize / pagesize / 4, 1 << i)) + split_thp_in_pagecache_to_order_at(fd_size, fs_loc, i, offset); cleanup_thp_fs(fs_loc, created_tmp); =20 ksft_finished(); --=20 2.45.2