From patchwork Mon Jul 17 13:10:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yicong Yang X-Patchwork-Id: 13315656 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 3F66AC001B0 for ; Mon, 17 Jul 2023 13:12:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D371E6B0072; Mon, 17 Jul 2023 09:12:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D0E0E8D0006; Mon, 17 Jul 2023 09:12:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD5D26B0075; Mon, 17 Jul 2023 09:12:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id AEAEE6B0072 for ; Mon, 17 Jul 2023 09:12:21 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 59EE91A02F2 for ; Mon, 17 Jul 2023 13:12:21 +0000 (UTC) X-FDA: 81021142482.12.75186E8 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf02.hostedemail.com (Postfix) with ESMTP id 953C38001B for ; Mon, 17 Jul 2023 13:12:18 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of yangyicong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yangyicong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689599539; 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=fhZ+V4S52X/kXuQV51PeKIPPTeN+0eX+HbKE+khnxNc=; b=rWPIuNPoMM4UJUPu0lZTg1p20KQ4ZRK9eZGQVoyq78xPZ53z8Qz+HUqrwz0AZMyeyKIvV8 4JwMRnsqfXHQizgX+Ao1AY2nOiyTfbPFMIRzNNB5l5qbdqCeCnLWgVBF9Huduy3XYeg8Pk VRH8z7NkfEbAaeTP3mZENGIRPoHUHJ8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689599539; a=rsa-sha256; cv=none; b=VbHRf5PG0EUn+sRkmDFsOGI9uHehtV8ExR+eNs/qvukpdE60OLNJQm3vZ7B+n6G2Ft9D76 wp6Eefoo7HA4HrEijyVcLmjQf09UiMT8NQJFCqIhx2wjdTWI2ZkB3mqHUSkMs8rAVomJJ+ vDt0nh3lnhgn1RiPj6ZTXnPNYq/gvHw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of yangyicong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yangyicong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from canpemm500009.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4R4Mps5c95zNmN0; Mon, 17 Jul 2023 21:08: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, 17 Jul 2023 21:12:12 +0800 From: Yicong Yang To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , Barry Song <21cnbao@gmail.com>, , , , Subject: [PATCH v11 3/4] mm/tlbbatch: Introduce arch_flush_tlb_batched_pending() Date: Mon, 17 Jul 2023 21:10:03 +0800 Message-ID: <20230717131004.12662-4-yangyicong@huawei.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20230717131004.12662-1-yangyicong@huawei.com> References: <20230717131004.12662-1-yangyicong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 953C38001B X-Rspam-User: X-Stat-Signature: wntp5fschjtumatgfwfr9pnhiqbqwbd9 X-Rspamd-Server: rspam03 X-HE-Tag: 1689599538-788147 X-HE-Meta: U2FsdGVkX19cWDgp9hp196Gh0+FiuC0Js3+7rh6D2+ZrhurXHFojCuOTn4772Z7FfgLBBnFvscuTNkjb86NGHiKcip/U/ZRg/cGanrG2wHBn/qg9Yo2Hj7BwqSSOckTLQA4atCfKU9bxMU29YjUwwWhK+NDHfdvNhw4vqGOCUfWjDK6vRapCGOHMHkalZWUJKxf5ac8rPMe/EhHmWca0o0VgRdJ9tq5saAtauR5sI1DXcpcJ6MfdETauAHi/2CZKUCZMXnxiC3s+oKuldsv0CuX5kkiuz6LO5ZOd3oE4NK1fIwElJtlQWPauOSqEVWw3euyzke8IbjlLeXBeIXq8dPx7z3RR6ZFyWCnliGtgqlVPCLLswfsxdC3hl3EpUfezivo/TJAGmGXjBCxOlHdqYHHO5jibYFbl7Iq5Ia6DFgRUJvddPnZ63LZwL78KxYdlLMOcsegDJUpNJb6WmHDQ7mEaXdwvBQ64q4MWLqBxg3xdnPzINeVtfIJrmO9KosyciT1IVFtlambRDE68RL8NbmpOLBb19T9jMISYWQOWca6mLXhxbP3zXUHppmpzebVG6LU7N8IwHcz7/QGfkIcVaUXuGdplR6WdXR5XwekF1E80wkyE2UJ+pdgDHplmR7pmNoU1SFA2577czEpXQNIGwsEeUAWFPdKxRgiuhrxqHC6JKhs8bQQlgNeGGEPoM6WCJNo3+R4CX56Uk/XOSKFNB0LMcSjiljYMZCv28JQopfXYPiuJX5HvastK0yxsgTkHGRVnKWG318Qoa0ZllJhiV0fPAv3lj+KlTgZ/pGz/QZ/QhPoDtJndo7NxjzOrkf1zn3BmWXqXNsRZ42eDaiUWaagEF21iRNUuH6IemfIyORuVdJVGddCdd4WFFOK5vY8+7yU4cGMYeCmo+2Jq3YnpjU6hmn12ru93uEja/mfl9WhUMXowHIaMovOctyMr5BtEb/Ev4aBzEdKCvuNxDj9 SDcmOUVj 8iABh9qKNDooRcpfx5nruWH9tP5O4/ZcIzzq06bGRnbViK3ZX9n8yYJSxhyczlmkkokBTanGfzWMiDvegufoAWowYto+7isAXZ3d9tkeO1Yxo8pOZp8xSXmat9Yke9ElsHsEdDSS999qKBVndO3/wo5dG7upynaTIUFtDGg1neV2uCfolqaCJk5B59jGonCbDrIhxx/zsd+JZ1k8dYidr1Yha75kYFMNbRKIRTxOmvTMDEXo= 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: Yicong Yang Currently we'll flush the mm in flush_tlb_batched_pending() to avoid race between reclaim unmaps pages by batched TLB flush and mprotect/munmap/etc. Other architectures like arm64 may only need a synchronization barrier(dsb) here rather than a full mm flush. So add arch_flush_tlb_batched_pending() to allow an arch-specific implementation here. This intends no functional changes on x86 since still a full mm flush for x86. Signed-off-by: Yicong Yang Reviewed-by: Catalin Marinas --- arch/x86/include/asm/tlbflush.h | 5 +++++ mm/rmap.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index 1c7d3a36e16c..837e4a50281a 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.h @@ -284,6 +284,11 @@ static inline void arch_tlbbatch_add_pending(struct arch_tlbflush_unmap_batch *b cpumask_or(&batch->cpumask, &batch->cpumask, mm_cpumask(mm)); } +static inline void arch_flush_tlb_batched_pending(struct mm_struct *mm) +{ + flush_tlb_mm(mm); +} + extern void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch); static inline bool pte_flags_need_flush(unsigned long oldflags, diff --git a/mm/rmap.c b/mm/rmap.c index 9699c6011b0e..3a16c91be7e2 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -717,7 +717,7 @@ void flush_tlb_batched_pending(struct mm_struct *mm) int flushed = batch >> TLB_FLUSH_BATCH_FLUSHED_SHIFT; if (pending != flushed) { - flush_tlb_mm(mm); + arch_flush_tlb_batched_pending(mm); /* * If the new TLB flushing is pending during flushing, leave * mm->tlb_flush_batched as is, to avoid losing flushing.