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 86D7FC25B7E for ; Tue, 4 Jun 2024 08:18:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A11B6B009A; Tue, 4 Jun 2024 04:18:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 050AB6B009B; Tue, 4 Jun 2024 04:18:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0B926B009C; Tue, 4 Jun 2024 04:18:57 -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 C07C36B009A for ; Tue, 4 Jun 2024 04:18:57 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 67856121318 for ; Tue, 4 Jun 2024 08:18:57 +0000 (UTC) X-FDA: 82192505514.03.BF87970 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by imf07.hostedemail.com (Postfix) with ESMTP id F199C40011 for ; Tue, 4 Jun 2024 08:18:52 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=k7wRSzgq; spf=pass (imf07.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=1717489134; 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=3uVJ03wHHaJoCeSH6rZGt0UVQDtWvA6kGyOdcJXdKr8=; b=g9rXnW+2IlOgLjaQkKtOWntqB5gDKba/ve6ynDfPSJ0X+3zUqDwn+pc0CZUn8tgMQ0qnnq lo0InEUFFiP8HnMmJaNWU8Fa8ch3zIep3GmJw1TXhFXEvM3sOzPYU/wDeLJXcwiwyXEHWb J0QesPL+q1ddK4lIYljB4fmzwzPQX1U= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=k7wRSzgq; spf=pass (imf07.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=1717489134; a=rsa-sha256; cv=none; b=TxVsOWZkRZKIIKA3K02vyUYwXA1fT8ewZngaQie1Xytajhog/56B6A49F6TkSqKiLaid8k KmlnktRbQShE6bDs0r7f5uV/zoGvqiDt87+7Rly1NUzwSzTs4Cj6Efn4uxzp7oU3UHW1jJ DFyrI5Yn2w0g9sV3C8uYD+ioCxMkEZQ= Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20240604081850euoutp02604938196584d4b56be494d8eda17920~Vv0O71jr41511315113euoutp02g for ; Tue, 4 Jun 2024 08:18:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20240604081850euoutp02604938196584d4b56be494d8eda17920~Vv0O71jr41511315113euoutp02g DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1717489130; bh=3uVJ03wHHaJoCeSH6rZGt0UVQDtWvA6kGyOdcJXdKr8=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=k7wRSzgqzmP+nXWj45q5oO2HOh6sjbtKCeUNkmLq9008FVHXfJzdfptDy6PraWFNM 4yeNQY/KcY5/2Sdfocyw6Azyu9CPxBIymtSaATrav2nzuvqgQJ3dkalaHSRiCk5lWf hyj+jKfBfQsvrZNNT2BjIw1N3xy5BFl1RKuDn1Hk= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240604081850eucas1p2c7c6ea5d8c237786ba22a4edb2489300~Vv0OqpWvm1807418074eucas1p2a; Tue, 4 Jun 2024 08:18:50 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id B5.5D.09624.AEDCE566; Tue, 4 Jun 2024 09:18:50 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20240604081849eucas1p1ea15f8fe8c27c90fae6b7614dfd98b37~Vv0OIIxnl0373503735eucas1p12; Tue, 4 Jun 2024 08:18:49 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240604081849eusmtrp2f3bcefffc5a58f14e77c1345e76c32e0~Vv0OHTubW2263022630eusmtrp2O; Tue, 4 Jun 2024 08:18:49 +0000 (GMT) X-AuditID: cbfec7f2-c11ff70000002598-3b-665ecdea347b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 21.C6.09010.9EDCE566; Tue, 4 Jun 2024 09:18:49 +0100 (BST) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240604081849eusmtip176168a20bb66ea38ab6d2f3d74fa2db7~Vv0NylVOW0291302913eusmtip1h; Tue, 4 Jun 2024 08:18:49 +0000 (GMT) Received: from CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 4 Jun 2024 09:18:48 +0100 Received: from CAMSVWEXC01.scsc.local ([::1]) by CAMSVWEXC01.scsc.local ([fe80::7d73:5123:34e0:4f73%13]) with mapi id 15.00.1497.012; Tue, 4 Jun 2024 09:18:47 +0100 From: Daniel Gomez To: David Hildenbrand CC: Baolin Wang , "akpm@linux-foundation.org" , "hughd@google.com" , "willy@infradead.org" , "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 v3 0/6] add mTHP support for anonymous shmem Thread-Topic: [PATCH v3 0/6] add mTHP support for anonymous shmem Thread-Index: AQHasjX9yP1IBMh0VkC4Fzv01OfbabGxBpEAgAAKfoCAABD5AIAGGG2A Date: Tue, 4 Jun 2024 08:18:47 +0000 Message-ID: In-Reply-To: <502fb3df-b42b-4f0c-a98d-348c3d544721@redhat.com> 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: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHKsWRmVeSWpSXmKPExsWy7djP87qvzsalGXz7wGnx+a6QxZz1a9gs /u89xmjxdf0vZounn/pYLBb9Nra4vGsOm8W9Nf9ZLXp2T2W0WHBiMaNF4+f7jBa/fwAlTs6a zGIx++g9dgc+jzXz1jB67Jx1l91jwaZSj5Yjb1k9Nq/Q8li85yWTx6ZPk9g9Tsz4zeKx86Gl R2/zOzaP9/uusnl83iQXwBPFZ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Or4WBeeyUc+y/+9LGC60mrVz6TZ99rs++5926C5SsM0zGnZ cSWW4oxEQy3mouJEAK0yddUJBAAA X-CMS-MailID: 20240604081849eucas1p1ea15f8fe8c27c90fae6b7614dfd98b37 X-Msg-Generator: CA X-RootMTR: 20240531111357eucas1p2338be7f326d8d9176d2ee212a10fc9db X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240531111357eucas1p2338be7f326d8d9176d2ee212a10fc9db References: <502fb3df-b42b-4f0c-a98d-348c3d544721@redhat.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: F199C40011 X-Stat-Signature: or1b5btxxbc34p14iypobijk4xatgjca X-Rspam-User: X-HE-Tag: 1717489132-271065 X-HE-Meta: U2FsdGVkX1+JXr0o3fGgbJYvhYlrjARx7sJR7qpPJ/uSXg2Jw95y6Csjvb+4zZ0SWARCzPHJgs1OVXJPVajmxDWWyA+Or5/aRxfMVB0IyiarTcXn3H9wnj13AGs/N7bvbuAMXSE3WzBBoN1GnCFveTopIY8UXWprGni+h1UbezrPIfxhXW3pp4nWzhETJNg6R0bhu4zwXOIleBxVr8qpO/bd004FjDWjhzu243z7phIQ7VKkXZWCd/JaGtQmoVbOLIBNeZtUKodaeR8rCcEu3SM+j/fvf/5nFIADrZ/FHZlNs+w+iX53K7RR9tDY6tbSXYo8uWu81/cMo7A850pKb8IfbNEXIpnr1+NP6f94AeUIikj9/N/Js2A1mUY9L8IELqYVq/DbaLe/+ddZ5ToVfInE2IIe7x+aviDPVIUk7g8vhtEipITvK/HJ/z+AGZI1dLRx+ycyDddhvVThSAchoqkewkhsUbi3TCHfmCUFb58owcsHgEDZk48R5n6B1oaQsFDAvLc2vDtaCwoOCAvaWWKn5BUVUyFH7XKMxt4aKypIu0a+vP0r13OsuA8LhB5wgcg6mjli7llsMxAoxOtXK/EKITwzLh32u+bGFlxrphb1mH8Rw62L6UxvxSUpgrlNg2dC/llevvm+gvX8Sf/0ckWW5NT1z632wSOcO7nLR5tNieyOjFd/7gZUcqlk7jUUufVGFrN/n+S+boAKTMVog0nm1B5xn932RxiqZx+6P4W9/we4tnV8Ee6ab27BjVYHgdpmtE5vDtKUkRNZ8kqVAJgpa6K8shUFVH1ExrPqa0li1nj+J28lrCgvKYue4LYiSmVNNEllVQWsW9xclIdspMPhL2+bUvgZrKQICOgNrbjMHbLAzeK41l/YGf13GZZAKn6sGiBUHQOqgBXoDhJOzERcQ++1jPk2o/ggXoQHX92HW0oXIFXic/mFSz5Y73Sjx+T7mYnUDqNxALrW1ps kPak/F0P +xdFonyNT1N2pgGDrZFehekncgwwYHEv/+f6Y8qujON8TBcyccgWhKcodFDQqLRzR4cvumm61QDJ0Mu0ayuywtdkHPoqjdsIVRFJdH4XTBd6+OY4SgzhDTILkajSyHDKkJJ2Io54n3hFZfd2zEz4TXxCN1r+s8RSOgtfo 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 Fri, May 31, 2024 at 01:13:48PM +0200, David Hildenbrand wrote: > > >=20 > > > As a default, we should not be using large folios / mTHP for any shme= m, > > > just like we did with THP via shmem_enabled. This is what this series > > > currently does, and is aprt of the whole mTHP user-space interface de= sign. > > >=20 > > > Further, the mTHP controls should control all of shmem, not only > > > "anonymous shmem". > >=20 > > Yes, that's what I thought and in my TODO list. >=20 > Good, it would be helpful to coordinate with Daniel and Pankaj. I've integrated patches 11 and 12 from the lsf RFC thread [1] on top of Bao= lin's v3 patches. You may find a version in my integration branch here [2]. I can attach them here if it's preferred. [1] https://lore.kernel.org/all/20240515055719.32577-1-da.gomez@samsung.com= / [2] https://gitlab.com/dkruces/linux-next/-/commits/next-20240604-shmem-mth= p The point here is to combine the large folios strategy I proposed with mTHP user controls. Would it make sense to limit the orders to the mapping order calculated based on the size and index? @@ -1765,6 +1798,10 @@ static struct folio *shmem_alloc_and_add_folio(struc= t vm_fault *vmf, order =3D highest_order(suitable_orders); while (suitable_orders) { + if (order > mapping_order) { + order =3D next_order(&suitable_orders, orde= r); + continue; + } pages =3D 1UL << order; index =3D round_down(index, pages); folio =3D shmem_alloc_folio(gfp, order, info, index= ); Note: The branch still need to be adapted to include !anon mm. >=20 > >=20 > > >=20 > > > Also, we should properly fallback within the configured sizes, and no= t > > > jump "over" configured sizes. Unless there is a good reason. > > >=20 > > > (3) khugepaged > > >=20 > > > khugepaged needs to handle larger folios properly as well. Until fixe= d, > > > using smaller THP sizes as fallback might prohibit collapsing a > > > PMD-sized THP later. But really, khugepaged needs to be fixed to hand= le > > > that. > > > > (4) force/disable > > >=20 > > > These settings are rather testing artifacts from the old ages. We sho= uld > > > not add them to the per-size toggles. We might "inherit" it from the > > > global one, though. > >=20 > > Sorry, I missed this. So I thould remove the 'force' and 'deny' option > > for each mTHP, right? >=20 > Yes, that's my understanding. But we have to keep them on the top level f= or > any possible user out there. >=20 > >=20 > > >=20 > > > "within_size" might have value, and especially for consistency, we > > > should have them per size. > > >=20 > > >=20 > > >=20 > > > So, this series only tackles anonymous shmem, which is a good startin= g > > > point. Ideally, we'd get support for other shmem (especially during > > > fault time) soon afterwards, because we won't be adding separate togg= les > > > for that from the interface POV, and having inconsistent behavior > > > between kernel versions would be a bit unfortunate. > > >=20 > > >=20 > > > @Baolin, this series likely does not consider (4) yet. And I suggest = we > > > have to take a lot of the "anonymous thp" terminology out of this > > > series, especially when it comes to documentation. > >=20 > > Sure. I will remove the "anonymous thp" terminology from the > > documentation, but want to still keep it in the commit message, cause I > > want to start from the anonymous shmem. >=20 > For commit message and friends makes sense. The story should be "controls > all of shmem/tmpfs, but support will be added iteratively. The first step= is > anonymous shmem." >=20 > --=20 > Cheers, >=20 > David / dhildenb > =