linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: John Reiser <jreiser@bitwagon.com>
Cc: linux-mm@kvack.org
Subject: Re: msync() seems not to clean the data cache
Date: Fri, 25 Apr 2025 20:31:41 +0100	[thread overview]
Message-ID: <aAvjHe6lLkyySN9-@casper.infradead.org> (raw)
In-Reply-To: <9a70a70d-9dce-46a0-997e-b8a346e60902@bitwagon.com>

On Fri, Apr 25, 2025 at 12:17:37PM -0700, John Reiser wrote:
> The system call write() cleans the hardware data cache (writes any dirty
> values from the data cache into RAM memory) before passing to the VFS
> the region to be written.  The system call msync() should do likewise.
> Currently msync() does not clean the hardware data cache, as seen on
> PowerPC, PowerPC64, and arm64; and probably any CPU that does not
> have a Write-through cache.  (x86 and x86_64 do have write-through.)

I think you're right; we don't flush before writeback.  Does this
fix your problem?

+++ b/mm/page-writeback.c
@@ -2432,6 +2432,7 @@ static bool folio_prepare_writeback(struct address_space *mapping,
        if (!folio_clear_dirty_for_io(folio))
                return false;

+       flush_dcache_folio(folio);
        return true;
 }


By the way, x86 does not have writethrough caches.  Instead it has DMA
coherent caches, so modified cachelines in the cache will take
precedence over the contents of memory.


  reply	other threads:[~2025-04-25 19:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-25 19:17 John Reiser
2025-04-25 19:31 ` Matthew Wilcox [this message]
2025-04-25 20:45   ` John Reiser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aAvjHe6lLkyySN9-@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=jreiser@bitwagon.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox