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 F15E1C25B75 for ; Wed, 15 May 2024 13:49:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 612AD6B037B; Wed, 15 May 2024 09:49:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CC4B6B03C1; Wed, 15 May 2024 09:49:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 462EA6B03C6; Wed, 15 May 2024 09:49:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 258246B037B for ; Wed, 15 May 2024 09:49:40 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CBE38161494 for ; Wed, 15 May 2024 13:49:39 +0000 (UTC) X-FDA: 82120762878.02.06F79D5 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by imf20.hostedemail.com (Postfix) with ESMTP id EC40F1C0026 for ; Wed, 15 May 2024 13:49:36 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=MtrqCxSe; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of shy828301@gmail.com designates 209.85.167.51 as permitted sender) smtp.mailfrom=shy828301@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715780977; 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=po6Xli+Sjya1+5CauOG0SZdm/lP8+JnkgWFO/a8IWk4=; b=E/JnZ84rboe2rAFDQr+VcIbrlB4IOU36/u33nUqUkCFqU8yNd1Ed08cxU+HTgSAcJp5uMC pnqz1ZYWcIn5bb8aoEj2kSfrBC47TMguVEO2fwKdk3RqzD+6nUy7MA3KOtJvHrbTPb4I8V ob94W7+oDbhYHOlIwtsQLWIYkGGgvJc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715780977; a=rsa-sha256; cv=none; b=pUNwobPr2yTEo9Lcq8sv/DqbptlISaZ7Zwc7Ebbp1HZADGEXBQThB24EM1FXuEqINlY2Cc bedgaxrSvzRlLWUX/XTFCkV+ifkbPIqGae0XRqrS+GpNXY8IVC6op3aLz5BuUG3WGHLFMd FfRZoGRGsKhEJzgsaV2CT/k2r58DiCA= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=MtrqCxSe; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf20.hostedemail.com: domain of shy828301@gmail.com designates 209.85.167.51 as permitted sender) smtp.mailfrom=shy828301@gmail.com Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-51fb14816f6so8942095e87.0 for ; Wed, 15 May 2024 06:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715780975; x=1716385775; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=po6Xli+Sjya1+5CauOG0SZdm/lP8+JnkgWFO/a8IWk4=; b=MtrqCxSeW/OPWR6oIy3bhB0lFXBbQuy7sQ6UcztjiLD1lrelk3HXkZiz5ZrvJVmFWx VqRtnWCqt/v1TGGYGnXWpOH1csje7XXJHTD9SY4/3gnxsU7urih6898QMfi49ldgWphO v/pA5dnrUfcv6EtSzkJtAW1+7HzZNHXBJGx9gduraqYg3r0g6bECVQ1e02ZVrnrb7OpO NMieE54yIFzYY/FHhCKfPYB+AWB8cQc09djSNS5wCHJYHwYQEXCOQ4MkPaorRZbOSqk7 aUQV0UyQ1In7HBcyEV4O8qxjZQyCmp9+dCgbprxu7eIFTRyNzHpu+GqZwKAly3BDMLVf yq8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715780975; x=1716385775; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=po6Xli+Sjya1+5CauOG0SZdm/lP8+JnkgWFO/a8IWk4=; b=sy7e1R7zob+ABbIue1bNzbZiagRuyVELTF/ShvMT+IbOwPugPSPtEre5f99WUYlINW QoQwaHkKYcKpIJ9vMZtYidWjhwf+75iAdW7hRL9N/ryCIigOr0RSdHZD/pSJNlTXZsa6 GB7f2vTy5vhthgu0afMtJVziDw53N5pEXOfcnoB5KWXU0YHDFrd4llsrFSSoiIUKojJc HjQOOAFvATlTzpfgH/eZZUPZc1qllvIWxdBGWLjbhbCGXYrr7T4n/BmfKnZSs/IzxW37 D+cyaLu9yb2+XMK8kWZMtx6QRUHWyqKUP2VJZ/f0rnY98VZBSTbvJUWZ8GYr1ZHmGOln UbHQ== X-Forwarded-Encrypted: i=1; AJvYcCVqL8rAw+Usf1aHlK180ueW8r2Zi2Qy/i2HXRqydLHjhIr6hG6vieU/PkvGLSN22wzIj8bQOis0ES7F9KzQflG/eiU= X-Gm-Message-State: AOJu0YwvF3tSdtKw9e6IYDHrNc9eHNfjUfUFJRC/+5j4QrnAQxOil3KP LlOzFHPB3H2eBOcW9MPd5MhN/QS0bVxkELU9kKHDyX3bzd/Lym0LLS3y/1YhHpeHM2kh31RPP0E qvdSNmpWIN5vhZFM/1b/QOsLCz8EIbQ== X-Google-Smtp-Source: AGHT+IHZII+I2Uc12tcOg6KAI2LJoOI2VywCRKOHrzfZmaZHUUUk8DCcr9l0MTOZVNkYPr02G7DXKp/kmplez/R3rV4= X-Received: by 2002:ac2:51b0:0:b0:51f:5d0a:d716 with SMTP id 2adb3069b0e04-52210273d64mr9265683e87.63.1715780974902; Wed, 15 May 2024 06:49:34 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yang Shi Date: Wed, 15 May 2024 07:49:22 -0600 Message-ID: Subject: Re: [LSF/MM/BPF TOPIC]mTHP reliable allocation and reclamation To: Barry Song <21cnbao@gmail.com> Cc: lsf-pc@lists.linux-foundation.org, Linux-MM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: grttqew7fuybd1ef6z4psdpjgec6hi51 X-Rspamd-Queue-Id: EC40F1C0026 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1715780976-733241 X-HE-Meta: U2FsdGVkX1/XvIgzbfw9gelN9FGDAM0RP1lIRpbeY0IhhMUl3jx1gfUzUFvYKbQHEpFsedqYIi46US+1tWJlIQZ/hjOvEyy3Hyelc6uleJfn5b7i8mWk4MPdW1lRL2NvBh3YGTq9z/yEe4uAqLG5EgfcPGaioZ+E/z4DrOc4VSSnzR36gJxs2DXrTRu+i55R8Vv6sFJMIH6BnMc06gxaypgZfsDeEtTkfzPqlBFBVdWjo3/lqRomsGO/0NYT4c9u63I5Qy1esqcibkvFCOsrce0ZQuXQDra3AuFd1dOATvjTMpLk1x+YnLunoePTMikusNYNqQv2Rqo9br34vaqtmgXLxpwbJfKHfeq40vK+q5SwvOfC1/6sP6i5/T+dGFx7VgTDGjrJnh96czHmdhZxUmd3ShK2//xMS8liH/p3DGz/tFqcpSEhVvo8Bz1WAomXsHwArO0SKwv6ZTNT5uKE6C8LpjNAoDaORnNFI9rzy0clG6G4FtHdPWHJR30JXZOxDhnuQSOppXvvLyOyCzqqvIfoVCUkSAonaqOhGjz1RZR4G5x5nf0rAtdUQnXHMjb5N9YVcNnekcQI9ByjIbLawG8zuZ04eW+4bCRSpXBNcGki6mGfkt6mv6e/w+KWmWCnewopyrY6N8Zk3/l25yeZiw64n7EI9855TFkWZJqt+9Whx0dnSKfO7whKUxOs9kEJWp2p7KTu5LW8QN31N+6jTm+Vyyz5OdhtACgDiKs1sk1kDNprciikeMjXi5Bp3ysYhubXgeW2GAvnIP7K+ijQEd0nMErnake2WsxC3tT5CgesY+gHC79IPg9SDuoDrHadV249q2qwFPzZSLDbtS6tck6474OVWlwTV7lF/JdYLvYQqPH621URBO8BYXLgxXUwgS0rK/0j8k07n+f4P943Iy9v/6tX4Wla5yX+TpKjfXsapw2QFcCcFrczy4+CRKWmKYNifHd0oJzWwaGRlC9 6pAzs990 kUKZ2FsNQ6l+VEcjv+n8rPAyXvhjOEHXrqKmdOH4HNunLGoi3pzirqf+W3/WlS8LCj2FM67p72mMV0jaDBOXtCjS0zG1WfH44L0rfSBFFlcbVFOuoljfNZAkdT+lk6xFjAvMWC68gA1ShBmziR8/tGhzJZjgfRwoq4J3XI5TANzJJgQRafQemMU9W9c5FZP7txQRz77kOexkETOde+oF/NgKD1R3waqTTZWH0w5Thu/SrDojmBm4yKZU16h9Cj1EzznZl6TdCrj0OpzVgXDBgaAuJsW873eYdCgSEt4PP0kZIeCBRlGk8ocF1zPdjeE68Oprq25lRMcI86r5JWI/WfeYhPIMgQhL1J015HqRXdszIDfhOTqXSnbr0gn5LMfniK0k8k8uxjcf7yAG7M4eoai5LaAMaa2cm6s0jK8C9r68jAL5ecAY9hBrLNL9ctHxtqLAv19FI/mwxvw7wPW+Wa04HuoVN4Lg6QzT0a8ZFfCcKb4nykS5ocryWQuZ6XhiDHN4m39K9dgaDKFxfpzsUF5/3vhw5w32K02wKWnp3q3+hkQjwZto0Zh3beTTiOTbkFxDzzgk3/oycUkdWJ08IGRitORdbHoSzGAQVhyOUMKrMh9Y= X-Bogosity: Ham, tests=bogofilter, spamicity=0.016956, 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 Tue, May 14, 2024 at 3:20=E2=80=AFAM Barry Song <21cnbao@gmail.com> wrot= e: > > On Sat, May 11, 2024 at 9:18=E2=80=AFAM Yang Shi wr= ote: > > > > On Thu, May 9, 2024 at 7:22=E2=80=AFPM Barry Song <21cnbao@gmail.com> w= rote: > > > > > > Hi, > > > > > > I'd like to propose a session about the allocation and reclamation of > > > mTHP. This is related to Yu Zhao's > > > TAO[1] but not the same. > > > > > > OPPO has implemented mTHP-like large folios across thousands of > > > genuine Android devices, utilizing > > > ARM64 CONT-PTE. However, we've encountered challenges: > > > > > > - The allocation of mTHP isn't consistently reliable; even after > > > prolonged use, obtaining large folios > > > remains uncertain. > > > As an instance, following a few hours of operation, the likelihood > > > of successfully allocating large > > > folios on a phone may decrease to just 2%. > > > > > > - Mixing large and small folios in the same LRU list can lead to > > > mutual blocking and unpredictable > > > latency during reclamation/allocation. > > > > I'm also curious how much large folios can improve reclamation > > efficiency. Having large folios is supposed to reduce the scan time > > since there should be fewer folios on LRU. But IIRC I haven't seen too > > much data or benchmark (particularly real life workloads) regarding > > this. > > Hi Yang, > > We lack direct data on this matter, but information from Ryan's THP_SWPOU= T > series [1] provides insights as follows: > > | alloc size | baseline | + this series | > | | mm-unstable (~v6.9-rc1) | | > |:-----------|------------------------:|------------------------:| > | 4K Page | 0.0% | 1.3% | > | 64K THP | -13.6% | 46.3% | > | 2M THP | 91.4% | 89.6% | > > > I suspect the -13.6% performance decrease is due to the split > operation. Once the split > is eliminated, the patchset observed a 46.3% increase. It is presumed > that the overhead > required to reclaim 64K is reduced compared to reclaiming 16 * 4K. Thank you. Actually I care about 4k vs 64k vs 256k ... I did a simple test by calling MADV_PAGEOUT on 4G memory w/ the swapout optimization then measured the time spent in madvise, I can see the time was reduced by ~23% between 64k vs 4k. Then there is no noticeable reduction between 64k and larger sizes. Actually I saw such a pattern (performance doesn't scale with page size after 64K) with some real life workload benchmark. I'm going to talk about it in today's LSF/MM. > > However, at present, in actual android devices, we are observing > nearly 100% occurrence > of anon_thp_swpout_fallback after the device has been in operation for > several hours[2]. > > Hence, it is likely that we will experience regression instead of > improvement due to the > absence of measures to mitigate swap fragmentation. > > [1] https://lore.kernel.org/all/20240408183946.2991168-1-ryan.roberts@arm= .com/ > [2] https://lore.kernel.org/lkml/CAGsJ_4zAcJkuW016Cfi6wicRr8N9X+GJJhgMQdS= Mp+Ah+NSgNQ@mail.gmail.com/ > > > > > > > > > For instance, if you require large folios, the LRU list's tail coul= d > > > be filled with small folios. > > > LRU(LF- large folio, SF- small folio): > > > > > > LF - LF - LF - SF - SF - SF - SF - SF - SF -SF - SF - SF - SF - S= F - SF - SF > > > > > > You might end up reclaiming many small folios yet still struggle to > > > allocate large folios. Conversely, > > > the inverse scenario can occur when the LRU list's tail is populated > > > with large folios. > > > > > > SF - SF - SF - LF - LF - LF - LF - LF - LF -LF - LF - LF - LF - L= F - LF - LF > > > > > > In OPPO's products, we allocate dedicated pageblocks solely for large > > > folios allocation, and we've > > > fine-tuned the LRU mechanism to support dual LRU=E2=80=94one for smal= l folios > > > and another for large ones. > > > Dedicated page blocks offer a fundamental guarantee of allocating > > > large folios. Additionally, segregating > > > small and large folios into two LRUs ensures that both can be > > > efficiently reclaimed for their respective > > > users' requests. However, while the implementation may lack aestheti= c > > > appeal and is primarily tailored > > > for product purposes, it isn't fully upstreamable. > > > > > > You can obtain the architectural diagram of OPPO's approach from link= [2]. > > > > > > Therefore, my plan is to present: > > > > > > - Introduce the architecture of OPPO's mTHP-like approach, which > > > encompasses additional optimizations > > > we've made to address swap fragmentation issues and improve swap > > > performance, such as dual-zRAM > > > and compression/decompression of large folios [3]. > > > > > > - Present OPPO's method of utilizing dedicated page blocks and a > > > dual-LRU system for mTHP. > > > > > > - Share our observations from employing Yu Zhao's TAO on Pixel 6 phon= es. > > > > > > - Discuss our future direction=E2=80=94are we leaning towards TAO or = dedicated > > > page blocks? If we opt for page > > > blocks, how do we plan to resolve the LRU issue? > > > > > > [1] https://lore.kernel.org/linux-mm/20240229183436.4110845-1-yuzhao@= google.com/ > > > [2] https://github.com/21cnbao/mTHP/blob/main/largefoliosarch.png > > > [3] https://lore.kernel.org/linux-mm/20240327214816.31191-1-21cnbao@g= mail.com/ > > > > Thanks, > Barry