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 89499C47422 for ; Mon, 29 Jan 2024 09:07:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 145946B0088; Mon, 29 Jan 2024 04:07:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0CE5B6B0089; Mon, 29 Jan 2024 04:07:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EB1D56B008A; Mon, 29 Jan 2024 04:07:08 -0500 (EST) 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 D72F26B0088 for ; Mon, 29 Jan 2024 04:07:08 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A1896A05C5 for ; Mon, 29 Jan 2024 09:07:08 +0000 (UTC) X-FDA: 81731769336.01.928FA18 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by imf08.hostedemail.com (Postfix) with ESMTP id 4B32E16001D for ; Mon, 29 Jan 2024 09:07:04 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=e6fhD+O5; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706519226; 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:dkim-signature; bh=KUezvJVDIf6W8wGNmbwFG3CDHyZ9aptM3Tm8M9vDOX0=; b=d24cqHIvlOWTT5yCVl3CZwEwM7JNzJ6zqRJMYzje3A0mkIQ6bMx+/ubhGBqn3M0wZ963RZ v/puwXQ6MjxSTBlq8WCqc8Yq0DjKN8Hk8OyP1nEpmCPZtPyaxoMugevBH/gbf1F30w90Ga D4RyZgTzKr0CO1e8mGnIv3LVjdvyOm4= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=e6fhD+O5; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.hostedemail.com: domain of ying.huang@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=ying.huang@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706519226; a=rsa-sha256; cv=none; b=LYPRoSMrtLpa17Z/2hXl29XsApp/f4QAG2aACgDJO4SW3O0zI31YtVyYaLRpEwXKFNa3XI Klq+18St8LO9yqCzcxe86QLeeXxJriNDN0VDo9C0zZsUd6mgDs4a8D37cppwJeM+tzrmah WR6hcvtCgP14BQNTc+aS3bUyIqJUD6Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706519225; x=1738055225; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=tN7xWY/aoRePb/06SXJNtwJUb0WC049eAoR7aYoGkmo=; b=e6fhD+O5Rpmoj4DfuMrO7jpQdDqjRr+IJttSUj2txT3bGqC9Q6tFlqtS L9Kn13yUGO3dnEyjls+Z55Cb2Iu2AA4B5fj9HM0pxZx+7wHK2Utp5RR6H jolNTCLgx1fqzrgCzqzmXXe/uqtsRD0NLBwkxkDsTtRGRZHuQZkvdH8Hw 2SGvSJvHqHoETXPBUDA4nSpZjYvtyWd3fVtE7wh+JYJEzkjN6awXvefAO G+pcF+crs0g0W35E371YRlKrOzd6CluEZF4m0ZwH3DRyn33eZuBxXBT1o P7EPnpV5/BKGrW2nMkG0NOKE0hfdQX5O7M+lK7Mzb818s+P9nAfi2rbE+ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10967"; a="434060462" X-IronPort-AV: E=Sophos;i="6.05,226,1701158400"; d="scan'208";a="434060462" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2024 01:07:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10967"; a="787771793" X-IronPort-AV: E=Sophos;i="6.05,226,1701158400"; d="scan'208";a="787771793" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2024 01:06:58 -0800 From: "Huang, Ying" To: Barry Song <21cnbao@gmail.com> Cc: ryan.roberts@arm.com, akpm@linux-foundation.org, david@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, mhocko@suse.com, shy828301@gmail.com, wangkefeng.wang@huawei.com, willy@infradead.org, xiang@kernel.org, yuzhao@google.com, surenb@google.com, steven.price@arm.com Subject: Re: [PATCH RFC 0/6] mm: support large folios swap-in In-Reply-To: <20240118111036.72641-1-21cnbao@gmail.com> (Barry Song's message of "Fri, 19 Jan 2024 00:10:30 +1300") References: <20231025144546.577640-1-ryan.roberts@arm.com> <20240118111036.72641-1-21cnbao@gmail.com> Date: Mon, 29 Jan 2024 17:05:01 +0800 Message-ID: <8734ugjyrm.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Rspamd-Queue-Id: 4B32E16001D X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: ww9wijj63qu4iqzc4shm3qmg8if1bfc3 X-HE-T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uHAkeYhnS2/lorFUTRV3tBcakB/nBibDtpwIXE6qgHc6yR8MQRlN4oOnrq1WxKM67lybGV3yDzFMfqn7jLmhvvpXRq7Ks3z7Yyq9lqtBWysATNjQj7mVEEiflAwdmyI6efhLlGahBDEs2k2tmmBbyZ6P0GI/+wn5JHEtUwUhiM0iXIz2ue4PCqjIG4HEgE1QmwjKLY2BXzSRB5sdU6cP/ipdCOAUJU/SDSQ== 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: Barry Song <21cnbao@gmail.com> writes: > On an embedded system like Android, more than half of anon memory is actually > in swap devices such as zRAM. For example, while an app is switched to back- > ground, its most memory might be swapped-out. > > Now we have mTHP features, unfortunately, if we don't support large folios > swap-in, once those large folios are swapped-out, we immediately lose the > performance gain we can get through large folios and hardware optimization > such as CONT-PTE. > > In theory, we don't need to rely on Ryan's swap out patchset[1]. That is to say, > before swap-out, if some memory were normal pages, but when swapping in, we > can also swap-in them as large folios. But this might require I/O happen at > some random places in swap devices. So we limit the large folios swap-in to > those areas which were large folios before swapping-out, aka, swaps are also > contiguous in hardware. On the other hand, in OPPO's product, we've deployed > anon large folios on millions of phones[2]. we enhanced zsmalloc and zRAM to > compress and decompress large folios as a whole, which help improve compression > ratio and decrease CPU consumption significantly. In zsmalloc and zRAM we can > save large objects whose original size are 64KiB for example. So it is also a > better choice for us to only swap-in large folios for those compressed large > objects as a large folio can be decompressed all together. Another possibility is to combine large folios swap-in with VMA based swap-in readahead. If we will swap-in readahead several pages based on VMA, we can swap-in a large folio instead. I think that it is similar as allocating large file folios for file readahead (TBH, I haven't check file large folios allocation code). -- Best Regards, Huang, Ying > Note I am moving my previous "arm64: mm: swap: support THP_SWAP on hardware > with MTE" to this series as it might help review. > > [1] [PATCH v3 0/4] Swap-out small-sized THP without splitting > https://lore.kernel.org/linux-mm/20231025144546.577640-1-ryan.roberts@arm.com/ > [2] OnePlusOSS / android_kernel_oneplus_sm8550 > https://github.com/OnePlusOSS/android_kernel_oneplus_sm8550/tree/oneplus/sm8550_u_14.0.0_oneplus11 > > Barry Song (2): > arm64: mm: swap: support THP_SWAP on hardware with MTE > mm: rmap: weaken the WARN_ON in __folio_add_anon_rmap() > > Chuanhua Han (4): > mm: swap: introduce swap_nr_free() for batched swap_free() > mm: swap: make should_try_to_free_swap() support large-folio > mm: support large folios swapin as a whole > mm: madvise: don't split mTHP for MADV_PAGEOUT > > arch/arm64/include/asm/pgtable.h | 21 ++---- > arch/arm64/mm/mteswap.c | 42 ++++++++++++ > include/asm-generic/tlb.h | 10 +++ > include/linux/huge_mm.h | 12 ---- > include/linux/pgtable.h | 62 ++++++++++++++++- > include/linux/swap.h | 6 ++ > mm/madvise.c | 48 ++++++++++++++ > mm/memory.c | 110 ++++++++++++++++++++++++++----- > mm/page_io.c | 2 +- > mm/rmap.c | 5 +- > mm/swap_slots.c | 2 +- > mm/swapfile.c | 29 ++++++++ > 12 files changed, 301 insertions(+), 48 deletions(-)