From: Karim Manaouil <k.manaouil@gmail.com>
To: kernelnewbies@kernelnewbies.org
Subject: Race between flush_cache_page and flush_tlb_page
Date: Thu, 4 May 2023 11:30:41 +0100 [thread overview]
Message-ID: <CADsNLn2=MD+AC=6=pCL-7ymrj8J24i=f+19PX7pg0RFDAoVtXA@mail.gmail.com> (raw)
Hi,
In try_to_unmap_one(), flush_cache_page() [1] is called before
flush_tlb_page() [2].
The following scenario can happen:
cpu0: cpu1:
flush_cache_page()
User writes to page
ptep_clear_flush()
Since the two operations on cpu0 are not atomic, a write from the user
can happen
right after flush_cache_page() is called, but before flushing the tlb.
Thus there is a risk
the last updates from the user on cpu1 won't be flushed to memory.
I understand that not all CPUs need flush_cache_page, but for those
that require it,
how is correctness guaranteed in this case?
[1] https://elixir.bootlin.com/linux/latest/source/mm/rmap.c#L1572
[2] https://elixir.bootlin.com/linux/latest/source/mm/rmap.c#L1587
Cheers
Karim
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
reply other threads:[~2023-05-04 10:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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='CADsNLn2=MD+AC=6=pCL-7ymrj8J24i=f+19PX7pg0RFDAoVtXA@mail.gmail.com' \
--to=k.manaouil@gmail.com \
--cc=kernelnewbies@kernelnewbies.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).