From patchwork Mon Jul 10 08:39:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yicong Yang X-Patchwork-Id: 13306472 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 E7FF2EB64DA for ; Mon, 10 Jul 2023 08:41:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E57A6B0075; Mon, 10 Jul 2023 04:41:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 292E56B0078; Mon, 10 Jul 2023 04:41:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15C136B007B; Mon, 10 Jul 2023 04:41:19 -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 F1F946B0075 for ; Mon, 10 Jul 2023 04:41:18 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id AB27F1A030D for ; Mon, 10 Jul 2023 08:41:18 +0000 (UTC) X-FDA: 80995057836.19.99AB65B Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf26.hostedemail.com (Postfix) with ESMTP id 2877D14000F for ; Mon, 10 Jul 2023 08:41:14 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of yangyicong@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=yangyicong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688978476; 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=sUBByuZXbpyKrc9wDQ9lkzXHe8yqE1f/9cc7ANd+/4c=; b=eQNF2kkmNAhjFFJlrXdGN6TPIl9aZglj5mz3zaVB25kXE0uYcFUuDYsa4igO9dZQXAToOY OtHjVvNYsG0KmKdClOenN5OPLmjKh3oOCBq1wx6VR/GgRfqWhkAwbZQYZq1GtWCprmONt2 TMoZMPQAc2GP5610bN7vcoJ8RtWagG4= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf26.hostedemail.com: domain of yangyicong@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=yangyicong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688978476; a=rsa-sha256; cv=none; b=dxMPj8VQ4bHnhufHIM5roGPks+s5BMMfihHXBvqUMCiGkNUyCkEUyYzp7/ReMyQJgq/XLb oi5lzaOOCdjqi8EiForeTq80k5IP6ctp5DW514w3RchBUjOxhJ8jjYoBKMPbu0iDu743Sg /19DmmgPhD4TUnu052paZi1PossgH6A= Received: from canpemm500009.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Qzy8Y0ThMzPk21; Mon, 10 Jul 2023 16:38:53 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 10 Jul 2023 16:41:10 +0800 From: Yicong Yang To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , Barry Song <21cnbao@gmail.com>, , , , , Barry Song , Nadav Amit , Mel Gorman Subject: [PATCH v10 2/4] mm/tlbbatch: Rename and extend some functions Date: Mon, 10 Jul 2023 16:39:12 +0800 Message-ID: <20230710083914.18336-3-yangyicong@huawei.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20230710083914.18336-1-yangyicong@huawei.com> References: <20230710083914.18336-1-yangyicong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 2877D14000F X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: rnftbqpzkib9o3x3xyt489zctjjcret6 X-HE-Tag: 1688978474-655822 X-HE-Meta: U2FsdGVkX18anhICHHB6sSz3w+ONYwpBheG3N51uspzWIbTccmf1HSfiXpreA8eO2FiDEEZP5lv06wYYjVPToQIHnKciN9It6DHkhhlSjqZqYbDS6m5p9tVSSs2CiwG8NACLINvt6SH8dV+GAub13C+7PoiG4YYq4YZi/S7zqEOEuu4L5Y4edJxOQUqF5dv7QbfV6OlLioLiLNJsfAuY2X0vMy3FsoV+cElElpWkdCM5Zdmm+QAHna7wyT7sCtmAB/BU5jW6WEzLUIFZIwXkD3bqWQpqmNUS94Sa6HuxDK6m1Yk4gVbdyfnZmNxEfHogSEiyT7Qyxv1KLMC3UQiq0VgofTgMZoiDXkyCYX1y9Fe80He34aF7QziiDGu4mrsOn8VAUvBvTe+lt2CsCjfrV1Xh9L/QU8puv1nc4ZebSMBvtEDMbbgOnMYEdAE+PblqxErSxoJQc26yMsqsiuLVk5OztArJUP/eRJDFCLXjoQ1fH/AnIw2olw9OSESwOSnAUyajWFliW02c6O2WiH5Cw5pIwBCOQl3iN8KDWSU4oFTaFkblqYLtkdvQS+xRjoLEqoo1pdYuj6kYjOpU7PqXxiYkNEyT++Kne5hSRyBJG3s2Z7nan/ge+kLR2MaAOvznJPnX8nTs1/aXH72rk49tZZKdbRkjkk4Ru/85Vp1Qa13Vo48UIuK+xhBnSZ1wZ2/BJEOHdj2QcvdIKcqK5KYoquADvQjOg6BgJt50IormUeSAEqjFKg6w/Qv9ejnL7YXMcuJMHnIGdRcLfSB6AaHuzwUOPYnM56L1c5aVhc7KNYuBvCyDkpGZxjEf7zKihPZxr/xJofffbyluK6LD4v3SRUXESOSiICeATICLP3GOWOy27KvvM2FBL8pPioBIZMttcpuBt5KTA8sP1NkO47P4+qXDQCxCZSJwWQsDt9BRRIj/Oc0Wv7MfOh4UNW+jyedOfE6/0ezFYkb5rWyJvsZ XbgSHv+W TTAEkSYxWvAquoXJEvyZMLPzyCP7XkRMxT5/QdBHyn27t1NAqJhGv2sRYYgs9l0jEszRgNYC5qWXJuEnkJgNJZT/6O5oZjEqaYTpbe7CCywAOwx9AK/SPl2CdW9eYic9HZB8/mQKXMmxCiviwo6pIdOdMfD5DfNi2jTk3HMUFRAJFvA/kOyHlYjgRrx3WWJbvpm/VPWHZnRdTrEMGbDLgPQd8dpKRZ+9Z+3QHK24byJyvNLcOFn7TO2yP4BeZW2Ok1nkR2ocw1AiChrF6Oxhsntj73uVxAfNPqnzqxhnFjguyNSBDSuoILymk/0BFk7uq+S+TDKugURl9JXNGTK7blui71+ENN2nbvz7pQ48s42TgKdT5NpowbXCoqEGc4PX8Fj84tNKLtfAg4y/ocjx5FIF4bxe2a0e67+QIbl5+uo6nuCSS2YMl1hwS7+ufvM3gl1wca7oqQPP0gjfXzwsg+jxQgm4c+YEUr5BYsTNI5b2Wx6MHUXtiIb9W8A== 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: From: Barry Song This patch does some preparation works to extend batched TLB flush to arm64. Including: - Extend set_tlb_ubc_flush_pending() and arch_tlbbatch_add_mm() to accept an additional argument for address, architectures like arm64 may need this for tlbi. - Rename arch_tlbbatch_add_mm() to arch_tlbbatch_add_pending() to match its current function since we don't need to handle mm on architectures like arm64 and add_mm is not proper, add_pending will make sense to both as on x86 we're pending the TLB flush operations while on arm64 we're pending the synchronize operations. This intends no functional changes on x86. Cc: Anshuman Khandual Cc: Jonathan Corbet Cc: Nadav Amit Cc: Mel Gorman Tested-by: Yicong Yang Tested-by: Xin Hao Tested-by: Punit Agrawal Signed-off-by: Barry Song Signed-off-by: Yicong Yang Reviewed-by: Kefeng Wang Reviewed-by: Xin Hao Reviewed-by: Anshuman Khandual --- arch/x86/include/asm/tlbflush.h | 5 +++-- include/linux/mm_types_task.h | 4 ++-- mm/rmap.c | 12 +++++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index cf2a1de5d388..1c7d3a36e16c 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -276,8 +276,9 @@ static inline u64 inc_mm_tlb_gen(struct mm_struct *mm) return atomic64_inc_return(&mm->context.tlb_gen); } -static inline void arch_tlbbatch_add_mm(struct arch_tlbflush_unmap_batch *batch, - struct mm_struct *mm) +static inline void arch_tlbbatch_add_pending(struct arch_tlbflush_unmap_batch *batch, + struct mm_struct *mm, + unsigned long uaddr) { inc_mm_tlb_gen(mm); cpumask_or(&batch->cpumask, &batch->cpumask, mm_cpumask(mm)); diff --git a/include/linux/mm_types_task.h b/include/linux/mm_types_task.h index 5414b5c6a103..aa44fff8bb9d 100644 --- a/include/linux/mm_types_task.h +++ b/include/linux/mm_types_task.h @@ -52,8 +52,8 @@ struct tlbflush_unmap_batch { #ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH /* * The arch code makes the following promise: generic code can modify a - * PTE, then call arch_tlbbatch_add_mm() (which internally provides all - * needed barriers), then call arch_tlbbatch_flush(), and the entries + * PTE, then call arch_tlbbatch_add_pending() (which internally provides + * all needed barriers), then call arch_tlbbatch_flush(), and the entries * will be flushed on all CPUs by the time that arch_tlbbatch_flush() * returns. */ diff --git a/mm/rmap.c b/mm/rmap.c index 6480e526c154..9699c6011b0e 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -642,7 +642,8 @@ void try_to_unmap_flush_dirty(void) #define TLB_FLUSH_BATCH_PENDING_LARGE \ (TLB_FLUSH_BATCH_PENDING_MASK / 2) -static void set_tlb_ubc_flush_pending(struct mm_struct *mm, pte_t pteval) +static void set_tlb_ubc_flush_pending(struct mm_struct *mm, pte_t pteval, + unsigned long uaddr) { struct tlbflush_unmap_batch *tlb_ubc = ¤t->tlb_ubc; int batch; @@ -651,7 +652,7 @@ static void set_tlb_ubc_flush_pending(struct mm_struct *mm, pte_t pteval) if (!pte_accessible(mm, pteval)) return; - arch_tlbbatch_add_mm(&tlb_ubc->arch, mm); + arch_tlbbatch_add_pending(&tlb_ubc->arch, mm, uaddr); tlb_ubc->flush_required = true; /* @@ -726,7 +727,8 @@ void flush_tlb_batched_pending(struct mm_struct *mm) } } #else -static void set_tlb_ubc_flush_pending(struct mm_struct *mm, pte_t pteval) +static void set_tlb_ubc_flush_pending(struct mm_struct *mm, pte_t pteval, + unsigned long uaddr) { } @@ -1579,7 +1581,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, */ pteval = ptep_get_and_clear(mm, address, pvmw.pte); - set_tlb_ubc_flush_pending(mm, pteval); + set_tlb_ubc_flush_pending(mm, pteval, address); } else { pteval = ptep_clear_flush(vma, address, pvmw.pte); } @@ -1962,7 +1964,7 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, */ pteval = ptep_get_and_clear(mm, address, pvmw.pte); - set_tlb_ubc_flush_pending(mm, pteval); + set_tlb_ubc_flush_pending(mm, pteval, address); } else { pteval = ptep_clear_flush(vma, address, pvmw.pte); }