From patchwork Wed Dec 20 05:18:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nanyong Sun X-Patchwork-Id: 13499492 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 C914DC46CD4 for ; Wed, 20 Dec 2023 04:21:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61C388D0001; Tue, 19 Dec 2023 23:21:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E3CD8D0008; Tue, 19 Dec 2023 23:21:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35D298D0007; Tue, 19 Dec 2023 23:21:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 1FBC48D0001 for ; Tue, 19 Dec 2023 23:21:49 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EA5EA801CA for ; Wed, 20 Dec 2023 04:21:48 +0000 (UTC) X-FDA: 81585898296.04.E7A8A83 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf01.hostedemail.com (Postfix) with ESMTP id 4295740014 for ; Wed, 20 Dec 2023 04:21:45 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of sunnanyong@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=sunnanyong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703046107; 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=Q0QXhCfXUpQ0lsgYwaOUqV8ddW58wap0TJEwDEHxftM=; b=KjPBR1U3I29u/5JkpizHoaF5oxwozseJMh45yDSJ4PLZUX6r9oMb8MD6nbvvTUrw33w6Cd AJ74JZrF13MQpMn5T1n6uS1wen046gOwsikmvMiiItYIBJMemuC2L19zjz8Vy9GKb+Vfr/ XUfKQ7SgOB/5Tb4iOSjcUw5fmi688UE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf01.hostedemail.com: domain of sunnanyong@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=sunnanyong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703046107; a=rsa-sha256; cv=none; b=UJ1CYc4Un3APmO2DhnGK8tqYmjWQ1Uuvd8crnlNkwVbdibwIilaF+KBYK/p08CS4//nh6z Z49jcAcy7F16UOqihCTH1uABzGBUMMoGqCZiKAGpRopj5lEZSCixMvWGyeH61dwJouMVg6 0Z+uIAjrgm+2g9DwgkMek8XVoYgH/Fc= Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Sw0kD4qwgz1Q65Q; Wed, 20 Dec 2023 12:21:24 +0800 (CST) Received: from kwepemm000003.china.huawei.com (unknown [7.193.23.66]) by mail.maildlp.com (Postfix) with ESMTPS id 302BA1402DE; Wed, 20 Dec 2023 12:21:41 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemm000003.china.huawei.com (7.193.23.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 20 Dec 2023 12:21:40 +0800 From: Nanyong Sun To: , , , , , CC: , , , , , Subject: [PATCH v2 0/3] A Solution to Re-enable hugetlb vmemmap optimize Date: Wed, 20 Dec 2023 13:18:52 +0800 Message-ID: <20231220051855.47547-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: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm000003.china.huawei.com (7.193.23.66) X-Rspam-User: X-Stat-Signature: zkmhyapkczqkenaj4wgjguoxbfmk9u63 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4295740014 X-HE-Tag: 1703046105-296903 X-HE-Meta: U2FsdGVkX18/LS8VgSQ3wHh/ksRO9qhX+uV98M0bHXFaV1+8r7+sGF52C65yPs+0QqRpMjzwM6Fg4h47TK3csdSz1o83yaSU1iIldLY1yKVtKyH3UMoVdgzaVxPqRJxNqq3fFBb9+WtxRUQOQbUBcB/iowKABkt7rf3E7VTh8kQ/RmZYjSGvHyLHKN8l4NL7mhIwbJbo0u0C70NMFqbMLHrlp+hnlzRcqx6Y2CPZN9ydCKwESlOcqACb81AF05BoSfVv2gv00RAPbQjsFx7NSBGmcWgkFK7cHvGbUI95imbIBa87gE15EvFdzBrNxdWjqBEIcLRsHbS+T0krNKb3UPhriScCw7oWXpSBleeMITZANsjjedMg7wSrVKI+z0BCDSfIlUGvSGhd20L3cEllHNDVViwseMv5yhSJg+ptRNlxZ0UvlbbWaX3ieFXPP+oInXY3n4YQl6jv0ttIu6XZZ2HRgqwYTTvM3OggA9IUehKdtjhMMZiE/uU6MkyeMdhXk5V0f522MTh1KT2Wu4pdzn/UCsyGqmttG5/NgoYF9ZDZlckBbqz8UPa2GBZthiCgjR+GeIKPSGo3ZHuvVD6BQIoVCdB6td9zNjKzgcdCJ1zcaARPbrbDrLQXmBX/GNxJe38wDRKTUegjvNfd34kHY2tsgrxxvB0rm3S2CW6iVULHUNVjAZmWHnWyluGDX0MUl/kwCHxHjDCjZC+zISlf8JcMp0SoRkXDYuI9R6XjXrbomMQxa+aB/Gpp/4VP/nNaCsr7VJyFiKJVmXfQiDQZ4TM2qkzW4W8C18H6Dq21MRpePvqdpWzJUyrIvnHdMu/Rv9fJE1ASKcr+f0jUwBQ/AxXG9I3ViaJnh+aPuRR3tUrLbg/twhxrXz7H0dW9ciQa+z/qH88XjVLQ5yCcpW4kAAcJOFnuDz+PNmEQlfWk9lMMLlDhMWeibDSiirGCGDp57zy3PAxME8t7uiHXcjR wDqRWwdC Z0IB2ISz/e0sscytck5OC9oFs/+adBBXFSfR2i6dVv3/w5WOrLbinhnfQcVvyH1Bka0J9fPC1sFsw/SHelTpVTA74QtXLd2R1YjblDgbB2WGh28AGB3x0RfMFOw== 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 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. 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/mmu.h | 20 +++++++++ arch/arm64/mm/fault.c | 78 ++++++++++++++++++++++++++++++++++-- arch/arm64/mm/mmu.c | 28 +++++++++++++ mm/hugetlb_vmemmap.c | 55 +++++++++++++++++++------ 6 files changed, 171 insertions(+), 15 deletions(-)