From mboxrd@z Thu Jan 1 00:00:00 1970 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 194D2CD3431 for ; Wed, 4 Sep 2024 11:36:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F49B6B018F; Wed, 4 Sep 2024 07:36:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 87C2D6B0192; Wed, 4 Sep 2024 07:36:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 743AC6B0195; Wed, 4 Sep 2024 07:36:18 -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 542EA6B018F for ; Wed, 4 Sep 2024 07:36:18 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EFF0681284 for ; Wed, 4 Sep 2024 11:36:17 +0000 (UTC) X-FDA: 82526852394.05.E6942A7 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf12.hostedemail.com (Postfix) with ESMTP id 382F24000A for ; Wed, 4 Sep 2024 11:36:16 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725449752; 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; bh=nFT/KBCV24yA8D1PJNlGPxfrxQqvBFdNVVwSAGO6HR0=; b=Zl9totgvR8dFEVEllk44lJrrxgoUwbtw5JSzE9PZHlwGgDaSL1Bx7WLT/AlESu5u1PCLC3 aiB0rs6h8+DgZFrTaNl5zKHqQFlX0hWNVkX0akYGQRGpdUuTXJ5eNorWmy2NNP4fPLBIS+ ITECTaMSF6MKYrsah54F57fHanKQUeU= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725449752; a=rsa-sha256; cv=none; b=CHy0UscQO0DdsvBxdilRwsWbO32k4wuMHHeAY/AsXU83SKg30vPpwx/unyXlEa1EAUGNFr uGPjVNM9axKJioirDqPudqxyjlniaBxIO8osp/RahF2dkI6MOH5E576XaeK9fKhHiuxdfK 4s23Y8IKRRgc51z0EdIkwItLBUlQG0c= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BBAEBFEC; Wed, 4 Sep 2024 04:36:41 -0700 (PDT) Received: from [10.57.87.65] (unknown [10.57.87.65]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 421993F73F; Wed, 4 Sep 2024 04:36:12 -0700 (PDT) Message-ID: <2427338d-7be5-4939-8d01-6d99b9167fea@arm.com> Date: Wed, 4 Sep 2024 12:36:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 0/2] Do not shatter hugezeropage on wp-fault Content-Language: en-GB To: Dev Jain , akpm@linux-foundation.org, david@redhat.com, willy@infradead.org, kirill.shutemov@linux.intel.com Cc: anshuman.khandual@arm.com, catalin.marinas@arm.com, cl@gentwo.org, vbabka@suse.cz, mhocko@suse.com, apopple@nvidia.com, dave.hansen@linux.intel.com, will@kernel.org, baohua@kernel.org, jack@suse.cz, mark.rutland@arm.com, hughd@google.com, aneesh.kumar@kernel.org, yang@os.amperecomputing.com, peterx@redhat.com, ioworker0@gmail.com, jglisse@google.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20240904100923.290042-1-dev.jain@arm.com> From: Ryan Roberts In-Reply-To: <20240904100923.290042-1-dev.jain@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspam-User: X-Stat-Signature: g1hqn4u4zqmn78po11b7tqpqxd4bpi3n X-Rspamd-Queue-Id: 382F24000A X-Rspamd-Server: rspam11 X-HE-Tag: 1725449776-449917 X-HE-Meta: U2FsdGVkX19T1BZrGtu/pwrcGglCzMXma7yGTzpH0ywWCL/Tg8hJ7Nr9Ktzusb37jjSZ/38uVlBBjQGqh0IJ+JQptQRtAGr4w3H6d5YVgpRbrApVCSnYTcXAyewtXU/uz3r54njWIlCprJlG6QfZt4SqwYvCQZxe6gDj8TYSHDNt56iFMYpFVcT86X+76WzbrI27RjcreKNIEQp7Kyd2juapIxrzlKfmM+anmMEcFz8jC6Wymxl3gHHgl/JeuiZ/G9GUf/JgYu2fhLFALzuqRnM856ERTeI61ZUwSKv+RnxcapQ+9A3kxUnxqsGFXy2JCcLTRVjuRoxphGdFwsu1iljCIypCwNRsQcVL+8aiTTTZIMZkbFNE8LtPWStoCYXkNTe+UmX5FgVnVognZDsOPJ31uam6RnNkIWQx0MwoEEPsDJdQ3gpVh/MqkEnsxQZObJC1jkfE4G8jFjHGnII94Ea0xnGCkAQMSOEfybApO+ocmcxO7gIn33aCVQGT+5GYfgkizOr4HfHZe1/Q2n9negHtpTBUnxa1oNOyr3A53hu8yHaVZEz8vb61WawneLW8lVHlrzq5YVrfYHo3l2pVYn0iL+8Vn6YXc1Bp7qUH2ZNNbAweM3TqHrnx6Cu3FLw+VCIiHb2NXczduTjzUfP5ADzRN7UAJdFxjSjGJY/sMnnQhrFf7+lTBNDe9H+QKlDjClDgiyrUFAmzYKIyvhHe4nRjTp++Hnt1j3X4egVwl9LdkPab707YHvPgZnmfFZJsVH3mI2orImHT0vMNwPabJyhsEzzBZagWzgBUBG6sACujZ9bmePUqQdBK5IMefyt9U+mZSa++gig2B2hPN7Vje+pPYALDBE7JjAYTuFPMiTgKt2X/XlSMbvCDy0no0BG5pNh+eJlSp80V22pMoKrvL9Pd7YBTsAoA1PJg0X2pNkKw2cYH5G8l6+XxE0FSJxpam2JmneUsek1jpTJyHhk a+dtHKbC ns0q98uVxsvBY5Df6gG2knGR7Fr49ZkSKbqTGoWK5f2TCOAxkRbZ3EagzaBExF3Blsgezh7bGfNoQwrv5zv2QpqWD7zZ6qoWI6Ca6k2P/PwslevpYd70KhZviobuAKXyeDbtxYTKlQDs5SaehU+IAZkkDCn30SIQ1r5YWr8C7mn37VLl9LaTuI1M46kZzv1wbWmiB8DgSn+vkFVDvLJmYs76LcfFB8YZqLZHH X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi Dev, On 04/09/2024 11:09, Dev Jain wrote: > It was observed at [1] and [2] that the current kernel behaviour of > shattering a hugezeropage is inconsistent and suboptimal. For a VMA with > a THP allowable order, when we write-fault on it, the kernel installs a > PMD-mapped THP. On the other hand, if we first get a read fault, we get > a PMD pointing to the hugezeropage; subsequent write will trigger a > write-protection fault, shattering the hugezeropage into one writable > page, and all the other PTEs write-protected. The conclusion being, as > compared to the case of a single write-fault, applications have to suffer > 512 extra page faults if they were to use the VMA as such, plus we get > the overhead of khugepaged trying to replace that area with a THP anyway. > > Instead, replace the hugezeropage with a THP on wp-fault. > > v1->v2: > - Wrap do_huge_zero_wp_pmd_locked() around lock and unlock > - Call thp_fault_alloc() before do_huge_zero_wp_pmd_locked() to avoid > - calling sleeping function from spinlock context > > [1]: https://lore.kernel.org/all/3743d7e1-0b79-4eaf-82d5-d1ca29fe347d@arm.com/ > [2]: https://lore.kernel.org/all/1cfae0c0-96a2-4308-9c62-f7a640520242@arm.com/ > > Dev Jain (2): > mm: Abstract THP allocation > mm: Allocate THP on hugezeropage wp-fault > > include/linux/huge_mm.h | 6 ++ > mm/huge_memory.c | 171 +++++++++++++++++++++++++++++----------- > mm/memory.c | 5 +- > 3 files changed, 136 insertions(+), 46 deletions(-) > What is the base for this? It doesn't apply on top of mm-unstable. Thanks, Ryan