From patchwork Tue Aug 1 02:31:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13335696 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 EB396C3DA40 for ; Tue, 1 Aug 2023 02:20:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B92628007A; Mon, 31 Jul 2023 22:20:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 943E72800C8; Mon, 31 Jul 2023 22:20:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D9FB28007A; Mon, 31 Jul 2023 22:20:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 42F892800C8 for ; Mon, 31 Jul 2023 22:20:09 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 12E2E1A02D8 for ; Tue, 1 Aug 2023 02:20:09 +0000 (UTC) X-FDA: 81073930938.22.178DEDC Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf11.hostedemail.com (Postfix) with ESMTP id B78BA4001D for ; Tue, 1 Aug 2023 02:20:05 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690856407; 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:in-reply-to:references:references; bh=a0sTaHbhpVIh0EDwBeNAdTWuVLNr0hHlmM2DUd7rVIY=; b=A/1FNJc7upd31SBfBCqdHpAXoyBOaE7O9KeLXGQnk3yAw/rzJQz6/spgOLKCGGsxINWlo1 nGrdlZ2vNMTaaXmbvV9aTqvBbofMGjynjKkppfErMEstRHmAu8FnKGg9IqD5cRI4AySnCp Rfm27xp53BqHssDQuER1/eoZV+AG0KM= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690856407; a=rsa-sha256; cv=none; b=1exf/CaqDTz5ja724dEf58WBOeT4X56Eg5lxAFVxgSN9rtneQlyBoqz/TsL9WZSB+E1/qG nLGTM+aGTRXbQNaG8GYLC2OroVm+zlEfzf73YYz/Vyj3diSU/w/+KCoZ/2dc14mIgx84wi /BhYOs7St3HMWM6b3MNIWtgtzemwmkI= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RFJgH72XqzVjpg; Tue, 1 Aug 2023 10:18:19 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 1 Aug 2023 10:20:01 +0800 From: Kefeng Wang To: Andrew Morton , Catalin Marinas , Will Deacon , Mike Kravetz , Muchun Song , Mina Almasry , , , , , CC: , , <21cnbao@gmail.com>, Kefeng Wang Subject: [PATCH v2 2/2] arm64: hugetlb: enable __HAVE_ARCH_FLUSH_HUGETLB_TLB_RANGE Date: Tue, 1 Aug 2023 10:31:45 +0800 Message-ID: <20230801023145.17026-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230801023145.17026-1-wangkefeng.wang@huawei.com> References: <20230801023145.17026-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: B78BA4001D X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: hkb8whgfgtk3dhtoyqwccah9k7t8xkp3 X-HE-Tag: 1690856405-328026 X-HE-Meta: U2FsdGVkX1+YnwQpkZS9vvxPbvXPavpt+K5H5UJX58YCq+5yJa4HFzVUdHkWj5gOeaGNnnut9nRHpD1ke5xmuQ4EOCru2WpEhBK7+6PdIHfLjrNrNurwNk1Qx2lrqyGqPbWe2r2mcBao+QzlsKnOBey96nsUlv06kI8d+6buZKSYR/m0sk7LBo+fsH4G2YyOxLR4V51mPsRM1ow7athBW9Mv/H62+5kvocYR55a1K5odZeeAeS1uv1uqJ/l5Qmdw0jrEMuo0X+9Jl0w/jUr7rE5UffvXceqEHYTRnYfMSDl2FF8eMo0GN/pYwtQPFINBHRCBNZ1pTKqg/z7dpte0QgZdeCM9UXJJMvWUkXeJiwIXb+ANsl0EYujxN0N6O8qnB8FHSTwITqT5Nk/+hOiHidyodEAu3HQCCXz6FVjpiR6TXn+SYDcWNGsO3R+/mnUUqw/eJE4dMJ8DUhJcs19z/tTOiR+CcfYGh4EF7MmMwRcnKN8wy4kUdlbLXsDq6hqkQCRFfPlkBIgv6IbK6atkCe7eGLg5esiS0bSiURrICTVei6uO8RiRWH/um/5UGXVKT6cBR/ZOUiP32SsD5vSDPFPkmmDokNFkp3J21HkxJG0YWQca+eGPAHWQG/1btV4ZF0+SvykHoY7cUe36hbUSWf5/cYgLJVDVs2v4hc4MwtDm0lKOa0u2UfWk/U3m+AcwxPPMOpSPz2SvT9ghuyG0ID/47FdwohApKR3cdyS1kUGc49cLIatYNwgVwIdczrqw/YXvD7AvGfW5pnIQZltYLuTkwTSSQz4IYxrvhMIao7LmJQgP5A+EyTXtwfk2t0Bqab3Sj3JsJ2zU4xxG/RgdBtkZLRqNnlBgkLN7/3uQPneFU4eNXnchc8VyNPxEDXMS93zmmuLzarU6UZomK+So06UTOCI9n7KhNpQhfr/kfy3M9ICAFy+jJszRFwBQ3cbEgiSVAucIvCaJwZeWF5s AkP9aT03 oImfwJgW2VxsU1UpvS7/mTM6soxRN21K6EmkkvNgynUruB7IgbBXFp33MJuYwRR9Xk9RC/0RomYvQA3JRZDfO4uqyCgguXMXwArRGFDJYPzMVjLrJzfME9bzGhVJTr9HMdkHKaHOWkkSZUrRLzXNYAlm6wadQFgZanmLRo+iQyCLYI3Kf1c26ZOQKDK1qdp2AWNwG 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: It is better to use huge page size instead of PAGE_SIZE for stride when flush hugepage, which reduces the loop in __flush_tlb_range(). Let's support arch's flush_hugetlb_tlb_range(), which is used in hugetlb_unshare_all_pmds(), move_hugetlb_page_tables() and hugetlb_change_protection() for now. Note, for hugepages based on contiguous bit, it has to be invalidated individually since the contiguous PTE bit is just a hint, the hardware may or may not take it into account. Signed-off-by: Kefeng Wang Reviewed-by: Muchun Song --- arch/arm64/include/asm/hugetlb.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h index 6a4a1ab8eb23..e5c2e3dd9cf0 100644 --- a/arch/arm64/include/asm/hugetlb.h +++ b/arch/arm64/include/asm/hugetlb.h @@ -60,4 +60,16 @@ extern void huge_ptep_modify_prot_commit(struct vm_area_struct *vma, #include +#define __HAVE_ARCH_FLUSH_HUGETLB_TLB_RANGE +static inline void flush_hugetlb_tlb_range(struct vm_area_struct *vma, + unsigned long start, + unsigned long end) +{ + unsigned long stride = huge_page_size(hstate_vma(vma)); + + if (stride != PMD_SIZE && stride != PUD_SIZE) + stride = PAGE_SIZE; + __flush_tlb_range(vma, start, end, stride, false, 0); +} + #endif /* __ASM_HUGETLB_H */