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: 13754339 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 2B2ADC3DA7F for ; Tue, 6 Aug 2024 02:21:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADAC26B0098; Mon, 5 Aug 2024 22:21:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A63276B00BE; Mon, 5 Aug 2024 22:21:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DCD16B00BF; Mon, 5 Aug 2024 22:21:22 -0400 (EDT) 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 670496B0098 for ; Mon, 5 Aug 2024 22:21:22 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 22440A052F for ; Tue, 6 Aug 2024 02:21:22 +0000 (UTC) X-FDA: 82420218804.23.2F27E02 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf18.hostedemail.com (Postfix) with ESMTP id 6FD001C000B for ; Tue, 6 Aug 2024 02:21:20 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=qPlBnY+r; spf=pass (imf18.hostedemail.com: domain of 3n4ixZgYKCLIqmrZSgYggYdW.Ugedafmp-eecnSUc.gjY@flex--yuzhao.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3n4ixZgYKCLIqmrZSgYggYdW.Ugedafmp-eecnSUc.gjY@flex--yuzhao.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722910818; 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:in-reply-to: references:dkim-signature; bh=9Kc8NvROSpEJ78Xe6Sx1mH5t16b+U6BnKH8GqJIoFj4=; b=RpJ0T7zUwB8cI4Yquv8Ry7+jTNxfLgBcEksCfllPf8+RacySNJgeTmM8uh1/drOwFyJ9HC OIt99/JlpJ6QHJrXBtUBHwmVbGcRgUcuvSzf75Jija/7fixQZjcy2LUmHXw21r4nX1NtTr ZAX9RLtegBuOLG/1A/NXrdvtuaYd4Go= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722910818; a=rsa-sha256; cv=none; b=o6P+Cw/yMeYOuprQ2QMh+ZqB9DIo3fggfeV4rD4tON01RM07LKcXeRMQ1hNd9UekogRgXh PZUWRiXcjNha8/0DPMj+3xP+0Gk/QRqVmAsn8QQGvDWp2xX3/iApqhl2H0NveeUWu1BXc0 VHRUPdLTW91cZHMBNnfxaQfjpcxiGOs= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=qPlBnY+r; spf=pass (imf18.hostedemail.com: domain of 3n4ixZgYKCLIqmrZSgYggYdW.Ugedafmp-eecnSUc.gjY@flex--yuzhao.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3n4ixZgYKCLIqmrZSgYggYdW.Ugedafmp-eecnSUc.gjY@flex--yuzhao.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-672bea19bedso6584057b3.3 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=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=9Kc8NvROSpEJ78Xe6Sx1mH5t16b+U6BnKH8GqJIoFj4=; b=qPlBnY+rAwn7JMwk1E3buoBmGIjEB8mQFWV5ZkqlkMwpQS/G7aHjl/oNxepO3Ioxrx rMOmbqbNIHLIyS6uIWQT1WZ9+6MOA52y7qLMKIf2OrcRaBwWf9sDkDw0zV2Kp3W5+wwi 8I4IR7bRfVV5rtKOVWuRwg8lKJfea6mQpnPINo8+bdzZwXl9EAov1RARtcQVkqJKb6uX ChQg551LOCjKBZzJ0UUQbO0OP1OpHOGMxVpPjVBQ7qIN8Lw53/bZ9nljcSPX48G/NGQD CH2oDn8aQQRFPF/kwlgiO+a4PkpyyglN/D7gkciBRrVC3B+wt579I3Kksu6JSzMRr+U6 WPgA== 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=LnriUZxHuRCBs0x+gDLhd/jOovshA0wO/w+RakfLNQV3D6dss3H/VH06a+VfNYfQkc 166A/oIZZHE6FxUqA7O20l4ObpmcNQGGVCPMxx2rx8ISgHBGgERnJ/Tn3kEX3iXYSQNx AmxJSsL3gJf1qBZUZXXx1HH39eQW3HOEgWC23IMevOc2G3uWxuuDwTMOpdKV0JvNYgwu OeAFPZnWUz2utqbAIK2AmhRCNCKf7Sad9oqNATO2zfaBQ/lJfepILukM15RrlHemDiNW wNSHPDrzlYNekxyF/LCIBusFSFlm24qL3oYJ1hyd9N+8OSKf6ndB/onCZVXKalfaKwEz sjmw== X-Forwarded-Encrypted: i=1; AJvYcCW3Xi92z4fcSwqO4FqUWtn3wn/3gXo1g+VaNcyGVcwGQom25fGgYyHd/HAiq/cx+TPthQcbWO3N/WZvEbnW7H0mTlc= X-Gm-Message-State: AOJu0Yybmok2eJzOQ/3YToudo2YLQtDp4tGYXQPcOO+VMw0s9TrTXHL5 wyKsUXtL9PhXmfscrUEfJDXSLdMiK1kW44X97RfmC63p9R2rzi8XPLIj+AI122Eu4CvFLredCcK rvQ== 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-Stat-Signature: 1z5u9osaiwfu9iehma37n14atr19o81w X-Rspamd-Queue-Id: 6FD001C000B X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1722910880-53509 X-HE-Meta: U2FsdGVkX1/PJDdVckB/nqCkPXNXEOK+hNny3JEwdavMh5JUTSHg58ODuJdjrCwJQkfxkI/FZapkPZl+t2udPxpFqUROeYo92NazRTN1+GUY2GUAUdGMjVU0mpoGmF2qw9v7rv5w3ToTlQH9Y9jyHIwD0X/bkyrUdNp7a/U6Y0JkZ6SiT5i09JUyng20fRQaSmF5Ii6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JRpVWH+dqS5f8iGJz5deJeIGq29KUsJdeomf8tXb4559Nw1wPyZ5i2ag3BpOAo91dsMgkLjXsVVcgm4uUiPzOioF+gnweQJ4R/k/BfniZToNBtD+43QSFNiwH8lD28K4L99wERLwS/9ZFGtozQrsYjkTuzbGqv/+3dbQC1aPt0XMnHF68n3Gzvt31zEcXmcYwswp0MHD5DSUxgMWuO16fx7lWdOTn9iwy6I3tkS3nqhcrMebnDaGjtFvUvjCVw91KtwYzfrLMnE/N8WvjVtpzXZ+m8eEQskFCUDeIfitBN3wJt9I+9tVWWI45aW2yC5U4EWTDL6qX2pcfhzA0aUGaHyod7uCA5qmDYdQth5F8ncMGflEpxOD2SJCTMGF3IzBYECnF4R99Kq2cLA6DDgNY1ON4Qj75ZFowCNMROxo3xLgYQ/BNCPH0MWziU2SQ9yGZA9SYnA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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