From patchwork Tue Jun 21 23:56:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Kravetz X-Patchwork-Id: 12889965 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 CC536C43334 for ; Wed, 22 Jun 2022 00:19:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 60ED06B00D5; Tue, 21 Jun 2022 20:19:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 598196B00D6; Tue, 21 Jun 2022 20:19:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C2A78E006E; Tue, 21 Jun 2022 20:19:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 276456B00D5 for ; Tue, 21 Jun 2022 20:19:46 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id DD1F535235 for ; Wed, 22 Jun 2022 00:19:45 +0000 (UTC) X-FDA: 79603963530.14.5099558 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf09.hostedemail.com (Postfix) with ESMTP id 72F8614001B for ; Wed, 22 Jun 2022 00:19:45 +0000 (UTC) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25M0JD02004543; Wed, 22 Jun 2022 00:19:14 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-2021-07-09; bh=gVCgyGS215qeuzVyh3NQ1QmLGn7c+lAD2oWKU3YYHCU=; b=dvYTpi2KO0H7AYAKJEd5OB0Hxx6hl3skv5Qg51vCWo/9f80z3o3/UHUEvIa+nF8uRXln wtMcz9S2d3VesV6EutRxAYzF0TBTaakaiXLfNdY99D5J40vc1psxjXHTs1C4P0f8f6YY GGgwKay1vHqL5ys5BqfO2bmuDl4GE/5J77OmeKvamfWsAX2Hfd7EUv2zjV9idtEE/ne0 EfWG2o903joIpoGT0ZUefYeVkXCZEL6z4Xw5vZPnHbFmPE2kSlLvFiFUGwClRQqg3xde JIDLQtZyVSyv32lpGWgLVo+DDSLL58SQSoZ5SUzchIZbf9tLqCo3iShcKoTG1CmtHX7n cg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3gs54cpyun-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Jun 2022 00:19:14 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 25LNoaFl013391; Tue, 21 Jun 2022 23:56:41 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3gtg3vqywj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Jun 2022 23:56:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AXvRpOqTnS13F3ZbGoSjJ8JhQr7xmBGHb8RYC7AbW+vYrkYRAXPo997g01OLL77KdY7B4c1Y7e/W1bXa3mmh12RCTGaTp4lDHNEi5+B6RFrWmrDm4eEY2Q/TeETrtAuk+qocTkbQkd8uHublF1qy6M/mDG5vDMhPx7+RIa4Bx/leZ4+DLxNnUEvc1kXPfNDmGogdUqLeATP4pyQN3mAOwknkxdYRneaF/0GWYpP/BuvNFKgJ5gxENEuZsdwacFW9lwBLzcsCfSMLw6nAfNeEhBbz1mR+9wJ7/LP6tHQxoymfiUyobQSR0Hf441h9hE1UpkWTPr9a1Aw8Qg0WSjbgKg== 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=gVCgyGS215qeuzVyh3NQ1QmLGn7c+lAD2oWKU3YYHCU=; b=ZooVdaMO6lQRv+09OAur/bK2hK6WbvvD3YcyicOPWjohfxwRruIUCBH25W/1PWGDLJ+vsQFfRQc614FABF+qlaa78u883x7YJQLJCq7m9LCaxhwKXboMJWHZ6snMgDj5VTOHgMPZe7Tt9c2xaORqI4iPg0khWulEAX3PVv6zqoOTTk2cosH//ysq7CIltLRk3nKlHtgcrZoz4x8W0Sp8EoZ9b8Fpw6G73us/1+UC/UttlZ05VKiot5Wl1KNQkO13vokgaD3d2AbFQ6QLAEnQfuDg6l8hDMvwlcu37/Hvh0psMkf0B2zwLqYdUMkNEGLD/iQCudn7D90ffCmy+QhN7Q== 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=gVCgyGS215qeuzVyh3NQ1QmLGn7c+lAD2oWKU3YYHCU=; b=I2OjtEAMjpJfcn+KxqTZbFfzYyM3dG/SlosbEVW7CARxHw4+zPvJiEn5SaduKIuTU5Cf0BFJ2iwcNUrcv35YLU+XWxFrdKHtfj7L13MJ5iu58HoMqTZTjP8OqJdkKwAmT+LpGsDV7rMcCDhriw/LmI7YUnLeOyP+gRbk4elLvPo= Received: from BY5PR10MB4196.namprd10.prod.outlook.com (2603:10b6:a03:20d::23) by MWHPR10MB1501.namprd10.prod.outlook.com (2603:10b6:300:24::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5353.15; Tue, 21 Jun 2022 23:56:40 +0000 Received: from BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::2125:9bb7:bfeb:81f9]) by BY5PR10MB4196.namprd10.prod.outlook.com ([fe80::2125:9bb7:bfeb:81f9%8]) with mapi id 15.20.5353.022; Tue, 21 Jun 2022 23:56:39 +0000 From: Mike Kravetz To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-ia64@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: Muchun Song , Baolin Wang , Michal Hocko , Peter Xu , Naoya Horiguchi , James Houghton , Mina Almasry , "Aneesh Kumar K . V" , Anshuman Khandual , Paul Walmsley , Christian Borntraeger , catalin.marinas@arm.com, will@kernel.org, Rolf Eike Beer , Andrew Morton , Mike Kravetz , David Hildenbrand Subject: [PATCH v2 4/4] hugetlb: Lazy page table copies in fork() Date: Tue, 21 Jun 2022 16:56:20 -0700 Message-Id: <20220621235620.291305-5-mike.kravetz@oracle.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220621235620.291305-1-mike.kravetz@oracle.com> References: <20220621235620.291305-1-mike.kravetz@oracle.com> X-ClientProxiedBy: MWHPR15CA0066.namprd15.prod.outlook.com (2603:10b6:301:4c::28) 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: dcafded0-41c6-4927-404e-08da53e1af1a X-MS-TrafficTypeDiagnostic: MWHPR10MB1501:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s9Ix0Q0WjEyHx3o1CIVwKZPZa5eEwG/qDjXsyMIqzrcYKO7J25YRBYHN6yiMeyN/0+rIfqrEODucNANWNcf9firw2GxDlFgtba0/qy0DquthtnDgMzFtLYg39yPV/nIRC3Hk/Y3BZiogQjMYcsOnl/wWApK+x121xRhee9F+G3fCSBz19sJ3Wb+k2JiihT/20uFnxRekXill8+9kz+ss9Jb7oBPBVT8jik4SLf29AmeuNBn1K092frsD23sVfBFigi8O3zVAwURvdDvlSjfM4Hdi1egYiHfmMZG9DIjhGvSdI8M6sRNKsqJnWVh2nIqIcoZB8b3wu/iRX04t5cAn/nnARByzNF3Rg6ugExORt12f8ICFLeGH8d/e8pBVhWPoS470tuoTM46YnZU64oCvBVHYOFn0q/MIUjjEelfybe3krYV+0S/arGahRDkbtxp8eNsOtoSZPjlwk9DFZlVCbyhAmmzbwEp3cMF5u6k+cqEnUJkgcehg4tIKeZgfbq5ERN7jOo6iDbxeaGV00wnT3f2QFQvxa3li9dqpMMGcxTlI10PODG3pg+4tNU+6pNwiJ55AZxaVKAQaxHNlX2y4StUDaBaoSgXEGltWdXrhhKQLuHVe/wBqFmqPxGMip3R/GSstmSLxn4rqULWE4MLadkQ7i+kLSeXQ2U097AaJ4qyzI5DlibbcZzUAJcUDLQ5V 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:(13230016)(366004)(396003)(136003)(39860400002)(346002)(376002)(2906002)(86362001)(4326008)(6486002)(44832011)(6506007)(54906003)(921005)(8676002)(36756003)(66476007)(66556008)(26005)(6512007)(66946007)(186003)(6666004)(38100700002)(7416002)(316002)(478600001)(1076003)(8936002)(2616005)(41300700001)(83380400001)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TlPjM4obrF6PM8hCyNaTJwD0HbbSMvxJ/Y+ivR3qBy/GrkX2KHcMP9Lq0KVB4V7/aNt1eBOgIbGB7uZ/GhLf56ElWlPad3feEk05SjPqflFzDGfA7MzFLw2B/IJRcmenn9DYLhb5cUWEJV8kf5awRjtG7BLYUzQLtddMAKO4eiyTIXkDKABoFU88IEwPLc9rMcQnK6d3OMx2wqu5k+qiK2JcnRJ4uSAxsUzLR+olyX/QRZRLbTimLbioY+a45ti7xPU2ae9R3Anm+ujWHeNSyH0OLtONtMkjH3OLV1ZdPpCwh37+vJb4XthkIIGbeNosNv4aywm+P5S5LJn4h80CXQYbkswtfhE/wuq2uk1hNhNJ1FmzeO4gHWgFnQwv0k/2HkIYdQXsilUCYFihmd0wVEp6OaNhsafprPL5GIMsyxUoxePb6+xEIpmd9766l88Dqm5USFrXlBngZuNYk9MnXCScYfZStB/rKkFmHXUF6WSeOzJ1bv+kukYngo/Yiuja06EihS2kWvxCzpNTXut181QJ7kpWiWDjilPvU5X2AHeRefpGUZ6hMGZUqPslhS4cqPkf4pjCDBLxoQp1Trl1xSoi3CiBlJmuAe46FYP5/wOBTzIAZZ392NfbSCDy5eAFQllgooSKp7QL2zLg3DYQS1zKYzHIYHHI2WqQjmidibRcrNHwQ6Dc8FbnhUFSosdefZI4QMo+orharWkIRM1aLFGIqmy+v7oXXrdWGvYOsCMsf7ZJUhYQtTQO29p2dcbuuR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-Exchange-CrossTenant-AuthSource: BY5PR10MB4196.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2022 23:56:39.8076 (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: r98VtNgmrYghT2NI87WKK3IrU8gNeo9TSUm3gAK4NPDQpZ7ShdRVyVVGE3uBRBSzdbEvE2ccn98MqtUA/U24rg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1501 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.517,18.0.883 definitions=2022-06-21_10:2022-06-21,2022-06-21 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 bulkscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206210105 X-Proofpoint-GUID: HkzJfwX2EwmDyf35LBsT6Gri-nMPTsN7 X-Proofpoint-ORIG-GUID: HkzJfwX2EwmDyf35LBsT6Gri-nMPTsN7 ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655857185; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gVCgyGS215qeuzVyh3NQ1QmLGn7c+lAD2oWKU3YYHCU=; b=qROgVUj4gnqA6f/iXVXeDaDTfLyHN3jH5eW3s4ENNM6hjxAFtOBrzlIjkaavinwUl0Lh7u t7w6PrRDlU/zYP4w+IPjvgRBpo1rp741IyysDiVJdV/Hlv07KP3XKHAP/5whQZSlG/AH/X 4w+pUi/ZF+9a7O8bH0z4P0VJTghNSdg= ARC-Authentication-Results: i=2; imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=dvYTpi2K; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=I2OjtEAM; spf=none (imf09.hostedemail.com: domain of mike.kravetz@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1655857185; a=rsa-sha256; cv=pass; b=XQ98zkA2nyjUTcrscyibjWdCn1gx/+/Fl/Lh2WsYZQWIhyVhBdSgWsXX6515g/Hnt56cuT atbuOtJJrHHnrlM0SElsQ/plbvUpL4BT9Hi7QW1jMqfY4qebJ1mLCnRcuDq4GeCL/oiC6u hIsAKn70HwDknVylBIZGoE74yyn8nPk= X-Stat-Signature: a89etuitnkts9i893n3kfwrikgmqezeu X-Rspamd-Queue-Id: 72F8614001B X-Rspamd-Server: rspam11 X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=dvYTpi2K; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=I2OjtEAM; spf=none (imf09.hostedemail.com: domain of mike.kravetz@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=mike.kravetz@oracle.com; dmarc=pass (policy=none) header.from=oracle.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") X-HE-Tag: 1655857185-27874 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: Lazy page table copying at fork time was introduced with commit d992895ba2b2 ("[PATCH] Lazy page table copies in fork()"). At the time, hugetlb was very new and did not support page faulting. As a result, it was excluded. When full page fault support was added for hugetlb, the exclusion was not removed. Simply remove the check that prevents lazy copying of hugetlb page tables at fork. Of course, like other mappings this only applies to shared mappings. Lazy page table copying at fork will be less advantageous for hugetlb mappings because: - There are fewer page table entries with hugetlb - hugetlb pmds can be shared instead of copied In any case, completely eliminating the copy at fork time should speed things up. Signed-off-by: Mike Kravetz Acked-by: Muchun Song Acked-by: David Hildenbrand --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index fee2884481f2..90d2a614b2de 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1262,7 +1262,7 @@ vma_needs_copy(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma) if (userfaultfd_wp(dst_vma)) return true; - if (src_vma->vm_flags & (VM_HUGETLB | VM_PFNMAP | VM_MIXEDMAP)) + if (src_vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP)) return true; if (src_vma->anon_vma)