From nobody Tue Apr 7 20:07:42 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 63ED33C1977 for ; Fri, 27 Feb 2026 09:44:58 +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=1772185500; cv=none; b=rqfJJUwcGIhx0V1olN4wcco2e6vJc/0EGdGw+w6nObKFQY2dEynAaLKuZKxa3AeWiw1iJ6cCwAzVLwAtyq49uMEzrg0C3sd9eOe9MmfZfnsS0OoBaFQPDSq2Dl4/iyNHez82W7ctmlrDRPS/jYjCNSPG0+7I5h3ogDzedDHgmPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772185500; c=relaxed/simple; bh=4HxKxjmwrSuGDoVoBNMI8AAdABa/ffdH9PHwu9Qn+Oo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=co8lBEip5r6P/OwamqXlB/kBIfO1Xl6+eKWjBi7PUkhBIS0bEBIJ0TKLxhpE+Mhuz6hJKuQOqm+tPtZjNFYr8PFuRa9rtkOtWkRElzAXMQmtUiRm0UVn58takNBPZSWYtu7Glyewt4s47/83C67cfyMFgQp6R0GTGWXmCPl3k5c= 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=MN52tlDr; 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="MN52tlDr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1772185496; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=TFvgQ+JoosgOuHvCEtm/wySIDfFeyNBVmJ3HBIM12WU=; b=MN52tlDrVxlU2YBhdh34hRUl2Or13cX+jf1/VE9Il5HznzvPMH2VeSdquDkZnElioB0KH3VcdWTCfGtgs4WWiPTUxF+uqDUasIzXgp2fnuCQsrZfZUBNN1S2+Lz6J09ghDqOgB1zZA4QhhdTmtuvZ/niybo3JyroYIwLu1fw5/Q= Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0Wzu0LeH_1772185494 cluster:ay36) by smtp.aliyun-inc.com; Fri, 27 Feb 2026 17:44:54 +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 v2 3/6] mm: rmap: add a ZONE_DEVICE folio warning in folio_referenced() Date: Fri, 27 Feb 2026 17:44:37 +0800 Message-ID: <6562be8c92e07f0a69c8ffd4016d1b1e55198af6.1772185080.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 bff8f222004e..11cc6171344f 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