From patchwork Thu Jan 13 18:03:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 12713037 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 1369BC433F5 for ; Thu, 13 Jan 2022 18:04:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 879CF6B0075; Thu, 13 Jan 2022 13:04:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 829B56B0078; Thu, 13 Jan 2022 13:04:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 655806B007B; Thu, 13 Jan 2022 13:04:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay035.a.hostedemail.com [64.99.140.35]) by kanga.kvack.org (Postfix) with ESMTP id 56E346B0075 for ; Thu, 13 Jan 2022 13:04:29 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 1E9F961307 for ; Thu, 13 Jan 2022 18:04:29 +0000 (UTC) X-FDA: 79026038658.02.BE8AA09 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf01.hostedemail.com (Postfix) with ESMTP id 71FBA40022 for ; Thu, 13 Jan 2022 18:03:33 +0000 (UTC) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20DHnAqp002556; Thu, 13 Jan 2022 18:03:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=XDv7D4hJeN27xMCuPmsT0IC8yZkwj5c+OZ21G5wTyNo=; b=gVyFMVGs4/BV9gzer5qy4w7t/ArPmwBOxsmnpT4ALUQaEu+ZqFqtWMBnJJIWcl0kiHaz oxefVYdmfwc4IeZCj4/KYvz8ZeX6CaCWa6dbmznTTyAcfN6J9o+E5g3+Fsp9CKcJNoog jDsZMxfXqtOaxM+Sy9rzhbNQFoVy8bQkpz57xOKvNNMTJ0fMtuOFsbjINyXn010ym6aC 5A4oxC/pOSFvSuegfEwIjvTsrU55dU8AF7OEDWP1N7mib4ABNVSt44CTNnhEPNs6zh7w 81p3ykJNXEBf3pZmLxUlyFBWadF7LoedsUItk/O8fhAOw0j8ql3S0lP3+c//Z1MLo0EZ GA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3djgv69f4x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 13 Jan 2022 18:03:22 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 20DI27Sm000821; Thu, 13 Jan 2022 18:03:21 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by aserp3020.oracle.com with ESMTP id 3df2e86pje-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 13 Jan 2022 18:03:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CyV0esWaFTKGS++wbjbK3yKKMFOMAaacciXQLsWxWD1ytRLttO9yyQsM/+e9x59bJm/DPiDabQd82YpHVNn87a57bM7YDfYHsFvKGRLyTiP6Kfqm+Jyj1AjLJk+tDBs2wAxJJyNLRbzhA4WbE1eGOEqZqTvwyiYIjjjne/1e8wRRtl/UaRa7EmS26Kwjy4rI8D49y3aeF09Ahf5vP5btgZn0WeGQ0dmVTnthRiBuzgghV824U2i93BQlVKZEM6NFqMWQ3/X5H+cee93j4uoGDR68wU3EiXirdBrIwY/TO02YGWWk4TeyalVunviXctFueiAeZTUcTRjrGf+sIEj19Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=XDv7D4hJeN27xMCuPmsT0IC8yZkwj5c+OZ21G5wTyNo=; b=mCPhVo7hVpLA2qnv1QkcqQdxrDGyMyxA2c09lAmXod1xq0d2MXUl3K0X6oVL4NKp/sTzUqlyyUg7inEg3Nv0f4ufwOByX3VgZnyTqKmnpAFZ5T8oDH+NyXuumswIjm0ZPGaTRnDcvtP2hjsmtgjUDPhFG0nUOPGkuiLhAAI1G0P5fMV52Fv2gpSvktzSkrUDn8Mouc7mYJfPfnBjbILwjtB0UZT5Tq/Kz5EP1EOiS+dWwjZZkYe7riw8kJcyAGyJ2VahDxZtrWwB0jxoaJT6CVMJE+xH3kGZ6aPLnDa200C3j3OUZwJN8cpBwgypuTrf5K4mXyPXKR3bkkeez9Yq2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XDv7D4hJeN27xMCuPmsT0IC8yZkwj5c+OZ21G5wTyNo=; b=UY4akMCluMUcAhl90aFT0jWMMwcAqWgVoP5ZUqcZeb6GF2cNFzjJUSaETOYsiXGLFYNdRCQKj9thkl4bH+vyZ+NSghgslBM+nPJ9IbGFG3HNbQ6ORmEX2O4+5HlBTj7yErnkQ+ubTdSDdsNCCkXmL9P0pgxkEw4dFyyy2ALmd/Y= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by BN6PR10MB1540.namprd10.prod.outlook.com (2603:10b6:404:47::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.9; Thu, 13 Jan 2022 18:03:19 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8502:19a4:8a7f:ea73]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::8502:19a4:8a7f:ea73%7]) with mapi id 15.20.4888.011; Thu, 13 Jan 2022 18:03:19 +0000 From: Mike Kravetz To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Michal Hocko , Naoya Horiguchi , Axel Rasmussen , Peter Xu , Andrea Arcangeli , Mina Almasry , Shuah Khan , Andrew Morton , Mike Kravetz Subject: [RFC PATCH 0/3] Add hugetlb MADV_DONTNEED support Date: Thu, 13 Jan 2022 10:03:05 -0800 Message-Id: <20220113180308.15610-1-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: BYAPR08CA0009.namprd08.prod.outlook.com (2603:10b6:a03:100::22) To BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c53a1709-2bd0-4811-02a5-08d9d6befab3 X-MS-TrafficTypeDiagnostic: BN6PR10MB1540:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2733; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IW6cOnSfLwjyAoqFmdZr0JeIrV/oTrOpkkH3IEenC8QgcPWeimTCQRTvSTn8ppBE4RE3gkfxYeV4pUgF0HcQKddSZkUtBkL3n502iMiyNJkTKStayozNLl54gtDgQdI3u47J1CKs4itb5C97g/DCI5ND2Fy4G+d41wpk+V26hfFeRf3YSirMCGecBV3X0+pMkjs/i/vJuMeAESLWgMId7sD4F/HPurictVBMoObnqfxPzAuXWRUdOVjyEMOfdY3S071Id7TV7t23b5qN4KwVlDpvu40CWDCRSNl+r65aIXKdyupFeFoOYDNm5f3daR0MhYfK45jiQrTVWjWJXDVqy+/vjuj4zM7vmHcLGU+pELNgHVRZ0wLMpW2zbwU3sPz3RKXAOkg9hTVI09KzaZ3NtPJ9pNycc4SIjouVoftjsrTOvS+9d0LFys6OYUVa7UajGZk3o2RJMIc9LY6CWKlV6ujG9cF4+pcabCo7SHez8KHh7Wg9L4GcwwITfKQDna2+bO7CaTqYJy+qjqrAe2+3Jls7Pqj5qEUVrhmjHKXNPPPyhhtxmxzQd1isnE7CgMmeQ8jsx/d8HKfL8qwfJquIpBFBUNgXc0KoBPod/5yEcw7Lo5fdUTyA+p0Kd9rQwEtDkkXiljO0pE4XKIMWRsYRKOnSX3KNxZEEYP9VcUQBGXQZTZ+nC5Kob1OiAe+ZXy+3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR10MB4196.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(6512007)(4326008)(2906002)(6506007)(316002)(52116002)(8936002)(38350700002)(66476007)(38100700002)(508600001)(54906003)(66946007)(107886003)(8676002)(66556008)(6666004)(26005)(7416002)(2616005)(1076003)(44832011)(5660300002)(86362001)(36756003)(83380400001)(6486002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rakrL/+sn9no9CLIr2Aedwv7jkv364/ryDbuyHL3RfHV4VXmfMLCpjBL07PDmcpseLgnS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0UOz/+wtMqV8fTasErl5tH3rFmAZ5SzYVk02wcMQLB7F6eLyzDHrdUj4KQUd/qslzl/vSM5TMjKnikEFHbB7KurdNeQNTofnAYo3bbrhuH75Qs7xKtCcqXQvKJfLf15RcOfvDVmTl5UJ3PcOEQMcc5a6drArA7iQs082n9XsvZQ9s+zvs6xYErjnOAJZ9Dshu2Q8lguhRo40cHCGExyBRmM6x1rIlKHUGMlSST7LqjcVHUvQwYxJLrSZn/W6iqftvfop+tisoq0yWtaVgd84sxbyjSSzwIDQgDSg0Fj9FtHMjNaaJhfK2CKRbLwDKynhHA3LJVmrpHmQyFOoKTEXvuKxPGdAPDZRZLcT247c4ljO1/5pOl+R4tORTdY9jWA9mffR+mYvqygWdCfhJ6m7TkQ2dylONmVutbbv2ePGRS3DL7WEf2yTk/rgpncADlrRzqPCceuuI7DjMtc4v/lg1YrbCtHmBraRY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c53a1709-2bd0-4811-02a5-08d9d6befab3 X-MS-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2022 18:03:19.2332 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +4y6tkCRykWGISyFGIXTS8oEuNuq9nZ3fONKOVcBzpvad0lWa81uwNv+sIKBKgXGgf3tMllD1gNlwvViLkv9fw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR10MB1540 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10226 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 adultscore=0 suspectscore=0 mlxlogscore=883 bulkscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201130112 X-Proofpoint-ORIG-GUID: zweTD1IjkfUlZLobC5Z0NUkzJf2ey_nR X-Proofpoint-GUID: zweTD1IjkfUlZLobC5Z0NUkzJf2ey_nR Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=gVyFMVGs; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=UY4akMCl; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf01.hostedemail.com: domain of mike.kravetz@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=mike.kravetz@oracle.com X-Stat-Signature: x1id3x6egn8ur8xh3zk19cfkxo1zh8nq X-Rspamd-Queue-Id: 71FBA40022 X-Rspamd-Server: rspam12 X-HE-Tag: 1642097013-216729 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: Userfaultfd selftests for hugetlb does not perform UFFD_EVENT_REMAP testing. However, mremap support was recently added in commit 550a7d60bd5e ("mm, hugepages: add mremap() support for hugepage backed vma"). While attempting to enable mremap support in the test, it was discovered that the mremap test indirectly depends on MADV_DONTNEED. hugetlb does not support MADV_DONTNEED. However, the only thing preventing support is a check in can_madv_lru_vma(). Simply removing the check will enable support. This is sent as a RFC because there is no existing use case calling for hugetlb MADV_DONTNEED support except possibly the userfaultfd test. However, adding support makes sense as it is fairly trivial and brings hugetlb functionality more in line with 'normal' memory. After enabling support, add selftest for MADV_DONTNEED as well as MADV_REMOVE. Then update userfaultfd selftest. Once support is added, the madvise man page will need to be updated. Mike Kravetz (3): mm: enable MADV_DONTNEED for hugetlb mappings selftests/vm: add hugetlb madvise MADV_DONTNEED MADV_REMOVE test userfaultfd/selftests: enable huegtlb remap and remove event testing mm/madvise.c | 9 +- tools/testing/selftests/vm/Makefile | 1 + tools/testing/selftests/vm/hugetlb-madvise.c | 315 +++++++++++++++++++ tools/testing/selftests/vm/run_vmtests.sh | 12 + tools/testing/selftests/vm/userfaultfd.c | 67 ++-- 5 files changed, 369 insertions(+), 35 deletions(-) create mode 100644 tools/testing/selftests/vm/hugetlb-madvise.c