Received: by 2002:a05:7412:5190:b0:fa:69f9:95fb with SMTP id fn16csp864582rdb; Mon, 22 Jan 2024 09:57:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcw1xPm1nON5nJguDtFKfvwrJ+HlKi7f+Jarp4fkelXwXKs9aEdZRI5rt61kFSNnPJ9vVN X-Received: by 2002:a05:6a20:9195:b0:19a:4353:a0c0 with SMTP id v21-20020a056a20919500b0019a4353a0c0mr5218550pzd.67.1705946246829; Mon, 22 Jan 2024 09:57:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705946246; cv=pass; d=google.com; s=arc-20160816; b=r05+84ocuCWQtnoSCJV2SPnLCTDw6z7KiB3rkJSP0eyBTqYHjEWP+m2D+yhbXF0npu WzU+0Mz9LkLPUz5r2hdMGW4V9DkBH95m3M476fl2x8zyVRoWabvDZsJFRdPCyNy0PcIN Hy27PfHjsUFZ6r1zm8Rija4BViU4iDUhTBelp/KhJkE+NfX2A0LM6dNR9PW0/B9pkFra W8iD38O2l3NYpxYGTdReowFIRsacYlILXIEf/uHVdHXB2dgAJCUL1BEEHT+0121tg9fN ECtLEidNT5BmN6vyRlw1GaMBlgRZ53v6QqVzzIDE9YH0bH2eioc+8IScUFvkmSrE1iaT CpEQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=XhLeC5Lfj4S0c9LG1F/fnKLVs62IL7U4zQ+n1ywYzhU=; fh=SJ0bByOtZv8em+OSRHkIFlcvIcqwJWVEpMX4e9gWzQc=; b=ULFnSPn1GFqb1084+tH1+hJYTgPXzYyNk/rkVDNN3iNU1UgRqY9MwBNq3Jd94y527I HWWFuaatFQsJ94NiRmYVWQSQArrj4BE66YoWK0ZIoC+wL8YP4Fb5101jj3VjLAD4GPUD mh8wTn0ffBgrldSqmhzO8nrJGN8gHGc2YrJx2DwQoqFhgAE14WxgqG/+jZHOSAuozfJr 6KeQHB2vb4wY5PsMhBxzAWsN/x8Esi7mh1P/CKJVeEcBUqAg9FLpf9ANPDhUK4db/KJR gpYXgIb9KmJBlLE2ypZBPkqaMOe0ylJT5DdX+x5jXM/wZTv3mTkhL2rYeh+KVYykzZ4h GBjg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JdtUvXWX; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-33769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z9-20020a63c049000000b005c673abd811si8681191pgi.254.2024.01.22.09.57.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 09:57:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JdtUvXWX; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-33769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1F7F7283600 for ; Mon, 22 Jan 2024 17:51:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E5E55F84C; Mon, 22 Jan 2024 17:18:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JdtUvXWX" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 41C605F849 for ; Mon, 22 Jan 2024 17:17:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705943880; cv=none; b=GYAUf18moAsybwQuunwaRzddVcYHsAYcdL401mdmryBHfj1U2CC0fKHc4LdHcMnhpSGuiIe6qYf5fkuxWsLWt13HTZERrqex+CzH90j1ZWXB4aAxsh0U0D2Mlernx0xVMLt6N0U3X5YNny5WB2qPZbcmlOf2RTdF/3iU778QC4Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705943880; c=relaxed/simple; bh=AuAehTRQDKytPine/OlBkuYxFhvld+jjrKy3zbrkDJM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=irja//YGa9CLM6L4sSAzJ8Ef810PlbaXudylu9WxoRyo6bEp+Nw9AMKcXB0DyF3Q2MgtK7S1c0P1yMmmtwKZtL/NtEyjepvK0f4FRkQPLEiIW5v7J5gbKXTD5gww36vA0Q2XJ7StpUENMgOxLBseprozqhd66NKNp+FjQAJIKhw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=JdtUvXWX; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705943878; 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=XhLeC5Lfj4S0c9LG1F/fnKLVs62IL7U4zQ+n1ywYzhU=; b=JdtUvXWXW+aH8P8l7+pVX3PiuocstPVVHHT8wTX8j93UqrF7BOagxeNNacH4B/oU2Tdm7R U76Z+8z72KdEDVaGBWFCcZhkHusKJB2tpM23d6tRxpVcqt6NpRynKGYPSBwesAF5nhcTMn o2H/ANBaJr0vTCad6cFjMDWBPdQFvOM= 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-350-9e0_w3lbNNu16t2quNW2Tw-1; Mon, 22 Jan 2024 12:17:54 -0500 X-MC-Unique: 9e0_w3lbNNu16t2quNW2Tw-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 48ED1185A785; Mon, 22 Jan 2024 17:17:54 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.39.195.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B323C0FDCA; Mon, 22 Jan 2024 17:17:52 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Ryan Roberts , Matthew Wilcox , Andrew Morton Subject: [PATCH v1] mm/memory: fix folio_set_dirty() vs. folio_mark_dirty() in zap_pte_range() Date: Mon, 22 Jan 2024 18:17:51 +0100 Message-ID: <20240122171751.272074-1-david@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 The correct folio replacement for "set_page_dirty()" is "folio_mark_dirty()", not "folio_set_dirty()". Using the latter won't properly inform the FS using the dirty_folio() callback. This has been found by code inspection, but likely this can result in some real trouble when zapping dirty PTEs that point at clean pagecache folios. Reported-by: Ryan Roberts Closes: https://lkml.kernel.org/r/2445cedb-61fb-422c-8bfb-caf0a2beed62@arm.com Fixes: c46265030b0f ("mm/memory: page_remove_rmap() -> folio_remove_rmap_pte()") Cc: Matthew Wilcox (Oracle) Cc: Andrew Morton Signed-off-by: David Hildenbrand --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index 7e1f4849463aa..89bcae0b224d6 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1464,7 +1464,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, delay_rmap = 0; if (!folio_test_anon(folio)) { if (pte_dirty(ptent)) { - folio_set_dirty(folio); + folio_mark_dirty(folio); if (tlb_delay_rmap(tlb)) { delay_rmap = 1; force_flush = 1; -- 2.43.0