From patchwork Fri Aug 4 06:18:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Byungchul Park X-Patchwork-Id: 13341299 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 0BD98C04A6A for ; Fri, 4 Aug 2023 06:21:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80EA12802CA; Fri, 4 Aug 2023 02:21:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7BEE42802BC; Fri, 4 Aug 2023 02:21:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 686182802CA; Fri, 4 Aug 2023 02:21:32 -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 55BA52802BC for ; Fri, 4 Aug 2023 02:21:32 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1ACFE40CF5 for ; Fri, 4 Aug 2023 06:21:32 +0000 (UTC) X-FDA: 81085425624.11.6B2D06B Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by imf10.hostedemail.com (Postfix) with ESMTP id A2144C0011 for ; Fri, 4 Aug 2023 06:21:29 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691130090; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=6aZHKXw09WkOFhxJK04xg9jH6WiL2TNpEhPVoe2aOgM=; b=qWKOl9R/zGTU60gCUV2N91ut3Gq8/J1Pc7KmhZNCUEoIBEj1O1mZf21BpkjuHHz7Id5NTE ebrklpTC6gAPyQms+x8rNlkUfiEJlGwQAYE1+lj7K+zQiHubNuVdUscHM7xzoJtgOCi6YT 6lDibpK2dneHCahQjSSdvh+7Up1TIic= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691130090; a=rsa-sha256; cv=none; b=q9Xj6tupE7F0EMg/vJdY4Q+yHbZ4fwtaCt4RleVabMKImFDXymwy52nPndefU27vKrrBs9 hfK177nQWtcIOHvSTw/gCx6ocHOitQDg/Bv7d8p0Z7o3I7N08mQEQup8eUtLluYAvOlGl/ OTDh2hpG1HbpOmGIuJbIH6xeb1GhpwM= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none 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 ecnksenTJHa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KIrzX3gOFeFMSK6tSi/Lji0pzUosPMUpzsCiJ83qFpyYICaQn lqRmp6YWpBbBZJk4OKUaGIUDVj3yip1Vq/X1Zprx1P8de8XZCuaacViu33i0diPrcgU59tzO y8p5rjPOK8b9+/Xvo6b/Zme5dI2Xh1dt2/ByYmqtFq/iv4NpXqJ7I5P1Vhy76/i6gWm1NwN7 6V63+ftf3ow+NG9lv8iPwIhpE0+J9BgKxRlWVVmzy/hHMrI1G19w8XV9ocRSnJFoqMVcVJwI AKmbY+YWAgAA X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: A2144C0011 X-Rspam-User: X-Stat-Signature: a6tffehsr95egcbzcmma1cos9b79abpj X-Rspamd-Server: rspam03 X-HE-Tag: 1691130089-345818 X-HE-Meta: U2FsdGVkX19CzdhEr1XRhHowFHny2Rkwh6nbRx+C3eBnFYCOVTdsQ0VzTBPYaSX24KLLcB9GrYD6CMTDLp1xP8XMUTvIAVscMcsyVDAIih5erAZPrFd45UOLBZ+t2CsEF7ASG70CH8APqlD/cE78MIvIhlMizVuOHqajGQHsQS/84LiSbWYz2ObYyRb4i1fuefBhQYKHc18w4vSx/LvtViVfBz0F+gX9N4DOmc8+HaRqOiQxgJ2J7f3iNq8isY5I77S1M5MpOvDxbWsqXtxOdnzBXn5TaDwghIqgk83gIU8YIiBOV/YWCDv/JOXDDHL3euQVjAoWzdrApYhWKeOH0DZdH7NDnssjnU4lKRSegB2jOtbCxFbPa/8P/Jm2KmMn3Ld034agJCjCFB9pels56mE7PBAOjgSHzIBZyhcpk8Bl3Rk2TNP7mO3KvIvc6sDv7jxPLOO3hrbzAdBf6wF/AzZDYFJV48oR+L/VlPdCD8xM3SKDi29xTmc/je6gO2X7uNnYrdkKfudy6wBpn14UXIYbbIvENgqaGbM+4DXvI+CwrAn0pk3g0hZJR3m1l7fj46C3tc6CElrlV97GxDVMDz86ERE7Dshhg5kUSh5Y8bnux6wem6mnS9gNM9qBXY67yZcYBq/VyEA/AbaIOio5n3FCG1Vla+doAqlqHytMtM5B8HZAhEKoUCjXvi0THQ1Xl8J31a0/hQZZdh7PxWz4cnH5A8nT2vHY/kQ2AJgXaQOfLYPnGs7XvpMQE2OWfAg/s5EW+M1fkRAb2eCsOlZAy6MVIKhgRKeJjOxKK78CZjS6q4Je29tY6ZDowHDPbJJ5Q78YDJpaH8R0fny8hAiCNcD3oDNxvO50GPEcUaxbBfDXobcFehpGqNYLeXA9CeT7UY4vrVcVfGyprc1t5XMNAg== 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: 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(-)