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: 13947245 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 8ABD8C02181 for ; Wed, 22 Jan 2025 12:41:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D92466B0083; Wed, 22 Jan 2025 07:40:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D1A166B0085; Wed, 22 Jan 2025 07:40:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B46356B0088; Wed, 22 Jan 2025 07:40:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9114F6B0083 for ; Wed, 22 Jan 2025 07:40:59 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 13ED6A0B70 for ; Wed, 22 Jan 2025 12:40:59 +0000 (UTC) X-FDA: 83035047438.12.E3F3287 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2045.outbound.protection.outlook.com [40.107.220.45]) by imf21.hostedemail.com (Postfix) with ESMTP id 3E5B11C0011 for ; Wed, 22 Jan 2025 12:40:55 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b="gbtKqrR/"; spf=pass (imf21.hostedemail.com: domain of ziy@nvidia.com designates 40.107.220.45 as permitted sender) smtp.mailfrom=ziy@nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737549656; 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: references:dkim-signature; bh=WyURrOf1NUHmAiMEXV1zetxPd9i+upU8gYqrWH1keF4=; b=Zk2Dir2LdfJYzyYTVL1ArIIePvmwRbXbTnlhj/8J4V1Fr5ys69G8m4RDhkIzEcZgMfBnL2 usbKE0muP7qOGQ0kOvYlIJ6iU3ueYQHywUjUXbegsBtUwMCGEpdMvz8zjoQuA2mZ+/Okyo yFh0Ych9V2bkFeK+Bh7T6gFrN+D7mTw= ARC-Authentication-Results: i=2; imf21.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b="gbtKqrR/"; spf=pass (imf21.hostedemail.com: domain of ziy@nvidia.com designates 40.107.220.45 as permitted sender) smtp.mailfrom=ziy@nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=reject) header.from=nvidia.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1737549656; a=rsa-sha256; cv=pass; b=Mpy9RG1HhoXqoXzekPyZn4qRToz4XrLbhq2jKPG9iZ/RIDQDuu8XQteMxsaPl5xoZQdAMZ QwWkVKatOT/F/DbeMqbUP9oePt7JnAo/nTRAl4/tcErNvWkGq0MU2xLNsSqrXox6l3lW/8 2wk6qCiWGJSS3wIUPUwBcXic6gB3XWQ= 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== 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) 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/myY3RnUlajbtPJkWwuQDIaNsMGxHK7ga0HxcaHjDcEsdCAzFnq2R+zNhuUAr3DfR64p3nSEbOQEUA44LMevqIq+JMyRJZMc/8LtfLZyY9yvYmEK2Neiicum21qRiC2ybQ1hy4SWt36d8GVLCPsFjTGpDo8VmYYUFMPX30lwVrKriUm/2YhK9WN4WVbkPrsaNkhpi8cmebETT+0zfW51RfLjemdmzr0vsMFhpwHVHIVcdhchw9D3MZ9XyIRHWUxFytuT7uHy+e+EeZEzYfDh+DIHGorNkoP8xm8OBaVz39i54L0SsNlbpa4E+5RubFID7Dv29qxjOdEdFeW4dqcdIyVBbvKT1XvNxN+qwFoT5BBUW92Xeij7A52M7n8Oao3/mJbxjCYRiHKhEObKLkT9EDDIA60/0uZ8ULTUQRm+zrk5ltR4Qez4CQFpD+95f8UwHAT8QUXCxVu37hb6Nf2CaA/CiEyANiqgi5lW24S5kVoJzczrXsQH7STnhno8Io0G+0chPvwy8/yp8XeXbYglt/7kAJ0Q00kc89LqwfUB0Wu0+SZJOrLW6sglDCzyDid4FXArKaMuScQj2kgoKl2V82TilIloqyjF9HMauJPBxUkFDSPr5q/cdDxtOnr6g0+zxsuMzWnHHrLfrnfijXeHfNJW6mn51b2VzRsBoPnULS01PqGzrnrs1Sa/lwYaqxiqzVW2y5RRtlKdnm4f6u0QaF0fyYDdK89IQ2dZ0BPUAQnJOre0Sd9/4nWo1jyhRABTUvPlmH8vj0gNva3lhyD1wXyZdPQfNl2mvzljsj6S4dbxQd3UjeHGcUR9MT/YNapIGHsLx9iuzpYGsOhrzZnMNcrUkNcxZqQhfG27/1yzYL+b0pzU9LIfkaBBimhxuwKKOPa73ujeUEBsqtdXscCXpKVn1ZFqsVP4AI1jCV0kc40iURWl5doKNlzIIk7f8/BK3tflRPDENkVXDx0NWE7nbnrr6ldxELA+WUyUs6Ox+McxIyiX0dJTwWYzU/Xo6jB1VwpVJ7aroIj 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: BdlTob2Weuc1qnmUq//OcDPUsL4zICq3PQAMSBRGVcZn02JCUwEYNY98U+MHTXnXmfQxa74ejV0JQrFnnaA7d0bVtVkqwikxQeHTDiriBXKxhGzAps4cba4lutS5Otwqd9H+TPvWnDh4V4Ijrmzj28I4q3AkderFA6q148ePHFukOx1om2+ZeA0DfZylQa2j3YukStGNdv9FZWG4jr6/EP6eLxi9GMcyquqcmWtIJtZJuZdpoC6E3FJdTTcBXKq4uARwOUPmWyEFp779r0c6BsdmdX2H59m+t1AbHc7pdOMi0UBq7LAOGPsKe37JV4HvICytr55FsJB2UE2hpEBrhANPU03a5Rnoz8QplXTcGlasK1TOhmzTjMjnb8CRvkD/NIyw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DytmTAQNfyX3+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 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 3E5B11C0011 X-Stat-Signature: ccr9quehxpp346qwzi9qffkmr58pgmpj X-Rspam-User: X-HE-Tag: 1737549655-82530 X-HE-Meta: U2FsdGVkX1/rjXrkhhWoUXAPbJcTxvq6yxiJsWy+2wDkbjMxYnqt96xQb0SGguV91mk968KG7QXuh/GhciSA4c9y+VjReTS6my/31B8V9O321kkQ+8sUOKqNpItatKUasOkfFPsY4kKwR+YwVSRLD2qVUEVxESPuUyTpmwECG7lqRmd4BtQyZESWCYPxzoR/d9YFFYFo0AeNIOQbcK2OUtFALI8Gnhe9GL2x+H9lACkU+iMTBmKjgFcKCHV8dwyYigv6AjnPJnPaYFlxdQO0Li/4dVEvWnTppKJ5Ut0BJhKG70rMNGC7uPjqV4/goW5ZUhsVb9earZAyLCzSfVYLRAeYY7h/XKpmDRH7u83gQ8pNAf7sE42tYk54jy0iR0VuiRsb/xlavsOhb8MBRhYDXNSQ0bBTLvbxIMzaVLVvqLqb04rz4AO39OkzzJn50ueuHY70z7yMLTCWIeD3IYGNR4UFxfMS569z5kGrlKFUdZKIV8WQN4by0ybAKoz0DhwjL6fnjWB76P8qcQMpe8yYwhLlSdZCPCVaHBJbXfQXqHlIahVw89BMw7GW1mXSIDn6J/ZyusED6OMXmR9fl+9zjgtNdMWqo/t3devCbXvz9m8R7+4z7+T1d/ElsaDYJSuFRVGKP3exzvLu1g6POKYAR9C+O+/pTc+XgMHNvpUNuy0sO7GKUSGF6Olvnbvbtl44AWKJgehAblYkWQvu5ieFY+qYcGBie9H8/dco73B7oH4sL17CyU9qy6WEAQoV9AjoPOHzpS8sYF9anFXwusIK60bYA5Bqv65tj0ZOSWHrpLPbXQL8w35etXLb0fRO1rZcYPEUcgMU9YLtycp+YRVZXcGEf99SgaKv+D2BouAnxxk6Vkw7oH9ooIJrjFWlczy46nHKnCuG67cylSkpgu7rV82tQI5fi7lD8PdNv6ungYDtSPmsZJYWROO98D4ugGifyix2Nax6jnpx6mF8kqp YLWS4rGh pxX90t2KYbSPLJunky0BWkwVwmh8SUBLGDT8bBCysha0vXJosrhqOYIzl3S+FqkpdIlP8uEyRpxeD/Q8y5DtZko4QL3CviyRHfadu2kib3wTb/og4PmrQHa+egguVT2q+n3LJkUrJoHiTvSvbG60JIx1unOxO6uYDRVKxQiIP0kScX4xHrxntpUDRkaC2luo8huyKXvdR+1DUocBTNmSVprJVopqYRySdEJKGnL5FSyqG3h50H4GLmM2RCfDFTp2rxkarYKRfeL23CcAI13bgyE9Trr3a9Vgi8Aj2uX9xMvrZl07IO6ebQYRzHB/5aqFxH66jcyo3HPiV3nPLuP+KIcfUUfuGgS+PZbts7TWY4vJPFio= 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: List-Subscribe: List-Unsubscribe: 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: 13947247 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 8D22CC02181 for ; Wed, 22 Jan 2025 12:41:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1AC1F280004; Wed, 22 Jan 2025 07:41:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 10DC9280001; Wed, 22 Jan 2025 07:41:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2E7A280004; Wed, 22 Jan 2025 07:41:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C05E3280001 for ; Wed, 22 Jan 2025 07:41:17 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 467C381634 for ; Wed, 22 Jan 2025 12:41:17 +0000 (UTC) X-FDA: 83035048194.08.1DEAC80 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2060.outbound.protection.outlook.com [40.107.236.60]) by imf10.hostedemail.com (Postfix) with ESMTP id 761D2C000F for ; Wed, 22 Jan 2025 12:41:14 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=caM5M2rO; dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf10.hostedemail.com: domain of ziy@nvidia.com designates 40.107.236.60 as permitted sender) smtp.mailfrom=ziy@nvidia.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1737549674; a=rsa-sha256; cv=pass; b=pBIakkzX+yrJ5sqIZnLZRnji95we1AvzFYXw6Ai2ZsAppXDErVIDnJ9MALNIUX7zJbVgEJ z5PVWgiTjBpgFKlDNzppzuqyd8bs3q8lxxvRIn8bZSzKm3ZtG6ZX8TeHQdBM7dXNDhSUgO bZuHJ+2zbfR5aqyiylX9VpLczhlOuiU= ARC-Authentication-Results: i=2; imf10.hostedemail.com; dkim=pass header.d=Nvidia.com header.s=selector2 header.b=caM5M2rO; dmarc=pass (policy=reject) header.from=nvidia.com; spf=pass (imf10.hostedemail.com: domain of ziy@nvidia.com designates 40.107.236.60 as permitted sender) smtp.mailfrom=ziy@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=1737549674; 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=WmKa+b07ci/+SigIR8tnvRx0W0zt+6m9eZpwmObzkqI=; b=BoXTFCR3X4o4oRqD512WHmhxkGfakzR/K6nVqVaCl1kcreWKNdvcjtPXB1Vhy9OxTDHT36 +Od92LwR5fDYgIJqXDI8ZPzCfUt6FmDGn1S8ZnqitpufArzhdBVBVQiEQ5ELijtrB8TkSR UKi2oYNoscNIDK2OJRxZPchwDzdqOXA= 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== 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) 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+iGhMl18V7Y5h1WWiiBgefw2BJAA401zXGqdMIy4vUkwKxocNeH8fMAVg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: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/CGVas68Glc9mNDHw8PcPkjqtxYTROUBuir6ZrXJKtQK5xnnkcOvlstF1gcn649mGHSBHfHj1PLXJ1ve9WfnLoSRvpqbvQAQv2eErmPWqoNeRfZjQeRZR4vkkhFQP0lg1nBG8VOsgtf8r9f+aLR4TeWnCRGlcyLDBxE44iQFe7A9ms0MWJJAIYQFyxVGypnSA2Q0yNV8FEt7PRLoxwWy1Y6NtC30DqYIAARNtwxrAkjoyabu9QPlc+rY7eEqiCcnufkO+0vUhPfqxXX978iH7Ja4KVdTh9/TiKQ6qSPgPWxQIKoHKP2kk5r4wOVzPlFjQn5zVi5bIz8uvsdvguv/Np4HG0oMlJNQipgYrGbh3hh7tWfPHi2l0FOX8DErfAu4adEwO+s/w6AdEkd+IBxozP9KeI8dajcAmrT2cAcEW5JHNuC7Md2tlaUDE1fQZqPt49kqUhKNHmI5j+MQMcjVz7HluCgdTAen/Tr7ATJIuYVCOblKxbb6+8IIQgdXohFvPLFPSKOE5e5nGolUjCj5tS2Rq38k53koAuRemP67ot0pVpZIBdHRUcqTeuJi2BBOeE0YaNQQFbqZ7Xgr/rr/zvGq8hx1jibMY0fdToRVpbYutjofxpVyB09gRof8cEqsK8MeV8AY3j4ePzKW2tYrPawpBQObLxkca1hZBD5o6rEkISM/TdYQuXtJLb7urfJ0kydaWEJIGN4x8p1vjcrHhs01dNBZaughD4vy/mJSehoFLWryRyAeY8iLCFg8f13bIJwi5/T06c9aUTjQ5O6Bq59w0T+YUR1ylndWt8ogQDt7onotNWYAXcGYtZPQL321HZrr0V2+hotVX5KCDxVfsm3XU/WLoo2ghiwh+kBlQuntQIuMfsYOsHJPMId9e/yzx6LUjh2MzW5ntBBUfR6BjnjMDsRvKbu11hJcXSIJE3tGdxudCxt27vtCDsbhugHiMTricnlNyyhxaxbHKzkLwv92NHdC8ibDjOio9FziqGACzXz0McmVtCq4B9hkQQ6nmS5kQ+nUr8oaeVPbNb/U0p7HfYeNIRz0vgcmvxdV9L84iss1daILeC3aEJlwPhgbmBEMV16HI7VEgZSSjKP8fNtbWzgmYKu1nR8MUB8B/8NV5+dUG8JseLlmjds2nkhi8AyrdOZjCUdb+HYhB4+A5ykXsuX5WgO8o70c6t2XrbKFtxDMuRkp9K6F7vTIdwjTYiW9rKnijGWAIthMgLQeLmH21NFs7oGl+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 X-Rspam-User: X-Rspamd-Queue-Id: 761D2C000F X-Rspamd-Server: rspam10 X-Stat-Signature: 6ntwkozfwdqqxjow9wcit96pk4s97wb5 X-HE-Tag: 1737549674-238303 X-HE-Meta: U2FsdGVkX19tHA9IWoha7uUwKueGMKRMc1StciNWQGrP9FZupbEOM0StxRxZzG6JJ9yPP80QVNBGxFJhy9LtZrMVshILslzu8pRbQZcg+T/4aKG5yqSqaiFXsBC2Dm5jmLxCkvDv08wW0HI/md1llOBgW863r828Heoyri8Rx7j1OfV2oJzazVzph1CnxByEcs2sbdeUBfRARiumCDxeMSEWGE0itxduS1rJpZ1II6O19j1Ga2D3fN0Tr9Soq8J6h5M/3U4fejEu9J/txE8x1PNWKjKbcf/+hw7+IcNTtrXjejtJVVhgVUVS7EiAHuMw6p7ICj0zRQHz10dFQ/4Nf1ca4zVsnYG3AxjxNK3Xs2jVkepi4ywSgGCsi3bmYuHkzPptQlRaBDpR+sLJW0/hjBizbhkBJN2Ec6cEuh496VVhZ0K7E6hpqTeopSHupkSRQprX2dgYMsvmS+HU3+cgs2NP/M41AHn7dxfZW4loGZFD7k6K2jAcUaBxFYqqu/yVRorGUX/iUHLkqwH46XIg7dgALAJ4QNj6GbpkZQmtCVkqOFUv+kGu0E+nZJ1eBiKcJR/5SInkQ1PVyL5T9z7OuJsrodi+BbH07O3Kt+011lj9EDka8k5RKnI00rxtcV5D4em1kh5xkhHsRL7aszSn5bwxjJx5sZbBzKoNIcg6Lr6GNUlEnDF6TFUXrm+zs+++xypw+GQc58H/c819eYhLAbX9EdceNA+KlBqa8ItCRpdwxVcf/iNNDVo/QHS8II0FAxgimpMfDlK8XVkCT7oxdgZLd/MEsaPi+xG2zxzZEs6w8iBOfH+3k++8n0JPW1klMz3zrTkBdkmZAwTgMdl36+cRJ2XzzRg12NPh6kV86cpPyYJ2bEdDYfuniW5yLLxaTDfDYM7PdWq+I0HA6CX2tnn9qjJuhKBSxiwL5oXdXGNig6vZXaU0v6TGFMrfr4DkKIrIufInowohCMxu1It eFPiQqFK dPe4Tv8vMPBBAJ1RiiPt/DWrierGcYhC6jZzng3B2HCFFeNhruCLhLmSy6d7o1KsmbAYFNiw6UmKGj9rhMzaKCMBabjL1BOj/GSiOOakCqd2aAWD3LTSkDfYPoXz8lbxyoFB3iCZeVtEtO/O1yNXxAwKHoDUvwdl2BD7KoOkBjyXWDBllnnImwNDhfMGRwJXYoVuT4JRnW26VCMs/unht/SlfCD666jg6aQ310hO4YTeBdBFdjGsMMuphwzlgK3ILRIARv2NWt2zFXhejahTKuWYPuMXBY5a85DiNvT8zvOlZjAmBy32Gvz3vl5c+4m+zr9OfStDrO5CrfANZ5j8/tMdNbsVMWNjcUS/JxMRQtXd+UvpZE/EFcigGkq5hAd9sH7Grm/RNzYL8Do6XGccqMj/JvAJPX9oA6jFN 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: List-Subscribe: List-Unsubscribe: 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: 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++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oGb1PoC5ksr9vM9Li85MOmwXO4+/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 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/skXv8dOS1lQDVehxy4L5i1A3wVfZfIgWDONV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m7L6LsJUr7cTm/KrwVCRwwg/ypd0IWtwRFqCb5abPpiQxtoEDEF1WkfaJwkWJwTOW1LO5TD00Od9VJOOcLCOtm5t0oyRqPoa6lTXAQasMFVJGNWdM4HYbpdT9xnf0= 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: 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);