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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DA23C021B3 for ; Thu, 20 Feb 2025 11:09:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BBAA34401D5; Thu, 20 Feb 2025 06:09:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B42604401D8; Thu, 20 Feb 2025 06:09:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BC094401D5; Thu, 20 Feb 2025 06:09:48 -0500 (EST) 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 7AB0C4401D4 for ; Thu, 20 Feb 2025 06:09:48 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2C5AD120FE8 for ; Thu, 20 Feb 2025 11:09:48 +0000 (UTC) X-FDA: 83140052856.27.3EE9E3C Received: from invmail4.hynix.com (exvmail4.hynix.com [166.125.252.92]) by imf13.hostedemail.com (Postfix) with ESMTP id C7A2F20010 for ; Thu, 20 Feb 2025 11:09:45 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.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=1740049786; 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: in-reply-to:in-reply-to:references:references; bh=J6iCZ5Az7i/HtI1lssUh+mifvIoPTCxweCdLkEY20q8=; b=XA/3R3/mROLY9nYt8PoykgBk7Ki26SDgksFCqhzP/jS5/2VcZlbrh1GH676mUDOP2C3RJu /re2gShku8OT8JFC+L4/fRAnZFkDPD59h0uN4lbJWGWAUHegzdMncVUJwQPGL53uM1WEZj c29tCpd0IRJQ3hVbLlR0ctjKht03FU8= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of byungchul@sk.com designates 166.125.252.92 as permitted sender) smtp.mailfrom=byungchul@sk.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740049786; a=rsa-sha256; cv=none; b=UzFIYyqp7OpQGo1Mi3+UsUSJ+n9KqBtHOUcEsOV8957fYnodNtTnATVpJ+NpQ//PLb1FJd lMX3h9mGtlDZf2rPdDVIBSTSeMjZe5XWDQV1zfiUWqcgYuSWPJ+4BcaOjywHdin89Twu2G /SYhZujD2Ub8HXzeDVaXHNMGplZys44= X-AuditID: a67dfc5b-3c9ff7000001d7ae-54-67b70d741b4e Date: Thu, 20 Feb 2025 20:09:35 +0900 From: Byungchul Park To: Hillf Danton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel_team@skhynix.com Subject: Re: [RFC PATCH v12 00/26] LUF(Lazy Unmap Flush) reducing tlb numbers over 90% Message-ID: <20250220110935.GA64704@system.software.com> References: <20250220052027.58847-1-byungchul@sk.com> <20250220103223.2360-1-hdanton@sina.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250220103223.2360-1-hdanton@sina.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOLMWRmVeSWpSXmKPExsXC9ZZnoW4J7/Z0g3df1CwO/HzOYnF51xw2 i3tr/rM6MHts+jSJ3WPSC3ePz5vkApijuGxSUnMyy1KL9O0SuDJe7DnOVPBCqGLH3Y/MDYz7 +LoYOT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yxJzU5NLUgtgskycXBKNTAG f/D5+Ln72MWFbFsmPA9dIvVF2virVPP7zXJm7FEdnFtnZvp2bLkbzFuxdsOnP/ufMitz7rh9 NvKL3Yk959kt5/VsVZ9uuMPWVafHK5Tnr9kZBff6s8+Mt6ieWhNl/nieS8Vf2dUnFPe3e3iX /MhY4vdt7sMQ5gZbpX9FJTuVG8U+rLTN852sxFKckWioxVxUnAgAN+jY2jECAAA= X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: C7A2F20010 X-Stat-Signature: smotpuyib987kz5jcpf97cgg9eaizgct X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1740049785-86889 X-HE-Meta: U2FsdGVkX1/J0+WP0rMsr5b/pAvangwcMztRZ5qRlJpoxXIIuNfvbXCUbOpXOM1UgS7SJFQDUFaHwPzD20E6HC/quhSBbJ6CELCLK8UlvetInkn7jjgZLXq3LAGgcVKiRB8bnMV24JBScUNoVMcKXEivDHHAWtF0hjIV53r2VQDUwPrJ6pOvDbtnV3NUvwAfw0Hzw4cBSdTmAc7VBpOGgBP6S3YfstVstMO9OBP3uH91SKfWk3B1zr0cgBw5LxTvSi7l7TgK00sQKKHOy2NFnXeqpZvgtD2FukuPy03CV7/jPCCf9OfS0SVKakOhZ+NOpMNp7MLxgsU/Zrmr/GMCNoZHd+i+XyxCruen+G43WURVT4XELYF94pJdU+8eFCc+WmRhXrLgEMYEWWhwwuQaLvZpLqo42uG5wOWzNC3k6Fgl/YpCrC0PoDUk0LOjn6D/+fZuz4kruxc7QvXfGhP68+I00CEPZZrAQPMDlMOr0vu9cmXlJcuXDmPKe2QMUUIpZfgG37YUUDxp15loXU1wXrSD/cY8Ig0bvkDdt9YQYD3D5fs/YhXQutI+NxD2B7jbxWazjaERnKw6eIkYrXxS+/THKb8JF2ZOTYg9+KGb6WsUVPMHX+S5xsiXDTEx7SAMdpd3zEegdldr8evHan7Lvuwme/wtVRiz/GzzcbsOhGcFBBIgDr3FwOWzRjoKZZED5xZdpmMBLK9ZCjmRR5/jCly+UbeZdxRSdchXIO2SY2ubKkZSPUt5STNdvh8Uddo+NMR6gCCegyDxQUwisZlFkggh97L5YP4/TWPLjx7LDdvnwP/zRS8aARh2ExdPxkHfrZ1KepijcEYjBIVE8CZy9a/dnGvD/5ohTclEsZNzK+iHwec4JeQFQxr/cd4mQSdJXT3q+aj67rKN/m7X1vRJfDdlpFtb2APg6Ha3T7xgtcNR+hzesjGRm+7GMSlSMyenz7LyjsyTy0cBMko6AJM JVXgXxzE CnOwH 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: List-Subscribe: List-Unsubscribe: On Thu, Feb 20, 2025 at 06:32:22PM +0800, Hillf Danton wrote: > On Thu, 20 Feb 2025 14:20:01 +0900 Byungchul Park > > To check luf's stability, I ran a heavy LLM inference workload consuming > > 210GiB over 7 days on a machine with 140GiB memory, and decided it's > > stable enough. > > > > I'm posting the latest version so that anyone can try luf mechanism if > > wanted by any chance. However, I tagged RFC again because there are > > still issues that should be resolved to merge to mainline: > > > > 1. Even though system wide total cpu time for TLB shootdown is > > reduced over 95%, page allocation paths should take additional cpu > > time shifted from page reclaim to perform TLB shootdown. > > > > 2. We need luf debug feature to detect when luf goes wrong by any > > chance. I implemented just a draft version that checks the sanity > > on mkwrite(), kmap(), and so on. I need to gather better ideas > > to improve the debug feature. > > > > --- > > > > Hi everyone, > > > > While I'm working with a tiered memory system e.g. CXL memory, I have > > been facing migration 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 migration through hinting fault. I thought it'd > > be much better if we have a general mechanism to reduce all the tlb > > numbers that we can apply to any unmap code, that we normally believe > > tlb flush should be followed. > > > > I'm suggesting a new mechanism, LUF(Lazy Unmap Flush), that defers tlb > > flush until folios that have been unmapped and freed, eventually get > > allocated again. It's safe for folios that had been mapped read-only > > and were unmapped, as long as the contents of the folios don't change > > while staying in pcp or buddy so we can still read the data through the > > stale tlb entries. > > > Given pcp or buddy, you are opening window for use after free which makes > no sense in 99% cases. Just in case that I don't understand what you meant and for better understanding, can you provide a simple and problematic example from the u-a-f? Byungchul