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 BE6B7C27C5E for ; Mon, 10 Jun 2024 12:10:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4CAFF6B00A0; Mon, 10 Jun 2024 08:10:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 479D36B00A1; Mon, 10 Jun 2024 08:10:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F3266B00A2; Mon, 10 Jun 2024 08:10:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 120FE6B00A0 for ; Mon, 10 Jun 2024 08:10:48 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AB9B4A0F29 for ; Mon, 10 Jun 2024 12:10:47 +0000 (UTC) X-FDA: 82214862534.09.19BC1F8 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf14.hostedemail.com (Postfix) with ESMTP id 3163C10000A for ; Mon, 10 Jun 2024 12:10:43 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=G4Lrfem6; spf=pass (imf14.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718021444; a=rsa-sha256; cv=none; b=yf9AzuVPoSDK/W2MnoyQ7RsxT+PYVZaW0z98RT80OJ5NREA8HmMDi8cVbUwGi7IPzHjgrC hJwaib8uJxuQu4PWW6665iYJgB9Qouzek6SaV5kNqEIk+LXNLswh90N70pq46ZiHjgfPDv QkmBafMOO8bAKirQlSCUVtMAWehuXWg= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=G4Lrfem6; spf=pass (imf14.hostedemail.com: domain of da.gomez@samsung.com designates 210.118.77.12 as permitted sender) smtp.mailfrom=da.gomez@samsung.com; dmarc=pass (policy=none) header.from=samsung.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718021444; 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=rkkEM3mA3uk4SNgRfrq3+QmgSLD2WfsPubo4v3Su5qk=; b=SbBf96trvNBa1a5plSCmP50m3a7NzHZUivuw3HrxBgjCJWXXulFvSi7e5du4K9dVsF3nHy AxOVI1tBGU4wZ7yQzG7AcX+LtRwRFK8XBpFUzMSNt0TC2djg9IrFhNe5Jg3hm5dThXcMwK EemnUgyN4gCsuzO82XW9ABbom64vDck= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240610121041euoutp020b8e4d4ae09fe672d46d0c18ba3cdde9~Xo2YQJKRn0208102081euoutp02S for ; Mon, 10 Jun 2024 12:10:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240610121041euoutp020b8e4d4ae09fe672d46d0c18ba3cdde9~Xo2YQJKRn0208102081euoutp02S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1718021441; bh=rkkEM3mA3uk4SNgRfrq3+QmgSLD2WfsPubo4v3Su5qk=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=G4Lrfem6gWfc01CzinCqkVf3znEwIIP3jcjIx3L1brRN6cnSriN+qlHsSL8b/hVxK IhPiHeb1CmvJGi+X1j3CjuA79cbz9knHN3hfqcMwUGp7f+6EebDwEzlpGXIQuqHlIo lNvwkubDzQ6wHzuxjSgbViRpeou1CK0CoSzdE5qw= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240610121041eucas1p2d0460d1c4ce1103ba6b27d33646581a1~Xo2X6pgOG3102231022eucas1p2f; Mon, 10 Jun 2024 12:10:41 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id DF.3C.09624.14DE6666; Mon, 10 Jun 2024 13:10:41 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20240610121040eucas1p2ad07a27dec959bf1658ea9e5f0dd4697~Xo2XGVF8y3102231022eucas1p2e; Mon, 10 Jun 2024 12:10:40 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240610121040eusmtrp179b26fada87ae37141a6a01b432f5369~Xo2XFgDUS2993329933eusmtrp1g; Mon, 10 Jun 2024 12:10:40 +0000 (GMT) X-AuditID: cbfec7f2-c11ff70000002598-b2-6666ed4118e3 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id F1.CD.08810.04DE6666; Mon, 10 Jun 2024 13:10:40 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240610121040eusmtip1870fb5cae2f5ea39f32e5f2201f6d893~Xo2W44lUf2040020400eusmtip1P; Mon, 10 Jun 2024 12:10:40 +0000 (GMT) Received: from CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 10 Jun 2024 13:10:39 +0100 Received: from CAMSVWEXC01.scsc.local ([::1]) by CAMSVWEXC01.scsc.local ([fe80::7d73:5123:34e0:4f73%13]) with mapi id 15.00.1497.012; Mon, 10 Jun 2024 13:10:39 +0100 From: Daniel Gomez To: Baolin Wang CC: "akpm@linux-foundation.org" , "hughd@google.com" , "willy@infradead.org" , "david@redhat.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" , "ioworker0@gmail.com" , Pankaj Raghav , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v4 0/6] add mTHP support for anonymous shmem Thread-Topic: [PATCH v4 0/6] add mTHP support for anonymous shmem Thread-Index: AQHatmiq95ivPAYXR0GYcZOSYxXaqbHA4NQA Date: Mon, 10 Jun 2024 12:10:38 +0000 Message-ID: In-Reply-To: Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [106.110.32.67] Content-Type: text/plain; charset="us-ascii" Content-ID: <8E2699B9BF68B94B9183A109A6B07B1E@scsc.local> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDKsWRmVeSWpSXmKPExsWy7djP87qOb9PSDDp+sFl8vitkMWf9GjaL /3uPMVp8Xf+L2eLppz4Wi0W/jS0u75rDZnFvzX9Wi57dUxktFpxYzGjR+Pk+o8XvH0CJk7Mm s1jMPnqP3YHPY828NYweO2fdZfdYsKnUo+XIW1aPzSu0PBbvecnksenTJHaPEzN+s3jsfGjp 0dv8js3j/b6rbB6fN8kF8ERx2aSk5mSWpRb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V+LEkan/Oez7heda yxles9/xlXpea959afo5xbmNM1lj2MQOnF86ocY66tbmcwv3Wz/kd159R0Cz+7+Zm+KSJRf2 Gt13P7nXIFCJpTgj0VCLuag4EQACdCAkBgQAAA== X-CMS-MailID: 20240610121040eucas1p2ad07a27dec959bf1658ea9e5f0dd4697 X-Msg-Generator: CA X-RootMTR: 20240610121040eucas1p2ad07a27dec959bf1658ea9e5f0dd4697 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240610121040eucas1p2ad07a27dec959bf1658ea9e5f0dd4697 References: X-Rspamd-Queue-Id: 3163C10000A X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: ekhemncsubby73orxxp8minm4o4umang X-HE-Tag: 1718021443-538999 X-HE-Meta: U2FsdGVkX191Jcn5gqPtsAwC+F5G/yr1MDWKZKiFYXGQBTvNlG5zW0GDxD7ux9jc0DzbCYQCDg9k0/3Mjig+4Nb8u9mIB8RMrLYWPBR8fksHLd1DNEF1bVvBAZVcg9+cNszGPF19Oa1fA33OHN3Ei1c6LyIP4dEfClTs9ryOMwVITwC0M23k+JDSIPiAor7ytsMmkSIXKqJry1mLK7wp+8Lf8O+Ty5dKd6SgiL9Uuxv9ENbbJeE0sTC/yBbmATM2qAwcYIoPRZvDQBiBZ3ky2T0YNYwWPCqz2qKtuIbaQWhn6oEnqQxk6tl196jWF0LBRrhWyy422WD8gu9AhXm1+ua1jwWUiZiTMcjNCDRQAg8VS+1J70xvnhZYNl2nqj3IYdSQ30BGPpK/r6xZNS9RyHUSa/GG9536JMWfEeedJmmQZSMg9y1atS7CX2PBO0wnnen+h7gw8YN09r75qp+D5N9s4U/HX3sOoBw3K2uH77Zq7A22gdFyMjYUeWOO9Q0D+fSuigmhzGICW7JgaOB8te2Xwpem7yS0qD7/EORjm6qZVdelem+FBGYqXmC0xoP2XSGVZcFGVPF8mg+8XBjb9ABFbyciy1TezXnE9u5Fai0r8k0CZpxgVkfoVYS0aJRYtJY02+mpA7+X3Za1pW8KzjLO+rDjtuYun6L7C8nFVtj1btQBYcSi9fcwU/gfTg4BqwpPOH9z8kLfng1X2weQ7t7YAr1iR6Hc9KrWbHUfkrKlCKxtw0xzYghHL4KqTrudlyr3mJ3NhwquJaDHxqIXtQbdeJRnbwVhJf6678gMbWktBjhWlTfZuE/iw+V+h3I/YKl/OE/44xhq2Ic/M4IQerelOeY7YcZi4SFIAVoxU7m5cbGmWunScyJMw7eTbyd0nTxmVn9uGELPOVqhYBDWQfGGr8XJve/R1rtXyZzZyDxH/H+qXBu+gWn7DDXiDosn0L75NmIrcvbDiEI7WsF ui0xSl7B BO6Bz1LRD9VeUUXjpfAp0Hw/7Ph3cA5TFcHIyes7YOg11DgyKZ2IxmgcSCj1+RpODODgRNOLy2/da9MzCPjXTH/frS0C7YM3UR5saA2MaYGSkWGxgk60dQiQNuvIPZZquejjf9V6NJL+Fbm5i4zjcyCCGmz9oSsKJO7qX 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: Hi Baolin, On Tue, Jun 04, 2024 at 06:17:44PM +0800, Baolin Wang wrote: > Anonymous pages have already been supported for multi-size (mTHP) allocat= ion > through commit 19eaf44954df, that can allow THP to be configured through = the > sysfs interface located at '/sys/kernel/mm/transparent_hugepage/hugepage-= XXkb/enabled'. >=20 > However, the anonymous shmem will ignore the anonymous mTHP rule configur= ed > 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 examp= le, > lower latency than PMD-mapped THP, smaller memory bloat than PMD-mapped T= HP, > contiguous PTEs on ARM architecture to reduce TLB miss etc. >=20 > As discussed in the bi-weekly MM meeting[1], the mTHP controls should con= trol > all of shmem, not only anonymous shmem, but support will be added iterati= vely. > Therefore, this patch set starts with support for anonymous shmem. >=20 > The primary strategy is similar to supporting anonymous mTHP. Introduce > a new interface '/mm/transparent_hugepage/hugepage-XXkb/shmem_enabled', > which can have almost the same values as the top-level > '/sys/kernel/mm/transparent_hugepage/shmem_enabled', with adding a new > additional "inherit" option and dropping the testing options 'force' and > 'deny'. By default all sizes will be set to "never" except PMD size, whic= h > is set to "inherit". This ensures backward compatibility with the anonymo= us > shmem enabled of the top level, meanwhile also allows independent control= of > anonymous shmem enabled for each mTHP. >=20 > Use the page fault latency tool to measure the performance of 1G anonymou= s shmem I'm not familiar with this tool. Could you share which repo/tool you are referring to? Also, are you running or are you aware of any other tools/tests available f= or shmem that we can use to make sure we do not introduce any regressions? Thanks! Daniel > with 32 threads on my machine environment with: ARM64 Architecture, 32 co= res, > 125G memory: > base: mm-unstable > user-time sys_time faults_per_sec_per_cpu faults_per_sec > 0.04s 3.10s 83516.416 2669684.890 >=20 > mm-unstable + patchset, anon shmem mTHP disabled > user-time sys_time faults_per_sec_per_cpu faults_per_sec > 0.02s 3.14s 82936.359 2630746.027 >=20 > mm-unstable + patchset, anon shmem 64K mTHP enabled > user-time sys_time faults_per_sec_per_cpu faults_per_sec > 0.08s 0.31s 678630.231 17082522.495 >=20 > From the data above, it is observed that the patchset has a minimal impac= t when > mTHP is not enabled (some fluctuations observed during testing). When ena= bling 64K > mTHP, there is a significant improvement of the page fault latency. >=20 > [1] https://lore.kernel.org/all/f1783ff0-65bd-4b2b-8952-52b6822a0835@redh= at.com/ >=20 > Changes from v3: > - Drop 'force' and 'deny' testing options for each mTHP. > - Use new helper update_mmu_tlb_range(), per Lance. > - Update documentation to drop "anonymous thp" terminology, per David. > - Initialize the 'suitable_orders' in shmem_alloc_and_add_folio(), > reported by kernel test robot. > - Fix the highest mTHP order in shmem_get_unmapped_area(). > - Update some commit message. >=20 > Changes from v2: > - Rebased to mm/mm-unstable. > - Remove 'huge' parameter for shmem_alloc_and_add_folio(), per Lance. >=20 > Changes from v1: > - Drop the patch that re-arranges the position of highest_order() and > next_order(), per Ryan. > - Modify the finish_fault() to fix VA alignment issue, per Ryan and > David. > - Fix some building issues, reported by Lance and kernel test robot. > - Update some commit message. >=20 > Changes from RFC: > - Rebase the patch set against the new mm-unstable branch, per Lance. > - Add a new patch to export highest_order() and next_order(). > - Add a new patch to align mTHP size in shmem_get_unmapped_area(). > - Handle the uffd case and the VMA limits case when building mapping for > large folio in the finish_fault() function, per Ryan. > - Remove unnecessary 'order' variable in patch 3, per Kefeng. > - Keep the anon shmem counters' name consistency. > - Modify the strategy to support mTHP for anonymous shmem, discussed wit= h > Ryan and David. > - Add reviewed tag from Barry. > - Update the commit message. >=20 > Baolin Wang (6): > mm: memory: extend finish_fault() to support large folio > mm: shmem: add THP validation for PMD-mapped THP related statistics > mm: shmem: add multi-size THP sysfs interface for anonymous shmem > mm: shmem: add mTHP support for anonymous shmem > mm: shmem: add mTHP size alignment in shmem_get_unmapped_area > mm: shmem: add mTHP counters for anonymous shmem >=20 > Documentation/admin-guide/mm/transhuge.rst | 23 ++ > include/linux/huge_mm.h | 23 ++ > mm/huge_memory.c | 17 +- > mm/memory.c | 57 +++- > mm/shmem.c | 344 ++++++++++++++++++--- > 5 files changed, 403 insertions(+), 61 deletions(-) >=20 > --=20 > 2.39.3 > =