Message ID | 20240122171751.272074-1-david@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-33769-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2751044dyb; Mon, 22 Jan 2024 10:16:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IErYLnHFKuPpyCWIAxLDFN3Knl22M581ed42tChwzJIBodCLJAOGdokCtOmQTpojBsnxEtr X-Received: by 2002:aa7:d3d3:0:b0:55c:3794:d6f6 with SMTP id o19-20020aa7d3d3000000b0055c3794d6f6mr175703edr.5.1705947415000; Mon, 22 Jan 2024 10:16:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705947414; cv=pass; d=google.com; s=arc-20160816; b=MB3FxixMPtjSSyfCFPyAu7onXzeoa+JJxniWjSQPz2Ouz3qFdjWr+gpUfQ5HgihoL7 dV+D51FqzBtLt/9hf6bRFaGyPgTlIRKSsjMnm/m1oHv21ZjzNhh05Wy9nnDHfOsxjMDd P1HbB9CzQ3YQ97VvELEDrbIk79ErF/f2TPOltfdziK0kz5nJpZ9zlUe+jPttdtXoyuys 4YMoG8Dd2khrI0MedR6lMJlkOS93oZpbGDyhxaHNtVniu8tPBp+1ir6H/JJIRwks1ok5 vclqmBb4+J8sZ66GduG0cPmzJFx6Tn2Uy58v0j83XvGl8bIXJ68iTh8758E03JG+cSBH am+w== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33769-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g5-20020a50d5c5000000b00554228f1467si11065947edj.414.2024.01.22.10.16.54 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 10:16:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33769-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33769-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 302E01F24E95 for <ouuuleilei@gmail.com>; Mon, 22 Jan 2024 17:51:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 589EB5F85F; Mon, 22 Jan 2024 17:18:03 +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 <linux-kernel@vger.kernel.org>; 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 <david@redhat.com> To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand <david@redhat.com>, Ryan Roberts <ryan.roberts@arm.com>, Matthew Wilcox <willy@infradead.org>, Andrew Morton <akpm@linux-foundation.org> 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: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788814921628940141 X-GMAIL-MSGID: 1788815516173151763 |
Series |
[v1] mm/memory: fix folio_set_dirty() vs. folio_mark_dirty() in zap_pte_range()
|
|
Commit Message
David Hildenbrand
Jan. 22, 2024, 5:17 p.m. UTC
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 <ryan.roberts@arm.com>
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) <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
mm/memory.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Without this fix, testing the latest exfat with xfstests, test cases generic/029 and generic/030 will fail. > -----Original Message----- > From: owner-linux-mm@kvack.org <owner-linux-mm@kvack.org> On Behalf > Of David Hildenbrand > Sent: Tuesday, January 23, 2024 1:18 AM > To: linux-kernel@vger.kernel.org > Cc: linux-mm@kvack.org; David Hildenbrand <david@redhat.com>; Ryan > Roberts <ryan.roberts@arm.com>; Matthew Wilcox <willy@infradead.org>; > Andrew Morton <akpm@linux-foundation.org> > Subject: [PATCH v1] mm/memory: fix folio_set_dirty() vs. folio_mark_dirty() in > zap_pte_range() > > 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 <ryan.roberts@arm.com> > 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) <willy@infradead.org> > Cc: Andrew Morton <akpm@linux-foundation.org> > Signed-off-by: David Hildenbrand <david@redhat.com> > Reviewed-by: Ryan Roberts <ryan.roberts@arm.com> > --- > 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;
On 23.01.24 09:49, Yuezhang.Mo@sony.com wrote: > Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com> > > Without this fix, testing the latest exfat with xfstests, test cases generic/029 > and generic/030 will fail. Great, thanks for testing and for providing actual reproducers!
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;