From nobody Sat Feb 7 14:10:27 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 1E04A204F80 for ; Wed, 8 Jan 2025 23:33:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736379213; cv=none; b=GpxtJj8Rmik60HRmw2eWTg3VDyXTw3ZUnigz3/+Q8oF/W/YZV6Lzg3Mc6rUN/UpsDYa3LLmsacXm5eEMSkbarTkZKACj0Eid+KCDZ5Bj58pGCQUZZpR6TgoX3QvNgCsNQm4vt4fRXbSgThs6g3zac/KCrYyHzHNluK1yhV2qb7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736379213; c=relaxed/simple; bh=fNkGBIqJ9qIORN1Lf1JT8E7r97Bj8+Kl47v9jfAFSts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dtg0UtSn412+8ukzRCCV0n9liUDyKG7NpnyyH5qvOVeshAaid+l/xiF/K4saCYCcPlIio1dHwnLqEcJxBOH+F6WP061m9pIsEiaytmr5VCTdpR6iGy8N5Xq6mEWpQKRfQiXtUbHLJDvEUGsUHtJNu8XRcPuPajVtADaxQeNo9RY= 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=Aglp1BMU; arc=none smtp.client-ip=170.10.129.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="Aglp1BMU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736379211; 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=T3A+lzu2HXugNjY9ipPnv1YBHYwcAbMPAnaFgxhpBsc=; b=Aglp1BMUCzMS1BZxbEfFZHVB1x3S+se5JaKLbL2ig1Uhrwn4Mrv+3JskqARx1kO+jn5QpZ mGBNSlVRk1+pMzM6jc1vbxM8WCH0h7Sul495elD2QbpbXeQ+sND63/lzl50jKAW5lQ4AsF fm1yKxUlnRRF12pTH36K+lQQOXg9TGw= 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-639-lr8fwzThMiy_-N9z-nI7IQ-1; Wed, 08 Jan 2025 18:33:25 -0500 X-MC-Unique: lr8fwzThMiy_-N9z-nI7IQ-1 X-Mimecast-MFC-AGG-ID: lr8fwzThMiy_-N9z-nI7IQ 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 60E741944B2E; Wed, 8 Jan 2025 23:33:21 +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 2789F19560B7; Wed, 8 Jan 2025 23:33:11 +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 03/11] khugepaged: Don't allocate khugepaged mm_slot early Date: Wed, 8 Jan 2025 16:31:19 -0700 Message-ID: <20250108233128.14484-4-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" We should only "enter"/allocate the khugepaged mm_slot if we succeed at allocating the PMD sized folio. Move the khugepaged_enter_vma call until after we know the vma_alloc_folio was successful. Signed-off-by: Nico Pache --- mm/huge_memory.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index e53d83b3e5cf..635c65e7ef63 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1323,7 +1323,6 @@ vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault= *vmf) ret =3D vmf_anon_prepare(vmf); if (ret) return ret; - khugepaged_enter_vma(vma, vma->vm_flags); =20 if (!(vmf->flags & FAULT_FLAG_WRITE) && !mm_forbids_zeropage(vma->vm_mm) && @@ -1365,7 +1364,7 @@ vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault= *vmf) } return ret; } - + khugepaged_enter_vma(vma, vma->vm_flags); return __do_huge_pmd_anonymous_page(vmf); } =20 --=20 2.47.1