From nobody Sun Apr 5 21:17:50 2026 Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) (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 1FEF0371CE6 for ; Fri, 6 Mar 2026 06:44:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.97 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772779453; cv=none; b=r4J0R17ZGOMnfYvh7EDwf3DprxSb3x7C0TesumyZRxN8AFHvvWnAVSWqRo7qtsWfGVFIJPvvMSu3nQxAf2wvv8fXIzPC+VcakA4r6zego0y40HtPX5TtkToxtvQf5JMIEc0lVVjcomSt2qWZHcF5vIn0IMItoQF5CISE8gV9P7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772779453; c=relaxed/simple; bh=nwRBWLFjAOscqgJ3K43q8KfCEe4AX1vIU8v1hAiiSYo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qv3uvQ15ZEYwzqXUyRzzD4KgGe6P9MsgU/PdEXnOM+FM2ToelXUvFsoXsTjPqBQvndCHjvvaE4nFksME+uq6A+sG6LldvoHHA/TntJz2SBWIVrtAN0H4fP1JjOcEjEHwlwg/7RM26QlCcqilDHq8h4RQcFt6uDHSkGCssz9+c6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=tj1/oSdg; arc=none smtp.client-ip=115.124.30.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="tj1/oSdg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1772779444; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=HTT2hSwhIX0sy9uprNVi4qKHugU4cvVQ3G9ad8x784g=; b=tj1/oSdgunBO2uFijstY4+XQRmGVchCyYNbCy/0bphQ8LCt+17ihlQWaVnBs1pjiuCYN8rzw4V2wSvwK6D0nxPZ/O9Dji58mEf4Hnbsg4pkmHotXJdUmMznr6VnYiiATjWHgsOoU6Yx0z/jx2vvniXCjU+yvXyYGFN9pzjER/8o= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0X-MKhEA_1772779441 cluster:ay36) by smtp.aliyun-inc.com; Fri, 06 Mar 2026 14:44:02 +0800 From: Baolin Wang To: akpm@linux-foundation.org, david@kernel.org Cc: catalin.marinas@arm.com, will@kernel.org, lorenzo.stoakes@oracle.com, ryan.roberts@arm.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, riel@surriel.com, harry.yoo@oracle.com, jannh@google.com, willy@infradead.org, baohua@kernel.org, dev.jain@arm.com, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, hannes@cmpxchg.org, zhengqi.arch@bytedance.com, shakeel.butt@linux.dev, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/6] mm: rmap: add a ZONE_DEVICE folio warning in folio_referenced() Date: Fri, 6 Mar 2026 14:43:39 +0800 Message-ID: <64d6fb2a33f7101e1d4aca2c9052e0758b76d492.1772778858.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: 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 Content-Type: text/plain; charset="utf-8" The folio_referenced() is used to test whether a folio was referenced during reclaim. Moreover, ZONE_DEVICE folios are controlled by their device driver, have a lifetime tied to that driver, and are never placed on the LRU list. That means we should never try to reclaim ZONE_DEVICE folios, so add a warn= ing to catch this unexpected behavior in folio_referenced() to avoid confusion, as discussed in the previous thread[1]. [1] https://lore.kernel.org/all/16fb7985-ec0f-4b56-91e7-404c5114f899@kernel= .org/ Reviewed-by: Alistair Popple Acked-by: David Hildenbrand (Arm) Signed-off-by: Baolin Wang --- mm/rmap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/rmap.c b/mm/rmap.c index 603186ff4ba5..2d94b3ba52da 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1065,6 +1065,7 @@ int folio_referenced(struct folio *folio, int is_lock= ed, .invalid_vma =3D invalid_folio_referenced_vma, }; =20 + VM_WARN_ON_ONCE_FOLIO(folio_is_zone_device(folio), folio); *vm_flags =3D 0; if (!pra.mapcount) return 0; --=20 2.47.3