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 9CB7EC7EE32 for ; Wed, 25 Jun 2025 10:03:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40A006B00B6; Wed, 25 Jun 2025 06:03:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BB516B00B7; Wed, 25 Jun 2025 06:03:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 281C16B00BA; Wed, 25 Jun 2025 06:03:01 -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 14E6A6B00B6 for ; Wed, 25 Jun 2025 06:03:01 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A87E71064D8 for ; Wed, 25 Jun 2025 10:03:00 +0000 (UTC) X-FDA: 83593484520.02.EC293CA Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by imf20.hostedemail.com (Postfix) with ESMTP id 59CF21C0012 for ; Wed, 25 Jun 2025 10:02:56 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=paYKpYi2; spf=pass (imf20.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.110 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750845779; 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=Q2xEIG12L/x5PKgfFpP7sX4Fq2b51V9mENpLnQ81O2w=; b=cmet4r7SJSNuAx47EgWCFHWbsRS3aLkYp+b6khQNxJw/InQnj4ENoc36DXcP+AwmLg0YBh Fi2HK8cyo1nn7x4994U357awWSjS01rzUs2R8HIkFKn36INvPRnEbHvbm9D7m6jndE+S0e VsW4+kX2Z7+0M5pNkOGffBUxX55OFKM= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=paYKpYi2; spf=pass (imf20.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.110 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750845779; a=rsa-sha256; cv=none; b=y455IxomVCP7Id7PwDeLhH5Kbm4ijaZJ9vlHRmKVS5DSHBtniBh0HEYSHG3Z8K1bvRHCPX YA4gCv6s4iKmi8UrI2uwIwn4spXGjLiSRZIlC6TnucQ/vSBf7FUxeSnG0edFjCWVsD43HG yAfkoQho+8epeL/XMaAUOm9BTMaMC+o= DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1750845774; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=Q2xEIG12L/x5PKgfFpP7sX4Fq2b51V9mENpLnQ81O2w=; b=paYKpYi2JaFFOB46wcSbB4cLOnfUxbJAx7hy9KMf7ZiE853LJKjz7rJNha5xycWj7gIfQdU9KM5IQRGmS42JZYj4MJ9F7EDTbF9qVAyHTSYeZNewKiBGfKTqLlE1WAw/W2KwQjKga0pwqwBlng8zNF2XZJ+kh1bpupxU2RyRn3w= Received: from 30.74.144.110(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0WewhO11_1750845771 cluster:ay36) by smtp.aliyun-inc.com; Wed, 25 Jun 2025 18:02:53 +0800 Message-ID: <37fc3553-0d5a-4bdc-b473-cd740d47598e@linux.alibaba.com> Date: Wed, 25 Jun 2025 18:02:51 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 0/2] fix MADV_COLLAPSE issue if THP settings are disabled To: Lorenzo Stoakes Cc: David Hildenbrand , Hugh Dickins , akpm@linux-foundation.org, ziy@nvidia.com, Liam.Howlett@oracle.com, npache@redhat.com, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, zokeefe@google.com, shy828301@gmail.com, usamaarif642@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <75c02dbf-4189-958d-515e-fa80bb2187fc@google.com> <008ec97f-3b33-4b47-a112-9cef8c1d7f58@redhat.com> <01d679f2-fd64-472c-b9dc-ebe87268ce82@lucifer.local> <23b8ad10-cd1f-45df-a25c-78d01c8af44f@redhat.com> From: Baolin Wang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 59CF21C0012 X-Stat-Signature: 6z4inrhfepsmbkkgugps8bgwoa9ymm1c X-Rspam-User: X-HE-Tag: 1750845776-916997 X-HE-Meta: U2FsdGVkX1+dUEiymo+fOTdK28I4FxshEZulDZVUIMfqpObQp9fSB5i6Khnxo/HeQmZeAFM0WWWAJtLgWfO0bvIiA0dH00TkhJoHv3bd/UCz8CHHfdJue8Ba6wmAXIwVvubZ/l7mD80V9MKTXRznzUsH/x8NPM24up67SRtXii0XTQALRb6EblZmUKy02m7SpVh2qIpD+FFKS0EoaDVv4UeDcl+sURsw6p5lbujUSJ/HW/2/sMc4PvYHEJBAGNMj75cjRJdh9KS4hYX+zva9vvW4uAIBS6n2b6ZvyKl1Dr7mGhTBwLvB9c2Pxxlb9NaPRJzZaOEU0GpFfaqhEDE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vack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2025/6/25 17:31, Lorenzo Stoakes wrote: > On Wed, Jun 25, 2025 at 04:52:03PM +0800, Baolin Wang wrote: >> >> >> On 2025/6/25 16:37, Lorenzo Stoakes wrote: >>> Yeah maybe the best way is to just have another tunable for this? >>> >>> /sys/kernel/mm/transparent_hugepage/disable_collapse perhaps? >>> >>> What do you think Hugh, Baolin? >> >> I think it's not necessary to find a way to disable madvise_collapse. >> Essentially, it's a conflict between the semantics of madvise_collapse and >> the '/sys/kernel/mm/transparent_hugepage/enabled' interface. We should reach >> a consensus on the semantics first: >> >> Semantic 1: madv_collapse() should ignore any THP system settings, meaning >> we need to update the 'never' semantics in >> '/sys/kernel/mm/transparent_hugepage/enabled', which would only disable page >> fault and khugepaged, not including madvise_collapse. If we agree on this, >> then the 'never' for per-sized mTHP would have the same semantics, i.e., >> when I set 64K mTHP to 'always' and 2M mTHP to 'never', madvise_collapse >> would still allow the collapse of 2M THP. We should document this clearly in >> case users still want 64K mTHP from madvise_collapse. > > Right yeah, I mean this is in effect how things are now. So the task is > documentation. > >> >> >> Semantic 2: madv_collapse() needs to respect THP system settings, which is >> what my patch does. Never means never, and we would need to update the >> documentation of madv_collapse() to make it clearer. > > Yes, and indeed this is the choice. > > I think, as David said, it comes down to whether we have a legit use case that > truly relies on this. > >>> (One side note on PMD-sized MADV_COLLAPSE - this is basically completely >>> useless for 64 KB page size arm64 systems where PMD's are 512 MB :) >>> >>> Thoughts Baolin? >> >> We should not collapse 512MB THP on 64K pagesize kernel. So seems >> madv_collapse() can not work on 64K pagesize kernel. > > Well I don't think anything would prevent this now right? So MADV_COLLAPSE is > pretty problematic on 64K pagesize kernels in general. Yes, I don't mean it will prevent madvise_collapse(), just as you said that it could be problematic (it's horrible to try to collapse 512MB). > Anyway that's maybe a problem for another time :) Yeah, should consider mTHP-compatible MADV_COLLAPSE.