From: "Emilio G. Cota" <cota@braap.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2] translate-all: use glib for all page descriptor allocations
Date: Thu, 9 Apr 2015 16:03:44 -0400 [thread overview]
Message-ID: <1428609824-25613-1-git-send-email-cota@braap.org> (raw)
In-Reply-To: <5526CDE9.5060209@redhat.com>
Since commit
b7b5233a "bsd-user/mmap.c: Don't try to override g_malloc/g_free"
the exception we make here for usermode has been unnecessary.
Get rid of it.
Signed-off-by: Emilio G. Cota <cota@braap.org>
---
translate-all.c | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/translate-all.c b/translate-all.c
index 4d05898..c8f0e8c 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -389,18 +389,6 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc)
void **lp;
int i;
-#if defined(CONFIG_USER_ONLY)
- /* We can't use g_malloc because it may recurse into a locked mutex. */
-# define ALLOC(P, SIZE) \
- do { \
- P = mmap(NULL, SIZE, PROT_READ | PROT_WRITE, \
- MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
- } while (0)
-#else
-# define ALLOC(P, SIZE) \
- do { P = g_malloc0(SIZE); } while (0)
-#endif
-
/* Level 1. Always allocated. */
lp = l1_map + ((index >> V_L1_SHIFT) & (V_L1_SIZE - 1));
@@ -412,7 +400,7 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc)
if (!alloc) {
return NULL;
}
- ALLOC(p, sizeof(void *) * V_L2_SIZE);
+ p = g_malloc0(sizeof(void *) * V_L2_SIZE);
*lp = p;
}
@@ -424,12 +412,10 @@ static PageDesc *page_find_alloc(tb_page_addr_t index, int alloc)
if (!alloc) {
return NULL;
}
- ALLOC(pd, sizeof(PageDesc) * V_L2_SIZE);
+ pd = g_malloc0(sizeof(PageDesc) * V_L2_SIZE);
*lp = pd;
}
-#undef ALLOC
-
return pd + (index & (V_L2_SIZE - 1));
}
--
1.9.1
next prev parent reply other threads:[~2015-04-09 20:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-09 17:24 [Qemu-devel] [PATCH] translate-all: use g_malloc0 for all page descriptor allocations Emilio G. Cota
2015-04-09 19:07 ` Paolo Bonzini
2015-04-09 20:03 ` Emilio G. Cota [this message]
2015-04-09 20:07 ` [Qemu-devel] [PATCH v3] translate-all: use glib " Emilio G. Cota
2015-04-09 20:21 ` Paolo Bonzini
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=1428609824-25613-1-git-send-email-cota@braap.org \
--to=cota@braap.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@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).