Skip to content
Tags

,

Paging in Xen

March 3, 2011

Xen get booted before domain is booted:

Check this boot entry for Xen:
1.title Fedora Xen 4.0 with Linux 2.6.32.27 pvops dom0
2.root (hd0,5)
3.kernel /xen.gz loglvl=all guest_loglvl=all sync_console
4.module /vmlinuz-2.6.32.27 ro root=/dev/sda7 rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM
5.console=tty
6.module /initramfs-2.6.32.27.img

Line 3: here kernel is nothing but hypervisor
Line 4: here Domain kernel we are inserting as a module

So initially xen setup it’s own buddy allocator for allocating memory to Xen & requesting Domains (Kernels)
Note: To read the code from boot time start reading the code from /xen/arc/setup.c
Following are the few of the calls used for doing so.

1)
/* Allocate 2^@order contiguous pages. */
static struct page_info *alloc_heap_pages(
unsigned int zone_lo, unsigned int zone_hi,
unsigned int node, unsigned int order, unsigned int memflags)

This is the lowest level call for allocating memory. It gets the memory of order 2^order from the buddy allocator from the requesting zone. In the code tmem(explanation is required) also comes into picture which causes fragmentation of memory but a helpful and innovative technique for over-commitment.

2)When Xen wants to use pages from buddy then it calls
following call : void *alloc_xenheap_pages(unsigned int order, unsigned int memflags)
This function will call alloc_heap_pages from where it will get the pages.
3) When domain kernel requires pages then it makes following call:
struct page_info *alloc_domheap_pages(struct domain *d, unsigned int order, unsigned int memflags)
So how pages are assigned to domain :
alloc_domheap_pages make following calls
getpage from buddy allocator using alloc_heap_pages
assign this pages to the requesting domain using
int assign_pages(struct domain *d,struct page_info *pg,unsigned int order,unsigned int memflags)
So Call is some what similar to alloc_xenheap_pages only difference is it calls assign_pages and some other condition checking.

Calling Sequence:

Buddy_Allocator
1)Xen
1.void *alloc_xenheap_pages(unsigned int order, unsigned int memflags)
2) Domain
1.struct page_info *alloc_domheap_pages(struct domain *d, unsigned int order, unsigned int memflags)
1.void *alloc_xenheap_pages(unsigned int order, unsigned int memflags)
2.int assign_pages(struct domain *d,struct page_info *pg,unsigned int order,unsigned int memflags)

Advertisements

From → Xen

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: