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 3D20AC10F1A for ; Thu, 9 May 2024 03:08:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C7EC16B007B; Wed, 8 May 2024 23:08:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C06AE6B0085; Wed, 8 May 2024 23:08:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA7EA6B0088; Wed, 8 May 2024 23:08:56 -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 8C2E26B007B for ; Wed, 8 May 2024 23:08:56 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 16DA981214 for ; Thu, 9 May 2024 03:08:56 +0000 (UTC) X-FDA: 82097375472.29.E1BDAEC Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by imf27.hostedemail.com (Postfix) with ESMTP id 1A73A4000A for ; Thu, 9 May 2024 03:08:52 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=izWZFXSD; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf27.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715224134; 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=5EkEQoIaR256h7mVAdSvV5iKLkBhUyOBOqXGs/IWo7k=; b=FtnV4siw5CZo6qKHAI+oHNFO6dqbKDNwO7V/fATe/pxu6LmHy1EbrhAxaVZLvtalWIbIbs 8VCqm/gS5EVuhpL6QEgbGbmuo+vVubiQMU5YRuVhQSzFktoRiXuLEnhfh+Xg0mKlCJ5bV6 E8cUsbsH2zwm/HXG+4UXfkLK+oV3fIg= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=izWZFXSD; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf27.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.131 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715224134; a=rsa-sha256; cv=none; b=wAQoGgh/02aLqfxwHICzcjwoAwh0BULk9zV8t82hZD6n2MVAbnQLFDpL9Db4Ug8BxOXAoX EInyi5ltm8eO4eoZHz0vpR6BOfIwtVASt8gsDmrA8Rw9VgYsnZ7ZSinTPwtaYsG/TkjZYr AIt5y4lb31wIBumUGOSyQkB+zUOGFfA= DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1715224130; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=5EkEQoIaR256h7mVAdSvV5iKLkBhUyOBOqXGs/IWo7k=; b=izWZFXSDdlhLAWhJ6OB03C0TKgQoPhP60Ky5WfQsnHexrWAO2xkOeRjpFtweceYRObJVVCNucAlDO4ITG16Dxk6LBdbZqFNQ5PBbpqP7ToLyFw5zYHWPbPWM9Sq4r1d8aG9OISRdyHCjhuYdpLKEwqRSif9o8dysPHSNNl6fCG0= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033022160150;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0W65KgZQ_1715224127; Received: from 30.97.56.60(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W65KgZQ_1715224127) by smtp.aliyun-inc.com; Thu, 09 May 2024 11:08:48 +0800 Message-ID: <15314a86-5d9a-4fb4-a0f6-8b1a56764aad@linux.alibaba.com> Date: Thu, 9 May 2024 11:08:47 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/8] add mTHP support for anonymous shmem To: Daniel Gomez , David Hildenbrand Cc: "akpm@linux-foundation.org" , "hughd@google.com" , "willy@infradead.org" , "ioworker0@gmail.com" , "wangkefeng.wang@huawei.com" , "ying.huang@intel.com" , "21cnbao@gmail.com" <21cnbao@gmail.com>, "ryan.roberts@arm.com" , "shy828301@gmail.com" , "ziy@nvidia.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" References: From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Stat-Signature: sjg3bzsgb83nyy4x59888dfxt8wp1cqk X-Rspamd-Queue-Id: 1A73A4000A X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1715224132-385234 X-HE-Meta: U2FsdGVkX1/svK1W0k9ia+I2S+bLp71SfF6c1JysJHMfYUYmHV2nM9R7Jyw58H9aaRECl/mF+/HU2lofV+IW1srlwHWniWbRCI8vsPF92N6HOAPN8J86BN001zQ142pL8kQtHciwPIzKT1IWg+Gz/+tOoQ/CsQ3Qgkh7zFSqTmOOCtH0NJlL7mb+99ORgGKkGKb9ZqjML2OhSfGyDNUsgLqla8/L9Dx5r30fqK4LyICpJ/v+v1DIDQlr1zw+WzdxK95vHMf/TxRaZFXt2xERAe1+EMLOmR8dX8BwokBSRmGx5UU1FX4QCMf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Qa7YimJA== 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 2024/5/8 22:28, Daniel Gomez wrote: > On Wed, May 08, 2024 at 01:58:19PM +0200, David Hildenbrand wrote: >> On 08.05.24 13:39, Daniel Gomez wrote: >>> On Mon, May 06, 2024 at 04:46:24PM +0800, Baolin Wang wrote: >>>> Anonymous pages have already been supported for multi-size (mTHP) allocation >>>> through commit 19eaf44954df, that can allow THP to be configured through the >>>> sysfs interface located at '/sys/kernel/mm/transparent_hugepage/hugepage-XXkb/enabled'. >>>> >>>> However, the anonymous shared pages will ignore the anonymous mTHP rule >>>> configured through the sysfs interface, and can only use the PMD-mapped >>>> THP, that is not reasonable. Many implement anonymous page sharing through >>>> mmap(MAP_SHARED | MAP_ANONYMOUS), especially in database usage scenarios, >>>> therefore, users expect to apply an unified mTHP strategy for anonymous pages, >>>> also including the anonymous shared pages, in order to enjoy the benefits of >>>> mTHP. For example, lower latency than PMD-mapped THP, smaller memory bloat >>>> than PMD-mapped THP, contiguous PTEs on ARM architecture to reduce TLB miss etc. >>>> >>>> The primary strategy is similar to supporting anonymous mTHP. Introduce >>>> a new interface '/mm/transparent_hugepage/hugepage-XXkb/shmem_enabled', >>>> which can have all the same values as the top-level >>>> '/sys/kernel/mm/transparent_hugepage/shmem_enabled', with adding a new >>>> additional "inherit" option. By default all sizes will be set to "never" >>>> except PMD size, which is set to "inherit". This ensures backward compatibility >>>> with the shmem enabled of the top level, meanwhile also allows independent >>>> control of shmem enabled for each mTHP. >>> >>> I'm trying to understand the adoption of mTHP and how it fits into the adoption >>> of (large) folios that the kernel is moving towards. Can you, or anyone involved >>> here, explain this? How much do they overlap, and can we benefit from having >>> both? Is there any argument against the adoption of large folios here that I >>> might have missed? >> >> mTHP are implemented using large folios, just like traditional PMD-sized THP >> are. (you really should explore the history of mTHP and how it all works >> internally) > > I'll check more in deep the code. By any chance are any of you going to be at > LSFMM this year? I have this session [1] scheduled for Wednesday and it would > be nice to get your feedback on it and if you see this working together with > mTHP/THP. > > [1] https://lore.kernel.org/all/4ktpayu66noklllpdpspa3vm5gbmb5boxskcj2q6qn7md3pwwt@kvlu64pqwjzl/ Great. I'm also interested in tmpfs support for large folios (or mTHP), so please CC me if you plan to send a new version. As David mentioned, this patchset is mainly about adding mTHP support for anonymous shmem, and I think that some of the swap support for large folios could work together.