From nobody Mon Jun 8 05:24:59 2026 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (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 C26423655DB for ; Tue, 2 Jun 2026 17:23:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780420989; cv=none; b=ADogKgsvS0gzEJInkSCnjtQ9wkErcqzKf9+00lmDzrfoPXj8kWTD2UxSoBIPVVEssuRq7yxRXpe6W70nY9DlOlmecpnGHZBtGEvS/SmKvVK/AsZ5Es+SWnWssKkGOOHIb2VojxTG80nxHbmZ9WqAJuTPB2hAuuhVH/MEGUtR5Pc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780420989; c=relaxed/simple; bh=Nsybyk7HVXKzDtUuPadzS1apRsCDkcXWMmBJ7XMh6nM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=KGQ5v9FyfA2ARk7oFz/n1VErkBk2KODrfuqVhpNMUb7rEyO/sym832ByG1KS2KifqXkDVY8ev3nG/5gEO4aUd6n+N+q25UmpGjEZ6JaEo5SE3C0zhZRG5GaT4kZqFVBB4YSxIHaLkmmlkV04MEr5xiu3FhcioffdEtWw8cvrQys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=p8IkT7wf; arc=none smtp.client-ip=91.218.175.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="p8IkT7wf" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1780420985; 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; bh=LuoNOAKT3xp/Mcyg5zk9iG0boykaRa5ZJsdMV4nHiMc=; b=p8IkT7wf60XE8WKTbHBevmxzimClhYD6p5B4fw0QOtOGyK64bWuUPbRK4Eg6XWsVoqEG7I n5lMoOdDR4S5f9+WFRdbAxZUNNcodgoTxJJTxa/VRi4KYaox81WY7o5bmEJQj3Y0pYDjgK NhqNfISEye3bBLHg7kMXBBIQ0c6ffyc= From: Usama Arif To: Andrew Morton , jannh@google.com, liam@infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ljs@kernel.org, pfalcato@suse.de, vbabka@kernel.org Cc: chrisl@kernel.org, kasong@tencent.com, baoquan.he@linux.dev, youngjun.park@lge.com, hannes@cmpxchg.org, riel@surriel.com, shakeel.butt@linux.dev, kas@kernel.org, kernel-team@meta.com, Usama Arif Subject: [PATCH] mm/mincore: handle non-swap entries before !CONFIG_SWAP guard Date: Tue, 2 Jun 2026 10:22:47 -0700 Message-ID: <20260602172247.279421-1-usama.arif@linux.dev> 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-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" mincore_swap() also fields migration/hwpoison entries (and shmem swapin-error entries), which can exist on !CONFIG_SWAP builds when CONFIG_MIGRATION or CONFIG_MEMORY_FAILURE is enabled. The !IS_ENABLED(CONFIG_SWAP) guard ran before the non-swap-entry early return, so mincore_pte_range() can spuriously WARN and report these pages nonresident on !CONFIG_SWAP kernels. Move the guard below the non-swap-entry check so only true swap entries trip the WARN, and migration/hwpoison entries take the existing "uptodate / non-shmem" path. Fixes: 1f2052755c15 ("mm/mincore: use a helper for checking the swap cache") Signed-off-by: Usama Arif Acked-by: Johannes Weiner Reviewed-by: Kairui Song Reviewed-by: Lorenzo Stoakes Reviewed-by: Pedro Falcato --- This was discovered when working on PMD swap entry series (https://lore.kernel.org/all/20260602142537.198755-1-usama.arif@linux.dev/) --- mm/mincore.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/mincore.c b/mm/mincore.c index e5d13eea9234..296f2e3922b5 100644 --- a/mm/mincore.c +++ b/mm/mincore.c @@ -64,11 +64,6 @@ static unsigned char mincore_swap(swp_entry_t entry, boo= l shmem) struct folio *folio =3D NULL; unsigned char present =3D 0; =20 - if (!IS_ENABLED(CONFIG_SWAP)) { - WARN_ON(1); - return 0; - } - /* * Shmem mapping may contain swapin error entries, which are * absent. Page table may contain migration or hwpoison @@ -77,6 +72,11 @@ static unsigned char mincore_swap(swp_entry_t entry, boo= l shmem) if (!softleaf_is_swap(entry)) return !shmem; =20 + if (!IS_ENABLED(CONFIG_SWAP)) { + WARN_ON(1); + return 0; + } + /* * Shmem mapping lookup is lockless, so we need to grab the swap * device. mincore page table walk locks the PTL, and the swap --=20 2.52.0