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 52DB9C021B1 for ; Thu, 20 Feb 2025 10:51:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BD2056B0137; Thu, 20 Feb 2025 05:51:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B832C280282; Thu, 20 Feb 2025 05:51:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A4AEC6B0139; Thu, 20 Feb 2025 05:51:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 852B76B0137 for ; Thu, 20 Feb 2025 05:51:41 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 343EA1C7A87 for ; Thu, 20 Feb 2025 10:51:41 +0000 (UTC) X-FDA: 83140007202.22.1B3917A Received: from invmail4.hynix.com (exvmail4.skhynix.com [166.125.252.92]) by imf26.hostedemail.com (Postfix) with ESMTP id 97DC8140021 for ; Thu, 20 Feb 2025 10:51:38 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.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=1740048699; a=rsa-sha256; cv=none; b=Oqu6TiaEnvG+kMiS2V9KqRFN1z+NlUTINN/SWWroO6xpmrVpyYdXraVHdCGnyT6jz6J997 tlM5MyTnZUpzwfqFSJbdZ4sHJhH4UQa11LN3018oEC4FcwGKad4MTuY5mx4LVX1BikQBIW TEaAoK31hW027b0By8E5dHvExvBnMu4= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.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=1740048699; 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=GZzmuiJFSye+Q8/4R9ORxvPnW9+5YYI943xQu8NUROk=; b=HQTQ8HS5OQRDuVT+clDjnermcKo66NXTH3Tw8iQSR6XqXOZpQGKYvxnnlvzex56MARc6xf T7WwKJwnx2dhsGTwlijTOSvD0IRwlAG1+wcoGqWzq0i0EcN+rb0EzHQRGuR4VmeBXk+2pl pVwaIusv744VyjzkAKkPo0bJdzraSD8= X-AuditID: a67dfc5b-3c9ff7000001d7ae-92-67b709367d78 Date: Thu, 20 Feb 2025 19:51:29 +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: <20250220105129.GA54095@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+NgFtrOLMWRmVeSWpSXmKPExsXC9ZZnka4Z5/Z0g0fbNC0O/HzOYnF51xw2 i3tr/rM6MHts+jSJ3WPSC3ePz5vkApijuGxSUnMyy1KL9O0SuDL+bPzEXHBLqOJs2wq2BsZN fF2MnBwSAiYSFw+c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B6dUA6ND xMPJh/P5XrDeMbBmajbhsvIP26z6uPpLU9HrU3/q7MRWtaWLX78WeXpTa6r73naO8Pn6f7l2 2ffrcRUd/Hy9ZLrsLKZjeqZHflkp/OORmfxZi0fy5xZO+TudR85aLb13TF79yhIP98QdU97l xk5ubxe6+Pn+xRsmNS1FAnv5FFS3r3kv91qJpTgj0VCLuag4EQB+4dwpMQIAAA== X-CFilter-Loop: Reflected X-Stat-Signature: cbkh51h4bu1miw4b4qcrotwcqd8r75e1 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 97DC8140021 X-Rspam-User: X-HE-Tag: 1740048698-962366 X-HE-Meta: U2FsdGVkX1+0HJxxjalFyTy6w/9pWrWfdPuhihb0SS1AYgED1Fo/x67ZYW43VT6qb/ZC4D2969HkvUsjDMjmOoE1ClMmxoMAmRgI9VYlDLukBj7KjmDV49HDeMHPK0QZR4UDSuWsUkx5/qwHxWaQKKLKmN4mjZO7i3GW8MEKRE8FkFqPiT9oWUtzbDNLlz8suBLmMM/KWnCEBZQdypwcwY1WlX/a80q+WqeGFv/hGg8qZIST1dFaXRPIIBychSsvxchXF4/w6Lw4AnXubj5hs3uaWzINGqhJKTZxtr/XrCM9LGm8dvlhxCfji86tJ1FBc3tpEODE3X8OIlWdXvImgh83neZ02mV8R77uBU/ThnZZ58VUaNLGgurcan+oarMZduoHVGUDjiGXXdl3tRreica1yQogPIbrAcuKMdfX5CFV2t92rH/KsChGxLPzr7deWdsomRyejWDE3rjX4Wmdvr8LCW7jKU/ZrOEfe4qTDCx7rW0kyHkR5kOKLJZwHPDXb9zYNquw5y6L0JSumJJAyoB27NXDnwjpNkNiuMF4e6zVN+0z3APCZOLSAZb4gcel8evm7cSbTzKX0hFb6k+xTuYMi7GzYUA4Sl4EmbTROwWehPfi019Gy7kRBdjb08tx6VwibqeVoKf+9USvoo1NOXOFDUHQVmqdN9VQoUTzPlrfT14lztRnnvzMOdCrj6fLctcNzaK+rjYHo/KRt9VgeH33H+QJJCOMahAlTOQppZnqSPkqrmj97PlholnbejpqhSX4aB8iTBc71Ct5W0O7Nu5NsPWHqRmS/nQTiRHgirD74ytBnMt1MdhIB0O7ISqNmCBRebvPb5o6h3P9s8R2Af07ub1/w2jX6eMrAEZCLEQKiJnBb/5BuCwb1xTKHWTMyvtODHGXm8G4qEfwbH5QsVPyWdpSER7wPTZjMpVNYViYRhfb0R+87zgXbzY5Pt1E6Mthp9vaW8p5kyEQBda ZfGjpNwx nE8Iq 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. It's kinda 'use(= read only) after free' but luf ensures the data of the interesting pages doesn't change. That's what luf works on. Byungchul