From nobody Mon Feb 9 00:03:50 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 0A490204C2B for ; Wed, 8 Jan 2025 23:34:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736379275; cv=none; b=mN/6LaPiLp+hWCL5dXU9XXy0NE11ScXPSiANLTmTmAwtcZZOgDRE/tDRSQZ5/EQqpfXyy62EEG5oIQsOcpLme8I2qau1rZ15d4tXLWvX2CZqro++n6QD0ANnzkQzmQ0gtGwimrVh6XduEkOM4L0XHqwDzwNorfPWpRF0FZA6fS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736379275; c=relaxed/simple; bh=aGA3Cg3acrjmWfvKMaOzQWtX5r/SLsw3Ic0wyCbOOhY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tAVaEslmPVIKk4gZimyv4PFi8Kmu/zAQDhoTuZdMoQga6wkk5SrC6kKcgHXedtLLr+2IOIbRbGXEUDHExEjMXn6VHuH2O6jr0IpOZhdkbpivaKc24qYaZVPRbgoewyNMsjO9UWH2xTC4UXvWOylSLq+RAgLNFd0zQ70c5EkV08w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Lg3kC8q1; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Lg3kC8q1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736379273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j5EOVM0v0gflap4pKtAxxmUaALnCNv8cRd9oJSElYf8=; b=Lg3kC8q1v2MBNsj/lUmZi+FTmlFCFExfNt0uKLAyymjo322enanOAC5Fk0gIIikVIqHP7m h2xtTakft42J3pnlkmQeVhzpZXDUrqM5QdCX9Zq4PgsG+wSWW3Goa5/8VnMi0GLn5qcEQB Nsr0rDHy+ZaoDEP4fChEewZmQxLmaF0= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-584--pEwM4wDPgm_w6pskDoyhA-1; Wed, 08 Jan 2025 18:34:27 -0500 X-MC-Unique: -pEwM4wDPgm_w6pskDoyhA-1 X-Mimecast-MFC-AGG-ID: -pEwM4wDPgm_w6pskDoyhA Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E58CE1979053; Wed, 8 Jan 2025 23:34:22 +0000 (UTC) Received: from h1.redhat.com (unknown [10.22.80.41]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4B9B419560AE; Wed, 8 Jan 2025 23:34:14 +0000 (UTC) From: Nico Pache To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: 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, willy@infradead.org, kirill.shutemov@linux.intel.com, david@redhat.com, aarcange@redhat.com, raquini@redhat.com, dev.jain@arm.com, sunnanyong@huawei.com, usamaarif642@gmail.com, audra@redhat.com, akpm@linux-foundation.org Subject: [RFC 10/11] khugepaged: remove max_ptes_none restriction on the pmd scan Date: Wed, 8 Jan 2025 16:31:26 -0700 Message-ID: <20250108233128.14484-11-npache@redhat.com> In-Reply-To: <20250108233128.14484-1-npache@redhat.com> References: <20250108233128.14484-1-npache@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 Content-Type: text/plain; charset="utf-8" now that we have mTHP support, which uses max_ptes_none to determine how "full" a mTHP size needs to collapse. lets remove the restriction during the scan phase so we dont bailout early and miss potential mTHP candidates. Signed-off-by: Nico Pache --- mm/khugepaged.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 4d3c560f20b4..61a349eb3cf4 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1446,15 +1446,12 @@ static int khugepaged_scan_pmd(struct mm_struct *mm, if (pte_none(pteval) || is_zero_pfn(pte_pfn(pteval))) { all_valid =3D false; ++none_or_zero; - if (!userfaultfd_armed(vma) && - (!cc->is_khugepaged || - none_or_zero <=3D khugepaged_max_ptes_none)) { - continue; - } else { + if (userfaultfd_armed(vma)) { result =3D SCAN_EXCEED_NONE_PTE; count_vm_event(THP_SCAN_EXCEED_NONE_PTE); goto out_unmap; } + continue; } if (pte_uffd_wp(pteval)) { /* --=20 2.47.1