From patchwork Wed Jan 8 23:31:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nico Pache X-Patchwork-Id: 13931713 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 28870E77188 for ; Wed, 8 Jan 2025 23:33:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3E846B008C; Wed, 8 Jan 2025 18:33:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AEED56B0093; Wed, 8 Jan 2025 18:33:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C1BF6B008C; Wed, 8 Jan 2025 18:33:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7D8B76B008C for ; Wed, 8 Jan 2025 18:33:33 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3B42D160B7D for ; Wed, 8 Jan 2025 23:33:33 +0000 (UTC) X-FDA: 82985888706.28.4C699C8 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 8019080009 for ; Wed, 8 Jan 2025 23:33:31 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dh1HAvXG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.hostedemail.com: domain of npache@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=npache@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736379211; a=rsa-sha256; cv=none; b=Mv8JkUl4Iu4F0I0prv2XyB1U/RtcOCh9u7KeISpxq17WbbDYjvxZRmFDbRBj92hSdaOC0k ybwfFUzsRpp0K3zUsdMg2JG/awiFtcCRXN6r5OvuzLh3oYkAp9oeGfpcGLD0PaJAuY087+ K07WTkw7EvXZiNjqWctYTuA1vkq37ts= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dh1HAvXG; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf30.hostedemail.com: domain of npache@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=npache@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736379211; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=T3A+lzu2HXugNjY9ipPnv1YBHYwcAbMPAnaFgxhpBsc=; b=zCfiQojx5QJIl8RaSb2TBC6kJLNFloiaqLsyjAFffdmeiG8t8IVxI+NwOEw3j958J5cD/Y +zNZBXnrzXqWDmRp7t+eFSDoiS+mo60uL2fiUJLH3KKelzrDD1tOGZxvTiSpIzohLdsjWq gtFNalrPI6Yq/hIOtGPny9bE0XK4XJY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736379210; 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=dh1HAvXGNXwofMdV5utwg//XO2J+KZBAsRcO0BOVM8Wy9LmQ9RIl/aWOV9RvGB6sR6jZAO 35HLlXhaGROP7Y+gRrAwWw18ecg2cOg7x5SpoHpp6MP8khSEZ1GCTh9HrKXbpZL3pRZhky 8ZzI94F2eotZ9hCN3oRsBEILzIWHX5Y= 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> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8019080009 X-Stat-Signature: m49moj73fkk3w1t3gxggqtfy74t3ijoe X-Rspam-User: X-HE-Tag: 1736379211-799581 X-HE-Meta: U2FsdGVkX19SzXje0DGnLLy0Cxd3lrW3TzneXSG41TYh3U4JQxMF19cmPJTDaUYRSVldMfIRRVZN/tJs06/U868g5Iey6ZRJ2QTjdXc7TdRmFaIugBW4HmaXwcPu3RQZBe4xsffz2DZsZD1ownYMyBg/ruEBtREcL4XiCUz9AQ3OJZqUkYG73iaj0D3x+m9T/T+0sAAzWdLXCSu5OzrBH7CQExxgPlAv8IeiuX/5bWZ0x+lkPX7YB4SnRtKV+xc4Md0yhifrXgdkWjOm7VAjZL0gXbVo4dd3HPZyHIHTvN+gqWqpcun+Vw7c+j1Mqi8/0prJC2auJCHrBf2YGP2ZwpbNNiuBxqtyl1RMdj5xWetyuIfa/kIZRdasK5kfUGfssqm1+aDXndp/isqjmOmE3CUcC2rzvvVU7HpsbvPVZ9SGAklS3JQ9gWvwIrM4r6wC0rPT9DQeYhKvZCSsii6Bp1pcmdzRGOWkvc3hg8cBXlWHsONqxnIxrB8+XkRy9SY4B45yPfSTu4+KD2LPeOOGshzAANdQHKu00cY8kvHsq3Y7pu1sfvcqFiYamRPjtN7T3zNPHKDzrbKXodP7flp3MFlg8xnTMkd47qhcKxDAaVX5YRom8sZn4Qp2FtZWD2GL84VZRSyQ7x5I02ZfGG8erYty7Wng2VWtnpOwVNJaRwrx7FOmBi6lff52GQxzj9pg0N6vF4qsUVWPy6SW6HhkXxH3++hAlXP6mTph3/2XTBiBdQXBEBNLppMl7hljkMmFY+Kn3arYHBVrGW+Ou6s6XanzRtV6Jl9Jipcyj0kvXWFvYc7FroeeFR4BLu0FSflC/b4RiQpUJ/fEE2Tbhzitg7Rs0qsyEWd8kdKgJuAMMlOf7jOyfuVew36j2lU7tAh571cALhxM5SlrEQnDLAFglGp2IQ5WoeJ4zA7G1zY2VY6HtgRuRzyxDFRFjVijZ9i7WCUksrIY4aAECc998/Y G4D86Aoe tI1kqIakpxmBK2SXWx1zfakZbkpxTdl4MGkTXXtOp/A5wdONXEhKZ6/AXNcSSTHBAdumIeEmx7QHlDi0CH1cy7YHednS67Bocs1lcfFvMOum3ULSmkZigantShL7KC07CDk+W71Dux4Wq1qltVrnakqH6gaa3yNwrp9z5EYWrbarBK+6gvnfck+29tSoP9Vhg0SqCgojUZ8BxjFZyzH+fIJBCWn1u9TY4hzbBko6XwzNuhYjcdMzfVxNway0SPv7SzpadS+JyD3bU+FUTID/kDCdzwGBzaEGTjvFJ2LKUMrxclYRJOfycAGeVMrsSHR67O2IkyQiFhQftWqBmzcrZDRewaJGkjfFsBW8i6PYtYYhKJFmOevtosHha5cYbRupFhZzD5zHDfkhaqEV1zfT2VsuUChNg9A/LG7V9Ze44g959EOpCLeWx41uvv8565G24AI6I 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: 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 = vmf_anon_prepare(vmf); if (ret) return ret; - khugepaged_enter_vma(vma, vma->vm_flags); 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); }