* [PATCH] Increase NR_GRANT_FRAMES, more NICs per domU.
@ 2006-01-11 16:35 Christopher Clark
2006-01-12 9:42 ` Birger Tödtmann
0 siblings, 1 reply; 3+ messages in thread
From: Christopher Clark @ 2006-01-11 16:35 UTC (permalink / raw)
To: xen-devel; +Cc: Keir Fraser, Ian Pratt, Birger Tödtmann
[-- Attachment #1.1: Type: text/plain, Size: 9130 bytes --]
Hello
This patch increases the number of grant frames from 4 to 16, which then
increases the maximum number of NICs per domU to 15.
The maximum number of grant frames (NR_GRANT_FRAMES), should you wish to
increase this further, is now 128 though this untested.
The first patch is against testing-3.0, boots domU fine, NICs come up and
has had limited testing.
The second patch is exactly the same set of changes against unstable, which
is not testable at the moment.
Christopher
Signed-off-by: Christopher Clark
Unstable patch inline here:
diff -r c886f74b54a4 linux-2.6-xen-sparse/include/asm-xen/gnttab.h
--- a/linux-2.6-xen-sparse/include/asm-xen/gnttab.h Wed Jan 11 12:02:54 2006
+++ b/linux-2.6-xen-sparse/include/asm-xen/gnttab.h Wed Jan 11 16:21:56 2006
@@ -21,7 +21,7 @@
#ifdef __ia64__
#define NR_GRANT_FRAMES 1
#else
-#define NR_GRANT_FRAMES 4
+#define NR_GRANT_FRAMES 16
#endif
struct gnttab_free_callback {
diff -r c886f74b54a4 xen/common/grant_table.c
--- a/xen/common/grant_table.c Wed Jan 11 12:02:54 2006
+++ b/xen/common/grant_table.c Wed Jan 11 16:21:56 2006
@@ -45,7 +45,7 @@
unsigned int h;
if ( unlikely((h = t->maptrack_head) == (t->maptrack_limit - 1)) )
return -1;
- t->maptrack_head = t->maptrack[h].ref_and_flags >> MAPTRACK_REF_SHIFT;
+ t->maptrack_head = t->maptrack[h].ref;
t->map_count++;
return h;
}
@@ -54,7 +54,8 @@
put_maptrack_handle(
grant_table_t *t, int handle)
{
- t->maptrack[handle].ref_and_flags = t->maptrack_head <<
MAPTRACK_REF_SHIFT;
+ t->maptrack[handle].ref = t->maptrack_head;
+ t->maptrack[handle].flags = 0;
t->maptrack_head = handle;
t->map_count--;
}
@@ -161,7 +162,10 @@
memcpy(new_mt, lgt->maptrack, PAGE_SIZE << lgt->maptrack_order);
for ( i = lgt->maptrack_limit; i < (lgt->maptrack_limit << 1); i++
)
- new_mt[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
+ {
+ new_mt[i].ref = (i+1);
+ new_mt[i].flags = 0;
+ }
free_xenheap_pages(lgt->maptrack, lgt->maptrack_order);
lgt->maptrack = new_mt;
@@ -283,10 +287,9 @@
TRACE_1D(TRC_MEM_PAGE_GRANT_MAP, dom);
- ld->grant_table->maptrack[handle].domid = dom;
- ld->grant_table->maptrack[handle].ref_and_flags =
- (ref << MAPTRACK_REF_SHIFT) |
- (dev_hst_ro_flags & MAPTRACK_GNTMAP_MASK);
+ ld->grant_table->maptrack[handle].domid = dom;
+ ld->grant_table->maptrack[handle].ref = ref;
+ ld->grant_table->maptrack[handle].flags = (u8) dev_hst_ro_flags;
(void)__put_user((u64)frame << PAGE_SHIFT, &uop->dev_bus_addr);
(void)__put_user(handle, &uop->handle);
@@ -363,7 +366,7 @@
map = &ld->grant_table->maptrack[handle];
if ( unlikely(handle >= ld->grant_table->maptrack_limit) ||
- unlikely(!(map->ref_and_flags & MAPTRACK_GNTMAP_MASK)) )
+ unlikely(!(map->flags)) )
{
DPRINTK("Bad handle (%d).\n", handle);
(void)__put_user(GNTST_bad_handle, &uop->status);
@@ -371,8 +374,8 @@
}
dom = map->domid;
- ref = map->ref_and_flags >> MAPTRACK_REF_SHIFT;
- flags = map->ref_and_flags & MAPTRACK_GNTMAP_MASK;
+ ref = map->ref;
+ flags = map->flags;
if ( unlikely((rd = find_domain_by_id(dom)) == NULL) ||
unlikely(ld == rd) )
@@ -403,7 +406,7 @@
if ( flags & GNTMAP_device_map )
{
ASSERT(act->pin & (GNTPIN_devw_mask | GNTPIN_devr_mask));
- map->ref_and_flags &= ~GNTMAP_device_map;
+ map->flags &= ~GNTMAP_device_map;
if ( flags & GNTMAP_readonly )
{
act->pin -= GNTPIN_devr_inc;
@@ -423,7 +426,7 @@
goto unmap_out;
ASSERT(act->pin & (GNTPIN_hstw_mask | GNTPIN_hstr_mask));
- map->ref_and_flags &= ~GNTMAP_host_map;
+ map->flags &= ~GNTMAP_host_map;
if ( flags & GNTMAP_readonly )
{
act->pin -= GNTPIN_hstr_inc;
@@ -436,9 +439,10 @@
}
}
- if ( (map->ref_and_flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0 )
- {
- map->ref_and_flags = 0;
+ if ( (map->flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0 )
+ {
+ map->ref = 0;
+ map->flags = 0;
put_maptrack_handle(ld->grant_table, handle);
}
@@ -597,12 +601,12 @@
for ( i = 0; i < gt->maptrack_limit; i++ )
{
maptrack = >->maptrack[i];
- if ( maptrack->ref_and_flags & MAPTRACK_GNTMAP_MASK )
- DPRINTK("Grant: dom (%hu) MAP (%d) ref:(%hu) flags:(%x) "
+ if ( maptrack->flags )
+ DPRINTK("Grant: dom (%hu) MAP (%d) ref:(%hu) flags:(%c) "
"dom:(%hu)\n",
op.dom, i,
- maptrack->ref_and_flags >> MAPTRACK_REF_SHIFT,
- maptrack->ref_and_flags & MAPTRACK_GNTMAP_MASK,
+ maptrack->ref,
+ maptrack->flags,
maptrack->domid);
}
@@ -872,7 +876,10 @@
t->maptrack_limit = PAGE_SIZE / sizeof(grant_mapping_t);
memset(t->maptrack, 0, PAGE_SIZE);
for ( i = 0; i < t->maptrack_limit; i++ )
- t->maptrack[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
+ {
+ t->maptrack[i].ref = (i+1);
+ t->maptrack[i].flags = 0;
+ }
/* Shared grant table. */
t->shared = alloc_xenheap_pages(ORDER_GRANT_FRAMES);
@@ -915,13 +922,13 @@
for ( handle = 0; handle < gt->maptrack_limit; handle++ )
{
map = >->maptrack[handle];
- if ( !(map->ref_and_flags & (GNTMAP_device_map|GNTMAP_host_map)) )
+ if ( !(map->flags & (GNTMAP_device_map|GNTMAP_host_map)) )
continue;
- ref = map->ref_and_flags >> MAPTRACK_REF_SHIFT;
-
- DPRINTK("Grant release (%hu) ref:(%hu) flags:(%x) dom:(%hu)\n",
- handle, ref, map->ref_and_flags & MAPTRACK_GNTMAP_MASK,
+ ref = map->ref;
+
+ DPRINTK("Grant release (%hu) ref:(%hu) flags:(%c) dom:(%hu)\n",
+ handle, ref, map->flags,
map->domid);
rd = find_domain_by_id(map->domid);
@@ -932,16 +939,16 @@
act = &rd->grant_table->active[ref];
sha = &rd->grant_table->shared[ref];
- if ( map->ref_and_flags & GNTMAP_readonly )
- {
- if ( map->ref_and_flags & GNTMAP_device_map )
+ if ( map->flags & GNTMAP_readonly )
+ {
+ if ( map->flags & GNTMAP_device_map )
{
BUG_ON(!(act->pin & GNTPIN_devr_mask));
act->pin -= GNTPIN_devr_inc;
put_page(pfn_to_page(act->frame));
}
- if ( map->ref_and_flags & GNTMAP_host_map )
+ if ( map->flags & GNTMAP_host_map )
{
BUG_ON(!(act->pin & GNTPIN_hstr_mask));
act->pin -= GNTPIN_hstr_inc;
@@ -951,14 +958,14 @@
}
else
{
- if ( map->ref_and_flags & GNTMAP_device_map )
+ if ( map->flags & GNTMAP_device_map )
{
BUG_ON(!(act->pin & GNTPIN_devw_mask));
act->pin -= GNTPIN_devw_inc;
put_page_and_type(pfn_to_page(act->frame));
}
- if ( map->ref_and_flags & GNTMAP_host_map )
+ if ( map->flags & GNTMAP_host_map )
{
BUG_ON(!(act->pin & GNTPIN_hstw_mask));
act->pin -= GNTPIN_hstw_inc;
@@ -977,7 +984,8 @@
put_domain(rd);
- map->ref_and_flags = 0;
+ map->ref = 0;
+ map->flags = 0;
}
}
diff -r c886f74b54a4 xen/include/asm-x86/grant_table.h
--- a/xen/include/asm-x86/grant_table.h Wed Jan 11 12:02:54 2006
+++ b/xen/include/asm-x86/grant_table.h Wed Jan 11 16:21:56 2006
@@ -7,7 +7,7 @@
#ifndef __ASM_GRANT_TABLE_H__
#define __ASM_GRANT_TABLE_H__
-#define ORDER_GRANT_FRAMES 2
+#define ORDER_GRANT_FRAMES 4
/*
* Caller must own caller's BIGLOCK, is responsible for flushing the TLB,
and
diff -r c886f74b54a4 xen/include/xen/grant_table.h
--- a/xen/include/xen/grant_table.h Wed Jan 11 12:02:54 2006
+++ b/xen/include/xen/grant_table.h Wed Jan 11 16:21:56 2006
@@ -61,12 +61,11 @@
* table of these, indexes into which are returned as a 'mapping handle'.
*/
typedef struct {
- u16 ref_and_flags; /* 0-4: GNTMAP_* ; 5-15: grant ref */
- domid_t domid; /* granting domain */
+ u16 ref; /* grant reference */
+ u8 flags; /* 0-4: GNTMAP_* */
+ domid_t domid; /* granting domain */
} grant_mapping_t;
-#define MAPTRACK_GNTMAP_MASK 0x1f
-#define MAPTRACK_REF_SHIFT 5
-#define MAPTRACK_MAX_ENTRIES (1 << (16 - MAPTRACK_REF_SHIFT))
+#define MAPTRACK_MAX_ENTRIES (1 << 16) /* limit is sizeof(grant_ref_t) */
/* Per-domain grant information. */
typedef struct {
[-- Attachment #1.2: Type: text/html, Size: 17109 bytes --]
[-- Attachment #2: testing-moregrants.patch --]
[-- Type: text/x-patch, Size: 8167 bytes --]
diff -r a91e4dcf629d linux-2.6-xen-sparse/include/asm-xen/gnttab.h
--- a/linux-2.6-xen-sparse/include/asm-xen/gnttab.h Fri Dec 23 01:12:41 2005
+++ b/linux-2.6-xen-sparse/include/asm-xen/gnttab.h Wed Jan 11 15:49:19 2006
@@ -21,7 +21,7 @@
#ifdef __ia64__
#define NR_GRANT_FRAMES 1
#else
-#define NR_GRANT_FRAMES 4
+#define NR_GRANT_FRAMES 16
#endif
struct gnttab_free_callback {
diff -r a91e4dcf629d xen/common/grant_table.c
--- a/xen/common/grant_table.c Fri Dec 23 01:12:41 2005
+++ b/xen/common/grant_table.c Wed Jan 11 15:49:19 2006
@@ -45,7 +45,7 @@
unsigned int h;
if ( unlikely((h = t->maptrack_head) == (t->maptrack_limit - 1)) )
return -1;
- t->maptrack_head = t->maptrack[h].ref_and_flags >> MAPTRACK_REF_SHIFT;
+ t->maptrack_head = t->maptrack[h].ref;
t->map_count++;
return h;
}
@@ -54,7 +54,8 @@
put_maptrack_handle(
grant_table_t *t, int handle)
{
- t->maptrack[handle].ref_and_flags = t->maptrack_head << MAPTRACK_REF_SHIFT;
+ t->maptrack[handle].ref = t->maptrack_head;
+ t->maptrack[handle].flags = 0;
t->maptrack_head = handle;
t->map_count--;
}
@@ -161,7 +162,10 @@
memcpy(new_mt, lgt->maptrack, PAGE_SIZE << lgt->maptrack_order);
for ( i = lgt->maptrack_limit; i < (lgt->maptrack_limit << 1); i++ )
- new_mt[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
+ {
+ new_mt[i].ref = (i+1);
+ new_mt[i].flags = 0;
+ }
free_xenheap_pages(lgt->maptrack, lgt->maptrack_order);
lgt->maptrack = new_mt;
@@ -363,10 +367,9 @@
TRACE_1D(TRC_MEM_PAGE_GRANT_MAP, dom);
- ld->grant_table->maptrack[handle].domid = dom;
- ld->grant_table->maptrack[handle].ref_and_flags =
- (ref << MAPTRACK_REF_SHIFT) |
- (dev_hst_ro_flags & MAPTRACK_GNTMAP_MASK);
+ ld->grant_table->maptrack[handle].domid = dom;
+ ld->grant_table->maptrack[handle].ref = ref;
+ ld->grant_table->maptrack[handle].flags = (u8) dev_hst_ro_flags;
(void)__put_user((u64)frame << PAGE_SHIFT, &uop->dev_bus_addr);
(void)__put_user(handle, &uop->handle);
@@ -427,7 +430,7 @@
map = &ld->grant_table->maptrack[handle];
if ( unlikely(handle >= ld->grant_table->maptrack_limit) ||
- unlikely(!(map->ref_and_flags & MAPTRACK_GNTMAP_MASK)) )
+ unlikely(!(map->flags)) )
{
DPRINTK("Bad handle (%d).\n", handle);
(void)__put_user(GNTST_bad_handle, &uop->status);
@@ -435,8 +438,8 @@
}
dom = map->domid;
- ref = map->ref_and_flags >> MAPTRACK_REF_SHIFT;
- flags = map->ref_and_flags & MAPTRACK_GNTMAP_MASK;
+ ref = map->ref;
+ flags = map->flags;
if ( unlikely((rd = find_domain_by_id(dom)) == NULL) ||
unlikely(ld == rd) )
@@ -468,7 +471,7 @@
act->pin -= (flags & GNTMAP_readonly) ? GNTPIN_devr_inc
: GNTPIN_devw_inc;
- map->ref_and_flags &= ~GNTMAP_device_map;
+ map->flags &= ~GNTMAP_device_map;
(void)__put_user(0, &uop->dev_bus_addr);
}
@@ -479,15 +482,16 @@
if ( (rc = destroy_grant_host_mapping(addr, frame, flags)) < 0 )
goto unmap_out;
- map->ref_and_flags &= ~GNTMAP_host_map;
+ map->flags &= ~GNTMAP_host_map;
act->pin -= (flags & GNTMAP_readonly) ? GNTPIN_hstr_inc
: GNTPIN_hstw_inc;
}
- if ( (map->ref_and_flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0)
- {
- map->ref_and_flags = 0;
+ if ( (map->flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0)
+ {
+ map->ref = 0;
+ map->flags = 0;
put_maptrack_handle(ld->grant_table, handle);
}
@@ -654,12 +658,12 @@
for ( i = 0; i < gt->maptrack_limit; i++ )
{
maptrack = >->maptrack[i];
- if ( maptrack->ref_and_flags & MAPTRACK_GNTMAP_MASK )
- DPRINTK("Grant: dom (%hu) MAP (%d) ref:(%hu) flags:(%x) "
+ if ( maptrack->flags )
+ DPRINTK("Grant: dom (%hu) MAP (%d) ref:(%hu) flags:(%c) "
"dom:(%hu)\n",
op.dom, i,
- maptrack->ref_and_flags >> MAPTRACK_REF_SHIFT,
- maptrack->ref_and_flags & MAPTRACK_GNTMAP_MASK,
+ maptrack->ref,
+ maptrack->flags,
maptrack->domid);
}
@@ -925,7 +929,10 @@
t->maptrack_limit = PAGE_SIZE / sizeof(grant_mapping_t);
memset(t->maptrack, 0, PAGE_SIZE);
for ( i = 0; i < t->maptrack_limit; i++ )
- t->maptrack[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
+ {
+ t->maptrack[i].ref = (i+1);
+ t->maptrack[i].flags = 0;
+ }
/* Shared grant table. */
t->shared = alloc_xenheap_pages(ORDER_GRANT_FRAMES);
@@ -968,13 +975,13 @@
for ( handle = 0; handle < gt->maptrack_limit; handle++ )
{
map = >->maptrack[handle];
- if ( !(map->ref_and_flags & (GNTMAP_device_map|GNTMAP_host_map)) )
+ if ( !(map->flags & (GNTMAP_device_map|GNTMAP_host_map)) )
continue;
- ref = map->ref_and_flags >> MAPTRACK_REF_SHIFT;
-
- DPRINTK("Grant release (%hu) ref:(%hu) flags:(%x) dom:(%hu)\n",
- handle, ref, map->ref_and_flags & MAPTRACK_GNTMAP_MASK,
+ ref = map->ref;
+
+ DPRINTK("Grant release (%hu) ref:(%hu) flags:(%c) dom:(%hu)\n",
+ handle, ref, map->flags,
map->domid);
rd = find_domain_by_id(map->domid);
@@ -985,15 +992,15 @@
act = &rd->grant_table->active[ref];
sha = &rd->grant_table->shared[ref];
- if ( map->ref_and_flags & GNTMAP_readonly )
- {
- if ( map->ref_and_flags & GNTMAP_device_map )
+ if ( map->flags & GNTMAP_readonly )
+ {
+ if ( map->flags & GNTMAP_device_map )
{
BUG_ON((act->pin & GNTPIN_devr_mask) == 0);
act->pin -= GNTPIN_devr_inc;
}
- if ( map->ref_and_flags & GNTMAP_host_map )
+ if ( map->flags & GNTMAP_host_map )
{
BUG_ON((act->pin & GNTPIN_hstr_mask) == 0);
act->pin -= GNTPIN_hstr_inc;
@@ -1001,13 +1008,13 @@
}
else
{
- if ( map->ref_and_flags & GNTMAP_device_map )
+ if ( map->flags & GNTMAP_device_map )
{
BUG_ON((act->pin & GNTPIN_devw_mask) == 0);
act->pin -= GNTPIN_devw_inc;
}
- if ( map->ref_and_flags & GNTMAP_host_map )
+ if ( map->flags & GNTMAP_host_map )
{
BUG_ON((act->pin & GNTPIN_hstw_mask) == 0);
act->pin -= GNTPIN_hstw_inc;
@@ -1030,7 +1037,8 @@
put_domain(rd);
- map->ref_and_flags = 0;
+ map->ref = 0;
+ map->flags = 0;
}
}
diff -r a91e4dcf629d xen/include/asm-x86/grant_table.h
--- a/xen/include/asm-x86/grant_table.h Fri Dec 23 01:12:41 2005
+++ b/xen/include/asm-x86/grant_table.h Wed Jan 11 15:49:19 2006
@@ -7,7 +7,7 @@
#ifndef __ASM_GRANT_TABLE_H__
#define __ASM_GRANT_TABLE_H__
-#define ORDER_GRANT_FRAMES 2
+#define ORDER_GRANT_FRAMES 4
/*
* Caller must own caller's BIGLOCK, is responsible for flushing the TLB, and
diff -r a91e4dcf629d xen/include/xen/grant_table.h
--- a/xen/include/xen/grant_table.h Fri Dec 23 01:12:41 2005
+++ b/xen/include/xen/grant_table.h Wed Jan 11 15:49:19 2006
@@ -61,12 +61,11 @@
* table of these, indexes into which are returned as a 'mapping handle'.
*/
typedef struct {
- u16 ref_and_flags; /* 0-4: GNTMAP_* ; 5-15: grant ref */
+ u16 ref; /* grant reference */
+ u8 flags; /* 0-4: GNTMAP_* */
domid_t domid; /* granting domain */
} grant_mapping_t;
-#define MAPTRACK_GNTMAP_MASK 0x1f
-#define MAPTRACK_REF_SHIFT 5
-#define MAPTRACK_MAX_ENTRIES (1 << (16 - MAPTRACK_REF_SHIFT))
+#define MAPTRACK_MAX_ENTRIES (1 << 16)
/* Per-domain grant information. */
typedef struct {
[-- Attachment #3: unstable-moregrants.patch --]
[-- Type: text/x-patch, Size: 8350 bytes --]
diff -r c886f74b54a4 linux-2.6-xen-sparse/include/asm-xen/gnttab.h
--- a/linux-2.6-xen-sparse/include/asm-xen/gnttab.h Wed Jan 11 12:02:54 2006
+++ b/linux-2.6-xen-sparse/include/asm-xen/gnttab.h Wed Jan 11 16:21:56 2006
@@ -21,7 +21,7 @@
#ifdef __ia64__
#define NR_GRANT_FRAMES 1
#else
-#define NR_GRANT_FRAMES 4
+#define NR_GRANT_FRAMES 16
#endif
struct gnttab_free_callback {
diff -r c886f74b54a4 xen/common/grant_table.c
--- a/xen/common/grant_table.c Wed Jan 11 12:02:54 2006
+++ b/xen/common/grant_table.c Wed Jan 11 16:21:56 2006
@@ -45,7 +45,7 @@
unsigned int h;
if ( unlikely((h = t->maptrack_head) == (t->maptrack_limit - 1)) )
return -1;
- t->maptrack_head = t->maptrack[h].ref_and_flags >> MAPTRACK_REF_SHIFT;
+ t->maptrack_head = t->maptrack[h].ref;
t->map_count++;
return h;
}
@@ -54,7 +54,8 @@
put_maptrack_handle(
grant_table_t *t, int handle)
{
- t->maptrack[handle].ref_and_flags = t->maptrack_head << MAPTRACK_REF_SHIFT;
+ t->maptrack[handle].ref = t->maptrack_head;
+ t->maptrack[handle].flags = 0;
t->maptrack_head = handle;
t->map_count--;
}
@@ -161,7 +162,10 @@
memcpy(new_mt, lgt->maptrack, PAGE_SIZE << lgt->maptrack_order);
for ( i = lgt->maptrack_limit; i < (lgt->maptrack_limit << 1); i++ )
- new_mt[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
+ {
+ new_mt[i].ref = (i+1);
+ new_mt[i].flags = 0;
+ }
free_xenheap_pages(lgt->maptrack, lgt->maptrack_order);
lgt->maptrack = new_mt;
@@ -283,10 +287,9 @@
TRACE_1D(TRC_MEM_PAGE_GRANT_MAP, dom);
- ld->grant_table->maptrack[handle].domid = dom;
- ld->grant_table->maptrack[handle].ref_and_flags =
- (ref << MAPTRACK_REF_SHIFT) |
- (dev_hst_ro_flags & MAPTRACK_GNTMAP_MASK);
+ ld->grant_table->maptrack[handle].domid = dom;
+ ld->grant_table->maptrack[handle].ref = ref;
+ ld->grant_table->maptrack[handle].flags = (u8) dev_hst_ro_flags;
(void)__put_user((u64)frame << PAGE_SHIFT, &uop->dev_bus_addr);
(void)__put_user(handle, &uop->handle);
@@ -363,7 +366,7 @@
map = &ld->grant_table->maptrack[handle];
if ( unlikely(handle >= ld->grant_table->maptrack_limit) ||
- unlikely(!(map->ref_and_flags & MAPTRACK_GNTMAP_MASK)) )
+ unlikely(!(map->flags)) )
{
DPRINTK("Bad handle (%d).\n", handle);
(void)__put_user(GNTST_bad_handle, &uop->status);
@@ -371,8 +374,8 @@
}
dom = map->domid;
- ref = map->ref_and_flags >> MAPTRACK_REF_SHIFT;
- flags = map->ref_and_flags & MAPTRACK_GNTMAP_MASK;
+ ref = map->ref;
+ flags = map->flags;
if ( unlikely((rd = find_domain_by_id(dom)) == NULL) ||
unlikely(ld == rd) )
@@ -403,7 +406,7 @@
if ( flags & GNTMAP_device_map )
{
ASSERT(act->pin & (GNTPIN_devw_mask | GNTPIN_devr_mask));
- map->ref_and_flags &= ~GNTMAP_device_map;
+ map->flags &= ~GNTMAP_device_map;
if ( flags & GNTMAP_readonly )
{
act->pin -= GNTPIN_devr_inc;
@@ -423,7 +426,7 @@
goto unmap_out;
ASSERT(act->pin & (GNTPIN_hstw_mask | GNTPIN_hstr_mask));
- map->ref_and_flags &= ~GNTMAP_host_map;
+ map->flags &= ~GNTMAP_host_map;
if ( flags & GNTMAP_readonly )
{
act->pin -= GNTPIN_hstr_inc;
@@ -436,9 +439,10 @@
}
}
- if ( (map->ref_and_flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0 )
- {
- map->ref_and_flags = 0;
+ if ( (map->flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0 )
+ {
+ map->ref = 0;
+ map->flags = 0;
put_maptrack_handle(ld->grant_table, handle);
}
@@ -597,12 +601,12 @@
for ( i = 0; i < gt->maptrack_limit; i++ )
{
maptrack = >->maptrack[i];
- if ( maptrack->ref_and_flags & MAPTRACK_GNTMAP_MASK )
- DPRINTK("Grant: dom (%hu) MAP (%d) ref:(%hu) flags:(%x) "
+ if ( maptrack->flags )
+ DPRINTK("Grant: dom (%hu) MAP (%d) ref:(%hu) flags:(%c) "
"dom:(%hu)\n",
op.dom, i,
- maptrack->ref_and_flags >> MAPTRACK_REF_SHIFT,
- maptrack->ref_and_flags & MAPTRACK_GNTMAP_MASK,
+ maptrack->ref,
+ maptrack->flags,
maptrack->domid);
}
@@ -872,7 +876,10 @@
t->maptrack_limit = PAGE_SIZE / sizeof(grant_mapping_t);
memset(t->maptrack, 0, PAGE_SIZE);
for ( i = 0; i < t->maptrack_limit; i++ )
- t->maptrack[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
+ {
+ t->maptrack[i].ref = (i+1);
+ t->maptrack[i].flags = 0;
+ }
/* Shared grant table. */
t->shared = alloc_xenheap_pages(ORDER_GRANT_FRAMES);
@@ -915,13 +922,13 @@
for ( handle = 0; handle < gt->maptrack_limit; handle++ )
{
map = >->maptrack[handle];
- if ( !(map->ref_and_flags & (GNTMAP_device_map|GNTMAP_host_map)) )
+ if ( !(map->flags & (GNTMAP_device_map|GNTMAP_host_map)) )
continue;
- ref = map->ref_and_flags >> MAPTRACK_REF_SHIFT;
-
- DPRINTK("Grant release (%hu) ref:(%hu) flags:(%x) dom:(%hu)\n",
- handle, ref, map->ref_and_flags & MAPTRACK_GNTMAP_MASK,
+ ref = map->ref;
+
+ DPRINTK("Grant release (%hu) ref:(%hu) flags:(%c) dom:(%hu)\n",
+ handle, ref, map->flags,
map->domid);
rd = find_domain_by_id(map->domid);
@@ -932,16 +939,16 @@
act = &rd->grant_table->active[ref];
sha = &rd->grant_table->shared[ref];
- if ( map->ref_and_flags & GNTMAP_readonly )
- {
- if ( map->ref_and_flags & GNTMAP_device_map )
+ if ( map->flags & GNTMAP_readonly )
+ {
+ if ( map->flags & GNTMAP_device_map )
{
BUG_ON(!(act->pin & GNTPIN_devr_mask));
act->pin -= GNTPIN_devr_inc;
put_page(pfn_to_page(act->frame));
}
- if ( map->ref_and_flags & GNTMAP_host_map )
+ if ( map->flags & GNTMAP_host_map )
{
BUG_ON(!(act->pin & GNTPIN_hstr_mask));
act->pin -= GNTPIN_hstr_inc;
@@ -951,14 +958,14 @@
}
else
{
- if ( map->ref_and_flags & GNTMAP_device_map )
+ if ( map->flags & GNTMAP_device_map )
{
BUG_ON(!(act->pin & GNTPIN_devw_mask));
act->pin -= GNTPIN_devw_inc;
put_page_and_type(pfn_to_page(act->frame));
}
- if ( map->ref_and_flags & GNTMAP_host_map )
+ if ( map->flags & GNTMAP_host_map )
{
BUG_ON(!(act->pin & GNTPIN_hstw_mask));
act->pin -= GNTPIN_hstw_inc;
@@ -977,7 +984,8 @@
put_domain(rd);
- map->ref_and_flags = 0;
+ map->ref = 0;
+ map->flags = 0;
}
}
diff -r c886f74b54a4 xen/include/asm-x86/grant_table.h
--- a/xen/include/asm-x86/grant_table.h Wed Jan 11 12:02:54 2006
+++ b/xen/include/asm-x86/grant_table.h Wed Jan 11 16:21:56 2006
@@ -7,7 +7,7 @@
#ifndef __ASM_GRANT_TABLE_H__
#define __ASM_GRANT_TABLE_H__
-#define ORDER_GRANT_FRAMES 2
+#define ORDER_GRANT_FRAMES 4
/*
* Caller must own caller's BIGLOCK, is responsible for flushing the TLB, and
diff -r c886f74b54a4 xen/include/xen/grant_table.h
--- a/xen/include/xen/grant_table.h Wed Jan 11 12:02:54 2006
+++ b/xen/include/xen/grant_table.h Wed Jan 11 16:21:56 2006
@@ -61,12 +61,11 @@
* table of these, indexes into which are returned as a 'mapping handle'.
*/
typedef struct {
- u16 ref_and_flags; /* 0-4: GNTMAP_* ; 5-15: grant ref */
- domid_t domid; /* granting domain */
+ u16 ref; /* grant reference */
+ u8 flags; /* 0-4: GNTMAP_* */
+ domid_t domid; /* granting domain */
} grant_mapping_t;
-#define MAPTRACK_GNTMAP_MASK 0x1f
-#define MAPTRACK_REF_SHIFT 5
-#define MAPTRACK_MAX_ENTRIES (1 << (16 - MAPTRACK_REF_SHIFT))
+#define MAPTRACK_MAX_ENTRIES (1 << 16) /* limit is sizeof(grant_ref_t) */
/* Per-domain grant information. */
typedef struct {
[-- Attachment #4: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Increase NR_GRANT_FRAMES, more NICs per domU.
2006-01-11 16:35 [PATCH] Increase NR_GRANT_FRAMES, more NICs per domU Christopher Clark
@ 2006-01-12 9:42 ` Birger Tödtmann
2006-01-12 9:45 ` Birger Tödtmann
0 siblings, 1 reply; 3+ messages in thread
From: Birger Tödtmann @ 2006-01-12 9:42 UTC (permalink / raw)
To: Christopher Clark; +Cc: Keir Fraser, xen-devel, Ian Pratt
[-- Attachment #1.1: Type: text/plain, Size: 1228 bytes --]
Am Mittwoch, den 11.01.2006, 16:35 +0000 schrieb Christopher Clark:
[...]
> This patch increases the number of grant frames from 4 to 16, which
> then increases the maximum number of NICs per domU to 15.
>
> The maximum number of grant frames (NR_GRANT_FRAMES), should you wish
> to increase this further, is now 128 though this untested.
>
[...]
> The second patch is exactly the same set of changes against unstable,
> which is not testable at the moment.
[...]
It (the unstable patch) did not apply cleanly to the latest snapshot so
I did some minor fiddling. The resulting patch (attached) works fine
and testing so far yielded good functionality. Great work, thank you
very much!
A question to Xen maintainers: is the roadmap towards resource
management (grant tables) pointing in this general direction (=will
Christophers changes be included in some way in the future), or will it
be finally more something like Xenidc?
Regards,
--
Birger Tödtmann email:btoedtmann@iem.uni-due.de
Technik der Rechnernetze, Institut für Experimentelle Mathematik
Universität Duisburg-Essen, Campus Essen, Germany.
skype:birger.toedtmann pgp:0x6FB166C9 phone: +49-(0)201-1837662
[-- Attachment #1.2: Dies ist ein digital signierter Nachrichtenteil --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Increase NR_GRANT_FRAMES, more NICs per domU.
2006-01-12 9:42 ` Birger Tödtmann
@ 2006-01-12 9:45 ` Birger Tödtmann
0 siblings, 0 replies; 3+ messages in thread
From: Birger Tödtmann @ 2006-01-12 9:45 UTC (permalink / raw)
To: Christopher Clark; +Cc: Keir Fraser, xen-devel, Ian Pratt
[-- Attachment #1: Type: text/plain, Size: 565 bytes --]
Am Donnerstag, den 12.01.2006, 10:42 +0100 schrieb Birger Tödtmann:
[...]
> It (the unstable patch) did not apply cleanly to the latest snapshot so
> I did some minor fiddling. The resulting patch (attached) works fine
[...]
*Sigh* - here comes the code finally (not my day this day).
Regards,
--
Birger Tödtmann email:btoedtmann@iem.uni-due.de
Technik der Rechnernetze, Institut für Experimentelle Mathematik
Universität Duisburg-Essen, Campus Essen, Germany.
skype:birger.toedtmann pgp:0x6FB166C9 phone: +49-(0)201-1837662
[-- Attachment #2: latestsnapsh-moregrants.patch --]
[-- Type: text/x-patch, Size: 8214 bytes --]
diff -r c886f74b54a4 linux-2.6-xen-sparse/include/asm-xen/gnttab.h
--- a/linux-2.6-xen-sparse/include/asm-xen/gnttab.h Wed Jan 11 12:02:54 2006
+++ b/linux-2.6-xen-sparse/include/asm-xen/gnttab.h Wed Jan 11 16:21:56 2006
@@ -21,7 +21,7 @@
#ifdef __ia64__
#define NR_GRANT_FRAMES 1
#else
-#define NR_GRANT_FRAMES 4
+#define NR_GRANT_FRAMES 16
#endif
struct gnttab_free_callback {
diff -r c886f74b54a4 xen/common/grant_table.c
--- a/xen/common/grant_table.c 2006-01-12 08:46:29.000000000 +0100
+++ b/xen/common/grant_table.c 2006-01-12 00:19:16.000000000 +0100
@@ -45,7 +45,7 @@
unsigned int h;
if ( unlikely((h = t->maptrack_head) == (t->maptrack_limit - 1)) )
return -1;
- t->maptrack_head = t->maptrack[h].ref_and_flags >> MAPTRACK_REF_SHIFT;
+ t->maptrack_head = t->maptrack[h].ref;
t->map_count++;
return h;
}
@@ -54,7 +54,8 @@
put_maptrack_handle(
grant_table_t *t, int handle)
{
- t->maptrack[handle].ref_and_flags = t->maptrack_head << MAPTRACK_REF_SHIFT;
+ t->maptrack[handle].ref = t->maptrack_head;
+ t->maptrack[handle].flags = 0;
t->maptrack_head = handle;
t->map_count--;
}
@@ -161,7 +162,10 @@
memcpy(new_mt, lgt->maptrack, PAGE_SIZE << lgt->maptrack_order);
for ( i = lgt->maptrack_limit; i < (lgt->maptrack_limit << 1); i++ )
- new_mt[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
+ {
+ new_mt[i].ref = (i+1);
+ new_mt[i].flags = 0;
+ }
free_xenheap_pages(lgt->maptrack, lgt->maptrack_order);
lgt->maptrack = new_mt;
@@ -363,10 +367,9 @@
TRACE_1D(TRC_MEM_PAGE_GRANT_MAP, dom);
- ld->grant_table->maptrack[handle].domid = dom;
- ld->grant_table->maptrack[handle].ref_and_flags =
- (ref << MAPTRACK_REF_SHIFT) |
- (dev_hst_ro_flags & MAPTRACK_GNTMAP_MASK);
+ ld->grant_table->maptrack[handle].domid = dom;
+ ld->grant_table->maptrack[handle].ref = ref;
+ ld->grant_table->maptrack[handle].flags = (u8) dev_hst_ro_flags;
(void)__put_user((u64)frame << PAGE_SHIFT, &uop->dev_bus_addr);
(void)__put_user(handle, &uop->handle);
@@ -427,7 +430,7 @@
map = &ld->grant_table->maptrack[handle];
if ( unlikely(handle >= ld->grant_table->maptrack_limit) ||
- unlikely(!(map->ref_and_flags & MAPTRACK_GNTMAP_MASK)) )
+ unlikely(!(map->flags)) )
{
DPRINTK("Bad handle (%d).\n", handle);
(void)__put_user(GNTST_bad_handle, &uop->status);
@@ -435,8 +438,8 @@
}
dom = map->domid;
- ref = map->ref_and_flags >> MAPTRACK_REF_SHIFT;
- flags = map->ref_and_flags & MAPTRACK_GNTMAP_MASK;
+ ref = map->ref;
+ flags = map->flags;
if ( unlikely((rd = find_domain_by_id(dom)) == NULL) ||
unlikely(ld == rd) )
@@ -468,7 +471,7 @@
act->pin -= (flags & GNTMAP_readonly) ? GNTPIN_devr_inc
: GNTPIN_devw_inc;
- map->ref_and_flags &= ~GNTMAP_device_map;
+ map->flags &= ~GNTMAP_device_map;
(void)__put_user(0, &uop->dev_bus_addr);
}
@@ -479,15 +482,16 @@
if ( (rc = destroy_grant_host_mapping(addr, frame, flags)) < 0 )
goto unmap_out;
- map->ref_and_flags &= ~GNTMAP_host_map;
+ map->flags &= ~GNTMAP_host_map;
act->pin -= (flags & GNTMAP_readonly) ? GNTPIN_hstr_inc
: GNTPIN_hstw_inc;
}
- if ( (map->ref_and_flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0)
+ if ( (map->flags & (GNTMAP_device_map|GNTMAP_host_map)) == 0 )
{
- map->ref_and_flags = 0;
+ map->ref = 0;
+ map->flags = 0;
put_maptrack_handle(ld->grant_table, handle);
}
@@ -654,12 +658,12 @@
for ( i = 0; i < gt->maptrack_limit; i++ )
{
maptrack = >->maptrack[i];
- if ( maptrack->ref_and_flags & MAPTRACK_GNTMAP_MASK )
- DPRINTK("Grant: dom (%hu) MAP (%d) ref:(%hu) flags:(%x) "
+ if ( maptrack->flags )
+ DPRINTK("Grant: dom (%hu) MAP (%d) ref:(%hu) flags:(%c) "
"dom:(%hu)\n",
op.dom, i,
- maptrack->ref_and_flags >> MAPTRACK_REF_SHIFT,
- maptrack->ref_and_flags & MAPTRACK_GNTMAP_MASK,
+ maptrack->ref,
+ maptrack->flags,
maptrack->domid);
}
@@ -925,7 +929,10 @@
t->maptrack_limit = PAGE_SIZE / sizeof(grant_mapping_t);
memset(t->maptrack, 0, PAGE_SIZE);
for ( i = 0; i < t->maptrack_limit; i++ )
- t->maptrack[i].ref_and_flags = (i+1) << MAPTRACK_REF_SHIFT;
+ {
+ t->maptrack[i].ref = (i+1);
+ t->maptrack[i].flags = 0;
+ }
/* Shared grant table. */
t->shared = alloc_xenheap_pages(ORDER_GRANT_FRAMES);
@@ -968,13 +975,13 @@
for ( handle = 0; handle < gt->maptrack_limit; handle++ )
{
map = >->maptrack[handle];
- if ( !(map->ref_and_flags & (GNTMAP_device_map|GNTMAP_host_map)) )
+ if ( !(map->flags & (GNTMAP_device_map|GNTMAP_host_map)) )
continue;
- ref = map->ref_and_flags >> MAPTRACK_REF_SHIFT;
+ ref = map->ref;
- DPRINTK("Grant release (%hu) ref:(%hu) flags:(%x) dom:(%hu)\n",
- handle, ref, map->ref_and_flags & MAPTRACK_GNTMAP_MASK,
+ DPRINTK("Grant release (%hu) ref:(%hu) flags:(%c) dom:(%hu)\n",
+ handle, ref, map->flags,
map->domid);
rd = find_domain_by_id(map->domid);
@@ -985,15 +992,15 @@
act = &rd->grant_table->active[ref];
sha = &rd->grant_table->shared[ref];
- if ( map->ref_and_flags & GNTMAP_readonly )
- {
- if ( map->ref_and_flags & GNTMAP_device_map )
+ if ( map->flags & GNTMAP_readonly )
+ {
+ if ( map->flags & GNTMAP_device_map )
{
BUG_ON((act->pin & GNTPIN_devr_mask) == 0);
act->pin -= GNTPIN_devr_inc;
}
- if ( map->ref_and_flags & GNTMAP_host_map )
+ if ( map->flags & GNTMAP_host_map )
{
BUG_ON((act->pin & GNTPIN_hstr_mask) == 0);
act->pin -= GNTPIN_hstr_inc;
@@ -1001,13 +1008,13 @@
}
else
{
- if ( map->ref_and_flags & GNTMAP_device_map )
+ if ( map->flags & GNTMAP_device_map )
{
BUG_ON((act->pin & GNTPIN_devw_mask) == 0);
act->pin -= GNTPIN_devw_inc;
}
- if ( map->ref_and_flags & GNTMAP_host_map )
+ if ( map->flags & GNTMAP_host_map )
{
BUG_ON((act->pin & GNTPIN_hstw_mask) == 0);
act->pin -= GNTPIN_hstw_inc;
@@ -1030,7 +1037,8 @@
put_domain(rd);
- map->ref_and_flags = 0;
+ map->ref = 0;
+ map->flags = 0;
}
}
diff -r c886f74b54a4 xen/include/asm-x86/grant_table.h
--- a/xen/include/asm-x86/grant_table.h Wed Jan 11 12:02:54 2006
+++ b/xen/include/asm-x86/grant_table.h Wed Jan 11 16:21:56 2006
@@ -7,7 +7,7 @@
#ifndef __ASM_GRANT_TABLE_H__
#define __ASM_GRANT_TABLE_H__
-#define ORDER_GRANT_FRAMES 2
+#define ORDER_GRANT_FRAMES 4
/*
* Caller must own caller's BIGLOCK, is responsible for flushing the TLB, and
diff -r c886f74b54a4 xen/include/xen/grant_table.h
--- a/xen/include/xen/grant_table.h Wed Jan 11 12:02:54 2006
+++ b/xen/include/xen/grant_table.h Wed Jan 11 16:21:56 2006
@@ -61,12 +61,11 @@
* table of these, indexes into which are returned as a 'mapping handle'.
*/
typedef struct {
- u16 ref_and_flags; /* 0-4: GNTMAP_* ; 5-15: grant ref */
- domid_t domid; /* granting domain */
+ u16 ref; /* grant reference */
+ u8 flags; /* 0-4: GNTMAP_* */
+ domid_t domid; /* granting domain */
} grant_mapping_t;
-#define MAPTRACK_GNTMAP_MASK 0x1f
-#define MAPTRACK_REF_SHIFT 5
-#define MAPTRACK_MAX_ENTRIES (1 << (16 - MAPTRACK_REF_SHIFT))
+#define MAPTRACK_MAX_ENTRIES (1 << 16) /* limit is sizeof(grant_ref_t) */
/* Per-domain grant information. */
typedef struct {
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-01-12 9:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-11 16:35 [PATCH] Increase NR_GRANT_FRAMES, more NICs per domU Christopher Clark
2006-01-12 9:42 ` Birger Tödtmann
2006-01-12 9:45 ` Birger Tödtmann
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.