From: Dan Magenheimer <dan.magenheimer@oracle.com>
To: Keir Fraser <keir.fraser@eu.citrix.com>, xen-devel@lists.xensource.com
Subject: RE: Re: Xenheap disappearance: (was: xen_phys_start for 32b)
Date: Thu, 15 Jan 2009 18:15:53 +0000 (GMT) [thread overview]
Message-ID: <96d6ebb0-6ee2-494b-8a53-da25eba119d2@default> (raw)
In-Reply-To: <C594A68D.20FD4%keir.fraser@eu.citrix.com>
[-- Attachment #1: Type: text/plain, Size: 829 bytes --]
> Xmalloc/xfree can use alloc_domheap_pages always on x86/64.
> A temporary
> ifdef inside xmalloc is better than an extra xmalloc interface.
OK, I see. So what you want is xmalloc to be the only interface.
And "temporary" means until Xen no longer supports 32-bit at all?
Will you take this patch then? I think this patch meets your
objectives and is greatly simplified.
> Also, this will be a small patch you can carry in your own
> patchset for now.
I'm just trying to contribute to your stated objective:
> Xenheap will disappear entirely on x86/64 in future.
and trying to get the syntax/semantics pinned down. Is
this not what you intended to implement for 3.4? Or did
you have something entirely different in mind?
Thanks,
Dan
Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
[-- Attachment #2: xmalloc.patch --]
[-- Type: application/octet-stream, Size: 2789 bytes --]
diff -r 4f6a2bbdff3f xen/common/xmalloc_tlsf.c
--- a/xen/common/xmalloc_tlsf.c Tue Jan 13 15:53:47 2009 +0000
+++ b/xen/common/xmalloc_tlsf.c Thu Jan 15 10:42:03 2009 -0700
@@ -283,6 +283,39 @@ static inline void ADD_REGION(void *regi
* TLSF pool-based allocator start.
*/
+#ifdef __x86_64__
+extern void free_domheap_pages(struct page_info *pg, unsigned int order);
+extern struct page_info *alloc_domheap_pages(
+ struct domain *d, unsigned int order, unsigned int memflags);
+
+static inline void *alloc_xheap_pages(unsigned int order)
+{
+ struct page_info *pi = 0;
+
+ if ((pi = alloc_domheap_pages(0,order,0)) == NULL)
+ return NULL;
+ return mfn_to_virt(page_to_mfn(pi));
+}
+
+static inline void free_xheap_pages(void *p, unsigned int order)
+{
+ free_domheap_pages(mfn_to_page(virt_to_mfn(p)),order);
+}
+#else
+extern void free_xenheap_pages(void *p, unsigned int order);
+extern void *alloc_xenheap_pages(unsigned int order);
+
+static inline void *alloc_xheap_pages(unsigned int order)
+{
+ return (void *)alloc_xenheap_pages(order);
+}
+
+static inline void free_xheap_pages(void *p, unsigned int order)
+{
+ free_xenheap_pages(p,0);
+}
+#endif
+
struct xmem_pool *xmem_pool_create(
const char *name,
xmem_pool_get_memory get_mem,
@@ -300,7 +333,7 @@ struct xmem_pool *xmem_pool_create(
pool_bytes = ROUNDUP_SIZE(sizeof(*pool));
pool_order = get_order_from_bytes(pool_bytes);
- pool = (void *)alloc_xenheap_pages(pool_order);
+ pool = (void *)alloc_xheap_pages(pool_order);
if ( pool == NULL )
return NULL;
memset(pool, 0, pool_bytes);
@@ -334,7 +367,7 @@ struct xmem_pool *xmem_pool_create(
return pool;
out_region:
- free_xenheap_pages(pool, pool_order);
+ free_xheap_pages(pool, pool_order);
return NULL;
}
@@ -505,12 +538,12 @@ static void *xmalloc_pool_get(unsigned l
static void *xmalloc_pool_get(unsigned long size)
{
ASSERT(size == PAGE_SIZE);
- return alloc_xenheap_pages(0);
+ return alloc_xheap_pages(0);
}
static void xmalloc_pool_put(void *p)
{
- free_xenheap_pages(p,0);
+ free_xheap_pages(p,0);
}
static void *xmalloc_whole_pages(unsigned long size)
@@ -518,7 +551,7 @@ static void *xmalloc_whole_pages(unsigne
struct bhdr *b;
unsigned int pageorder = get_order_from_bytes(size + BHDR_OVERHEAD);
- b = alloc_xenheap_pages(pageorder);
+ b = alloc_xheap_pages(pageorder);
if ( b == NULL )
return NULL;
@@ -593,7 +626,7 @@ void xfree(void *p)
}
if ( b->size >= (PAGE_SIZE - (2*BHDR_OVERHEAD)) )
- free_xenheap_pages((void *)b, get_order_from_bytes(b->size));
+ free_xheap_pages((void *)b, get_order_from_bytes(b->size));
else
xmem_pool_free(p, xenpool);
}
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next prev parent reply other threads:[~2009-01-15 18:15 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-06 6:36 xen_phys_start for 32b Cihula, Joseph
2009-01-06 8:42 ` Keir Fraser
2009-01-06 18:29 ` Cihula, Joseph
2009-01-06 22:12 ` Keir Fraser
2009-01-06 22:19 ` Cihula, Joseph
2009-01-07 8:54 ` Keir Fraser
2009-01-07 15:13 ` Cihula, Joseph
2009-01-07 15:40 ` Keir Fraser
2009-01-07 21:37 ` Cihula, Joseph
2009-01-07 23:27 ` Keir Fraser
2009-01-08 0:17 ` Xenheap disappearance: (was: xen_phys_start for 32b) Dan Magenheimer
2009-01-08 9:04 ` Keir Fraser
2009-01-08 17:53 ` Dan Magenheimer
2009-01-14 22:45 ` Dan Magenheimer
2009-01-15 0:27 ` Dan Magenheimer
2009-01-15 1:48 ` Dan Magenheimer
2009-01-15 8:38 ` Keir Fraser
2009-01-15 8:41 ` Keir Fraser
2009-01-15 18:15 ` Dan Magenheimer [this message]
2009-01-15 18:51 ` Keir Fraser
2009-01-16 8:11 ` Re: Xenheap disappearance: (was: xen_phys_start for32b) Jan Beulich
2009-01-16 23:16 ` Dan Magenheimer
2009-01-19 8:22 ` Re: Xenheap disappearance: (was: xen_phys_startfor32b) Jan Beulich
2009-01-19 20:04 ` Dan Magenheimer
2009-01-20 9:11 ` Re: Xenheap disappearance: (was:xen_phys_startfor32b) Jan Beulich
2009-01-20 9:16 ` Keir Fraser
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=96d6ebb0-6ee2-494b-8a53-da25eba119d2@default \
--to=dan.magenheimer@oracle.com \
--cc=keir.fraser@eu.citrix.com \
--cc=xen-devel@lists.xensource.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.