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 08ECFE77188 for ; Thu, 2 Jan 2025 21:59:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56F056B00AF; Thu, 2 Jan 2025 16:59:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F8406B00B2; Thu, 2 Jan 2025 16:59:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3708A6B00B4; Thu, 2 Jan 2025 16:59:25 -0500 (EST) 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 14E9E6B00AF for ; Thu, 2 Jan 2025 16:59:25 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A9D208045B for ; Thu, 2 Jan 2025 21:59:24 +0000 (UTC) X-FDA: 82963876674.07.4853F6E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id EA0C0A0005 for ; Thu, 2 Jan 2025 21:58:45 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZZGLwiF2; spf=pass (imf25.hostedemail.com: domain of npache@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=npache@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735855139; 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=2dmhZ7gmG7X6uKXVMhM4JfmTa0O6Rc/rND4J5rIyD/o=; b=pRLKc1amuhAY7Kb56GidkFGXOr/XhHwXeCAc4nX8FsGsRoV8C0/9tYEdVs4Hi96+ZtFZRW QpZCCW6gfJ1u1Jj967H2R37OH9mCCkYd04+ye+gjuWCBLjHsu+ubHFUEvYb2qo5LTEqdEt kPr0B68JMyd2NxDSx/OmOJ07e2gJDI8= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZZGLwiF2; spf=pass (imf25.hostedemail.com: domain of npache@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=npache@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735855139; a=rsa-sha256; cv=none; b=z/IF6MHpYzt65iS4hL0MruxslbfS156wpPlZ2QdlJOkkjutnOCDqm8w3pBRv3jwzDRMhFp g+E5RfF/wM13VLG1bsRS6eXlH7Er2o5atxmLL5aDFrcWcxkoXMrc4mJnwW5oTaRbomFyfq bhMXrIhhvC+So+naIn5EJ6d7MwHb+YY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735855161; h=from:from: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; bh=2dmhZ7gmG7X6uKXVMhM4JfmTa0O6Rc/rND4J5rIyD/o=; b=ZZGLwiF2Ue0+AlG/vE4sA8rPrTxZpSWxt3yt1Ds6ggMJIv3EvHfCAa0l5auT/uW8LBeUUr bONaLO6dYTu5pV7YmPj0OFp8TuFU9yjwjyRTGJ+L9UM+m01wbSOx2r1NfL3hjUM9tnFEJW uqYbkxwMmQSfVTJrCTR1SEQrr05dXyc= Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-215-s_sNx5hNMISzQmIT7ZcuIA-1; Thu, 02 Jan 2025 16:59:18 -0500 X-MC-Unique: s_sNx5hNMISzQmIT7ZcuIA-1 X-Mimecast-MFC-AGG-ID: s_sNx5hNMISzQmIT7ZcuIA Received: by mail-yb1-f198.google.com with SMTP id 3f1490d57ef6-e35e0e88973so26515029276.0 for ; Thu, 02 Jan 2025 13:59:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735855158; x=1736459958; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2dmhZ7gmG7X6uKXVMhM4JfmTa0O6Rc/rND4J5rIyD/o=; b=kiWl7R5nVtpojDZI4RF2oTvEeIpLhjEtaJ2+iYFkWFMFjdcGpEzE5zf+RMhN36j4vJ b6C82CWlTetaRPQHRLLrsNEETxS5xYCUe4Dj8pQNjXz5v/eAWdCKVa+nwr8ZZiTDd+E6 UytTjm7dTT3ARuRBJedF+EZuxHKcU0onyWLjfpnvB4fBXldznNPfDNRiJURtcl3ncXYn 08JLbco6tEflHcvgjOaRlWuULLkXHM5PXOvvYfwu/34ne3Uobp8HE7IB21YOmVeQ8er0 ZT8J5+uxPqBbCFNtoiDwgqI153kEjjzw3/fOa7GhHVIFbfxZOGaYW/FLHtPnArJCHlyu Ka6g== X-Forwarded-Encrypted: i=1; AJvYcCXyIOQbEEV7AL1ScN88CNAOxCFb93SWaohrHR3816JZAXLszvn57cdbIR+8hTAsYMl2ouE2Tv/FTA==@kvack.org X-Gm-Message-State: AOJu0YxV6TWupLw97E20v2FEicNH5JOSUzmWWw7Q/2OlJLsH7L/v4nxs sDrCNppbNNwJrbuyqU5mdSlKnETM+rQ6ouT0tkBc7iTDmwHJpcCMm6I8Z7loBZJEPVz68rXtEj0 npdt3w4ZP8DichtFcX/gp0LiANCxyLOkB+z8t4ebE57nMw/zSgCulUUh2xXXO6FJeVLkBQAL7rE LEjcijJOarqqXaY/Wg76bacYI= X-Gm-Gg: ASbGncu1jD+73ER4iJjnkz24C+KhQUzlSAUQfH6MVEC6roVrWO+cYkEv4AHF5dowvxM 2fzutxZYea7Z6PhtQ+ITXuMOIvar/OTuFPhdn4MAxMZRsMLGwvy6d X-Received: by 2002:a25:8682:0:b0:e3c:89ad:79e7 with SMTP id 3f1490d57ef6-e537657addfmr38510619276.8.1735855158026; Thu, 02 Jan 2025 13:59:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEaPNBBVUmYIULRKmrbScf8x9hgM9Aui1e8/Wk6tcIl7TwBQwVSQIeE5jMFnk5DDulhpp2lPV9A7S72tpPT8dI= X-Received: by 2002:a25:8682:0:b0:e3c:89ad:79e7 with SMTP id 3f1490d57ef6-e537657addfmr38510579276.8.1735855157710; Thu, 02 Jan 2025 13:59:17 -0800 (PST) MIME-Version: 1.0 References: <20241216165105.56185-1-dev.jain@arm.com> <6f7fe967-0864-4b96-8426-cd9d6655d207@arm.com> In-Reply-To: <6f7fe967-0864-4b96-8426-cd9d6655d207@arm.com> From: Nico Pache Date: Thu, 2 Jan 2025 14:58:51 -0700 Message-ID: Subject: Re: [RFC PATCH 00/12] khugepaged: Asynchronous mTHP collapse To: Dev Jain Cc: akpm@linux-foundation.org, david@redhat.com, willy@infradead.org, kirill.shutemov@linux.intel.com, ryan.roberts@arm.com, anshuman.khandual@arm.com, catalin.marinas@arm.com, cl@gentwo.org, vbabka@suse.cz, mhocko@suse.com, apopple@nvidia.com, dave.hansen@linux.intel.com, will@kernel.org, baohua@kernel.org, jack@suse.cz, srivatsa@csail.mit.edu, haowenchao22@gmail.com, hughd@google.com, aneesh.kumar@kernel.org, yang@os.amperecomputing.com, peterx@redhat.com, ioworker0@gmail.com, wangkefeng.wang@huawei.com, ziy@nvidia.com, jglisse@google.com, surenb@google.com, vishal.moola@gmail.com, zokeefe@google.com, zhengqi.arch@bytedance.com, jhubbard@nvidia.com, 21cnbao@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: qS1EQzvaxMs1-aSyeRV8RaKh_Lptri4eNATjvWBTVIQ_1735855158 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: EA0C0A0005 X-Stat-Signature: eyxrahw8taq9q83dg8cti8jpq6j3yrfo X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1735855125-676196 X-HE-Meta: U2FsdGVkX1/FG2W8agwn+rPQpJk9uISGuAA1acfE+zLwRl4HyqjdACgczb3l+Z+KiQy/MspRp93vxa6Bn6ndLITe19vFvCBdWAqh4zfSwI3GzxE1jbQhuCiRL137eSsIUii7mE6NE0BB5HKaF21z3PUTqAX00W/QDZkV27cjnJTL5BuJpU4xb91cL5pWMN9dLNaUyofFY7023dEX24XbY/2A9CddeeN96PVaX5ZSnmpZVnRMp05YTWlmPSF/cJp+v/eVDw7UAwH+3elbl7H7euwWz5fKSl9EflEsHLEBCputA30DwtFllWI0z3WSob5GFL3tieUXLwtmNHPIITcDK6UB4QpytwEVHVINfbPKx/ggqAKdXXsChoplLkLgdTXEEEGdXx2qL8ofnryEFnl4G3yIayoW7eucWPppnsvRVeUcp7f3ve18oRU1rCc3R30wLZgFCcOx/1OCFsNYhn2Uyf49LLb/QaXIMXtcwlvG/xUVV0d0BKeJfcL2e8y8+0r6AXRG9q6LAJyxlMEuaWQ4Zh7j4MCe+TsRyWVZydqvLxgQXM6Y8KSO1773lewVEU/YqanwAl4RaPkwBASsxpk7t9jAGYEsDiyjXSMkIXUTTGLGSzVZJ7naTolTUC4gBDbfrxBpvpw9A4gzEJTFt8ykxWSG0f7UQjj0v1ZU3eqDN/kxm77w+DPXm2UoB4FAwb939rRGYALvcOKIHJ98EjtMIL8UvGE9ja9xRCkhMtILP/OR/0JWdT1+nryQN0YSxdSoCm0VyaIIcN3TXLt4SzLA2LnPSc4EVasMz+w1zYjDkTHwwPf/F9mWh/P4+yyhHPXS0huM40ZHogRltGvsjU/Tt7F8xLb6OvR9vvepeJ7+hxXWQEcUgGLsjrLsI3iMEMkphbAl/TeSp3/q+XH6hWUDl7YDgIPNSbzQfQdSw+RxiwRPnPRMwKLdMlDq9A+rtgZv//BrQK5Lb7uz8zuKeO7 TU3Pe8Ur ziNODEQ/MvBHx7/p7uqEVrghpQP2yWs29UdyqmxmTWeEfmx+EGKPNj5XKt7jY+LlFHnf8KLc4gQqiwcKNAC4DEAqAftedpvfnJehmuJyZNM6UWpdmOZeiJaF8Gp0K8KQ9uh7gi9pHOXBOPHZlxaszutq5hAkMmhoFmhFeUq44HSy9Ta+4gxbs15xuMCTfwTn641Fm2ykgBbx4zwntPKi0R5OXxd3zifzOS5lAjQ4DBDyVxAKVYmjccCJvptZZaybToqjB5FOiyUlBm71Fsuzn9ukYBlCw4h/hb50bpeWtu2kufCfTTIgGAl+VQYWZJSJgck9/+E9bqYVAUDHjK/zKx45zN8bfBCF47nR9TGuDNSgSuG56Q9KqhbUbzo57Q3e0Tdnl 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 Mon, Dec 16, 2024 at 10:31=E2=80=AFAM Dev Jain wrote: > > +Nico, apologies, forgot to CC you. Hey Dev, Happy New Year! Thanks! I'm trying to apply/test your patches, but am failing to apply them due to mm-unstable which has "unstable" sha values, making applying them difficult. Could you share a public git repo to your patches? Also, have you seen any issues with your patches? My version of khugepaged mTHP support was mostly done before the holidays but I haven't posted due to some issues with (BAD PAGE) refcount issues when trying to reclaim pages that I haven't found the cause of yet. -- Nico > > On 16/12/24 10:20 pm, Dev Jain wrote: > > This patchset extends khugepaged from collapsing only PMD-sized THPs to > > collapsing anonymous mTHPs. > > > > mTHPs were introduced in the kernel to improve memory management by all= ocating > > chunks of larger memory, so as to reduce number of page faults, TLB mis= ses (due > > to TLB coalescing), reduce length of LRU lists, etc. However, the mTHP = property > > is often lost due to CoW, swap-in/out, and when the kernel just cannot = find > > enough physically contiguous memory to allocate on fault. Henceforth, t= here is a > > need to regain mTHPs in the system asynchronously. This work is an atte= mpt in > > this direction, starting with anonymous folios. > > > > In the fault handler, we select the THP order in a greedy manner; the s= ame has > > been used here, along with the same sysfs interface to control the orde= r of > > collapse. In contrast to PMD-collapse, we (hopefully) get rid of the mm= ap_write_lock(). > > > > --------------------------------------------------------- > > Testing > > --------------------------------------------------------- > > > > The set has been build tested on x86_64. > > For Aarch64, > > 1. mm-selftests: No regressions. > > 2. Analyzing with tools/mm/thpmaps on different userspace programs mapp= ing > > aligned VMAs of a large size, faulting in basepages/mTHPs (accordin= g to sysfs), > > and then madvise()'ing the VMA, khugepaged is able to 100% collapse= the VMAs. > > > > This patchset is rebased on mm-unstable (e7e89af21ffcfd1077ca6d2188de64= 97db1ad84c). > > > > Some points to be noted: > > 1. Some stats like pages_collapsed for khugepaged have not been extende= d for mTHP. > > I'd welcome suggestions on any updation, or addition to the sysfs i= nterface. > > 2. Please see patch 9 for lock handling. > > > > Dev Jain (12): > > khugepaged: Rename hpage_collapse_scan_pmd() -> ptes() > > khugepaged: Generalize alloc_charge_folio() > > khugepaged: Generalize hugepage_vma_revalidate() > > khugepaged: Generalize __collapse_huge_page_swapin() > > khugepaged: Generalize __collapse_huge_page_isolate() > > khugepaged: Generalize __collapse_huge_page_copy_failed() > > khugepaged: Scan PTEs order-wise > > khugepaged: Abstract PMD-THP collapse > > khugepaged: Introduce vma_collapse_anon_folio() > > khugepaged: Skip PTE range if a larger mTHP is already mapped > > khugepaged: Enable sysfs to control order of collapse > > selftests/mm: khugepaged: Enlighten for mTHP collapse > > > > include/linux/huge_mm.h | 2 + > > mm/huge_memory.c | 4 + > > mm/khugepaged.c | 445 +++++++++++++++++------= - > > tools/testing/selftests/mm/khugepaged.c | 5 +- > > 4 files changed, 319 insertions(+), 137 deletions(-) > > >