From patchwork Mon Jul 10 08:39:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yicong Yang X-Patchwork-Id: 13306474 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 CCCC8EB64D9 for ; Mon, 10 Jul 2023 08:41:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A4DC6B007B; Mon, 10 Jul 2023 04:41:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52E0A6B007D; Mon, 10 Jul 2023 04:41:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 37E816B007E; Mon, 10 Jul 2023 04:41:21 -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 277556B007B for ; Mon, 10 Jul 2023 04:41:21 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id EDB891A02FF for ; Mon, 10 Jul 2023 08:41:20 +0000 (UTC) X-FDA: 80995057920.05.B387EF9 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf21.hostedemail.com (Postfix) with ESMTP id A9F881C0018 for ; Mon, 10 Jul 2023 08:41:18 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of yangyicong@huawei.com designates 45.249.212.189 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=1688978479; 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=3zkG7LH91Hl6KKWXw8RhZ4+BU82myW+34WC1somP9BI93kbDaE4oOBkDh/eGAgSTk2/nFH Wd/xkUBwl8aOzeWWCIBmhSCV49VC9ISjL+Mgy+IbatySOuIzJKDG6tc43bEsWI33B6YWLU jBPv18vUG7MVXegA9VLdGQ10EC0Q+RQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688978479; a=rsa-sha256; cv=none; b=si9i/iuiBmgEuC2o0o3abpQCwDY/mgpcDNPcW/NvBYQYCrM2vohsmU3OT6i/KeDi4Mff/s PdfQBTTQkJqSvsbvQWZ0T5xnl+lCyDmLw3/lXdmj5diHoWzDFvYBCW2Jd5d7jygZ/PwAHP MRzH7dIqEno08TcVXGYDrXg30t2JiUM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; spf=pass (imf21.hostedemail.com: domain of yangyicong@huawei.com designates 45.249.212.189 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.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Qzy8Y75pSzPk2S; 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:11 +0800 From: Yicong Yang To: , , , , , , , , , CC: , , , , , , , , , , , , , , , , , Barry Song <21cnbao@gmail.com>, , , , Subject: [PATCH v10 3/4] mm/tlbbatch: Introduce arch_flush_tlb_batched_pending() Date: Mon, 10 Jul 2023 16:39:13 +0800 Message-ID: <20230710083914.18336-4-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: A9F881C0018 X-Rspam-User: X-Stat-Signature: cr6bmrpkgysx7nd8mht4kowzu1yfkedt X-Rspamd-Server: rspam03 X-HE-Tag: 1688978478-988674 X-HE-Meta: U2FsdGVkX1/BvuUxRwetBoH33nMn00sPlWuZsNYIJU2+jd4PYl3CHXiywNUxkjWzliqHqvP97Kzi5D4BkrO6gDCwXJWDg9SUv/BI1UIYoywvr7SdmUqkwqoIlkiox1w93iHRnSI2Oqsr8MayBhrLaqQtF6gWYh+B9ThQsLt0okbQcoRziMbMLVAiq5d5k8EICUlFjBxatTr2gc0zAMK87cWEIEtypuCnKdB5MV8fZGNzAlSH/RXNRPwnrzLyUCgnoPaiapyxGK7Bek+yahG/pw/b27yuDSzO886d8uHrySnt5P5axDIIypwcXOQGgKxwhAEsR1xqi8fFRxCQ0yjWGC8K1aePxMC7YiGR6pVc/oqHVesaTdMLqQlT0A/PDmFPdACZzPlhHL5xvFQwrpZOH5KAiDM9TTqPxNAcNfDhmPPYcpN49r2Mk1xmv1CADjmFTSqi2H2DBqHGGLFaeqyTuT3U3yzKnnWrU6iXplwpdf0atIIqPuFEJa7xvGKf5oB0r1TT3fn+w3+B4GRM8LVUFGoQ8pcsiQ0RFr46GTKtJriSWYE4lcdUTXdh7alb563+kz7V/gI+LTUNxQSymLgfNYy99ZBJfAKCwoofp3k/yoE4Z0G2RgZJE5kCkXl05OEqSjM5Ujn3+LLPd7tTNVytN8lTqPsONhcbSBT7rITBwMiJ32QmtFxbd3atm+6j3MCe4OogofuzET3rsSzWRmLoR4pg1WI6bfuat77YJM3hBpyceYO+rYvpxxVs7/lR1w4hI2EZnv+tIILxm5HFe6hmL/yloJhROQHU572Ab7e+lJGJjWWwvp3Z9Q/2vCLcHHiXJDoJslOHJctXyuc/7kHtM7WDKzRZrmltdxgiX+lBJiFehMKzOpn47XUtZVFzFeHczo24n7Fw7gwK7ib+nnzg1bvegug1/zzGni7pmaXDk10uJ/G1RET5ZjhWTWb0FmYvSafZm4NDCeX624cBkzJ FGcBo1be TapVDvMhNC/mgctis8rD+vl9I/JT0w38KT6mn/ygdj8dW+kftEsBTyRAvWp1esYHmfn5M4elD5S4AKYjZ93n5ZnZTyRBfbSEmdb9KAld/sWEdN0HNhHd06A3fXUWpaXUd6RqGFr+WNj0qNsX3E4VXxauKgOBNBRb2fxYWj7ms/j9pNNOhyGngwh5cjLxb2rI+qtan9oPHwBbkPPt3OkBwrzJe1Ir2Vv8UiphJ/8o9AXaSzjA= 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 --- 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.