From patchwork Tue Aug 1 02:31:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13335695 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 8806AC04A94 for ; Tue, 1 Aug 2023 02:20:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76DF42800C6; Mon, 31 Jul 2023 22:20:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C1DF2800C9; 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 3ECD428007A; 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 2D83A2800C6 for ; Mon, 31 Jul 2023 22:20:09 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 018B5160150 for ; Tue, 1 Aug 2023 02:20:08 +0000 (UTC) X-FDA: 81073930938.25.D479B66 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf19.hostedemail.com (Postfix) with ESMTP id 9C5E81A000F for ; Tue, 1 Aug 2023 02:20:06 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=IFMGozlLYJVoltO3CseRa5j/Y+k4oC5qFh+PfUDcvBw=; b=ONC+0We2wS9qQuwz+Gh6wSR+mVOUJSNHzqo4lBrv600AwNwT+u05CT1UjL6AREiI7b+x4L QL3POraCeSJ5Ty50WPwDHAIp3XeyvAToyTLVx8aqgkIbAd6nUVtjEZxfR+K6XcemyYjpm9 b1DvHnAZvENUPLZTosr5QSwyXyD03Tc= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf19.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 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=1ukEyjOrO9sgcFduMPoq+f3iTpDcsqItlkk8+ud64SO9T+6ORSiuAn/j2IMbxxkQ+8U+RX FZOE0/GMz+5taFMKxfUKYojkSCqJzc8zFqJjJSRVgHW9VyJ4ohFgnp+MC1oRjhv/IQpB2c I4H6Y/zT9bT04BVSg7KMAGK2hu21cWo= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RFJh45z2lzrRx1; Tue, 1 Aug 2023 10:19:00 +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 , Muchun Song Subject: [PATCH v2 1/2] mm: hugetlb: use flush_hugetlb_tlb_range() in move_hugetlb_page_tables() Date: Tue, 1 Aug 2023 10:31:44 +0800 Message-ID: <20230801023145.17026-2-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-Rspam-User: X-Stat-Signature: xeqtnfa5p15ng74fmd5h849yfg9oe1pa X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9C5E81A000F X-HE-Tag: 1690856406-791378 X-HE-Meta: U2FsdGVkX1/tev29XYb8sLsLK/tWFQTk5N+tvDZ0oVnAxpzWrVi4XaVBdC7luaM0OzehNmjfLeULSZuoNZtvHAkJ6aG7HCj9xRvdM/8HgxCfbYLrenxTSPeoqGnojNbg0KeUlaMIZIYlviqy8vF9z4qQyQ46T7X4RgdSkGgdS8iBXzO7CNs7J4TUBPbgRL3VY0pXF0+6xDNV6RWG5bXuxGmtRIZdOqDS5FWu3zGr00VO2rSYFiB51UtPnBKiUHfPD+TB2s7jMbTHRP4DSzjochOscV5CNuYmKUuzPfE52jd1NfuX2+vq9afKBuhfRuMRZa0l/jGwu73AIfc189h2kd046bvbeau/5aB51uDWBpdF5IIUvvtTeiL7KdDbSOLTPm1aN9lbp+ZilMz78+oO/mAaPerwvS3TuJgSn0IZFRSDFDN0U9f81BNjCjsG+OggGwHa13MSfI/RaHTyzH/zBAGDamv208s+8FPyT35AQN8+uwI8qB0/VtymazE0GIoCIe5hPehdA97peBXGyJFveVqrAZn6ffaY04haQp/LCYyX40TXDFZYqqvVBe14gOLMkG3lWs5rYaZMZ/fpr2VY7uChjeUgOKMXuBOjV7jVutPLtipqg6Mg27Ab6sGPXmxFluRNPW4xIz9q8+dBfe+qieHoZRIW+8nUTPB6VKyVr3owxMtLHNEP4ZY28bGh5WJsn7La+kJdrLM6W88XYAJ9xb8boO0yXAMuNptIM7DP+ZAJcmxfC1DGdcjamyY/FDXS4DPdIDaicdf6/65uC2NzrVRvtYTBXjEPmHr1tkdP9mj/Z+KCEBkhh2Nk7uZXGI1iJ0RUnAROau6VSjejKV76HdNiv46sqTTN5BbkTc5jokrvC7rKS1oKE5xXLDAypkJO5zOCkf4yzscxXsYAFHS7cz33e4lrQ+FUc07K8FSDpaEeD8qgnHgTXLsWeJ5DnGkY9T/Rkf6jCoTnIgP3YML 0NZswqJI aT38uy4bySnrDDM0ABX/ci6kgmm6xSIyEBdpPOoUhjZ6hjIQtxpqN7y43I8Krk/GEg5BAlY+WpXEjML8OpKU2nS+ctrd2FubVSGH8u4Zqd7ugAap+kQF6XseYuX6m9KMTYRTcHjSXpOU+Y9DWImRT8P3j5zCkuWAAvQ4FkDV7DtBbWapJhXDqwkW+HbNWE3KnrEFr/0uJ4YDxdYozovDrDcgiiuHmvmeDoS5xwVG3A10OllE/A5GU04Fr/tGDvQ4N+1jS1EKhJWxfU0WOq9j3rnclkQ== 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: Archs may need to do special things when flushing hugepage tlb, so use the more applicable flush_hugetlb_tlb_range() instead of flush_tlb_range(). Reviewed-by: Mike Kravetz Acked-by: Muchun Song Fixes: 550a7d60bd5e ("mm, hugepages: add mremap() support for hugepage backed vma") Signed-off-by: Kefeng Wang --- mm/hugetlb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 64a3239b6407..ac876bfba340 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5281,9 +5281,9 @@ int move_hugetlb_page_tables(struct vm_area_struct *vma, } if (shared_pmd) - flush_tlb_range(vma, range.start, range.end); + flush_hugetlb_tlb_range(vma, range.start, range.end); else - flush_tlb_range(vma, old_end - len, old_end); + flush_hugetlb_tlb_range(vma, old_end - len, old_end); mmu_notifier_invalidate_range_end(&range); i_mmap_unlock_write(mapping); hugetlb_vma_unlock_write(vma); 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 */