From patchwork Thu Feb 11 00:03:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 12082087 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,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 39FFAC433DB for ; Thu, 11 Feb 2021 00:03:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A17FC64E31 for ; Thu, 11 Feb 2021 00:03:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A17FC64E31 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 EE8B36B0005; Wed, 10 Feb 2021 19:03:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E9AF56B0006; Wed, 10 Feb 2021 19:03:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D39C96B006C; Wed, 10 Feb 2021 19:03:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id BE1CF6B0005 for ; Wed, 10 Feb 2021 19:03:47 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 88D00180ACF7F for ; Thu, 11 Feb 2021 00:03:47 +0000 (UTC) X-FDA: 77804038494.25.3D03C91 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by imf17.hostedemail.com (Postfix) with ESMTP id 87BBB40001FE for ; Thu, 11 Feb 2021 00:03:46 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11ANxdJV100513; Thu, 11 Feb 2021 00:03:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=wAWXgNyLuvU0f8MOWGmRhDVqVdXn0dina7dfnF9YD9E=; b=uY66WZUFdMIs5OzEaT9MJ5MYjolWkQd0mT17m06WnuXkwyX56ZsbSJgL/vx5bgRtAiRe akkcKRfEUE17hbx7Yxa7l8+VXwoebobkbIxyvzvpymsjkbpI9jyvgx06bJVPz/9v3d80 sF6Lw+86Fd40AJCKaMx0z8jgXoCPwpn1OBwLJxj8RMp/lC7uUYnHguwkSggdeOCirO2C V/errWaQib0Q03yrkbb/HhvUprExZ3wd/PhL8jQJyOmbH8AYBHXXo6OPXxLlRDq3UBZe fdWQxMcSpniZcCL6IcBn3slkqWO/BUW/amf9fujcWF8wDgrQfxuBrvJCRhxflDYS4grh 6A== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 36m4upv2bs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 00:03:38 +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 11B001ro158444; Thu, 11 Feb 2021 00:03:37 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2107.outbound.protection.outlook.com [104.47.70.107]) by aserp3030.oracle.com with ESMTP id 36j4pqtph3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 00:03:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iyPvZZY09gy2YshrKBzKCrEssTwc4LafuLkxb68KXcZDuNsJJaT3pJOtkELBARLOaxOlJhXq35xwvEx/pZtK27C36HJ4SfWPnlNyYo47H0iqrJA7aROUYpyUXej7XYAgXYnDB/xQ14BgfqtwCSDlPGGiZNWhlXTKVPp9K/xtobl+07lpb5gDOMP89hZelqRbRo8CIGVEtXEYxMXPrTz6aNNchnTBqIsR1hxxpE+3OQUAaRHxtvEW4Ek3GOho/GKWd0wKJvqjhFLTIpibO4tCjj2YevFMlz28ZhGOhccEcAgT1CoL8UMOqpHpF5ZWGV2dFCz7bCupNHjkqK+4diWFMw== 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=wAWXgNyLuvU0f8MOWGmRhDVqVdXn0dina7dfnF9YD9E=; b=Ssed28rbIU9JW6j33GlPOG5E2cfyC2K4Sv+7m9TmUSKmCm41vlY5auV3iDgtNzAMdXmq2NfemL/T5R0kqQgw3zlZhPkI5fTjaIgG2YghX0v4TORImLq6GP1Jz59XohD38cL3E39cqFTQo5bX7yedHhgmRT5nleYlNHum6oGAMxLpBYQLcARKrrr8JFmIYMoTQfR5u26guktl1wPGfXrHF/Y9Gqo9FVOCaaCvJPb0/3ZjF/c61gGc+FqamN1wq+fN7RNw9++CMO6DKnZhwEBRp46tpJsZt5tDc16U//b8hyHxARK36JbLaOS8TMKkwfOxhzvnG5NBsevHfjUsF24UnA== 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=wAWXgNyLuvU0f8MOWGmRhDVqVdXn0dina7dfnF9YD9E=; b=z9z7xE3EK/lffIPCpMpLqHQAqzffDK5nCEcsBD3GHXypeS1YZRIwtj1fVBLleaifaLzVVHuCSZuwRmPqKyuqElGz6BcR26a3HMYHwyfiTkNk0r7/vkejVSUCNn59hPdTiJF17+SgpqwQXuuarolYbKBS71xdizCg4idyl4FGr54= 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:35 +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:35 +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 1/5] hugetlb: add hugetlb helpers for soft dirty support Date: Wed, 10 Feb 2021 16:03:18 -0800 Message-Id: <20210211000322.159437-2-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210211000322.159437-1-mike.kravetz@oracle.com> References: <20210211000322.159437-1-mike.kravetz@oracle.com> 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:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 37ab7c82-c94e-4e69-f8ec-08d8ce207978 X-MS-TrafficTypeDiagnostic: MWHPR10MB1341: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:187; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MZfA7ux8D8Fw6/1RTU3TBrlx8A9lcHoRy0kf0xrlBD+angg+TqMgR8InBYmSKHQRGzt3NzdF6jmpHqPGebOqZd8l7+dVlfS9Wjg6YZy8WCeVGwotLQiFhzHEdEVUVGVYopR2HSoOxSuY5xClWzXWSfUVVcTrSsMVqmFILXI+BV6uCaE0RO4Nx/GEAxpZQgWOm79+4n/WKR9S5phWWZ31b7TYsbSgSe2yWCwe70PF3BEscpJErOgPEgN3VI/lAeFXy4rQkyq01WvlkFS9DVjQ/w4Drr10TJDTryndMPUCB4agcPqxDLan4DUn/tPwKaDpgTdDiP7+ZFHi29zV3DgXDTCG3tRoWIpPXPF/sX03f5IBh19HS9QHvT/cF1ZbW6FYo4LiNol6kpa1RFBb+1IO589VK0Ps41ZPC5wUV/bmpFfASooe/P9Z5VvzrOeNfgzELRNc9A5EkQoNCOrv2d42AUebnX1364isM9W2m4e9M9bEo4+MCH+ZhDzpiyxmHVhy9p+Vq5Si4KZgI+Ct6iEnAy3/ItmQ1L/IwIYIPi1JvZm3Fqts/H+YCmYbzTy0FDpl 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)(36756003)(14143004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: TXOJnrS4g8peNhlpBnmteGKecm2wU1ZSiosZ++NjNGBARnR+erg02vMmjfA5x6PvZga6kh2usfppmeLHzqLqJhkI9BjAeSTRBjiQK+3KVGdTdRNISuLXLKJqbTJ64oRgM0emU48xP4l5vdg+ilg8WH4Sw4trxxc4g7s4ffj95lxF9OvdMInix0+E8AFYcMjioC8oY+A/8vjX966wPD7TzU9NH+zjc5mwc5mS9/EpJO2QvfKuyjN/HRQZOy6PebRV9Gg9J+RFNgZZVv7ktdx9GNbzRV7z6xTh56oKUBhRflvH8uMiM/zQn3RWN9BMcrJYbRegvJnQF2eA05cgtfns+j8jwkvzWTy2OnN74ARMQisA9gAn6Ldi/uYZLYu4uPznN6S7gY77meYLJGWMcTfLE3R1WZoixbWKNdAnorXV4F31CkYGKPR7XBDKFyOMwein5zJ/npS1uvbWkYASKSQee880JbdD1Jrk9RAXTBLVxlNVyZIvYomen4TJ/qyPZO+3jNtbWCfHzI3LO9S6yw7hCWUQrUkN90d4PKa6moJP7XHdNqGM8vOQHRJjbUAQf6mQIiIaGRnZIrla+PqUcevahyGoV86mk+9iknxDa/L8rf8eb6DBdsrePeZFy/pPYR5wkmupNQNkfxI0hU2X3Mzq80zfChDoqBy3e9Osb0WoFcfEnOqLdv1cuDo/jl46R3Ga+cNNl5CqqiERXJN2Y8cH6pEgLOex+l/nj+tXbX6ZxPI4DudMsd0RAa/XN10QvQrOkcqGV2RY6M/KP3mGhkYutBc+KIn3HApD3VRG3GsQ4v8ig3UZHt9vqWIJnHbfo8VSNH03xsxMmxqhOn6rjVJvEDQmqn36lx1pspo17KqzfxJmN9qFAh30+vs9pDRfHRvr0AZUZqUi8tpazHAyRHf7ipPIyT1QcUdxUumQ6SAM0y1bYAEVnu5WU/yUI1T6ohpeU1EnwU8iBWYk5wKjovirlxUETfT0DESfZeCVAtqN+FuXiPTbdRL94UPWfd0CmcMoG3oi0nszrMMfsKDOCczB6Jh1h9v/96L/tkCXu68TRhrTzWZasq9fO838RqZYXzBGdyyKajrXfaTsk2eHt4591TTnJauRhmlMWpFlb4wkOrdeNjo9Rr5GqdVk8+a5gc/a4hiZdZSUzB3CgfGXMw70tQhTsHD9KAZrlJiU3+7t/FJgO0mPlzC26M1GLyfuAaYWWx1WqOIZsCWNw9ne78YZgcbBbQ4IFGII4kGeo0TPsShaNbeGPtPVcrKkd53qNZhJjj/WT3Kh5WSbsMkrsntncb/jHb/cz8QsmQ2tbHWSQCbAggJZpn36W6FT+/rT6Lo/ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 37ab7c82-c94e-4e69-f8ec-08d8ce207978 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:35.1798 (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: FeaDhLT3mB4WQe7v8x8/95anFElVrsjS1mRTb4b9MwJZnFIJwakTk57pZO3o7CPEjKD2OX1oYM5XcNv8T1F6nA== 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=999 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 priorityscore=1501 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 clxscore=1015 suspectscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100209 X-Stat-Signature: mcmwkcubqngkhhdcoz5j5bswioejy1s8 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 87BBB40001FE Received-SPF: none (oracle.com>: No applicable sender policy available) receiver=imf17; identity=mailfrom; envelope-from=""; helo=aserp2120.oracle.com; client-ip=141.146.126.78 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613001826-412662 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: Add interfaces to set and clear soft dirty in hugetlb ptes. Make hugetlb interfaces needed for /proc clear_refs available outside hugetlb.c. arch/s390 has it's own version of most routines in asm-generic/hugetlb.h, so add new routines there as well. Signed-off-by: Mike Kravetz --- arch/s390/include/asm/hugetlb.h | 30 ++++++++++++++++++++++++++++++ include/asm-generic/hugetlb.h | 30 ++++++++++++++++++++++++++++++ include/linux/hugetlb.h | 1 + mm/hugetlb.c | 10 +--------- 4 files changed, 62 insertions(+), 9 deletions(-) diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h index 60f9241e5e4a..b7d26248fb1c 100644 --- a/arch/s390/include/asm/hugetlb.h +++ b/arch/s390/include/asm/hugetlb.h @@ -105,6 +105,11 @@ static inline pte_t huge_pte_mkdirty(pte_t pte) return pte_mkdirty(pte); } +static inline pte_t huge_pte_mkyoung(pte_t pte) +{ + return pte_mkyoung(pte); +} + static inline pte_t huge_pte_wrprotect(pte_t pte) { return pte_wrprotect(pte); @@ -115,9 +120,34 @@ static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot) return pte_modify(pte, newprot); } +static inline bool huge_pte_soft_dirty(pte_t pte) +{ + return pte_soft_dirty(pte); +} + +static inline pte_t huge_pte_clear_soft_dirty(pte_t pte) +{ + return pte_clear_soft_dirty(pte); +} + +static inline pte_t huge_pte_swp_clear_soft_dirty(pte_t pte) +{ + return pte_swp_clear_soft_dirty(pte); +} + static inline bool gigantic_page_runtime_supported(void) { return true; } +#if !defined(__HAVE_ARCH_FLUSH_HUGETLB_TLB_RANGE) && !defined(MODULE) +#include + +static inline void flush_hugetlb_tlb_range(struct vm_area_struct *vma, + unsigned long start, unsigned long end) +{ + flush_tlb_range(vma, start, end); +} +#endif + #endif /* _ASM_S390_HUGETLB_H */ diff --git a/include/asm-generic/hugetlb.h b/include/asm-generic/hugetlb.h index 8e1e6244a89d..d8a78dab63bf 100644 --- a/include/asm-generic/hugetlb.h +++ b/include/asm-generic/hugetlb.h @@ -27,11 +27,31 @@ static inline pte_t huge_pte_mkdirty(pte_t pte) return pte_mkdirty(pte); } +static inline pte_t huge_pte_mkyoung(pte_t pte) +{ + return pte_mkyoung(pte); +} + static inline pte_t huge_pte_modify(pte_t pte, pgprot_t newprot) { return pte_modify(pte, newprot); } +static inline bool huge_pte_soft_dirty(pte_t pte) +{ + return pte_soft_dirty(pte); +} + +static inline pte_t huge_pte_clear_soft_dirty(pte_t pte) +{ + return pte_clear_soft_dirty(pte); +} + +static inline pte_t huge_pte_swp_clear_soft_dirty(pte_t pte) +{ + return pte_swp_clear_soft_dirty(pte); +} + #ifndef __HAVE_ARCH_HUGE_PTE_CLEAR static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep, unsigned long sz) @@ -133,4 +153,14 @@ static inline bool gigantic_page_runtime_supported(void) } #endif /* __HAVE_ARCH_GIGANTIC_PAGE_RUNTIME_SUPPORTED */ +#if !defined(__HAVE_ARCH_FLUSH_HUGETLB_TLB_RANGE) && !defined(MODULE) +#include + +static inline void flush_hugetlb_tlb_range(struct vm_area_struct *vma, + unsigned long start, unsigned long end) +{ + flush_tlb_range(vma, start, end); +} +#endif + #endif /* _ASM_GENERIC_HUGETLB_H */ diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index b5807f23caf8..7b6c35c5df99 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -187,6 +187,7 @@ unsigned long hugetlb_change_protection(struct vm_area_struct *vma, unsigned long address, unsigned long end, pgprot_t newprot); bool is_hugetlb_entry_migration(pte_t pte); +bool is_hugetlb_entry_hwpoisoned(pte_t pte); #else /* !CONFIG_HUGETLB_PAGE */ diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 4bdb58ab14cb..47f3123afd1a 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3759,7 +3759,7 @@ bool is_hugetlb_entry_migration(pte_t pte) return false; } -static bool is_hugetlb_entry_hwpoisoned(pte_t pte) +bool is_hugetlb_entry_hwpoisoned(pte_t pte) { swp_entry_t swp; @@ -4965,14 +4965,6 @@ long follow_hugetlb_page(struct mm_struct *mm, struct vm_area_struct *vma, return i ? i : err; } -#ifndef __HAVE_ARCH_FLUSH_HUGETLB_TLB_RANGE -/* - * ARCHes with special requirements for evicting HUGETLB backing TLB entries can - * implement this. - */ -#define flush_hugetlb_tlb_range(vma, addr, end) flush_tlb_range(vma, addr, end) -#endif - unsigned long hugetlb_change_protection(struct vm_area_struct *vma, unsigned long address, unsigned long end, pgprot_t newprot) { From patchwork Thu Feb 11 00:03:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 12082091 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,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 C64D4C433E0 for ; Thu, 11 Feb 2021 00:03:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5826D64E2E for ; Thu, 11 Feb 2021 00:03:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5826D64E2E 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 D40F86B006C; Wed, 10 Feb 2021 19:03:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC93E6B006E; 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 ACCA66B0070; Wed, 10 Feb 2021 19:03:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id 80ED76B006E for ; Wed, 10 Feb 2021 19:03:48 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4FD0E181AC553 for ; Thu, 11 Feb 2021 00:03:48 +0000 (UTC) X-FDA: 77804038536.08.field66_0f1754227614 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 366C21819E862 for ; Thu, 11 Feb 2021 00:03:48 +0000 (UTC) X-HE-Tag: field66_0f1754227614 X-Filterd-Recvd-Size: 12731 Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Thu, 11 Feb 2021 00:03:47 +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 11B00vap123526; Thu, 11 Feb 2021 00:03:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=lWuyKdSvNH7sRgrTc7guPksVygGWWPSQVwqqKuMLE04=; b=q2YQpqhfZo38GyY+7ysC80wGjyB6jOKQfUTjZGUbqGbRNWPFBGXZkyN43DRzl+e1qKIL cW+nBwBpkcwOd/ex/jSWNWOB1EaBxRPsNcjARcaERYDWHchYpTmn2s9xS5ED0ghclrkS bFAxooOWUXI05d+N4rAyRp+FXEDzSLW9lfuw5xvIgPwHJRsxdEEwVNv03RS6kKhVao5m kBjHhn7IU7dxXtaEsitKQvRSHscrZX9/n1ahHQccbVhqK7QToj1W0pHXyQcGzBK4LGN9 pWMBXt2fZMZU3N/WLV6nJBmzm576uKr2x2hLUyotdkNTThIx6ts3q/KMgqtrKi1QASDW qg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 36hkrn5fv2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 00:03:39 +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 11B001rp158444; Thu, 11 Feb 2021 00:03:38 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2107.outbound.protection.outlook.com [104.47.70.107]) by aserp3030.oracle.com with ESMTP id 36j4pqtph3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 00:03:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iSE7nqoEyBQNniTvQdK0ewBHPuu/in01Sy5OQrYVV2j6XsAX3C3kM5F3qGL+ERE6rU35Y5P65JMTHeVRaeCYiRXffa4kax7KJc+bBZ3GcuvU3Lzgf/W+JAeyTru33LLQ329OcCuY16vPJEbfngoRyIgx4xcxinFleGejGklnqxDT6algUa4wOm/eTRtpVzZRXmZIGG4f9msXszlsYne6I47dmxr3lEpt9Ls866QxmUjBLH8XWEBfpLEeedjkbD6mAlDRFT1NSGsp1fqhvzCTVFUmw73kZawapNdNvLyWvC+9GzhJZyWmTifzPvNN2uLUt0LYPaYOtnKwKwiSQ62/mg== 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=lWuyKdSvNH7sRgrTc7guPksVygGWWPSQVwqqKuMLE04=; b=gixddey1NH7VC0Mm/exMzwpAiJPAVzzBIb53qQ+tx9eF+NCir9M5fbSlPZD6z/gp0uJ/zZcY0TG5aeGCyO0DesRrb4gj2Pf8wDn+p3zqLGW3fWJvKVeJgGzrs+wYqpoML5Su+uInS/gN8Wn2cHyknB5534OZWOyhH9Hxt0RjeGI98SZLWtjKbQ1tNXxp53DBMbHbF1qWrVp0l9FV48kKvk2eOAMizsvnA2zC3/zZda2KJokr19BGC498x8shd14elEm0zRM7b6WxVGxXWMKe3evwUfhaTIE8mtPCqgxG3MK8T5BFlupBzdcVdwlTbp1TEfQ3kPixCLn46OAbb1QKLw== 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=lWuyKdSvNH7sRgrTc7guPksVygGWWPSQVwqqKuMLE04=; b=w9XOru1MR8UpVPdB5mqxA8hFoTWn3H+y1HvcSNb1XzYNfaKl0TnKywMhbwrTHtOJvO1xrSEySVMYnNqPCr7Vg1J12vUBouPi9zswFJXCXUxnIScm7DGa8Ds6517NfPpBkgMZtqOvXomHsYFPtXTVscVWNRGRxr0kDT86jtOa0VE= 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:37 +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:37 +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 2/5] hugetlb: enhance hugetlb fault processing to support soft dirty Date: Wed, 10 Feb 2021 16:03:19 -0800 Message-Id: <20210211000322.159437-3-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210211000322.159437-1-mike.kravetz@oracle.com> References: <20210211000322.159437-1-mike.kravetz@oracle.com> 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:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3f7f2bbe-a67f-4e51-1f39-08d8ce207ae4 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: WIsAGNNgNlLyMfCxx9W0RFLcX8tZHMUfkRzhA0KMDTHTdyJpkNK1JQXpTMhy12EA3iHI6wasX9lvloTswnfIRChXojYyYMEg2K7qhU/a1MFLlb2FUXONwAv5/cXARP6LiVR4GvrI917q+w33vTnK7/HBLNXm22F8kY04EVHMiqE88do9lwHzXSZTv/Jqxc83nkUYTf0V9qmpuQBE0QYEDC9GizjTFK8kZK5TRt5GWGpGHN40ieqbn91fPedtRK4aOcQzia6uo+iJNRcgCgwhmG7E+9f/JdD3jEdDmrnsSlCBlO4WoNBeck56R9v+yirVmLqdnKa1/KiMWmNhlw1Nk8HC4Qnc+YxposaR8b0vAwSeHZk2RTNNQU1rZvf7nweh2C43VfDih4Pk/u5AaHssQOrgMQLKmUB6d9IeZgoAVvqqXgKgJu1cjEiLbpkV9TtxU+mrUKdPLclHHijf2yadbIXCX48exguICD5HpeFTkMGXeC0/VlPiIse9ZrAzJIsri1WRhleF+fzDUQf8z56AxeChh3o9l3lbpuF+k8Ys9F+UIfwKrwdfh5yFEueLAwLH 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)(36756003)(14143004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: HFlX9d0ng6lP6Vqf/N21PM/JZBYqgjEI+jD70iO+l+x5xuRbNOJ3FlrEUoWPuF20tkPJ401CM9jrd3tYuTA7t50uSzZln0eQvz+ZsCERhtFtmIu60p4GDZrSNacL5s4ONUk2b6rdUypzTeAMywgHySXZSNsCtI7LOv1OQjZmnQBhuo//b9yuiudBIK9PolY/QYxMhufAiBVwWIju1tvtSQ1NmUPT3VAh7xWW2FWT66boHQliFj7NhIl3U2Ofxufd+9gPLWk35p8e2DzRigFsKHXoWO/lejZiZaI81I1dgu0vMY5UTt02sGX/3SRY2TUPkS8nxChxURiK53Et0hG+HTaK60kDJQYj/ZaqeIxnIriUIJC3X70BleSjTkChdE8ndK7FGYT9QRW+kVy4JTzb4JL++den36zlIoVQfTTjXf4MB4piRpMutqWzS4WW4PfhrAeLU7B0swQF+LFuwVAgOX6XQZ77GJ8DGXs+B+TMzZ9n1E9iSVbROeUHCfXRfxx+D4QuaLyzL8Z351sEZRCX0wVZDiwxjq7mksl2d6/XRQ01HaUz/hoLA9Igw7azafx7IT5IoI7xsk/63F2bkk/6wpBDCGepMO+C8IU/QrBFbQ/otAn5Fq0Gkr40Poa/qSVq8Zoia9VSJPeqWsWmoiRj7TEmyhRhH1cNVz6m0XjTM4Egm8W0jsd74HhjTUqKRZUwv8bMkdX8u9UwYrqR9sybzG56qnE1d27OHPEOmEAiPdrHs4YAQHhTxNfGKVB5GJHXKAxnzLRMTPpTKxI44Rp3PLDmFFGOzj3IJcjuqcj1wl41zDe/Hw9iQ27ycBo779I73u39Y4OoKznR6vJktFjNusevh40qCIVQUBMQUALJk+XDChVl3jARihT4XlSX8vQAez6Bnjj9YZqQEhDLnoeGgPFKWcMSakIHd3LpW6BnHmau43dMVnluBOvw6JMA+zxNzZu6ztNLpahEM6vdNemk88LSSogcrPsh3CiU6Jgw7K7kTQGR5JMvRSRlAvaaMmJ0N1xrYCXrpFBWkA+XVoziqE5iTvfyu4U48hqY//dPaDxVWkLatqq8JF7F2PP/gVjxE+qmREvPKiisQ8xsyUFkwwO6MSdcy4N4NRYsqcu5dXUnudwe7r5zQcFlSjgaybu9577w6b3Fj7lKXF2KwSpNynp+lVtr6+X/b53s+3VYZh0QlkvJv+W4PLD4fEuz7aRR5lMd47UH0ssh2n2713HomeVzq8sfHs6Wp9BKOM8Nm8LF7HqRHN6F2WVmDhAgzU9RpUtYMWfNfApAhvEgnvuhgAMK0KD2JO7qIEKXSGdqqucc1D+c/K0L8jqFRlYOdt/o X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f7f2bbe-a67f-4e51-1f39-08d8ce207ae4 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:37.0990 (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: JOML5WnJf7tvSy9ZmE/9E41VOiOrFfuh/Vt7u9Vm4JRxwZzPyKHsJ7KN5KRweb5w5TuK/6TkyKpWg7T39hhZCA== 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=999 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=999 adultscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100209 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: hugetlb fault processing code would COW all write faults where the pte was not writable. Soft dirty will write protect ptes as part of it's tracking mechanism. The existing hugetlb_cow code will do the right thing for PRIVATE mappings as it checks map_count. However, for SHARED mappings it would actually allocate and install a COW page. Modify the code to not call hugetlb_cow for SHARED mappings and just update the pte. Signed-off-by: Mike Kravetz --- mm/hugetlb.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 47f3123afd1a..b561b6867ec1 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4584,8 +4584,10 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, * spinlock. For private mappings, we also lookup the pagecache * page now as it is used to determine if a reservation has been * consumed. + * Only non-shared mappings are sent to hugetlb_cow. */ - if ((flags & FAULT_FLAG_WRITE) && !huge_pte_write(entry)) { + if ((flags & FAULT_FLAG_WRITE) && !huge_pte_write(entry) && + !(vma->vm_flags & VM_SHARED)) { if (vma_needs_reservation(h, vma, haddr) < 0) { ret = VM_FAULT_OOM; goto out_mutex; @@ -4593,9 +4595,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, /* Just decrements count, does not deallocate */ vma_end_reservation(h, vma, haddr); - if (!(vma->vm_flags & VM_MAYSHARE)) - pagecache_page = hugetlbfs_pagecache_page(h, - vma, haddr); + pagecache_page = hugetlbfs_pagecache_page(h, vma, haddr); } ptl = huge_pte_lock(h, mm, ptep); @@ -4620,9 +4620,18 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, if (flags & FAULT_FLAG_WRITE) { if (!huge_pte_write(entry)) { - ret = hugetlb_cow(mm, vma, address, ptep, - pagecache_page, ptl); - goto out_put_page; + if (!(vma->vm_flags & VM_SHARED)) { + ret = hugetlb_cow(mm, vma, address, ptep, + pagecache_page, ptl); + goto out_put_page; + } + + /* write protected for soft dirty processing */ + if ((vma->vm_flags & VM_WRITE) && + (vma->vm_flags & VM_SHARED)) + entry = huge_pte_mkwrite(entry); + + entry = huge_pte_mkdirty(entry); } entry = huge_pte_mkdirty(entry); } From patchwork Thu Feb 11 00:03:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 12082093 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,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 58810C433E9 for ; Thu, 11 Feb 2021 00:03:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D837E64E31 for ; Thu, 11 Feb 2021 00:03:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D837E64E31 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 293916B006E; Wed, 10 Feb 2021 19:03:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CC9E6B0070; Wed, 10 Feb 2021 19:03:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE92D6B0071; Wed, 10 Feb 2021 19:03:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0005.hostedemail.com [216.40.44.5]) by kanga.kvack.org (Postfix) with ESMTP id D90886B006E for ; Wed, 10 Feb 2021 19:03:49 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A146A801A38A for ; Thu, 11 Feb 2021 00:03:49 +0000 (UTC) X-FDA: 77804038578.28.army36_5911e9027614 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 816F2908B for ; Thu, 11 Feb 2021 00:03:49 +0000 (UTC) X-HE-Tag: army36_5911e9027614 X-Filterd-Recvd-Size: 11020 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Thu, 11 Feb 2021 00:03:48 +0000 (UTC) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11ANwanx049333; Thu, 11 Feb 2021 00:03:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=41m33m6pb/5tzcg1lV7rHhfzJFmmxyrpW6KDrRb/R8Y=; b=LSgWQMxuEr8Utti8NtxKQ0xae/uZfgPZHhBsEtvSNQf2fTkqou0GL3/hNsQd2mBlcKn+ TzcJpa/e1K26ohAzT8K5npFWdewk1QOim8cuByCxecKg9B6sIgQ5jCl4z2cx87PtrJpP 21aVdBfUtqQGD6ambDwSB9rP+zGgQ0H2b22PGSTTVRs56ugLWeWfgfqvn7iRRAVXLpe1 CLC1MIv7b0ElCAn1EWRxfta76Q51WW6MvphcqT519pqaKvzhXCcUkHXa2jazNjSs3G/5 i73kWkQn23u1h07HTQjn2gvYe4vD1Pzo7+tTGHnpJ0FGPwbw4uU2YvCoBW5rZwXSj1Qa Kg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 36hjhqwhr9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 00:03:42 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B01UV6063108; Thu, 11 Feb 2021 00:03:41 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by aserp3020.oracle.com with ESMTP id 36j513asg2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 00:03:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IRfGhzXxHZzlE9bWPkclEkkmJrdbrFOt4FApoQFaZYj7iMlRJ9UdlCLaLX8qyudDBRHHCMOlIAGEnMsvs6KNkPIsmEjz4g/8ULBdk2nnBAtjCgB8errwWrkj55I6MOI9+GWczTqsa221Yk4Tw9XF9bFzlAuHfh4rKnkuJKUXNufrwYdcqHfRIDP79wTaf+WUfgNTPoEc34Ok3EcjX6hPnkiRxURRpQvf/zkSI5dKxL4wdwhbUsTH5fn0fTAAQotM8AwHDI1xnwmRDCDk6yKqnFrUhdljaY/gNc5cgCFGYhxXtSaSud00oWe1th0zgjpQ7m8LKaGM/f2JoJzQUtlCkA== 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=41m33m6pb/5tzcg1lV7rHhfzJFmmxyrpW6KDrRb/R8Y=; b=mORW2tFvwGU3ROpyuvvw2vvSEqZNu4RNNWpXvje0WV6Iay3tNeGvv7nVpRGoeb7jqrLUgP+Fl81DPEndOrjo4bp5U8+WgPAPncWYq1WZYRk0RebUNSHe86rXc6BKtkgFM8GSM158fJPsW1aWUn6nhkFgFGQ4JlR7mCG/uqtxH7EGZj/kIvhz4yZb0mR/0ydPmfBjGmuhKvgv/ftqnFxWiRXKx07eMYmZAVx58PE/lDEtSX63PePTwVbZkH4yXvOYGsxje4ip5GwmFqAE7m8vImi8KCTUU9bJqUYsMrBlb7/3bTnsceyd0bzb3kSmOcLZ81s4v97Jp0l+mEy17nl3wA== 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=41m33m6pb/5tzcg1lV7rHhfzJFmmxyrpW6KDrRb/R8Y=; b=LMUSzjNLQvfOEhoXtpMcLeWgJVUf0u4urwz4wcuC93Tvny2k/UUIbGmdTQlZNWw52rpKZliHd7GDm0l1ogViA/98obZvPb0K5t54xQt+E3ZJzvvamin85yXv6wbPL8tvJPg+VmCYmDfpyr2gQyo/Ff3sAVes05hK1UlnEfSp1Ok= 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:38 +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:38 +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 3/5] mm proc/task_mmu.c: add soft dirty pte checks for hugetlb Date: Wed, 10 Feb 2021 16:03:20 -0800 Message-Id: <20210211000322.159437-4-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210211000322.159437-1-mike.kravetz@oracle.com> References: <20210211000322.159437-1-mike.kravetz@oracle.com> 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:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 70cee33d-11b8-4455-0043-08d8ce207bd8 X-MS-TrafficTypeDiagnostic: MWHPR10MB1341: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:854; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UPuykCYzUl7j+djUECd2t7e2xAzfO5Zd5huSz88FrTC89EiqV9LMVfvqff4BI6T85dBlkYL16aq54zDWad8MWk1YxipuFddM5f4DXN4i7sCzyVpH8eMeNvifnHbHAVwlQE9AudDPhEqttsyDP15FQHNeMtF58Jl0L8clzOAE0DCRquw2y1/U816RJM4y4sYtiNdpyiwi5uxFQDuuQwFLr+2j/SlDRvQbaYs12y2h3Y899I2RCdcThdkMA/9hd9UZhu2dlwvQcRNk2tU1BXWvcKUrimOotBiUfdRfRcazDRhUTfs6a66Ck5Xk6MziqBaNAyslbFByZDhCsDUSGBK3t+KT/1l4esDDaWTFhMXE6VNS05AoYzaK30S34zLNzhAlbAsag/piW0XYKdg6mU3NFvOfi0EdqWOK3DgLwdy1YeeC6Rw2qED2pz0hN1xSiN4xNHwylqD0b1eK/JIopl0jcFmdbqPz6j6x98Rl1g3LVljQkN3q7U9P38SeK5Icf16cv8SoZ/Y/OWP5ZbzuOuuFuxBWe2ERXqSVMlby85cwTGos1nPCnEk0/IufvoCjXBmk 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)(66476007)(54906003)(1076003)(2616005)(956004)(7696005)(5660300002)(26005)(478600001)(52116002)(86362001)(8936002)(6486002)(66946007)(316002)(4744005)(186003)(16526019)(36756003)(14143004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: un5siEY7ATgDBVlI1LqymOBYogAp8COB9gqeODpkOLhLep0ydF38A4NIOWcZ9jbCgSPGs7+hccr3LX88TApQ/72fE5Xs7DScjXVZ5b/Jusr80ZOfWHqIxzz7biY/kWruJqk4tAfMhjX+tf4Ak9j0Rkc3UiJwWMvrbocf1mGFxZX7EhW1a40ghjGOOBz1i6sEaEZ4G5RLOckeUfXzEs7UaQdMjf4vcBibRJ/Q/IFbzT3OHTLncVZiloCZjETkGtDCgsnDrJvoDjzy7+/l4fDO95ryXVGDkEic8+lsnm77833nwXM7M5GELV7JA00rOlYgkwbEXW1RiP1CZXrFt/OWvo2iZG44BcazkRIIhSkKSmFsR0NbnjhNp5tRN5mwZn3TgI9dD4yaBiYorOZg/WOjpDIob2GJm751EtFsZSj2RsX3LA8LKw9eTxnVkUSsQpGabueo1qDHEbb8qAkQlSQY2KCD2Zxc3MUADT4E+tsRnaxZjzchDjYaX1XyBqZv1wELiC1NgDIPQD170kil5gfu/As/ASZ40a2+BQ+aLmizy1T/ijDfhrZFyp4Ht+VWOgRdRNt10cHZN+UYekM1wxBXc3QuPm6duDKnskcblZUGohl2SXC0VzWwx50N916eXvvBgB8scZPOGCSvLJ/9UaU+B4+kuiDzLxy72lr9DR5Fjopy34KI04dljAXbgKoGft4laKUGo1zSP3MK0Rz0EyMYVu/BLUwr7oQ2pubEV+YAgir8EeCIFQvD6iDc87jNkq1OywNXXJrMVN7wTIXqFg0SuwCiuPxYbM/1xyDA7UjQm6xrffVej35dcMhNdoOzK6fHNzDl1nLmljRRSIcPCRk6Jn2Lic+6/v1t0ehYA5W5qaMUUExkN4WbVLjc6d7RYfZBq+944tbkn/TXBJlOV8z3BhdxAnb+nvWXPmjtLUKvhnQypULiVdQTCgOSutYXRst+xswKQVSi2rAZ72XroJsD+A4l4jinPA8R/3k1SujtLvqnyaUXdhdcR5rqT74h2FxrFEVF+jxCVWmyimnBvjmncTZO6uCDW2bLLlrfwRb45BjZadTQ2k3AXGvpijKqj8JAK9QaL5s+45LfboPC9CD3FNzrG7S1p+j+CilFyaSggcplX6LvDhoL4d94bqkEH+fWa3bjr5touxKps9Bvd3WiIJXAxhBAZe08y1a4EVW3qMUrSbYOaoQHrgOn+0Yt32/SI1xxVM3XjbhLeL+0CXDQ6+aYQZj3kHgvLsIWJWL0bb2rWz17uCRPamu1rD5ZM88oVvpeP2HBpSLF3bvRMscmYlUlzq+b/yIq2GcqfBTFHco6bcwq2gcx8LD0iXgNQKoE X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70cee33d-11b8-4455-0043-08d8ce207bd8 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:38.7762 (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: 5rNgNZ/Ff9agW0QNZFLCoREFojky8E2O/CFGwQsBEACvTxgCpasC1JxTEbUCHFhGbPoxqysX+n45OKEGMXk+JQ== 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 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=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 malwarescore=0 impostorscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100209 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: Pagemap was only using the vma flag PM_SOFT_DIRTY for hugetlb vmas. This is insufficient. Check the individual pte entries. Signed-off-by: Mike Kravetz --- fs/proc/task_mmu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 602e3a52884d..829b35016aaa 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1507,6 +1507,10 @@ static int pagemap_hugetlb_range(pte_t *ptep, unsigned long hmask, flags |= PM_SOFT_DIRTY; pte = huge_ptep_get(ptep); + + if (huge_pte_soft_dirty(pte)) + flags |= PM_SOFT_DIRTY; + if (pte_present(pte)) { struct page *page = pte_page(pte); From patchwork Thu Feb 11 00:03:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 12082095 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,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 E6751C433DB for ; Thu, 11 Feb 2021 00:03:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 87F8064E31 for ; Thu, 11 Feb 2021 00:03:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 87F8064E31 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 B92BC6B0070; Wed, 10 Feb 2021 19:03:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B695F8D0001; Wed, 10 Feb 2021 19:03:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 98F926B0072; Wed, 10 Feb 2021 19:03:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0140.hostedemail.com [216.40.44.140]) by kanga.kvack.org (Postfix) with ESMTP id 7DDB16B0070 for ; Wed, 10 Feb 2021 19:03:50 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 52667908B for ; Thu, 11 Feb 2021 00:03:50 +0000 (UTC) X-FDA: 77804038620.04.glove44_140d2a727614 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 361D9801A84D for ; Thu, 11 Feb 2021 00:03:50 +0000 (UTC) X-HE-Tag: glove44_140d2a727614 X-Filterd-Recvd-Size: 11787 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Thu, 11 Feb 2021 00:03:48 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B00Wt8101389; Thu, 11 Feb 2021 00:03:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=b6uhz8t6mOEare+e+GqBSxU9tnKQVAFPSxxdOxPKIsI=; b=EhwJ8l2c7PWMaeToSVzq2gp361kQ0zey299RjVIMQsmJJIOUIqsS+hhx8X+Zi531ngBP QnWBrFDrc5kSk+RioskWe8diXvZA4IY4qBjqscyFMPpU6S7RYOZl3NxapmIlxh7LqxZi yvsa0k6T5dLXmOP8YJB+sqT/pSyDjISPf3D0OWjEQ1yGSocHoxGgA9wf9zYrzDodmM9D At7CWr9hVf1iEZmwWDPZngf4BMSzPjFCkMTXxPQQPk6RbkOYqNJA04izp56h4SQKmmB2 /86Ml2hEp1vlFcIJFsFWjp/STgWIRhxr1PjlXiIE9lZxpuZdDf21W9j+R2Ebw1intwP4 9A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 36m4upv2bx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 00:03:42 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B01UV7063108; Thu, 11 Feb 2021 00:03:42 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by aserp3020.oracle.com with ESMTP id 36j513asg2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 00:03:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TXTGsM+BUBaPwPMgQgPy39myphRKNEhPUrJZrjIkV9MEPGJNFhC6u5ezm1DKdDhyWYL3KuGkMgzsWpBuX7KQ7BcHtSwGArMaCGMODGVJx5wJLwB675Sc5HJQWjK1ww2XQhZXzGVYCyLhCBskgNP43qlCMQdL3FmM74V7BoUp4qI4e8758Xm/zha2a+BwH7BMU45Yc8fdlF2lih5tFVe13LOc5fYxwIsPz729vb5S/U1ff8BnvvQ56b2Y+yUQcLxo2fDbKpFFDOk3z+eHnEmtfKXlA4RqS38smCImT4Nixab5rPK4/ye/cOqBlRygTVLdK7SCLjTj8Sn4jmvthN0DjQ== 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=b6uhz8t6mOEare+e+GqBSxU9tnKQVAFPSxxdOxPKIsI=; b=badELTo3DwQLLVCVSlNig7nVXBgyWARhlPvOnc/gDAmAX+JNu76+i4MpeRZ5HSeSReIdnkd4h3CprN3sVpjZ8jWCRh9LwF6Dl90q4GuW5+dZIk9hCVTpsuNhRz68EH1aZzw4wbA3ILP0M79jkd6rAm5jtwBsSayODF+eOk3kBgkZJ3nWoJ4tI80fybl9GZgJUJhUwWvMv1XbsA0rr6i9169mZFm1jxBHuX5SMgNTwuZjRazdee1MSBgJ6cwTrnTdZMkJncFb7WJVeC2Orlmpczi9wAtzs6OkP+m0M43aKhXHZ7f73ENVpSbeCpVP9gBdsHq1rriSVoYi6advIvMHMw== 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=b6uhz8t6mOEare+e+GqBSxU9tnKQVAFPSxxdOxPKIsI=; b=F57cB+s8STO5xn8VcOlukT6hve2TiiZhSopvH92ibjA/L4P01dBE+MKKl7x4YnnjDczh2a0t06ti1rstncmn0X+adhJlTSDEnbsFmceKm5fIkRXglbEyXEvE2jEX5SeeE5dGGyxc1i+TwIiZpKoZV8v9sRVj6/GfpYb2hDdT2Bk= 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:40 +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:40 +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 4/5] hugetlb: don't permit pmd sharing if soft dirty in use Date: Wed, 10 Feb 2021 16:03:21 -0800 Message-Id: <20210211000322.159437-5-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210211000322.159437-1-mike.kravetz@oracle.com> References: <20210211000322.159437-1-mike.kravetz@oracle.com> 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:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 36f53ff6-f073-41a3-56c0-08d8ce207cc3 X-MS-TrafficTypeDiagnostic: MWHPR10MB1341: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /ksQx2B7qbn6kIB+HD5OxcDnHXMRnV66FB24g168VLFlucRy1ylhQTgE4iATT18TRGCVVeT3gi0aSP4YL541sLIOVrMlOPyaFpMy2lGi9HMnoyw/h4AgJnLpznqsij3NQHr/TLSDYRHIOKmTSRC2mvsAG3O9XTqaTsC32dD6CrLmj3CbYtPFt9mjPpvlTNd3ak8+7nMh95UpVb93U6sitimeOHKfRG3TDqmGMqaSiq7qPEX4W3UZGkAyY7/FaaUlzYAJLhi8H2XexedYfKZ/iRnObYWYlfYHaMY4CfvoN8iVl20lN8doyfcgSIS1XFpCPV/7MfaGoAWfdEYS3UrgY3qxkqxgks9WKyLaxKDpeSgs7jkHTx2NQoxjODCFmEn8T+MJJQxJiEKmFG9efsx33wat8KcL42SoiCRXFr66/LgJrj378Mw5loaPev2UqGRu4B/G0mwxut6dYyISXd5yzQilATPsCNpNhfe0yZeyLahHIw2DhPTfnBibDvDioyLCyOhqqK/f2j8w+azKccn5U+Z0sh/ZKZy2lj05GsdCl7BpZacuHsY/uYe6tD6a6HW+ 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)(36756003)(14143004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: jjem+YexpO/FALGLqGAW9Z7jnn46WQJQqrpOg3g24oEIo1zxRLQs5Ax79HrAfawxZ5qhFyxWhpiCIvb5AUjVnzDKJIE04epxXVygJpjdAsKDbF+LkDBDX7jZwhRYpUokE0phz2xBjoMRltCoq7GqUI1wJMXsZNEXBM1MOO4lv+FSEb+f0rxPm/Fp2Ix3+WxNFaL5uv4T9m+3cFBzYDA1PeMZNJG7OI52ODecDpjba6CfzWo8qtzucX7P7C4IVkclpRfWcoNZ732dGiF/PtA6aaPRwXYxWmQQeH5edIk6Zv9QyqbQgrb1d6CgfPQch0MNI67O1LXx8P/9DZ7QnIYuFxcccu7NAQVR/9mE/qoaiZ9jOxYFusy8ustp2gotc6BYpOR21lhutZsNbAL8nBLWW1wz75FIBYcPCMI/N6LvTACIzWl8i0xtfgnHa6qOyUR6QbqNGgdawhoynSBo1fkj+3bD/ZGIWQh5AebGjiQDRe7j/5VS8YLCRp1Q4PclI+5KADydUvch8P6CWHGA/p6QCwAHhf2FQNBpn8j2Nh+UACUQevyf54IVP6KEfNgp8gbcDFqZ6FFVyqzkZjv8F3oYVnVwjFYCJbBWreG/RMnfnuMg5SJaEGx8gg4aiw64koM/+4NUjRWI3mOMGbHQYgicNq5rkmFMgWcSNOExaYeif1I+OalB4PvuKLmer0UDUDgy57iKDeGGRZWKYbUKLffabyLfthrQfoNDTQT34l7iGR3gCmjefxqEUbu0GL9EG7qYKvBhxc+71HDoe1ZR4Fj4qJVjyeJwOmsJePLoOYPPzoFRF/NpcJZ21tRVXSmGD0gd8qGxNUnBDWKSNRdhaYYKIWIBPg7wI5REQnXYpJBa6Rn11fVMsL9jN9dYgsMhNc129Q+tD57Zzv/d6YJsNnyUEztVlCahHYGJCaCgz8nl/EDx5Dtg80azU4yj1X91Gxg+tHf9HYVdjBN+6zYfWVCx/AkFgaF5RjvYXjmIINp8U8khIaI+ynu/LOeK5Za0VtzLcZdO+aWeHv0jHeTcWbqCAwRbI7DOsZreMD95jDEzW7dCSoECUDo4gIDOX0ld6obdkHcZhIxcBhazHWAGtWEH93qDgTwsXJpqmxPEbdUnv5jFvilFM+5ofrsTmFUS/1mBCZhqvOJzItu91EsHzYUHXpHxyoksR1R+oUhcohqy4e23u7W4dYkfJYwdKH0JBeFYpzMBQI508kr0PRCj0Hhpff84HSGrbryPmmT84BZ4431pmmyG3llZv+1ArX3oc3mikdSu0PvZ4UcWwzAuo/WL+TPKUau9gjG7sLju/MqWzGn7RXyMHdyc2cwJqRAAm2TA X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36f53ff6-f073-41a3-56c0-08d8ce207cc3 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:40.2206 (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: KP1EZdlXjsMyX4ld5C/DMXQmDIibMO23yvqqhBTznPVNOYUmJLx7aqFvaK71XA55kq6locs8QfgF/mxBqv2KFw== 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 malwarescore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=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 priorityscore=1501 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 clxscore=1015 suspectscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100209 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: If page modifications are being monitoried with the soft dirty mechanism, then this information is contained in page table entries. Tracking is enabled on a 'per-process' basis. hugetlb pmd sharing allows processes to share page table entries. This makes pmd sharing incompatible with soft dirty monitoring. So, pmd sharing must be disabled if soft dirty tracking is in use. The VM_SOFTDIRTY flag is set in all vma's by default. When soft dirty monitoring is started, the flag is cleared. We can therefore allow pmd sharing in vmas with the VM_SOFTDIRTY flag set. Check this when deciding to perform pmd sharing. A subsequent patch will add code to allow soft dirty monitoring for hugetlb vmas. Any existing pmd sharing will be undone at that time. Signed-off-by: Mike Kravetz Reviewed-by: Peter Xu --- mm/hugetlb.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index b561b6867ec1..cf4aa63be9b1 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5285,6 +5285,13 @@ static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr) unsigned long base = addr & PUD_MASK; unsigned long end = base + PUD_SIZE; + /* + * Do not allow pmd sharing if soft dirty tracking is in use. + */ + if (IS_ENABLED(CONFIG_MEM_SOFT_DIRTY) && + !(vma->vm_flags & VM_SOFTDIRTY)) + return false; + /* * check on proper vm_flags and page table alignment */ From patchwork Thu Feb 11 00:03:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 12082097 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,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 007ADC433E0 for ; Thu, 11 Feb 2021 00:04:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8067764E2A for ; Thu, 11 Feb 2021 00:04:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8067764E2A 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 294756B0071; Wed, 10 Feb 2021 19:03:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2168A6B0072; Wed, 10 Feb 2021 19:03:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B7A16B0073; Wed, 10 Feb 2021 19:03:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id E85266B0071 for ; Wed, 10 Feb 2021 19:03:52 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B8DA2180ACF7F for ; Thu, 11 Feb 2021 00:03:52 +0000 (UTC) X-FDA: 77804038704.10.legs95_230c71b27614 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 955B116A4D2 for ; Thu, 11 Feb 2021 00:03:52 +0000 (UTC) X-HE-Tag: legs95_230c71b27614 X-Filterd-Recvd-Size: 14746 Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Thu, 11 Feb 2021 00:03:51 +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 11B003SH123011; Thu, 11 Feb 2021 00:03:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=xFDVWByD2oAC85jpuSE1pSb/AgKJj7UFlwVSzmEx6wE=; b=H0tLtdgDVbDnGHWElD+UWz1HCkMa6YNHgwdEiYal32Zj2X+q36mZ7PF+XpDtxJ7hID1k 4AprgG1dpjGYjmw/5Ksf7BsjCtMzqZJkFGU2RYlfKW0RzQ4Z5DAnL1t+vaFUTgzj3x2W WLgmuNEHtYf50BaUT0I+OuIbm7DLaf7duJv3o8mlMND31n8W9TdvXQ/g2NFX9F9CEQ0j 598n4vaY1G5tfMbUwTFJe0MvmTDlFq9HmRmo293mOSNeHjYGT3pnOy05ylBCDKgryNDs fPKD7r4Ew4g4bCr7HhD2RpDWRtj3ncxpfsQNzkDCR8fdAJ9HhnD/A3n/RJfb2pkeU+XN dw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 36hkrn5fv8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 00:03:45 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11B018pB028014; Thu, 11 Feb 2021 00:03:45 GMT Received: from nam02-bl2-obe.outbound.protection.outlook.com (mail-bl2nam02lp2056.outbound.protection.outlook.com [104.47.38.56]) by userp3030.oracle.com with ESMTP id 36j51y8pj5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Feb 2021 00:03:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ezv7eyO0MM/ugL3U2BWWpgZlGGTaPlC+50GhetSqGx7fZkhsSapbZDIp7qjC9ZRV8DjRmRX0tsL4YTvfWc/bh8ox7nxYlYPzjLHLbxJqlSk47bIh6rTIc5hSe8CkEYLACh0XSMMAWBRDAtrf2EpvBf+Ra8aNTjU5d2xIV49pW656uYI4fWOUAd0FMzuGEUZR8PZc1VJgheaqc3wAnN9B0wCH+onhUeMIITe1AdLCKzKsZBN50GOP/0HE78RgDvTACUPkM/EC6fUisiP49IfAj/XJE+Pm1vSJbAEV5ahbOtn42/WQkT0IHSru7cIjWn8QGosAvceG/Y+PQZ0dPRwIMw== 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=xFDVWByD2oAC85jpuSE1pSb/AgKJj7UFlwVSzmEx6wE=; b=P7yUqZ1nNwFuXUDMUrjXubSdQbltl892KcpCDNxTgSqzT1Bi8xuj0HmY6+lP8L/Gr2SB1g1/WWdBOXGHxSUxp5OAJFVzEkaCTVXrWL49PvSn2kwxBV10tFYu1pRojrlagF7wMSKl+baHX4UrAyWsTR2AKMTLAnjvyNiwQ9FEDQfseVNPdr0R1fz3NMDOhaLOSqTISnoNwC7L+/rVhebI8H8DBTzf6pl1eI1r0ewLF7XFAAdy2urhqrPQvR4jp3KOc/cT9lTyNYJMWgE3ptIA8un+v2fGTs2nqXgtBkozw+LP2ffGgR0ji4/EQje0944mBMMNiYBaVrQ/tsiInuaMGQ== 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=xFDVWByD2oAC85jpuSE1pSb/AgKJj7UFlwVSzmEx6wE=; b=V3mle0EDAPUgMBBGnFntuigWnbYwxxmCJGTzJFJ+kTPnGkyuboFIYdaHGHP06IUuCgm+dvx1JTDV5vccLsw+SBcrrMiBUXOO9qrKRi6GoaSfsahhts4PSkmBw6qYYWVK0TuWJZDfDR4KD1mvUAkIR86QkA4Uj+Q2e76tfsnCcNE= 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 MWHPR10MB1933.namprd10.prod.outlook.com (2603:10b6:300:10b::20) 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:42 +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:42 +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 5/5] mm proc/task_mmu.c: add hugetlb specific routine for clear_refs Date: Wed, 10 Feb 2021 16:03:22 -0800 Message-Id: <20210211000322.159437-6-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210211000322.159437-1-mike.kravetz@oracle.com> References: <20210211000322.159437-1-mike.kravetz@oracle.com> 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:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 703a04e7-6d7e-4493-b9db-08d8ce207dba X-MS-TrafficTypeDiagnostic: MWHPR10MB1933: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bS9AxGaAbmEytK+Yh5ULJxL0Siyho4mjv/w5yZvGele0SghLWkDSo4CwzVaKBtDJ5s0D03AxXPlsuDYaoFfIPTHh//CxraNE4jOV9HeBo/S+OLjMQllEK0aAl/X5xG4EpnChvIHDMZwA2b00+IiCfwEpV+SXNvur3lAKEz92IeiynCljCez4e8HSNzfhm7UGamNbjHPyAr1vMGHqx1PQrkQks8EzdhDpZqd9UTeGrIVI60+PvWaUpRi6sZ3yiXP/NyQAnRDOAMESb1PNhu8P2TVMC/DlcaRuE8AbCqRiOtB1gOpGMWB30pWwEatvKDg8qR6DxPvqi1xjWUEEsjzmk02apAPAlucpOj6+bqiu9cbNiQmavvbHGgJsFutyk5NQcL74h189YDn3+v2Lv9XkXShGVEmyoYxIlLkmjMHlrAxEpy3Mue645l0/ILIXXuDmi1ANQK4JmoBz7BmZE9FZFOdI+sMVKY0JEPQj+Lva0P056BOL7xPtxOqwp/GgHlAtxhEcKfvqJ5gyd2E/rmae7w== 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:(366004)(396003)(136003)(39860400002)(376002)(346002)(7696005)(5660300002)(26005)(478600001)(52116002)(86362001)(1076003)(2616005)(956004)(186003)(36756003)(16526019)(8936002)(6486002)(66946007)(316002)(44832011)(7416002)(107886003)(8676002)(2906002)(4326008)(6666004)(66556008)(66476007)(54906003)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Ro/dEOPiGmHiPE06hxt4NoxNurlGma6YN6sOipMkALeilkUozRjsZkUyNXi2PbB2Uoe1HWS17mRz8UFoMw10t3QGcqCb13xQhOUN/yK2QA7u1lRIlJ6gp/hHs4xvv3cmX6LFbU31NC8Vx0TtXDQ0Sa2CcNqrsiEzLUuwWy3Z9YV2VgHKwCuwzKgmWBOZ2ubmhsAwUFyIYlUgwliY/WaubpjE2x3Dri36d+b6bnU38NfdIlskaGwwAWU5Ecfg1Atoa5GvkwlxHT6sSUouXYWhFI5fTW1U+ZFCZ/91VPwsXCMeXu/0kRw2ZmL5zY7bX140+DRcygQn35NTd/kEqCGuHjn3CwaI97iO7vYcT1B4jugso+YCaDoSjZzObYsDfWAHyXzFYNmmByfB/LG1cIBxb1IFrVDqQLTrDhVh3+WhmOi+FafnYIkXSUM1A7zPOOxyglvnu+S+x2pwBOsJQF97Y4rK+HJBtxKTQidO0g+qX/IcEfeqozuwcOZbX6NUKXUZqnu+Q/qNhEbj72pGY8gw0nFo0s1GJrWectnSbS1sa0sfcWzOoC5wT8J+rsCi/PA72uJhhi5V1FEKEvsoUiFfqfGf93R4Z/y3JiWAj/t7ZvSiox1JGuvBtkgcphN923B7/5WjtPdiVbfTKZvwaHMWgduJRIy9PbSXe6BcJFtSKc6D/f+wThPc/my7Qs9cZ2ewo4G4vv3ZlJRXxdltgrSS1vn5T0PNc268LBIjxC3Xu5o7+YYUlIMMbT/J/7/U+FJ4h13vmZv88LvucLZfQ/TRs0pJUG2MtibalC0uCrZ0PmwcF6df5MN45yN/qzlZRw86xLE0NcSb55Yx5OmVrHda+KxW3p4SvdPlPmfhES92VcuZqG/5WpqCs3v2/BNEc1GAnYLtoExcHQ5eb2+FoFDJQOGIrHbr6O4fDd/Hggd0ut0r+Q4auKlM0EbgIETeeMUm9S5Nm93cn0YQrOeAnoif004KWToW4BF2WdQ2jq7Ymn5kMKsr9LcXC4GSjRBlcK6rKA9BnozghKY8S1Vo2U/fFuups/CediBtoyNrs4BHl31a2qBiUeJi9GJUg0SmFW7NEiVQDj7kM5Ee49byvojVmBDjkMYlxWMtDJSaS/KP7VFhzMtaYHFB6l9v67XlB7BWdldRJOArK9aGmkSo92m3wjbgcg52vB1JBcf6EWRUJK2Hca3yWGYnfN+TUbuLtbnzvkZar3yTasN+P0a0e/d5dUmXZgkuBt1SGAM6R69A3+bH07E/rhvFzbhQRyVROEOEUKeE4ODgHqyYhAFwQpp59D2gn/l8tjXy2R3aRpZ8M5vB8w0nKx5+DIoKYJ7chWrE X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 703a04e7-6d7e-4493-b9db-08d8ce207dba 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:41.9818 (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: pWFocIIsVsJBvsNyjSsA5W0MF1T/CkYn8bXMI7uVODF4UBolRrnQlZx/DGDTcZrRNs67nGkUbhKt1TEeA1mnlw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1933 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9891 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 adultscore=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=999 adultscore=0 clxscore=1015 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102100209 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: There was is no hugetlb specific routine for clearing soft dirty and other referrences. The 'default' routines would only clear the VM_SOFTDIRTY flag in the vma. Add new routine specifically for hugetlb vmas. Signed-off-by: Mike Kravetz --- fs/proc/task_mmu.c | 110 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 829b35016aaa..f06cf9b131a8 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1116,6 +1116,115 @@ static inline void clear_soft_dirty_pmd(struct vm_area_struct *vma, } #endif +#ifdef CONFIG_HUGETLB_PAGE +static inline bool huge_pte_is_pinned(struct vm_area_struct *vma, + unsigned long addr, pte_t pte) +{ + struct page *page; + + if (likely(!atomic_read(&vma->vm_mm->has_pinned))) + return false; + page = pte_page(pte); + if (!page) + return false; + return page_maybe_dma_pinned(page); +} + +static int clear_refs_hugetlb_range(pte_t *ptep, unsigned long hmask, + unsigned long addr, unsigned long end, + struct mm_walk *walk) +{ + struct clear_refs_private *cp = walk->private; + struct vm_area_struct *vma = walk->vma; + struct hstate *h = hstate_vma(walk->vma); + unsigned long adj_start = addr, adj_end = end; + spinlock_t *ptl; + pte_t old_pte, pte; + + /* + * clear_refs should only operate on complete vmas. Therefore, + * values passed here should be huge page aligned and huge page + * size in length. Quick validation before taking any action in + * case upstream code is changed. + */ + if ((addr & hmask) != addr || end - addr != huge_page_size(h)) { + WARN_ONCE(1, "%s passed unaligned address\n", __func__); + return 1; + } + + ptl = huge_pte_lock(hstate_vma(vma), walk->mm, ptep); + + /* Soft dirty and pmd sharing do not mix */ + + pte = huge_ptep_get(ptep); + if (!pte_present(pte)) + goto out; + if (unlikely(is_hugetlb_entry_hwpoisoned(pte))) + goto out; + + if (cp->type == CLEAR_REFS_SOFT_DIRTY) { + if (huge_pte_is_pinned(vma, addr, pte)) + goto out; + + /* + * soft dirty and pmd sharing do not work together as + * per-process is tracked in ptes, and pmd sharing allows + * processed to share ptes. We unshare any pmds here. + */ + adjust_range_if_pmd_sharing_possible(vma, &adj_start, &adj_end); + flush_cache_range(vma, adj_start, adj_end); + /* + * Only atttempt unshare if sharing possible. If we unshare, + * then pte's for a PUD sized area are effectively removed for + * this process. That clears soft dirty. + */ + if (adj_start != addr || adj_end != end) { + struct mmu_notifier_range range; + int unshared; + + mmu_notifier_range_init(&range, MMU_NOTIFY_CLEAR, + 0, vma, vma->vm_mm, adj_start, adj_end); + mmu_notifier_invalidate_range_start(&range); + i_mmap_lock_write(vma->vm_file->f_mapping); + unshared = huge_pmd_unshare(vma->vm_mm, vma, + &addr, ptep); + i_mmap_unlock_write(vma->vm_file->f_mapping); + mmu_notifier_invalidate_range_end(&range); + if (unshared) + goto unshare_done; + } + + if (is_hugetlb_entry_migration(pte)) { + pte = huge_pte_swp_clear_soft_dirty(pte); + set_huge_pte_at(walk->mm, addr, ptep, pte); + } else { + old_pte = huge_ptep_modify_prot_start(vma, addr, ptep); + pte = pte_mkhuge(huge_pte_wrprotect(pte)); + pte = arch_make_huge_pte(pte, vma, NULL, 0); + pte = huge_pte_clear_soft_dirty(pte); + pte = huge_pte_mkyoung(pte); + huge_ptep_modify_prot_commit(vma, addr, ptep, + old_pte, pte); + } + +unshare_done: + flush_hugetlb_tlb_range(vma, addr, end); + } + + /* reference bits in hugetlb pages are not reset/used */ +out: + spin_unlock(ptl); + return 0; +} +#else /* CONFIG_HUGETLB_PAGE */ +static int clear_refs_hugetlb_range(pte_t *ptep, unsigned long hmask, + unsigned long addr, unsigned long end, + struct mm_walk *walk) +{ + return 1; +} +#endif /* CONFIG_HUGETLB_PAGE */ + static int clear_refs_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end, struct mm_walk *walk) { @@ -1198,6 +1307,7 @@ static int clear_refs_test_walk(unsigned long start, unsigned long end, } static const struct mm_walk_ops clear_refs_walk_ops = { + .hugetlb_entry = clear_refs_hugetlb_range, .pmd_entry = clear_refs_pte_range, .test_walk = clear_refs_test_walk, };