From patchwork Thu Feb 11 00:03:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 12082089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36CFFC433E0 for ; Thu, 11 Feb 2021 00:03:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D6D6664E31 for ; Thu, 11 Feb 2021 00:03:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6D6664E31 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 76E376B0006; Wed, 10 Feb 2021 19:03:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 71E706B006C; Wed, 10 Feb 2021 19:03:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E8146B006E; Wed, 10 Feb 2021 19:03:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id 48E1A6B0006 for ; Wed, 10 Feb 2021 19:03:48 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 19ED69892 for ; Thu, 11 Feb 2021 00:03:48 +0000 (UTC) X-FDA: 77804038536.24.57C44EB Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by imf15.hostedemail.com (Postfix) with ESMTP id 1D756A0000FC for ; Thu, 11 Feb 2021 00:03:46 +0000 (UTC) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B008Hn123030; Thu, 11 Feb 2021 00:03:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=Bsctkq57JSaT40cpFveOgi9TJ3BanrKGCjZ8mgj40J0=; b=J9pxody6E5FccDKun2f4iSMl60d3pHusOrhwq3LM0iabJTvFk6B/bJ36ErrYEyH6lgtY ZNUk3tMgDSJWK1bj3sjYipJDQBVTc69mhL/r5zf1YTfQJuw2nRaM/M1raFXrDXJ9yyfz T46xXDEH37zQAM+Psii9Q65KyBdNMlgL8YdI/8f0rgpxueDpWFKxdnzisQioloQRoPNM 8MtnqHmfaA6SWEX8ZMsXCYntcT8tINT2D4zU3EcQiz2PxOKLNZ4VorhN2o1FSCo+mUz1 LCMyA5GOpeo+pbhVDGZXpLOyJyPhsgmp1dsoLCzRXi8yGurvdkUwFye5RBO4WkDySti9 Sg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 36hkrn5fuv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 00:03:36 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B001ZG158383; Thu, 11 Feb 2021 00:03:35 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by aserp3030.oracle.com with ESMTP id 36j4pqtpfx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 00:03:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F3DbQEmeDESqLzh+0LEEGxa/SnYHDNHakg1nsn9vp/I/kwdI0rvRGAuoW4bFCMl2sWyfN7+peyeFjpJw5vJ2YosswHYdQYdMhk6n5JIx0FWMWmP07ik/Ns+V51LfyOhvz6FTK+WkW4hzdkVZPA4GtOOFka9zakMnVJn4/PimIsan+6UzyZxmzFdj9cso+H1Ogcci51YbkG5ANlc0qTpD8B6U6q+3oVoVLXphckaOtUdQ5UEmVTyj70AClG1bZr/llfQkzK/LziG99gn8qRNdf0DA03maJ+OYDr6deGbNqHQCy3ckImkW0Mn14gtQnZXrFM4TgYb8X07L3w5L7oB4PA== 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-SenderADCheck; bh=Bsctkq57JSaT40cpFveOgi9TJ3BanrKGCjZ8mgj40J0=; b=ZTCwokDb5z/WLnEcib+jMOcHLhmpec07IvaBoqjoUMBQI9IQZe0v6b+GPgBZjFHdMVCRvcE44tjh0+QMbvYsSTonZ1E4tXVjLayYxNMHVKvYnMpPUBQ7BFiySjhK4hniEeNP3UcrHaTMz5U1b//tp4MOnyaDlaq6yhKnmrUBkyz8SqoG+FFFzM0xROZPrXQTUxiaFDa3d8keZQUYEDyay8LKFj1GGpNhn+9vqicp3+juCvQpmWMxBjBSksMSw68iyVznb3ZtlgBy3W37NOeWo6wI0LrmpfbmdY+DamyS7d5wAMjIbglwUiSothVyMsBV5q2gHFL8aVhLb7Wp2xt6FQ== 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=Bsctkq57JSaT40cpFveOgi9TJ3BanrKGCjZ8mgj40J0=; b=dwMosigWhKqW6gay/wxlNBuMZtFp9k7xFmxj9x9DIbZW0/sPW/Ft7+P9WGfrB4XDDkq+DfiuhxzJ2XBAdK/+i4BTYygoVnJMEbOlMVOuntPXHv3T05rAxwtL3H5UFCXSc5E7JAF+67tVvhKmGq8lQZQbQtgFHTHLhtcsZr4d0zw= Authentication-Results: kvack.org; dkim=none (message not signed) header.d=none;kvack.org; dmarc=none action=none header.from=oracle.com; Received: from MWHPR10MB1389.namprd10.prod.outlook.com (2603:10b6:300:21::22) by MWHPR10MB1341.namprd10.prod.outlook.com (2603:10b6:300:20::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.25; Thu, 11 Feb 2021 00:03:32 +0000 Received: from MWHPR10MB1389.namprd10.prod.outlook.com ([fe80::897d:a360:92db:3074]) by MWHPR10MB1389.namprd10.prod.outlook.com ([fe80::897d:a360:92db:3074%5]) with mapi id 15.20.3846.028; Thu, 11 Feb 2021 00:03:32 +0000 From: Mike Kravetz To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Cc: shu wang , Axel Rasmussen , Peter Xu , Andrea Arcangeli , Heiko Carstens , Alexey Dobriyan , Matthew Wilcox , Michel Lespinasse , Andrew Morton , Mike Kravetz Subject: [RFC PATCH 0/5] Add hugetlb soft dirty support Date: Wed, 10 Feb 2021 16:03:17 -0800 Message-Id: <20210211000322.159437-1-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.29.2 X-Originating-IP: [50.38.35.18] X-ClientProxiedBy: MWHPR01CA0032.prod.exchangelabs.com (2603:10b6:300:101::18) To MWHPR10MB1389.namprd10.prod.outlook.com (2603:10b6:300:21::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from monkey.oracle.com (50.38.35.18) by MWHPR01CA0032.prod.exchangelabs.com (2603:10b6:300:101::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27 via Frontend Transport; Thu, 11 Feb 2021 00:03:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fef043d0-fbc1-4e1c-e763-08d8ce207827 X-MS-TrafficTypeDiagnostic: MWHPR10MB1341: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x7VTX64i7BoTzrAwZ/FChqJzkxIwtthgGwHYZ+G5zjG0QX/QMkjVGptSYEpyn6sYY63rKkTLaLmmAIRHZPdRPzz5uVTNThYeMJiZ+VQA6uoWJLBYwliZdPBqZY7PLAgtYXF17cULPH312imb/kq5kwiN1u0vpufIHoB0ySktzzFUE/HhOfefaEb4wSwqTnnAiJcs6pk3ATksfLsaEQjL/gvzJRzjgLhAMsWy28BNcirfYCUqa+FoTf370y+Bm5YP1FY2HTy5dhM+Zbalirpynk6cFndBnHv/lKPo/txrSDsLiT/TQPi6/w7C9bIF7KPuIlVUy12wBAlCL48umxDhZ8p2ZgZxmtqJUlj5quIpT0vjqa5v74hiosYDvIF1B4ukKZOHD9odhTMmeHiF5nbyPIE8/WuX81J1uDxngG8yVCizbAnS9hItR+qBkoYvs3RvVubYhuw38rBltF/mMKcmSDM/n/ePkfUtQKWzlOvwSsQqio/sidm239Wo1UzqlaA/o7IMvPSU+0FhhzW4fOnAjK5YLzFX+V2/SxV/p8pI8NhH5Voa0Wxn9rgAnpsQN/phfqWGyDBmWXkK8OHy8goX2BI55QLQA/bzfleHvGMXAXExK/7kVivA9SxPeDWzIOd4xLNJZ7FeK6LN6lBX1jzZzQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR10MB1389.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(376002)(39860400002)(346002)(366004)(396003)(136003)(107886003)(4326008)(6666004)(2906002)(8676002)(44832011)(7416002)(66556008)(83380400001)(66476007)(54906003)(1076003)(2616005)(956004)(7696005)(5660300002)(26005)(478600001)(52116002)(86362001)(8936002)(6486002)(66946007)(316002)(186003)(16526019)(966005)(36756003)(14143004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?qrwV9K/SadNgbsTIs4Wr6jT6dgIyCA?= =?utf-8?q?13rZ2r/pD4ARsPuvmDo1oDoxm2jxKVyyHOQmDbmFqNqdygNiw0M5+OK9GkSD6bauE?= =?utf-8?q?OowdKxQEEh2M0jyURpmOpelo+aNR1RSPH9q6oe1N+RdVdCEr5kBuph0aDOpso3w07?= =?utf-8?q?YWqbM5Y2qDgWLtoHKAezXHidzIyexmYkTwMoBFvfu1yhbZZlJf0Lfo8/gUtxEX1bg?= =?utf-8?q?9DZ3S/69NUuO4wpCLPr0WuyeTm22h6c7F85cxhR723xwlAt6lHqfPRg0ssI/fPiXe?= =?utf-8?q?h3fCkH3z2fMRlRnx1SOIY5WVnP7Qvl5PCyOaip69iZ+BhzA+AsxyTVeckLY06rqRe?= =?utf-8?q?ODSrmSuOQ1BAy9ND3sgL/zyx4dIraOBxj1C62vkwhSb7hQQj7TrbA4H5zqcbS9zYV?= =?utf-8?q?MxW536jlnOnBBuZkUylUdeB4a+hxB8ZE6+k8QrO6qVeHs0/dt4U6+NcUW00VIyjAU?= =?utf-8?q?b0p2H68/deRZcdIJJHPFMcf9B6d5kvhg/dUiT8y9sbWWfB/jFv8p1q9h9H+zaydSN?= =?utf-8?q?R9Qdc6Bz8iiX4DUAODI2A6DrHBSM160Gskq+dmbR/dqA7LzfoU5aQ7i6dtYiRv8RW?= =?utf-8?q?3b+WpLmyUR6EhmusHKODUOcnXFSSviZngeRKg+facRh91aBbSKtfwKZ8FXSfXQiW1?= =?utf-8?q?o6CzS2JCei9MZdpAGrZflx3nsdYHPr6U+5UwAp6TOeCoWoyAlR6BoVojYIIqelbwm?= =?utf-8?q?V/RenUjyuAYV9GuNjP4OXaNLRb/Me4vapWe9rsyLOX973VncFM8KafLP2kPfIvoKu?= =?utf-8?q?LrSSZwDycY4uXjOFid2iJEXrKdc7sHQE6AO7OG6BxesKyvFC0yAtrIAK6Jj+Wkgfr?= =?utf-8?q?Q7T4BwGsGTSylbgV+Xg+kgGYPZPpNBW+rmTs0AQKrwHWET6KZg3OimbbpDR31kKgK?= =?utf-8?q?i83S11WrJBnejKZJMwYnv/nnUhD+PF1ROPw7R9OG7h/E5Ywfowb9uDQPuXhTG9YFC?= =?utf-8?q?y9vTdVRjgtcV5rtz+YoOav+9Gk/g50lQ78zg0PSwnymlTTrICYzXyF/zX5P0z+PRA?= =?utf-8?q?Oc4pYGffKi2Ojv4F09xRUveASKlNrQEvFpYFw6lpknUYqq+M5IsPeWI1LKgQJFHob?= =?utf-8?q?bsajF8jJf3E//Re1yvZ4XEHoF1funHg2kGQ3GGM8xUd0H+p8hNFRoqpvsNXa4iiR7?= =?utf-8?q?8pY4pjZDZFVj9r2/KpnhnDoU5hwfbgWZkHRbI/JhBtwjFKbAGvnX/zFZUn4/ynPb6?= =?utf-8?q?7WuKSlNnrBMKMWfjJvHrwK2CK5oar9AF0XVAWuvEmmURtsy7jOrt4GpQJbpTk4S66?= =?utf-8?q?pHp4DwgEBxELGA?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fef043d0-fbc1-4e1c-e763-08d8ce207827 X-MS-Exchange-CrossTenant-AuthSource: MWHPR10MB1389.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2021 00:03:32.5370 (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: vg4oZFoECFo+DFEMgfva9NbJwcEXr5w1m7hn5+IEB9ahkHhSGRhbEdExqg8Vx3mPxWy7GWo+2MU0F1DVy5kOgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1341 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9891 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 mlxlogscore=572 malwarescore=0 bulkscore=0 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100209 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9891 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 spamscore=0 impostorscore=0 mlxscore=0 suspectscore=0 mlxlogscore=752 adultscore=0 clxscore=1011 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100209 X-Stat-Signature: nuxdauamghaz8wzrw3ij8aozuq1j7jja X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1D756A0000FC Received-SPF: none (oracle.com>: No applicable sender policy available) receiver=imf15; identity=mailfrom; envelope-from=""; helo=userp2120.oracle.com; client-ip=156.151.31.85 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613001826-936098 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: Shu Wang opened bugzilla 211287 [1] saying, When a memory region is mapped with huge pages, the softdirty bit is set only right after the huge pages is mapped. After the memory mapping, if the softdirty bit is cleared and the memory is written again, the softdirty bit is not set when reading from the process's pagemap. Their use case for hugetlb soft dirty is, We maps both PMEM and hugetlb DRAM to process’s address space to provide large amount of memory to the application. Periodically, we clear the soft dirty bit by writing ‘4’ to the clear_refs. Then, we check the page’s soft dirty bit from pagemap and use this information to track write activity to memory. We migrate the data between DRAM and PMEM based the write activity for better performance. A quick check of the code revealed, The /proc clear_refs code handles THP pages and 'normal' pages. There is no check/processing for hugetlb pages. All the code will do is clear the VM_SOFTDIRTY vma flag and vma_set_page_prot. None of the individual ptes or page flags are touched. The only soft dirty checking done by the /proc pagemap code is at the vma level. It checks the VM_SOFTDIRTY flag. It does not look for soft dirty on the individual ptes. That explains the behavior described in the bugzilla report. This series adds soft dirty support for hugetlb. It has only passed some very basic testing and likely needs more work. However, Axel Rasmussen's "userfaultfd: add minor fault handling" and Peter Xu's "userfaultfd-wp: Support shmem and hugetlbfs" work touch the same areas and have similiar issues. Therefore, code is being sent earlier than normal so that efforts in common areas can be coordinated. [1] https://bugzilla.kernel.org/show_bug.cgi?id=211287 Mike Kravetz (5): hugetlb: add hugetlb helpers for soft dirty support hugetlb: enhance hugetlb fault processing to support soft dirty mm proc/task_mmu.c: add soft dirty pte checks for hugetlb hugetlb: don't permit pmd sharing if soft dirty in use mm proc/task_mmu.c: add hugetlb specific routine for clear_refs arch/s390/include/asm/hugetlb.h | 30 +++++++++ fs/proc/task_mmu.c | 114 ++++++++++++++++++++++++++++++++ include/asm-generic/hugetlb.h | 30 +++++++++ include/linux/hugetlb.h | 1 + mm/hugetlb.c | 40 ++++++----- 5 files changed, 199 insertions(+), 16 deletions(-)