From patchwork Tue Apr 30 20:40:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13649976 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 42FA6C19F4F for ; Tue, 30 Apr 2024 20:41:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 196EC6B0089; Tue, 30 Apr 2024 16:41:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F77D6B008A; Tue, 30 Apr 2024 16:41:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDA116B008C; Tue, 30 Apr 2024 16:41:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CDD1C6B0089 for ; Tue, 30 Apr 2024 16:41:01 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 575D91C0DAC for ; Tue, 30 Apr 2024 20:41:01 +0000 (UTC) X-FDA: 82067367522.25.DDF17BE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id AEF98C000E for ; Tue, 30 Apr 2024 20:40:59 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HnSGJog+; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714509659; 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=M+xMysOaTLOUYcuh4ijK9OYwvDDRj3hF0BT7ZxHVSLo=; b=GD+m2641quwjN+KLJB8bEOFDUVzseBI+0M/NjZCvw2ko33dh+tYHBprRzVEHVY47XoxxPQ 9Liu9XC8FYINE1sLOLNhRhI9v/5oQQSXrmA9Ca1wsrzFlx7c7MkxFoaSfJJ4KKwFWa463W J/0xNxehUFeG1fhygBOz7qWKPPCbkuk= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HnSGJog+; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714509659; a=rsa-sha256; cv=none; b=OjY6D/OqzUS9qId1DhSsu0yhZC5sQtWbyE6bgaBkPqfs6vaKt37NK/DSZBwWBlvprgI9bD lfsdbX/QrgquVavPaubCSETp0DGDZpReCKVqJQuhIvoFERoHySEeib+5R6gnzpKqpvZqOT yBQGB8BirKb73zWoQFWmG52wk7ZPkOs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714509659; 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=M+xMysOaTLOUYcuh4ijK9OYwvDDRj3hF0BT7ZxHVSLo=; b=HnSGJog+6I8Alx1Td8Aep2FqFmftETxmJ20EgeyT72bq+EB+F0rinXFtWi0nN7TVvx0ixp f/aLr/JuBvsETnBlKMUwzAexXaCRGVJdp/sHzgEeWna0NXDi2tY9jLf4nT3WcKrVx9iIhQ yeOfPt3U6mdJbrdn1IHjvK1mdQKFRwk= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-529-YnVIUqY2MHGA4ILpxZDr4A-1; Tue, 30 Apr 2024 16:40:55 -0400 X-MC-Unique: YnVIUqY2MHGA4ILpxZDr4A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 093CA3C000AA; Tue, 30 Apr 2024 20:40:55 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.39.192.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 288E9C13FA1; Tue, 30 Apr 2024 20:40:52 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Vincent Donnefort , Dan Williams Subject: [PATCH v1 2/2] mm/rmap: sanity check that zeropages are not passed to RMAP Date: Tue, 30 Apr 2024 22:40:44 +0200 Message-ID: <20240430204044.52755-3-david@redhat.com> In-Reply-To: <20240430204044.52755-1-david@redhat.com> References: <20240430204044.52755-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: AEF98C000E X-Stat-Signature: a8km9mpui71arp317uk9icr53ibyqc94 X-HE-Tag: 1714509659-727222 X-HE-Meta: U2FsdGVkX19eqQpXACt14MrrzqTU4ofwl+2GfekyIjx0+iPnMqGy0CGrBJ8+UPA6rK3ZtbN0ywZ7sZSrI/XOWtwvPqRdgnHgw+OCFoPBkx7Qo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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: Using insert_page() we might have previously ended up passing the zeropage into rmap code. Make sure that won't happen again. Note that we won't check the huge zeropage for now, which might still end up in RMAP code. Signed-off-by: David Hildenbrand --- include/linux/rmap.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 7229b9baf20d8..5cb0d419a1d75 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -200,6 +200,9 @@ static inline void __folio_rmap_sanity_checks(struct folio *folio, /* hugetlb folios are handled separately. */ VM_WARN_ON_FOLIO(folio_test_hugetlb(folio), folio); + /* When (un)mapping zeropages, we should never touch ref+mapcount. */ + VM_WARN_ON_FOLIO(is_zero_folio(folio), folio); + /* * TODO: we get driver-allocated folios that have nothing to do with * the rmap using vm_insert_page(); therefore, we cannot assume that