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: 18347 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2409941dyi; Tue, 19 Dec 2023 20:22:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqiApo+ripRRqj5R+aaJ889ehurTY1um5YZgrlFuK9ZHLjax6pOmLB69W/wzWE0pdjqf/b X-Received: by 2002:a05:600c:1989:b0:40c:4716:5116 with SMTP id t9-20020a05600c198900b0040c47165116mr4140230wmq.260.1703046125020; Tue, 19 Dec 2023 20:22:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703046124; cv=none; d=google.com; s=arc-20160816; b=tV4aI8VyUmc6CdMZOHZtC6TkMhJDuULnyf2A9ZCjEa6iPAw/BZYpO2e1sTabnM8mIo uT/hDHHdhC/c92tSKHfUYepn9R8TCqr8wt8cXGuz9USSvF9WYA+ZPteO5mKvumvTJJUF ocVVzmHvXmhBSLb9xxBfWECK2elxVJKPbAby3m4VcJu76V22hOrPKKVAlXcxE2NE6iGZ qMCwOLlSddGNTWAzwnfp/yTLmcQz7SC1Bl9xSAsfYzeRY8KZ1R1QD5TyNppewQ2hI5Rl rAJYb3yDyAie864M4kFZEiAFC1mHux8RxjfypRG2qbdgyv56c7feydUTc9MfUVAmfLHn g7iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=Q0QXhCfXUpQ0lsgYwaOUqV8ddW58wap0TJEwDEHxftM=; fh=IBRY2OfN0iTWW2ZjSSKvUJynIiV/JLaiDZe55wN3MqA=; b=O7+TFe056DoAk4ttYuZOiX2yBB8dLC+pXJpLO2aiCr6jUcYd4AEzn3lqTsvXN3vRNY W9Sj3r1caeoyDZ0LlvJkd1Ewk9GSF0rMLkNdoVFtVdVw7SuYcGN9pYmo0LhHaDbvXt05 qUUEDVqpKc166E1OZ/3NrgxncmMCyJScNb7pc6S0ilHXKBISk0I66uFXh9SaoZQRV1uf 345hpwzw6oh24q4JGlo1X58zhBMGIY4DGYNWcQr8P7eCHYkLHCaMtyUfOhnwZfY5eNR2 mu+hxM6iiz0lYXRCqKEGFhOMEOkzXHQQpkg02wpn2vN+8PL9U8ZD/w8X/h+8zvp2Z+b3 UHFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-6363-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6363-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a15-20020a170906468f00b00a268f33ac1dsi332030ejr.477.2023.12.19.20.22.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 20:22:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6363-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-6363-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6363-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9F9281F25FFF for ; Wed, 20 Dec 2023 04:22:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5B12168B3; Wed, 20 Dec 2023 04:21:47 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EFB4156E2 for ; Wed, 20 Dec 2023 04:21:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm000003.china.huawei.com (7.193.23.66) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785773293403074829 X-GMAIL-MSGID: 1785773293403074829 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(-)