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 75EF5C3DA4A for ; Thu, 1 Aug 2024 12:53:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6D386B0088; Thu, 1 Aug 2024 08:53:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E1C2B6B008A; Thu, 1 Aug 2024 08:53:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C95BE6B008C; Thu, 1 Aug 2024 08:53:26 -0400 (EDT) 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 A70326B0088 for ; Thu, 1 Aug 2024 08:53:26 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 52C3E1C40A6 for ; Thu, 1 Aug 2024 12:53:26 +0000 (UTC) X-FDA: 82403667612.05.9E1A247 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id E5AC9140003 for ; Thu, 1 Aug 2024 12:53:23 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jT6ZvQdR; spf=pass (imf26.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722516775; a=rsa-sha256; cv=none; b=cVs/37wvCOT3mVHyfel1Sn8nStGVY3RJrJiL4bT6QZK0ZYx/G/ljzNKllGBfnRfsbpc3tP J4flJIbyMWq5BSUzujUNJNwRlQ9DMZH6wgUjaOSqJagHuzWn8JVkhvoyo2cyDF0/ZMATS0 kGJsfGCr59zV9DkiR8Ay0d3RMgBSgN0= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jT6ZvQdR; spf=pass (imf26.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722516775; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tY3FTh7vOTxS/LhqhyyExp9r4gGoOfraF1glml6en7Q=; b=xDGL4OaPzy77D7arbDIEj+wOunZ/AmAoFNyAb+FvmwQy12h5A9KbX0JKNjizsTJURTQzw3 zpT8GwNHJwMM3IWrxy+TN/8QLcAcOhXW++VDUbGRWuMtWO575jpFDQpenR4cztzU7jaNEt ILYe0AgBuRuUuyFyeqUuGAZ37yPnzhU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722516803; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=tY3FTh7vOTxS/LhqhyyExp9r4gGoOfraF1glml6en7Q=; b=jT6ZvQdRvro49pEJY5NrOAZPXhrtbv9EdybwviTXa/qHFcwuJFvXl2/scux24jm/bgfwM5 t9DapaXI47s0W5F2/iFetcXTJy1DftLXlC6CYLdYjupcBgMdwzN4ZtEDidahaWcaA5cnZ5 K1G55R0xigFgDkwn9cLQNJA7XsyIyGc= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-413-rJQT7CO_OCmqQ-yflb4O9Q-1; Thu, 01 Aug 2024 08:53:20 -0400 X-MC-Unique: rJQT7CO_OCmqQ-yflb4O9Q-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4281ca9f4dbso37461925e9.0 for ; Thu, 01 Aug 2024 05:53:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722516799; x=1723121599; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:cc:to:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=tY3FTh7vOTxS/LhqhyyExp9r4gGoOfraF1glml6en7Q=; b=tThuFPqdALPc/te6cvLu/4LzGrHhY72i30SdCnqnyNe5X2mAv0pkjGnQ3LilLhoOqr I0LNkxucgy+9goUjV1/BQ4rFqG4/7h+V+3YtqrXihI/BKQBCprXdGSs0o4PqqxsyCeHv k+BFAxBZW1dOh7kO6xds7ZPvB2fOKDCGk5kQuuiTAXvBKfCFuukvF88Knuzawg91yF19 LDyUTq68s6vQOA+Op+eVq7B1UOQALNkvLVp047TNsgsxGb4neNWuxWFItXYbQwjBVG+4 WRACM0repP85eoryZvBhXC1hzwpjZTZyEfAUSMNa46rFPh9+jt2YvDx1C352flI63dER qRwA== X-Forwarded-Encrypted: i=1; AJvYcCXVQM9uCTZeP5t5VIdQiVVSpeEbz9AljQYbgeCpYPYGci9saiPWViPYtpbilaiyuSq0weRa5gEuj7rSJcLi6tF5HOE= X-Gm-Message-State: AOJu0YyTGzgZ/AvibYIvPzdjR7qsSDESOdlCcT1Nn7ld8J25bSvS4nnA FlbWifDQXUA4ZHhIuP2nEW9lTlp0/qHBBBVjErlumwu3sm9HbaSWN+9HUkRRAdM7LE6X4YXtlPm 5mymu9X7+PYV1MaSO7uSP53m/dhCZz3ma/QC+APuVhDvxokonZZ1NMwyO X-Received: by 2002:adf:ed11:0:b0:364:8568:f843 with SMTP id ffacd0b85a97d-36baaf46ff3mr1747172f8f.59.1722516799370; Thu, 01 Aug 2024 05:53:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXkQzuiBajNhJVSP5UhLjv2gX0jPjX0Kpt2L7st5acq9l3/tBwA4i709DCI0A4Sa8f6WF5tw== X-Received: by 2002:adf:ed11:0:b0:364:8568:f843 with SMTP id ffacd0b85a97d-36baaf46ff3mr1747154f8f.59.1722516798788; Thu, 01 Aug 2024 05:53:18 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:5c00:e650:bcd7:e2a0:54fe? (p200300cbc7075c00e650bcd7e2a054fe.dip0.t-ipconnect.de. [2003:cb:c707:5c00:e650:bcd7:e2a0:54fe]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b36858197sm19818391f8f.68.2024.08.01.05.53.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Aug 2024 05:53:18 -0700 (PDT) Message-ID: Date: Thu, 1 Aug 2024 14:53:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 0/1] mm: introduce MADV_DEMOTE/MADV_PROMOTE To: Zhangrenze , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "akpm@linux-foundation.org" Cc: "arnd@arndb.de" , "linux-arch@vger.kernel.org" , "chris@zankel.net" , "jcmvbkbc@gmail.com" , "James.Bottomley@HansenPartnership.com" , "deller@gmx.de" , "linux-parisc@vger.kernel.org" , "tsbogend@alpha.franken.de" , "rdunlap@infradead.org" , "bhelgaas@google.com" , "linux-mips@vger.kernel.org" , "richard.henderson@linaro.org" , "ink@jurassic.park.msu.ru" , "mattst88@gmail.com" , "linux-alpha@vger.kernel.org" , Jiaoxupo , Zhouhaofan References: <3a5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CL4YjVoylWiBNknvQWBXS lQCWmavOT9sttGQXdPCC5ynI+1ymZC1ORZKANLnRAb0NH/UCzcsstw2TAkFnMEbo9Zu9w7Kv AxBQXWeXhJI9XQssfrf4Gusdqx8nPEpfOqCtbbwJMATbHyqLt7/oz/5deGuwxgb65pWIzufa N7eop7uh+6bezi+rugUI+w6DABEBAAHCwXwEGAEIACYCGwwWIQQb2cqtc1xMOkYN/MpN3hD3 AP+DWgUCXw7HsgUJEqkpoQAKCRBN3hD3AP+DWrrpD/4qS3dyVRxDcDHIlmguXjC1Q5tZTwNB boaBTPHSy/Nksu0eY7x6HfQJ3xajVH32Ms6t1trDQmPx2iP5+7iDsb7OKAb5eOS8h+BEBDeq 3ecsQDv0fFJOA9ag5O3LLNk+3x3q7e0uo06XMaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <3a5785661e1b4f3381046aa5e808854c@h3c.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Stat-Signature: omechp6rncdxb1h1c419e1wr35xposeh X-Rspamd-Queue-Id: E5AC9140003 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1722516803-29561 X-HE-Meta: U2FsdGVkX1+L3OIOSxA312WoJODLYCsHZNFZL+m6D3xLzs8vEaZvTka1txyebl4Si/mdDDUBbYq90yvROQJ5uwgh+UtvTeZH12rgZtkLl6cQn1PZEJeD3P6Aez3gGYx+rO52PJjRQmoVXb+hB7dv57FgqtNVBYe7lD031im3Uzm4A32nilKxLvuub9eIWVsWNDGN1vOkke3NMS5DxPxG8wPiv3FYRf8rDk9VbAqEdoIpye5czGLVY177metWjxIFe/21gSg7dewfl01JjhtGDG0UNQJoing+Vh34UK8MR/p4m1PlAu+vhHpdllmK2VqKQYpf4N/mQLN4LZUwFWzh3hlMBl5rmIztAEDvpLtcDOZUtZ9FyT3/PZGnBtXKCs3rSIl6Y9NcqegFHxi8gWm4wJu5AkhHyi0AXlshVKfQLuHLWHXBvTAfEWnbibTtbAgBpGSDRhzD32ao1VIMRAgCp3ipCgoD4gNELyLAAbriQqPnzTq7kRE6QkGHp0Mnn/3JCfOYfsLBWfrQjtHxtY2o3Qz3NYduBvaBPEqBhHD6XA2jdBrAt+gK3Ig9Pq7V2G1xdJICRCM1AEzo3Wgj3tC4NxBvpWwOjXP2UEaLGxSAfHR0VmvbWSY2EsWmyf17Tb9bqau8vUMwfQGo3TJKeyHhp5i0wf+QwePj5CCnL971ULDENXY8fzuQFKPfecET0TkcDylxAwQY1ramQ54Fgi230LR37sdk8xjaVZa1GA0PNqQEMAOQAaTmrzY/S+f1EGgu1qt4To/l8EGF3zIcFx0aE4LxO90tZdicKZ9AH7GZS5OVPFELFoICvegva+l8czsa9dO/tnopJ/aDcyxW3jxAQc2m4jwPRkjICuPMmJoi6vYSkM+Mx9kDaZ0T44CzHMaCwhu1NZvBgVMskESnuqINuxNUFvmF7LsC7GIwePLNcBovsyjImJNlLY8bYrt8ypfEHmqLbyosRi7a5hz87Dj aLd0qiXO v59tGsBWdEy246OYAlOEzTAf0mHukof9iftZtUZcSTeBoxqQPXEJW5+ty3cYQLvb0NAE1nlIrAPZ3uhDcv2VIdBaCsU2ssCtqqlQLJcPnzSexeab+IIoBCrss65xKFn8OClZ9eyw2lolTQBxfo31oMTidW2pF1z/JhLDDL4BHZHB4k449QFB6wZ7RHbC0FvSQCk5stLvbKTqmNWLU/w8fbCLcsklnb2PHVuL94erK28IvLevbToJrgh08ALFE7rfBoEbt5q/+luMKFiuiCHWif6JfcoGSG5W4LQBgXstjQtYZ2A+LwoizEAew/hvcnza5HgKFohZmxMHXbScEzZ72axD+VdB/617fcLlJn2QWnWCQQ7nfK6/DOq5MOFcQbdZoYnsf3p0Gn7t68GOIpuFDMGhueXWF9O8qcP0EcVbALgrVNrAyB1Jd6O1ntUTdjYeUsK++bmh1rrzCTmTkduxMAEoOv/4nfNAwhX6FiC7/S+061F0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.024720, 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 01.08.24 11:57, Zhangrenze wrote: >>> Sure, here's the Scalable Tiered Memory Control (STMC) >>> >>> **Background** >>> >>> In the era when artificial intelligence, big data analytics, and >>> machine learning have become mainstream research topics and >>> application scenarios, the demand for high-capacity and high- >>> bandwidth memory in computers has become increasingly important. >>> The emergence of CXL (Compute Express Link) provides the >>> possibility of high-capacity memory. Although CXL TYPE3 devices >>> can provide large memory capacities, their access speed is lower >>> than traditional DRAM due to hardware architecture limitations. >>> >>> To enjoy the large capacity brought by CXL memory while minimizing >>> the impact of high latency, Linux has introduced the Tiered Memory >>> architecture. In the Tiered Memory architecture, CXL memory is >>> treated as an independent, slower NUMA NODE, while DRAM is >>> considered as a relatively faster NUMA NODE. Applications allocate >>> memory from the local node, and Tiered Memory, leveraging memory >>> reclamation and NUMA Balancing mechanisms, can transparently demote >>> physical pages not recently accessed by user processes to the slower >>> CXL NUMA NODE. However, when user processes re-access the demoted >>> memory, the Tiered Memory mechanism will, based on certain logic, >>> decide whether to promote the demoted physical pages back to the >>> fast NUMA NODE. If the promotion is successful, the memory accessed >>> by the user process will reside in DRAM; otherwise, it will reside in >>> the CXL NODE. Through the Tiered Memory mechanism, Linux balances >>> betweenlarge memory capacity and latency, striving to maintain an >>> equilibrium for applications. >>> >>> **Problem** >>> Although Tiered Memory strives to balance between large capacity and >>> latency, specific scenarios can lead to the following issues: >>> >>> 1. In scenarios requiring massive computations, if data is heavily >>> stored in CXL slow memory and Tiered Memory cannot promptly >>> promote this memory to fast DRAM, it will significantly impact >>> program performance. >>> 2. Similar to the scenario described in point 1, if Tiered Memory >>> decides to promote these physical pages to fast DRAM NODE, but >>> due to limitations in the DRAM NODE promote ratio, these physical >>> pages cannot be promoted. Consequently, the program will keep >>> running in slow memory. >>> 3. After an application finishes computing on a large block of fast >>> memory, it may not immediately re-access it. Hence, this memory >>> can only wait for the memory reclamation mechanism to demote it. >>> 4. Similar to the scenario described in point 3, if the demotion >>> speed is slow, these cold pages will occupy the promotion >>> resources, preventing some eligible slow pages from being >>> immediately promoted, severely affecting application efficiency. >>> >>> **Solution** >>> We propose the **Scalable Tiered Memory Control (STMC)** mechanism, >>> which delegates the authority of promoting and demoting memory to the >>> application. The principle is simple, as follows: >>> >>> 1. When an application is preparing for computation, it can promote >>> the memory it needs to use or ensure the memory resides on a fast >>> NODE. >>> 2. When an application will not use the memory shortly, it can >>> immediately demote the memory to slow memory, freeing up valuable >>> promotion resources. >>> >>> STMC mechanism is implemented through the madvise system call, providing >>> two new advice options: MADV_DEMOTE and MADV_PROMOTE. MADV_DEMOTE >>> advises demote the physical memory to the node where slow memory >>> resides; this advice only fails if there is no free physical memory on >>> the slow memory node. MADV_PROMOTE advises retaining the physical memory >>> in the fast memory; this advice only fails if there are no promotion >>> slots available on the fast memory node. Benefits brought by STMC >>> include: >>> >>> 1. The STMC mechanism is a variant of on-demand memory management >>> designed to let applications enjoy fast memory as much as possible, >>> while actively demoting to slow memory when not in use, thus >>> freeing up promotion slots for the NODE and allowing it to run in >>> an optimized Tiered Memory environment. >>> 2. The STMC mechanism better balances large capacity and latency. >>> >>> **Shortcomings of STMC** >>> The STMC mechanism requires the caller to manage memory demotion and >>> promotion. If the memory is not promptly demoting after an promotion, >>> it may cause issues similar to memory leaks >> Ehm, that sounds scary. Can you elaborate what's happening here and why >> it is "similar to memory leaks"? >> >> >> Can you also point out why migrate_pages() is not suitable? I would >> assume demote/promote is in essence simply migrating memory between nodes. >> >> -- >> Cheers, >> >> David / dhildenb >> > > Thank you for the response. Below are my points of view. If there are any > mistakes, I appreciate your understanding: > > 1. In a tiered memory system, fast nodes and slow nodes act as two common > memory pools. The system has a certain ratio limit for promotion. For > example, a NODE may stipulate that when the available memory is less > than 1GB or 1/4 of the node's memory, promotion are prohibited. If we > use migrate_pages at this point, it will unrestrictedly promote slow > pages to fast memory, which may prevent other processes’ pages that > should have been promoted from being promoted. This is what I mean by > occupying promotion resources. > 2. As described in point 1, if we use MADV_PROMOTE to temporarily promote > a batch of pages and do not demote them immediately after usage, it > will occupy many promotion resources. Other hot pages that need promote > will not be able to get promote, which will impact the performance of > certain processes. So, you mean, applications can actively consume "fast memory" and "steal" it from other applications? I assume that's what you meant with "memory leak". I would really suggest to *not* call this "similar to memory leaks", in your own favor ;) > 3. MADV_DEMOTE and MADV_PROMOTE only rely on madvise, while migrate_pages > depends on libnuma. Well, you can trivially call that systemcall also without libnuma ;) So that shouldn't really make a difference and is rather something that can be solved in user space. > 4. MADV_DEMOTE and MADV_PROMOTE provide a better balance between capacity > and latency. They allow hot pages that need promoting to be promoted > smoothly and pages that need demoting to be demoted immediately. This > helps tiered memory systems to operate more rationally. Can you summarize why something similar could not be provided by a library that builds up on existing functionality, such as migrate_pages? It could easily take a look at memory stats to reason whether a promotion/demotion makes sense (your example above with the memory distribution). From the patch itself I read "MADV_DEMOTE can mark a range of memory pages as cold pages and immediately demote them to slow memory. MADV_PROMOTE can mark a range of memory pages as hot pages and immediately promote them to fast memory" which sounds to me like migrate_pages / MADV_COLD might be able to achieve something similar. What's the biggest difference that MADV_DEMOTE|MADV_PROMOTE can do better? -- Cheers, David / dhildenb