From: Alex Shi <seakeel@gmail.com>
To: alexs@kernel.org, Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
izik.eidus@ravellosystems.com, willy@infradead.org,
aarcange@redhat.com, chrisw@sous-sol.org, hughd@google.com,
david@redhat.com
Subject: Re: [RFC 3/3] mm/ksm: move flush_anon_page before checksum calculation
Date: Wed, 5 Jun 2024 18:04:19 +0800 [thread overview]
Message-ID: <a1ba41f1-ecff-4790-b85a-ce5dc8077b91@gmail.com> (raw)
In-Reply-To: <20240605095304.66389-3-alexs@kernel.org>
Let me withdraw this patch, the flush_anon_page come with the first patchset of ksm, and no explanation for them.
Though, no any guarantee for concurrent page write for the flush, but anyway I give up on the flush optimize.
Sorry for disturber.
Alex
On 6/5/24 5:53 PM, alexs@kernel.org wrote:
> From: "Alex Shi (tencent)" <alexs@kernel.org>
>
> commit 6020dff09252 ("[ARM] Resolve fuse and direct-IO failures due to missing cache flushes")
> explain that the aim of flush_anon_page() is to keep the cache and memory
> content synced. Also as David Hildenbrand pointed, flush page without
> the page contents reading here is meaningless, so let's move the flush action
> just before page contents reading, like calc_checksum(), not
> just find a page, flush it, w/o clear purpose. This should save some flush
> actions why keep page content safely synced.
>
> BTW, write_protect_page() do another type flush actions before pages_identical().
>
> Signed-off-by: Alex Shi (tencent) <alexs@kernel.org>
> ---
> mm/ksm.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/mm/ksm.c b/mm/ksm.c
> index ef335ee508d3..77e8c1ded9bb 100644
> --- a/mm/ksm.c
> +++ b/mm/ksm.c
> @@ -784,10 +784,7 @@ static struct page *get_mergeable_page(struct ksm_rmap_item *rmap_item)
> goto out;
> if (is_zone_device_page(page))
> goto out_putpage;
> - if (PageAnon(page)) {
> - flush_anon_page(vma, page, addr);
> - flush_dcache_page(page);
> - } else {
> + if (!PageAnon(page)) {
> out_putpage:
> put_page(page);
> out:
> @@ -2378,7 +2375,12 @@ static void cmp_and_merge_page(struct page *page, struct ksm_rmap_item *rmap_ite
> mmap_read_unlock(mm);
> return;
> }
> +
> + /* flush page contents before calculate checksum */
> + flush_anon_page(vma, page, rmap_item->address);
> + flush_dcache_page(page);
> checksum = calc_checksum(page);
> +
> if (rmap_item->oldchecksum != checksum) {
> rmap_item->oldchecksum = checksum;
> mmap_read_unlock(mm);
> @@ -2662,8 +2664,6 @@ static struct ksm_rmap_item *scan_get_next_rmap_item(struct page **page)
> if (is_zone_device_page(*page))
> goto next_page;
> if (PageAnon(*page)) {
> - flush_anon_page(vma, *page, ksm_scan.address);
> - flush_dcache_page(*page);
> rmap_item = get_next_rmap_item(mm_slot,
> ksm_scan.rmap_list, ksm_scan.address);
> if (rmap_item) {
next prev parent reply other threads:[~2024-06-05 10:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 9:53 [RFC 1/3] mm/ksm: add anonymous check in find_mergeable_vma alexs
2024-06-05 9:53 ` [RFC 2/3] mm/ksm: jump out early if vma out of date in cmp_and_merge_page alexs
2024-06-05 9:53 ` [RFC 3/3] mm/ksm: move flush_anon_page before checksum calculation alexs
2024-06-05 10:04 ` Alex Shi [this message]
[not found] ` <353d4f6c-ed3d-4afe-82ab-8c0b22a0178f@redhat.com>
2024-06-07 9:33 ` [RFC 1/3] mm/ksm: add anonymous check in find_mergeable_vma Alex Shi
2024-06-07 10:13 ` David Hildenbrand
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=a1ba41f1-ecff-4790-b85a-ce5dc8077b91@gmail.com \
--to=seakeel@gmail.com \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=alexs@kernel.org \
--cc=chrisw@sous-sol.org \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=izik.eidus@ravellosystems.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.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