From patchwork Wed May 22 12:57:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13670848 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 4BA28C25B7C for ; Wed, 22 May 2024 12:57:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 175E46B0092; Wed, 22 May 2024 08:57:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 126486B0095; Wed, 22 May 2024 08:57:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE1A76B0096; Wed, 22 May 2024 08:57:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BEDAB6B0092 for ; Wed, 22 May 2024 08:57:27 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 356B5A030F for ; Wed, 22 May 2024 12:57:27 +0000 (UTC) X-FDA: 82146032934.15.05810A9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 88B281C0028 for ; Wed, 22 May 2024 12:57:25 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BWAN6ygy; spf=pass (imf18.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716382645; 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=Qt4DlmVVsqb/QNq76vNlwwGXNiph41eusgcJK0KNhok=; b=A3i5tG4PUIWWolfCEj/wqU+njkwxtkLsKWbIdcCpnkTLJ3rO/TP73PLLx8iiyeHnUyk9T7 fTVUVSZxTLQIGLkWgfyYCg4roNiaUvbxDKPgp+2tW8Yi3cI5NIM2Y91fY+qdBVmOscLH2R PRs7EYPRyxusJursTqyV6UsZHXSr7a0= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BWAN6ygy; spf=pass (imf18.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716382645; a=rsa-sha256; cv=none; b=E+BA/Ot2wCTz1qE4FDr8Ng5TfdRev1WA4mPDUkW/xgie6vGKh0sQ62f89L65uXVj/vRLa1 bXqqNEnO86TBgDWKwiNf6m47L200VZmSjszJyjQXDcliJB6Qzmu1RH3CksP3lTaH2lMbiJ 9DNRoaDZh/t5Cohd+Jw3ykQ3E5Jy404= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716382644; 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=Qt4DlmVVsqb/QNq76vNlwwGXNiph41eusgcJK0KNhok=; b=BWAN6ygyn19hsy1OJ5KHl4XR3AA6HK+1lO1b9yDozXj0Fh+si/KWHWcBagoSpMy1/eOb6u z66392vvkw4rKXlMUuIhF/eUDqdcs0ky+btVTtdUtuEZ8HqQZByojJNbxjHlbxHOAOuP8o eyxyhNe1oL2zaAVwc1qN2vsdr01mNM4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-537-66OPK548MCiiS05cIhsAWg-1; Wed, 22 May 2024 08:57:20 -0400 X-MC-Unique: 66OPK548MCiiS05cIhsAWg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 905F7800169; Wed, 22 May 2024 12:57:19 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.195.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6CCEC40C6CB7; Wed, 22 May 2024 12:57:18 +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 v2 3/3] mm/rmap: sanity check that zeropages are not passed to RMAP Date: Wed, 22 May 2024 14:57:13 +0200 Message-ID: <20240522125713.775114-4-david@redhat.com> In-Reply-To: <20240522125713.775114-1-david@redhat.com> References: <20240522125713.775114-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 88B281C0028 X-Stat-Signature: aozt3bggu1748shuumdfaewajactwsm4 X-Rspam-User: X-HE-Tag: 1716382645-458151 X-HE-Meta: U2FsdGVkX1/PWRvXYY7C4dzdNWjRQMnN/AluQwI0Wm9uojmRXivJmZG1I9XlDD1c7vz3kDZIGEeKFSPAe8r/X/iqUY8LkowYdqJTgEAOCPiksr6n1M8jNvu7gO0oK8/Q8Kx82ir5hPZI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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 7229b9baf20d..5cb0d419a1d7 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