From: David Hildenbrand <david@redhat.com>
To: Yang Shi <yang@os.amperecomputing.com>,
catalin.marinas@arm.com, will@kernel.org,
anshuman.khandual@arm.com, scott@os.amperecomputing.com,
cl@gentwo.org
Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [v4 PATCH] arm64: mm: force write fault for atomic RMW instructions
Date: Thu, 6 Jun 2024 10:49:45 +0200 [thread overview]
Message-ID: <8e4cd345-2530-4ace-a596-a0fa6911a35e@redhat.com> (raw)
In-Reply-To: <20240605203723.643329-1-yang@os.amperecomputing.com>
On 05.06.24 22:37, Yang Shi wrote:
> The atomic RMW instructions, for example, ldadd, actually does load +
> add + store in one instruction, it will trigger two page faults per the
> ARM64 architecture spec, the first fault is a read fault, the second
> fault is a write fault.
>
> Some applications use atomic RMW instructions to populate memory, for
> example, openjdk uses atomic-add-0 to do pretouch (populate heap memory
> at launch time) between v18 and v22 in order to permit use of memory
> concurrently with pretouch.
>
> But the double page fault has some problems:
>
> 1. Noticeable TLB overhead. The kernel actually installs zero page with
> readonly PTE for the read fault. The write fault will trigger a
> write-protection fault (CoW). The CoW will allocate a new page and
> make the PTE point to the new page, this needs TLB invalidations. The
> tlb invalidation and the mandatory memory barriers may incur
> significant overhead, particularly on the machines with many cores.
>
> 2. Break up huge pages. If THP is on the read fault will install huge
> zero pages. The later CoW will break up the huge page and allocate
> base pages instead of huge page. The applications have to rely on
> khugepaged (kernel thread) to collapse huge pages asynchronously.
> This also incurs noticeable performance penalty.
>
> 3. 512x page faults with huge page. Due to #2, the applications have to
> have page faults for every 4K area for the write, this makes the speed
> up by using huge page actually gone.
All interesting and valid points.
As raised, the app likely really should be using MADV_POPULATE_WRITE.
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2024-06-06 8:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 20:37 [v4 PATCH] arm64: mm: force write fault for atomic RMW instructions Yang Shi
2024-06-06 8:49 ` David Hildenbrand [this message]
2024-06-14 12:20 ` Catalin Marinas
2024-06-26 18:45 ` Yang Shi
2024-06-26 20:50 ` Yang Shi
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=8e4cd345-2530-4ace-a596-a0fa6911a35e@redhat.com \
--to=david@redhat.com \
--cc=anshuman.khandual@arm.com \
--cc=catalin.marinas@arm.com \
--cc=cl@gentwo.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=scott@os.amperecomputing.com \
--cc=will@kernel.org \
--cc=yang@os.amperecomputing.com \
/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 NNTP newsgroup(s).