Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp890444lqo; Wed, 8 May 2024 20:09:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXg1IQrqsW3SkMOMCD1ZoYx/vLNHTrsOiv7NlKLd9w+6Ku1VIO29VcBM1L3bapmqPHaO79peftQtHVY83DWPrWQBUmRhYxuNXTeTS5/tw== X-Google-Smtp-Source: AGHT+IE3yZ0Adbew1FBTHWn5y1/VX0JKRom5al3VrTDAoIGqGnRbV658TsxNUR2OhUC39xnmKGh/ X-Received: by 2002:a17:90a:ac0a:b0:2b3:bcf7:3a9b with SMTP id 98e67ed59e1d1-2b616be54femr4260782a91.43.1715224143319; Wed, 08 May 2024 20:09:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715224143; cv=pass; d=google.com; s=arc-20160816; b=jgu8wXePJaTD52n7njdbGNn4z3fRnPkSBiF7ALCglhi3Emcorhe8WkDWWC9utWVgdk j69H7yBmmZ/iCh21LZaRPujB9nNoXc1zPe9M8WQJMSIqKORKPQUggz22aY2cO0jCVECR 1kM6bGSjXvUNSfG7Sc7vxzcguOUteEvzyxm4g54zCe+eBexLJ/QS/KmAeUn0yRrDBhOz kUNS4IDwvBipKPRUKoPKPE1QybUFJo7JQtfRcx99juIqTW+nNZf+EWPFIDFyhx2IQxl5 lqbkk1S/lGDfqUOranE5YLvwNjwYc3B6uB8IQuNW7n9E5x1dtfyzPQBd4Od4dfNOYHJi XL4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=5EkEQoIaR256h7mVAdSvV5iKLkBhUyOBOqXGs/IWo7k=; fh=9ykc2ivLiG2JefdeLTdaV7ppaWKsllq3Ev1kaySgEKw=; b=J22c48aIyaqJTCmhsZcEf9nz89epDVKAVw+fJ7g4eSwwm6T3dLN+j9o4ufZ9peQsNr 5yE6O6+R2Rm2EQ+ofYQVojIs4DbTsgOzCnSN1OWX0amv4PPYOa0xwSmudTwOLWrTLfXm SNOpwIdZfyflrFbBG3CSEkU2/bjR4cQAOZHO5ZB4EioGEJMTbef/feIbgQMC8VmWHxvK kgNPNDizsDm1nD3RdEgt1L3e+QyfmiMPyySvDMVcvVLeXlyYkoGCWHhI3PiLaK0sBKkZ mzt3TstUsaP1H0hnc2sviQC6QEfjO5pE1zE4xq8WaFVYHpcDmeJBtex0WQ5IGtqBdJRt J1VA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=izWZFXSD; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-174077-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174077-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b67158a9c0si571335a91.159.2024.05.08.20.09.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 20:09:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174077-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=izWZFXSD; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-174077-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174077-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 85916B220D9 for ; Thu, 9 May 2024 03:09:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F147146D5E; Thu, 9 May 2024 03:08:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="izWZFXSD" Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B85D113C3D3 for ; Thu, 9 May 2024 03:08:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.111 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715224136; cv=none; b=PS0kuJipwqFB5XcdUYCY1P0fSUEBd0pIKAaFie6DcTdUT9BK71RoKv7QPONIIxeXfUuAFp2sX4HiVS3wwOyieQYfLF2Irktb7gUd1O7x0g9AVGyIsdojHBhpTVldg4OQ3OzdOIs9/7+wFW+QyGAV2xW/O7t4oGbLFK6cnacapsg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715224136; c=relaxed/simple; bh=+viQcmRhjEvQ/mJCxM2OIlarFQs1cpr8hD+N0a8ZWkI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=nqYWSZwkKod9I+4vXOLaRgtfK5XwPV7z96/Pj4vLSFdDm1FMj09reqyO/5D/HgqXLvucZc809lcCDgJwIhVSc1+WnjFn2l1cQys2qFai0zmURpmFU2Kipon/G30dCfKZCAMhssqHFvkkxWtHxmchz1pH55m64tCd6BwWlUTJ1fA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=izWZFXSD; arc=none smtp.client-ip=115.124.30.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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.