From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH 2/2] osdep: Cache getpagesize() call in qemu_real_host_page_size()
Date: Mon, 3 Nov 2025 11:51:10 +0100 [thread overview]
Message-ID: <20251103105111.68294-3-philmd@linaro.org> (raw)
In-Reply-To: <20251103105111.68294-1-philmd@linaro.org>
Since we can not know whether a libc implementation of
getpagesize() calls syscalls -- potentially slow --, but
we know the host page size won't change during runtime,
we can cache its value.
Reported-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
util/osdep.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/util/osdep.c b/util/osdep.c
index 44fad13dcc7..9b50d00dbda 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -616,5 +616,11 @@ int qemu_fdatasync(int fd)
uintptr_t qemu_real_host_page_size(void)
{
- return getpagesize();
+ static uintptr_t real_host_page_size;
+
+ if (!real_host_page_size) {
+ real_host_page_size = getpagesize();
+ }
+
+ return real_host_page_size;
}
--
2.51.0
next prev parent reply other threads:[~2025-11-03 10:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-03 10:51 [PATCH 0/2] osdep: Cache getpagesize() call in qemu_real_host_page_size() Philippe Mathieu-Daudé
2025-11-03 10:51 ` [PATCH 1/2] osdep: Un-inline qemu_real_host_page_size() Philippe Mathieu-Daudé
2025-11-03 10:51 ` Philippe Mathieu-Daudé [this message]
2025-11-06 10:53 ` [PATCH 0/2] osdep: Cache getpagesize() call in qemu_real_host_page_size() Richard Henderson
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=20251103105111.68294-3-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).