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 5F136C021B1 for ; Thu, 20 Feb 2025 11:49:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6F9C4401E2; Thu, 20 Feb 2025 06:49:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DF9114401DF; Thu, 20 Feb 2025 06:49:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC1214401E2; Thu, 20 Feb 2025 06:49:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AA2C14401DF for ; Thu, 20 Feb 2025 06:49:43 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AEEA4B68A0 for ; Thu, 20 Feb 2025 11:49:41 +0000 (UTC) X-FDA: 83140153362.15.246644E Received: from mail115-24.sinamail.sina.com.cn (mail115-24.sinamail.sina.com.cn [218.30.115.24]) by imf23.hostedemail.com (Postfix) with ESMTP id E43D6140006 for ; Thu, 20 Feb 2025 11:49:37 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of hdanton@sina.com designates 218.30.115.24 as permitted sender) smtp.mailfrom=hdanton@sina.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740052179; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aBfFJS0qkleSaJGj9g72Kmdr3xSZy52F9Guh9LI2ZsA=; b=yW9AhdALOoA4OGc0rkad4+QGmUovGVpOAN063BTP7iK491KEXRjPtqsTYzakwZhsPWmDqr at3uHZVkY5v+cuuvxPVGXWMyUESTZSeDS/WB7KYMihSDIACTQqM3ONyYTVfEYFjg8KHJLm ghN4fIZLQ5A/sTBcWEOuYBl+sHeUj+Q= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of hdanton@sina.com designates 218.30.115.24 as permitted sender) smtp.mailfrom=hdanton@sina.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740052179; a=rsa-sha256; cv=none; b=b7fXI2NI4v7zJf/80eSHzfxgjd3kx6YuwsWTDpuWmox5krYSIw/a6Eah2uOtYekv2/ETCF 9zqltORzQoAQxfGZIWzkIiuqM1AHMbFDWP0dsUzzn1PwsRxhdbBNFIT4fnL05cO1WXfu7i tIMJazWd48vwZH42ppJR5Djz2eYx4vE= X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.88.51.172]) by sina.com (10.185.250.22) with ESMTP id 67B716C700007EBD; Thu, 20 Feb 2025 19:49:31 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 5901547602708 X-SMAIL-UIID: EDD8DF5FFF434C329343F466FEF693FA-20250220-194931-1 From: Hillf Danton To: Byungchul Park 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% Date: Thu, 20 Feb 2025 19:49:19 +0800 Message-ID: <20250220114920.2383-1-hdanton@sina.com> In-Reply-To: <20250220110935.GA64704@system.software.com> References: <20250220052027.58847-1-byungchul@sk.com> <20250220103223.2360-1-hdanton@sina.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-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d2XE+nJCf1Md3NixlJ6dU s24RRjbu 46OSLV1dgMjRNbNy8fiXEmG93Cbbdub+gdx8kTtsGIvs+Bvy6noI1swTA3v9vLLxJyNkCeyezwpi6m8LdUDGbZHxPau8KpKBsaIedanvz65w7tCnCDC4wXM9S2Z5XmUjzgwFfJZM3ooiMtJx/Ss+g1r1qydDLZPn7sZaUWQf0DR56Yb3MwmQuP66A4iyJwic54TDeY8AFE/gO6FBNc9/Rh2s0iy5VSHbdQYftF6XyDtMnjea1X9BBBPilmQ== 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, 20 Feb 2025 20:09:35 +0900 Byungchul Park wrote: > 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? > Tell us if it is illegal to commit rape without pregnancy in your home town? PS defering flushing tlb [1,2] is no go. Subject: Re: [PATCH v4 29/30] x86/mm, mm/vmalloc: Defer flush_tlb_kernel_range() targeting NOHZ_FULL CPUs [1] https://lore.kernel.org/lkml/20250127155146.GB25757@willie-the-truck/ [2] https://lore.kernel.org/lkml/xhsmhwmdwihte.mognet@vschneid-thinkpadt14sgen2i.remote.csb/