From patchwork Tue Aug 6 02:21:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 13754345 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B7799C3DA7F for ; Tue, 6 Aug 2024 02:22:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:Mime-Version:Date:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=9Kc8NvROSpEJ78Xe6Sx1mH5t16b+U6BnKH8GqJIoFj4=; b=pHeL6uX4J6WmTpkkNK79Y+j9j2 VV0FNtK+JmQ+2I7TKuOcjjLa6AK8Zk4VnKA7/IszW2koLuVrbBpjCThRMsduXr77XhFOhwK87/kJT CjcJzmuhJ6m9EiBUQPFM4QWRFvkeIjqYK/SvXHK6Qu65D3mTpw/yM6wJxUPmMRXSdNzDAsfY0F/oP eoTO+lx+LgM3wofSk0uwlBSxX83NjT8b/VsuRWxU6or5er+SqC47n45j1ftdNaqgZnjk5fd0Jn891 I5nDqKwlV0Y+k0Em7keaqW4nhYGXoAbl6JkmO8nxgk6Fj73zua+fvdNq+MJrF4Jr9UsR3fHVy5XcS 4y8hcXvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sb9pi-00000000G0V-2U1Q; Tue, 06 Aug 2024 02:21:54 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sb9pB-00000000Foa-2qcC for linux-arm-kernel@lists.infradead.org; Tue, 06 Aug 2024 02:21:23 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-66628e9ec89so6006137b3.1 for ; Mon, 05 Aug 2024 19:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722910879; x=1723515679; darn=lists.infradead.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=9Kc8NvROSpEJ78Xe6Sx1mH5t16b+U6BnKH8GqJIoFj4=; b=psXw0feRG2StRvPfVMIXKENIlRh6q3xRera4M19NeAQ827vO0zUPLjprBqD5pyYem9 CiZ2VHFkVVOSB7FQS0ubbIsSqpes6E9XRinD4sfhlJLh0iJVoleoaiex+4LSDirCvOkK XwiM7oBBvBVhYjt+6PjCsnyMaA5O7re7FtJq43wWlC5PGNvlsFaiAcqgA7KijNii/1Kj X4EcahPYzEn7EpHc0BVOc0c1dlkUrYIVU4JS9aXHTi6nU8JUbX2VZ9L9hBINpAV7tp4z rPbZOt6zT/ChigkiTXdFMMtEpjZogk4zd1rzKZUlMJ3PvU5c8WWJIT/z8o7iGHc2PYSo rj5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722910879; x=1723515679; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=9Kc8NvROSpEJ78Xe6Sx1mH5t16b+U6BnKH8GqJIoFj4=; b=eN94uom3P8jF0lLgFgPqgWU2TzyTqKRihK/bRwQu6JkFEQfjpYS8OaTLxpj3IgJpJr Zp0kBjZhpmlI6gjpCqaZu2RQrHnuZPWib99kGhfIp5GtiHj1YX7RMmoYcTgXQo/Mgqk6 e+2zbRRdYNoNs1u+H++oBWxY8LVJcBkhSatAqs38ge5L9TEoZKwlBmyfpFm/qRe8xfzL uEoWdQtz8MYzrF5JcSQFOUcw3A4pO8DGNOfougvbOj0bTSKAXw7aZlB1nXYakqz2XpdX kCKvSmBfLiJRoU/lGU0pPPXIEDrhQCRfealekjE8b1/yXIDs9763O85lg51Wx4Sz0JdA taVA== X-Forwarded-Encrypted: i=1; AJvYcCWiRZPtF0R1htXMAp0E72l9kqYk34qNq583B60LQD/5fdvZ+eCpdgPOgtTzemz0QOy4wvae3tzvRRDlQfbZ8t+yEjWZxpCI937iH+HxFY4UbOFrQZQ= X-Gm-Message-State: AOJu0Yy1NecZkU0TZLtYNTL25GGiZY6sHTAEgOuCmKAVnTEb88JaWO8N Izr1zYp0dY+3PC/alESvG+KqbUD9nhMby26XjIJWd9UX25XP1UeOMjzKpR+I72clQNGHl9RqEPE NkQ== X-Google-Smtp-Source: AGHT+IE5/NNaCt5h6Dt2X5qRoBiXQ4vsQr7fZ9vFfiahcevMcB5gDtTReZIFb+NOuG8AhBrTRmTP6C97EcE= X-Received: from yuzhao2.bld.corp.google.com ([2a00:79e0:2e28:6:261c:802b:6b55:e09c]) (user=yuzhao job=sendgmr) by 2002:a05:6902:2b0d:b0:dff:1070:84b7 with SMTP id 3f1490d57ef6-e0bde21e24dmr26817276.5.1722910879294; Mon, 05 Aug 2024 19:21:19 -0700 (PDT) Date: Mon, 5 Aug 2024 20:21:10 -0600 Mime-Version: 1.0 X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog Message-ID: <20240806022114.3320543-1-yuzhao@google.com> Subject: [RFC PATCH 0/4] mm/arm64: re-enable HVO From: Yu Zhao To: Catalin Marinas , Will Deacon Cc: Andrew Morton , David Rientjes , Douglas Anderson , Frank van der Linden , Mark Rutland , Muchun Song , Nanyong Sun , Yang Shi , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240805_192121_742195_C0D90F66 X-CRM114-Status: GOOD ( 10.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series presents one of the previously discussed approaches to re-enable HugeTLB Vmemmap Optimization (HVO) on arm64. HVO was disabled by commit 060a2c92d1b6 ("arm64: mm: hugetlb: Disable HUGETLB_PAGE_OPTIMIZE_VMEMMAP") due to the following reason: This is deemed UNPREDICTABLE by the Arm architecture without a break-before-make sequence (make the PTE invalid, TLBI, write the new valid PTE). However, such sequence is not possible since the vmemmap may be concurrently accessed by the kernel. Other approaches that have been discussed include: A. Handle kernel PF while doing BBM [1], B. Use stop_machine() while doing BBM [2], and, C. Enable FEAT_BBM level 2 and keep the memory contents at the old and new output addresses unchanged to avoid BBM (D8.16.1-2) [3]. A quick comparison between this approach (D) and the above approaches: --+------------------------------+-----------------------------+ | Pro | Con | --+------------------------------+-----------------------------+ A | Low latency, h/w independent | Predictability concerns [4] | B | Predictable, h/w independent | High latency | C | Predictable, low latency | H/w dependent, complex | D | Predictable, h/w independent | Medium latency | --+------------------------------+-----------------------------+ [1] https://lore.kernel.org/20240113094436.2506396-1-sunnanyong@huawei.com/ [2] https://lore.kernel.org/ZbKjHHeEdFYY1xR5@arm.com/ [3] https://lore.kernel.org/Zo68DP6siXfb6ZBR@arm.com/ [4] https://lore.kernel.org/20240326125409.GA9552@willie-the-truck/ Nanyong Sun (2): mm: HVO: introduce helper function to update and flush pgtable arm64: mm: Re-enable OPTIMIZE_HUGETLB_VMEMMAP Yu Zhao (2): arm64: use IPIs to pause/resume remote CPUs arm64: pause remote CPUs to update vmemmap arch/arm64/Kconfig | 1 + arch/arm64/include/asm/pgalloc.h | 55 ++++++++++++++++ arch/arm64/include/asm/smp.h | 3 + arch/arm64/kernel/smp.c | 110 +++++++++++++++++++++++++++++++ mm/hugetlb_vmemmap.c | 69 +++++++++++++++---- 5 files changed, 226 insertions(+), 12 deletions(-) base-commit: de9c2c66ad8e787abec7c9d7eff4f8c3cdd28aed