From: Peter Maydell <peter.maydell@linaro.org>
To: Maxim Ostapenko <m.ostapenko@samsung.com>
Cc: qemu-discuss <qemu-discuss@nongnu.org>,
QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [Qemu-discuss] ASan'ed binaries start up very slow under qemu-aarch64.
Date: Mon, 18 Jul 2016 16:51:21 +0100 [thread overview]
Message-ID: <CAFEAcA9dz65QeUp7-kmu_TWt=fO1kE6pLS-4OLUsJJVT8ofv8A@mail.gmail.com> (raw)
In-Reply-To: <578CEB7B.7010801@samsung.com>
(CCing qemu-devel, which is more likely to get developer attention)
On 18 July 2016 at 15:45, Maxim Ostapenko <m.ostapenko@samsung.com> wrote:
> 1) AddressSanitizer mmaps quite large regions of memory for redzones and
> shadow gap. In particular, for 39-bit AS it mmapes:
>
> || `[0x1400000000, 0x1fffffffff]` || HighShadow || - 48 Gb
> || `[0x1200000000, 0x13ffffffff]` || ShadowGap || - 8 Gb
> || `[0x1000000000, 0x11ffffffff]` || LowShadow || - 4 Gb
>
> 2) In QEMU, page_set_flags is called for these ranges. It cuts given range
> to individual pages and sets flags for them. Given the page size is 4 Kb,
> for 8 Gb range we have 2097152 iterations and for 48 Gb 12582912 iterations
> in inner loop. This is obviously a performance bottleneck.
Mmm, the algorithm here is pretty simple and basically assumes the
guest isn't going to be doing enormous allocations like that.
(If the host process doesn't happen to have a suitable big lump of its
VA space free then the mmap will fail anyway.)
> 3) Same issue may happen when ASan tries to read /proc/self/map later in
> page_check_range function, after it already mmaped HighShadow, ShadowGap and
> LowShadow regions.
>
> Could someone help me, how can I mitigate this performance issue? Do we
> really need to set flags to each page on entire (quite big) memory region?
Well, we do need to do some things:
* we're populating the PageDesc data structure which we later use
to cache generated code
* if we're marking the range as writeable and it wasn't previously
writeable, we need to check whether there's already generated code
anywhere in this memory range and invalidate those translations
This could probably be done in a way that doesn't iterate naively
through every page, though.
thanks
-- PMM
next parent reply other threads:[~2016-07-18 15:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <578CEB7B.7010801@samsung.com>
2016-07-18 15:51 ` Peter Maydell [this message]
2016-07-19 9:22 ` [Qemu-devel] [Qemu-discuss] ASan'ed binaries start up very slow under qemu-aarch64 Maxim Ostapenko
2016-07-19 9:49 ` Peter Maydell
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='CAFEAcA9dz65QeUp7-kmu_TWt=fO1kE6pLS-4OLUsJJVT8ofv8A@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=m.ostapenko@samsung.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-discuss@nongnu.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 NNTP newsgroup(s).