From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCC14C04A6A for ; Fri, 4 Aug 2023 06:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232571AbjHDGVf (ORCPT ); Fri, 4 Aug 2023 02:21:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230002AbjHDGVc (ORCPT ); Fri, 4 Aug 2023 02:21:32 -0400 Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0F774E70 for ; Thu, 3 Aug 2023 23:21:29 -0700 (PDT) X-AuditID: a67dfc5b-d85ff70000001748-31-64cc98e6931c From: Byungchul Park To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: kernel_team@skhynix.com, akpm@linux-foundation.org, ying.huang@intel.com, namit@vmware.com, xhao@linux.alibaba.com, mgorman@techsingularity.net, hughd@google.com, willy@infradead.org, david@redhat.com Subject: [RFC 0/2] Reduce TLB flushes under some specific conditions Date: Fri, 4 Aug 2023 15:18:48 +0900 Message-Id: <20230804061850.21498-1-byungchul@sk.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprDLMWRmVeSWpSXmKPExsXC9ZZnoe6zGWdSDPbuMbSYs34Nm8XX9b+Y LZ5+6mOxuLxrDpvFvTX/WS12LN3HZHF910NGi98/gGJzplhZnJw1mcWBy2PBplKPzSu0PBbv ecnksenTJHaPEzN+s3jsfGjp8X7fVTaPrb/sPD5vkvN4N/8tWwBXFJdNSmpOZllqkb5dAlfG lB0L2Ase8lfMftXA3MC4hruLk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Zprx1P8de8XZCuaacViu33i0diPrcgU59tzO y8p5rjPOK8b9+/Xvo6b/Zme5dI2Xh1dt2/ByYmqtFq/iv4NpXqJ7I5P1Vhy76/i6gWm1NwN7 6V63+ftf3ow+NG9lv8iPwIhpE0+J9BgKxRlWVVmzy/hHMrI1G19w8XV9ocRSnJFoqMVcVJwI AKmbY+YWAgAA X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, While I'm working with CXL, I have been facing migraion overhead esp. TLB shootdown on promotion or demotion between different tiers. Yeah.. most TLB shootdowns on migration through hinting fault can be avoided thanks to Huang Ying's work, commit 4d4b6d66db ("mm,unmap: avoid flushing TLB in batch if PTE is inaccessible"). However, it's only for ones using hinting fault. I thought it'd be much better if we have a general mechanism to reduce # of TLB flushes that we can apply to any type of migration. I tried it only for tiering migration for now tho. I'm suggesting a mechanism to reduce TLB flushes by keeping source and destination of folios participated in the migrations until all TLB flushes required are done, only if those folios are not mapped with write permission PTE entries at all. I saw the number of TLB full flush reduced over 50% and the performance a little bit improved but not that big with the workload I tested with, XSBench. However, I believe that it would help more with other ones or any real ones. It'd be appreciated to tell me if I'm missing something. Byungchul Byungchul Park (2): mm/rmap: Recognize non-writable TLB entries during TLB batch flush mm: Defer TLB flush by keeping both src and dst folios at migration arch/x86/include/asm/tlbflush.h | 9 + arch/x86/mm/tlb.c | 59 +++++++ include/linux/mm.h | 30 ++++ include/linux/mm_types.h | 34 ++++ include/linux/mm_types_task.h | 4 +- include/linux/mmzone.h | 6 + include/linux/sched.h | 5 + init/Kconfig | 12 ++ mm/internal.h | 14 ++ mm/memory.c | 9 +- mm/migrate.c | 287 +++++++++++++++++++++++++++++++- mm/mm_init.c | 1 + mm/page_alloc.c | 16 ++ mm/rmap.c | 121 +++++++++++++- 14 files changed, 595 insertions(+), 12 deletions(-) -- 2.17.1