From patchwork Sat Jan 13 09:44:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nanyong Sun X-Patchwork-Id: 13518903 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 70FF6C4706C for ; Sat, 13 Jan 2024 08:48:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DFDD26B008C; Sat, 13 Jan 2024 03:48:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D84006B0092; Sat, 13 Jan 2024 03:48:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C24C76B0093; Sat, 13 Jan 2024 03:48:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AC5B26B008C for ; Sat, 13 Jan 2024 03:48:21 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7E5D21202F7 for ; Sat, 13 Jan 2024 08:48:21 +0000 (UTC) X-FDA: 81673661202.16.954B2A9 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf04.hostedemail.com (Postfix) with ESMTP id 8046340003 for ; Sat, 13 Jan 2024 08:48:18 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of sunnanyong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=sunnanyong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705135699; 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: references; bh=7zI8o8wV/f/yjTtW1lV7+IUwZnz8TpP8RFm0kpmJmB4=; b=5W6/NxfBFjcS68FclRtPFzraXHygSrtzUtebf0WPntCMkvj5MZtxEcHjYETte+mhDVmDcO qwIi7Yd3nwY/GL9raTqHGNzJLhwvP0GdbYHadsh+Ozhsfnped+Nd4M7mVGUiAuiCr5Kxv5 2teW5TAF6x39XTOYKR4ARoYmDeC0F7M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705135699; a=rsa-sha256; cv=none; b=6k3emdxx9v1Gl6owctDFfhWbL2kngka3f98kcegjkO7/n/AUr/5Yn1c+O7GUFDqnxgDlKr iEW+Z45SLNQC4dmpLGSYObzH4s3nAf91AGGf6OOrlb6mH0ZXG2BW7lkMfli9jTzM3MilQW fDkdHwVsXC+9wpm1oC58qg2T4QIxeQA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.hostedemail.com: domain of sunnanyong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=sunnanyong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TBsQD2LV9z1FJ3B; Sat, 13 Jan 2024 16:44:04 +0800 (CST) Received: from kwepemm600003.china.huawei.com (unknown [7.193.23.202]) by mail.maildlp.com (Postfix) with ESMTPS id DC46A1404F7; Sat, 13 Jan 2024 16:48:13 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemm600003.china.huawei.com (7.193.23.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Sat, 13 Jan 2024 16:48:12 +0800 From: Nanyong Sun To: , , , , , CC: , , , , , Subject: [PATCH v3 0/3] A Solution to Re-enable hugetlb vmemmap optimize Date: Sat, 13 Jan 2024 17:44:33 +0800 Message-ID: <20240113094436.2506396-1-sunnanyong@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600003.china.huawei.com (7.193.23.202) X-Rspamd-Queue-Id: 8046340003 X-Rspam-User: X-Stat-Signature: t31wbyres1ejwue5mz8m1o1rpxmn773n X-Rspamd-Server: rspam03 X-HE-Tag: 1705135698-771199 X-HE-Meta: U2FsdGVkX1/Ix9lNtjcd7reYOEmIbEPW0nK0P6ZEuLJmYZNiHqprGRZumL2ntC2GftBj7Xn5o/2255+scj4c3OZpH0/juF+FMs19/9wEvsssDvYRPNBTd+QVJf7UyPkSeBEyxx4VjAex/7MGzafThO0ovpTu0nMyEHfcqy1hls+nYWEYsP5lMVfOty83fPiqnx9L57WZeEI9dJjrz1AA+ucacfsYaytBqKRQCiTzoO5G84jGp33peQ4B7b7ZbJfhbyH60r4sk98hPgQ4+obxXzednaR1GZB1byV60T8BT5W2kD+zcceknZx0Jc7nmeN2awnWgJkQsRQMfmgLYbY6N4EwECpTp7PNFqz3k8ZHt/Jrnfwca52e4arKu4zhnRg5hqOaQ+JC61ZxEZ6g4hnPi05ONk4VbZ4l5YOWxjKeO/uyUXbvJSs5Sz5VfqVbvoGAlgChiiuxiNvKA1YY9LuydDhPoctW2KhC6iUv6JiZoYuCULK9eMqTlsDvVZ98YL86HFUFVAHTBSvAsXeSTY76LWPOK9RKezOiZKj42ZqROKKzaghsbndpRNGTB4++nB3jLntZoSJbTqjlvZlVspWtnRG4oChEUXgYUwH8h8tgsjbCZLt41zMMET5aWnVdObMwRT9yN1Ojfw6WkA90vT/D6plaAmzaZ2vC4vuxWafeLcKNUpR15lTGcS/mR0ZWHXM/ia+JIEg+i3QTKUND90KTp6knOmXp35W7bQxJbmmpzUN8Zd58wuFhq2oLCk9iv8a4Xr2WsH2KiG/qOnHWdH5SZbjeNS5HfK65u/Tep4bUMoNqs+PWqinV/4U7aTuQWLC5hZ1PAd12YyHpLwSxEYe+7CeZEMn7SKZ8XgtFIOlX3tl/qMDopsuz3J6ndC4pHVk348d3WuHYcTdzOtmBkzQcFrUzPQXKHCgJdI9l2abmtfSV6nkSw3PZ/3/Ze6zECNQ3KBfInig4PwvEJblx+xC K4EWRAOI lir5taHRru006VGuVkUbgzpq2JM8xlhs3i0mNPNF9aSTjIRKTfQsp3+e6hmvPaq9lSD1Sy2jsYB52vaGY7xjqRUP+ST78Ef9NcVFuEkoNRwn0coUADoIotDyieA== 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: HVO was previously disabled on arm64 [1] due to the lack of necessary BBM(break-before-make) logic when changing page tables. This set of patches fix this by adding necessary BBM sequence when changing page table, and supporting vmemmap page fault handling to fixup kernel address translation fault if vmemmap is concurrently accessed. I have tested this patch set with concurrently accessing the vmemmap address when do BBM and can recover by vmemmap fault handler. Also tested under the config of 2/3/4 pgtable levels with 4K/64K page size and all works well. V3: Cleanup: Move the declarations of helper function in proper head file. V2: This version mainly changes some naming, and uses more appropriate helper functions to make the code more clean, according to review comments from Muchun Song and Kefeng Wang. [1] commit 060a2c92d1b6 ("arm64: mm: hugetlb: Disable HUGETLB_PAGE_OPTIMIZE_VMEMMAP") Nanyong Sun (3): mm: HVO: introduce helper function to update and flush pgtable arm64: mm: HVO: support BBM of vmemmap pgtable safely arm64: mm: Re-enable OPTIMIZE_HUGETLB_VMEMMAP arch/arm64/Kconfig | 1 + arch/arm64/include/asm/esr.h | 4 ++ arch/arm64/include/asm/pgtable.h | 8 ++++ arch/arm64/include/asm/tlbflush.h | 16 +++++++ arch/arm64/mm/fault.c | 78 +++++++++++++++++++++++++++++-- arch/arm64/mm/mmu.c | 28 +++++++++++ mm/hugetlb_vmemmap.c | 55 +++++++++++++++++----- 7 files changed, 175 insertions(+), 15 deletions(-)