Skip to contentSkip to conversation

Refactor ioreq server for better performance.

PATCH Superseded Yu Zhang 5 participants 24 messages Jul 6, 2015 – Jul 7, 2015

v2 of 12 Superseded Latest is v12 →

lore
Share & tools
lore

Yu Zhang

author
#0 lore raw

v2 cover Refactor ioreq server for better performance.

XenGT leverages ioreq server to track and forward the accesses to GPU I/O resources, e.g. the PPGTT(per-process graphic translation tables). Currently, ioreq server uses rangeset to track the BDF/ PIO/MMIO ranges to be emulated. To select an ioreq server, the rangeset is searched to see if the I/O range is recorded. However, traversing the link list inside rangeset could be time consuming when number of ranges is too high. On HSW platform, number of PPGTTs for each vGPU could be several hundred. On BDW, this value could be several thousand.

To accommodate more ranges, limitation of the number of ranges in an ioreq server, MAX_NR_IO_RANGES is changed - future patches will be provided to tune this with other approaches. And to increase the ioreq server performance, a new data structure, rb_rangeset, is introduced.

Changes in v2:
1> Split the original patch into 2;
2> Take Paul Durrant's comments:
a> Add a name member in the struct rb_rangeset, and use the 'q'
debug key to dump the ranges in ioreq server;
b> Keep original routine names for hvm ioreq server; c> Commit message changes - mention that a future patch to change
the maximum ranges inside ioreq server.

Yu Zhang (2):
Resize the MAX_NR_IO_RANGES for ioreq server
Add new data structure to track ranges.

 xen/arch/x86/domain.c            |   3 +
 xen/arch/x86/hvm/hvm.c           |  56 ++++++--
 xen/common/Makefile              |   1 +
 xen/common/rb_rangeset.c         | 281 +++++++++++++++++++++++++++++++++++++++
 xen/include/asm-x86/hvm/domain.h |   4 +-
 xen/include/asm-x86/hvm/hvm.h    |   1 +
 xen/include/xen/rb_rangeset.h    |  49 +++++++
 7 files changed, 379 insertions(+), 16 deletions(-)
 create mode 100644 xen/common/rb_rangeset.c
 create mode 100644 xen/include/xen/rb_rangeset.h
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v2 1/2 Resize the MAX_NR_IO_RANGES for ioreq server

MAX_NR_IO_RANGES is used by ioreq server as the maximum number of discrete ranges to be tracked. This patch changes its value to 8k, so that more ranges can be tracked on next generation of Intel platforms in XenGT. Future patches can extend the limit to be toolstack tunable, and MAX_NR_IO_RANGES can serve as a default limit.

---
 xen/include/asm-x86/hvm/domain.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/asm-x86/hvm/domain.h +1 -1
index ad68fcf..d62fda9 100644
@@ -49,7 +49,7 @@ struct hvm_ioreq_vcpu {
 };
 
 #define NR_IO_RANGE_TYPES (HVMOP_IO_RANGE_PCI + 1)
-#define MAX_NR_IO_RANGES  256
+#define MAX_NR_IO_RANGES  8192
 
 struct hvm_ioreq_server {
     struct list_head       list_entry;
Signature · 1 line
1.9.1
author
#23 lore raw

PATCH v2 2/2 Add new data structure to track ranges.

In reply to Yu Zhang

This patch introduces a new data structure, struct rb_rangeset, to represent a group of continuous ranges, e.g. the start and end addresses for PIO/MMIO regions. By now, this structure is supposed to assist ioreq server to forward the I/O request to backend device models more efficiently.

Behavior of this new data structure is quite similar to rangeset, with major difference being the time complexity. Based on doubly linked list, struct rangeset provides O(n) time complexity for searching. And struct rb_rangeset is based on red-black tree, with binary searching, the time complexity is improved to O(log(n)) - more suitable to track massive discrete ranges.

Ioreq server code is changed to utilize this new type, and a new routine, hvm_ioreq_server_dump_range_info, is added to dump all the ranges tracked in an ioreq server.

---
 xen/arch/x86/domain.c            |   3 +
 xen/arch/x86/hvm/hvm.c           |  56 ++++++--
 xen/common/Makefile              |   1 +
 xen/common/rb_rangeset.c         | 281 +++++++++++++++++++++++++++++++++++++++
 xen/include/asm-x86/hvm/domain.h |   2 +-
 xen/include/asm-x86/hvm/hvm.h    |   1 +
 xen/include/xen/rb_rangeset.h    |  49 +++++++
 7 files changed, 378 insertions(+), 15 deletions(-)
 create mode 100644 xen/common/rb_rangeset.c
 create mode 100644 xen/include/xen/rb_rangeset.h
xen/arch/x86/domain.c +3 -0
index a8fe046..f8a8b80 100644
@@ -2086,6 +2086,9 @@ int domain_relinquish_resources(struct domain *d)
 void arch_dump_domain_info(struct domain *d)
 {
     paging_dump_domain_info(d);
+
+    if ( is_hvm_domain(d) )
+        hvm_ioreq_server_dump_range_info(d);
 }
 
 void arch_dump_vcpu_info(struct vcpu *v)
xen/arch/x86/hvm/hvm.c +42 -14

135 lines not on this page · raw message

xen/common/Makefile +1 -0
index 1cddebc..c49040f 100644
@@ -28,6 +28,7 @@ obj-y += random.o
 obj-y += rangeset.o
 obj-y += radix-tree.o
 obj-y += rbtree.o
+obj-y += rb_rangeset.o
 obj-y += rcupdate.o
 obj-y += sched_credit.o
 obj-y += sched_credit2.o
xen/common/rb_rangeset.c new file +281 -0

281 lines not on this page · raw message

xen/include/asm-x86/hvm/domain.h +1 -1
index d62fda9..a2f60a8 100644
@@ -68,7 +68,7 @@ struct hvm_ioreq_server {
     /* Lock to serialize access to buffered ioreq ring */
     spinlock_t             bufioreq_lock;
     evtchn_port_t          bufioreq_evtchn;
-    struct rangeset        *range[NR_IO_RANGE_TYPES];
+    struct rb_rangeset     *range[NR_IO_RANGE_TYPES];
     bool_t                 enabled;
     bool_t                 bufioreq_atomic;
 };
xen/include/asm-x86/hvm/hvm.h +1 -0
index 57f9605..2b1ea30 100644
@@ -230,6 +230,7 @@ void hvm_vcpu_reset_state(struct vcpu *v, uint16_t cs, uint16_t ip);
 
 struct hvm_ioreq_server *hvm_select_ioreq_server(struct domain *d,
                                                  ioreq_t *p);
+void  hvm_ioreq_server_dump_range_info(struct domain *d);
 int hvm_send_assist_req(struct hvm_ioreq_server *s, ioreq_t *p);
 void hvm_broadcast_assist_req(ioreq_t *p);
 void hvm_complete_assist_req(ioreq_t *p);
xen/include/xen/rb_rangeset.h new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

In reply to Yu Zhang
Quoted 8 lines · Yu Zhang

MAX_NR_IO_RANGES is used by ioreq server as the maximum number of discrete ranges to be tracked. This patch changes its value to 8k, so that more ranges can be tracked on next generation of Intel platforms in XenGT. Future patches can extend the limit to be toolstack tunable, and MAX_NR_IO_RANGES can serve as a default limit.

I said this at the Hackathon, and I'll say it here: I think this is the wrong approach.

The problem here is not that you don't have enough memory ranges. The problem is that you are not tracking memory ranges, but individual pages.

You need to make a new interface that allows you to tag individual gfns as p2m_mmio_write_dm, and then allow one ioreq server to get notifications for all such writes.

-George

#3 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 24 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:36
To: Yu Zhang
Cc: [email protected]; Keir (Xen.org); Jan Beulich; Andrew Cooper; Paul Durrant; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 8 lines · Yu Zhang

MAX_NR_IO_RANGES is used by ioreq server as the maximum number of discrete ranges to be tracked. This patch changes its value to 8k, so that more ranges can be tracked on next generation of Intel platforms in XenGT. Future patches can extend the limit to be toolstack tunable, and MAX_NR_IO_RANGES can serve as a default limit.

I said this at the Hackathon, and I'll say it here: I think this is the wrong approach.

Quoted 8 lines

The problem here is not that you don't have enough memory ranges. The problem is that you are not tracking memory ranges, but individual pages.

You need to make a new interface that allows you to tag individual gfns as p2m_mmio_write_dm, and then allow one ioreq server to get notifications for all such writes.

I think that is conflating things. It's quite conceivable that more than one ioreq server will handle write_dm pages. If we had enough types to have two page types per server then I'd agree with you, but we don't.

Paul

Quoted 1 line

-George

#4 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 28 lines · Paul Durrant
Quoted 28 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:36
To: Yu Zhang
Cc: [email protected]; Keir (Xen.org); Jan Beulich; Andrew Cooper; Paul Durrant; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 8 lines · Yu Zhang

MAX_NR_IO_RANGES is used by ioreq server as the maximum number of discrete ranges to be tracked. This patch changes its value to 8k, so that more ranges can be tracked on next generation of Intel platforms in XenGT. Future patches can extend the limit to be toolstack tunable, and MAX_NR_IO_RANGES can serve as a default limit.

I said this at the Hackathon, and I'll say it here: I think this is the wrong approach.

The problem here is not that you don't have enough memory ranges. The problem is that you are not tracking memory ranges, but individual pages.

Quoted 6 lines
Quoted 4 lines

You need to make a new interface that allows you to tag individual gfns as p2m_mmio_write_dm, and then allow one ioreq server to get notifications for all such writes.

I think that is conflating things. It's quite conceivable that more than one ioreq server will handle write_dm pages. If we had enough types to have two page types per server then I'd agree with you, but we don't.

What's conflating things is using an interface designed for *device memory ranges* to instead *track writes to gfns*. Fundamentally the reason you have this explosion of "device memory ranges" is that what you're tracking isn't device memory, and it isn't a range. If your umbrella isn't very good at hammering in nails, the solution is to go get a hammer, not to add steel reinforcement to your umbrella.

My suggestion is, short-term, to simply allow the first ioreq server to register for write_dm notifications to get notifications, and return an error if a second one tries to do so.

If it becomes important for a single domain to have two ioreq servers that need this functionality, then we can come up with an internal Xen structure, *designed for gfns*, to track this. My suspicion is that it will never be needed.

-George

#5 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 46 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:50
To: Paul Durrant
Cc: Yu Zhang; [email protected]; Keir (Xen.org); Jan Beulich; Andrew Cooper; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 8 lines · Paul Durrant
Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:36
To: Yu Zhang
Cc: [email protected]; Keir (Xen.org); Jan Beulich; Andrew Cooper; Paul Durrant; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES

for

Quoted 25 lines
Quoted 24 lines

ioreq server

Quoted 8 lines · Yu Zhang

MAX_NR_IO_RANGES is used by ioreq server as the maximum number of discrete ranges to be tracked. This patch changes its value to 8k, so that more ranges can be tracked on next generation of Intel platforms in XenGT. Future patches can extend the limit to be toolstack tunable, and MAX_NR_IO_RANGES can serve as a default limit.

I said this at the Hackathon, and I'll say it here: I think this is the wrong approach.

The problem here is not that you don't have enough memory ranges. The problem is that you are not tracking memory ranges, but individual pages.

You need to make a new interface that allows you to tag individual gfns as p2m_mmio_write_dm, and then allow one ioreq server to get notifications for all such writes.

Quoted 6 lines
Quoted 1 line

I think that is conflating things. It's quite conceivable that more than one

ioreq server will handle write_dm pages. If we had enough types to have two page types per server then I'd agree with you, but we don't.

What's conflating things is using an interface designed for *device memory ranges* to instead *track writes to gfns*.

What's the difference? Are you asserting that all device memory ranges have read side effects and therefore write_dm is not a reasonable optimization to use? I would not want to make that assertion.

Paul

Quoted 16 lines

Fundamentally the
reason you have this explosion of "device memory ranges" is that what you're tracking isn't device memory, and it isn't a range. If your umbrella isn't very good at hammering in nails, the solution is to go get a hammer, not to add steel reinforcement to your umbrella.

My suggestion is, short-term, to simply allow the first ioreq server to register for write_dm notifications to get notifications, and return an error if a second one tries to do so.

If it becomes important for a single domain to have two ioreq servers that need this functionality, then we can come up with an internal Xen structure, *designed for gfns*, to track this. My suspicion is that it will never be needed.

-George

#6 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 46 lines · Paul Durrant
Quoted 46 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:50
To: Paul Durrant
Cc: Yu Zhang; [email protected]; Keir (Xen.org); Jan Beulich; Andrew Cooper; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 8 lines · Paul Durrant
Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:36
To: Yu Zhang
Cc: [email protected]; Keir (Xen.org); Jan Beulich; Andrew Cooper; Paul Durrant; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES

for

Quoted 25 lines
Quoted 24 lines

ioreq server

Quoted 8 lines · Yu Zhang

MAX_NR_IO_RANGES is used by ioreq server as the maximum number of discrete ranges to be tracked. This patch changes its value to 8k, so that more ranges can be tracked on next generation of Intel platforms in XenGT. Future patches can extend the limit to be toolstack tunable, and MAX_NR_IO_RANGES can serve as a default limit.

I said this at the Hackathon, and I'll say it here: I think this is the wrong approach.

The problem here is not that you don't have enough memory ranges. The problem is that you are not tracking memory ranges, but individual pages.

You need to make a new interface that allows you to tag individual gfns as p2m_mmio_write_dm, and then allow one ioreq server to get notifications for all such writes.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I think that is conflating things. It's quite conceivable that more than one

ioreq server will handle write_dm pages. If we had enough types to have two page types per server then I'd agree with you, but we don't.

What's conflating things is using an interface designed for *device memory ranges* to instead *track writes to gfns*.

What's the difference? Are you asserting that all device memory ranges have read side effects and therefore write_dm is not a reasonable optimization to use? I would not want to make that assertion.

The difference is that actual device memory is typically in big chunks, and each device rarely has more than a handful; whereas guest pfns allocated by the operating system to a driver are typically singleton pages scattered all over the address space.

Which is why a handful of memory ranges is sufficient for tracking devices with hundreds of megabytes of device memory, but thousands of memory ranges are not sufficient for tracking a megabyte or so of GPU
pagetables: the former is one or two actual ranges of a significant size; the latter are (apparently) thousands of ranges of one page each.

-George

#7 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

In reply to Paul Durrant
Quoted 46 lines · Paul Durrant
Quoted 46 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:50
To: Paul Durrant
Cc: Yu Zhang; [email protected]; Keir (Xen.org); Jan Beulich; Andrew Cooper; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 8 lines · Paul Durrant
Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:36
To: Yu Zhang
Cc: [email protected]; Keir (Xen.org); Jan Beulich; Andrew Cooper; Paul Durrant; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES

for

Quoted 25 lines
Quoted 24 lines

ioreq server

Quoted 8 lines · Yu Zhang

MAX_NR_IO_RANGES is used by ioreq server as the maximum number of discrete ranges to be tracked. This patch changes its value to 8k, so that more ranges can be tracked on next generation of Intel platforms in XenGT. Future patches can extend the limit to be toolstack tunable, and MAX_NR_IO_RANGES can serve as a default limit.

I said this at the Hackathon, and I'll say it here: I think this is the wrong approach.

The problem here is not that you don't have enough memory ranges. The problem is that you are not tracking memory ranges, but individual pages.

You need to make a new interface that allows you to tag individual gfns as p2m_mmio_write_dm, and then allow one ioreq server to get notifications for all such writes.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I think that is conflating things. It's quite conceivable that more than one

ioreq server will handle write_dm pages. If we had enough types to have two page types per server then I'd agree with you, but we don't.

What's conflating things is using an interface designed for *device memory ranges* to instead *track writes to gfns*.

What's the difference? Are you asserting that all device memory ranges have read side effects and therefore write_dm is not a reasonable optimization to use? I would not want to make that assertion.

Using write_dm is not the problem; it's having thousands of memory "ranges" of 4k each that I object to.

Which is why I suggested adding an interface to request updates to gfns (by marking them write_dm), rather than abusing the io range interface.

-George

#8 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 69 lines

-----Original Message-----
From: George Dunlap [mailto:[email protected]]
Sent: 06 July 2015 14:28
To: Paul Durrant; George Dunlap
Cc: Yu Zhang; [email protected]; Keir (Xen.org); Jan Beulich; Andrew Cooper; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 6 lines · Paul Durrant
Quoted 6 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:50
To: Paul Durrant
Cc: Yu Zhang; [email protected]; Keir (Xen.org); Jan Beulich;

Andrew

Quoted 2 lines
Quoted 2 lines

Cooper; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES

for

Quoted 10 lines
Quoted 10 lines

ioreq server

Quoted 6 lines · Paul Durrant
Quoted 6 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:36
To: Yu Zhang
Cc: [email protected]; Keir (Xen.org); Jan Beulich; Andrew

Cooper;

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Paul Durrant; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the

MAX_NR_IO_RANGES

Quoted 12 lines
Quoted 12 lines

for

Quoted 11 lines
Quoted 11 lines

ioreq server

Quoted 7 lines · Yu Zhang

MAX_NR_IO_RANGES is used by ioreq server as the maximum number of discrete ranges to be tracked. This patch changes its value to 8k, so that more ranges can be tracked on next generation of Intel platforms in XenGT. Future patches can extend the limit to be toolstack tunable, and MAX_NR_IO_RANGES can serve as a default limit.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

I said this at the Hackathon, and I'll say it here: I think this is the wrong approach.

The problem here is not that you don't have enough memory ranges.

The

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

problem is that you are not tracking memory ranges, but individual pages.

You need to make a new interface that allows you to tag individual gfns as p2m_mmio_write_dm, and then allow one ioreq server to get notifications for all such writes.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I think that is conflating things. It's quite conceivable that more than one

ioreq server will handle write_dm pages. If we had enough types to have two page types per server then I'd agree with you, but we don't.

What's conflating things is using an interface designed for *device memory ranges* to instead *track writes to gfns*.

What's the difference? Are you asserting that all device memory ranges

Quoted 9 lines

have read side effects and therefore write_dm is not a reasonable optimization to use? I would not want to make that assertion.

Using write_dm is not the problem; it's having thousands of memory "ranges" of 4k each that I object to.

Which is why I suggested adding an interface to request updates to gfns (by marking them write_dm), rather than abusing the io range interface.

And it's the assertion that use of write_dm will only be relevant to gfns, and that all such notifications only need go to a single ioreq server, that I have a problem with. Whilst the use of io ranges to track gfn updates is, I agree, not ideal I think the overloading of write_dm is not a step in the right direction.

Paul

Quoted 1 line

-George

#9 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 72 lines · Paul Durrant
Quoted 72 lines

-----Original Message-----
From: George Dunlap [mailto:[email protected]]
Sent: 06 July 2015 14:28
To: Paul Durrant; George Dunlap
Cc: Yu Zhang; [email protected]; Keir (Xen.org); Jan Beulich; Andrew Cooper; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 6 lines · Paul Durrant
Quoted 6 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:50
To: Paul Durrant
Cc: Yu Zhang; [email protected]; Keir (Xen.org); Jan Beulich;

Andrew

Quoted 2 lines
Quoted 2 lines

Cooper; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES

for

Quoted 10 lines
Quoted 10 lines

ioreq server

Quoted 6 lines · Paul Durrant
Quoted 6 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:36
To: Yu Zhang
Cc: [email protected]; Keir (Xen.org); Jan Beulich; Andrew

Cooper;

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Paul Durrant; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the

MAX_NR_IO_RANGES

Quoted 12 lines
Quoted 12 lines

for

Quoted 11 lines
Quoted 11 lines

ioreq server

Quoted 7 lines · Yu Zhang

MAX_NR_IO_RANGES is used by ioreq server as the maximum number of discrete ranges to be tracked. This patch changes its value to 8k, so that more ranges can be tracked on next generation of Intel platforms in XenGT. Future patches can extend the limit to be toolstack tunable, and MAX_NR_IO_RANGES can serve as a default limit.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

I said this at the Hackathon, and I'll say it here: I think this is the wrong approach.

The problem here is not that you don't have enough memory ranges.

The

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

problem is that you are not tracking memory ranges, but individual pages.

You need to make a new interface that allows you to tag individual gfns as p2m_mmio_write_dm, and then allow one ioreq server to get notifications for all such writes.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I think that is conflating things. It's quite conceivable that more than one

ioreq server will handle write_dm pages. If we had enough types to have two page types per server then I'd agree with you, but we don't.

What's conflating things is using an interface designed for *device memory ranges* to instead *track writes to gfns*.

What's the difference? Are you asserting that all device memory ranges

have read side effects and therefore write_dm is not a reasonable optimization to use? I would not want to make that assertion.

Quoted 8 lines
Quoted 6 lines

Using write_dm is not the problem; it's having thousands of memory "ranges" of 4k each that I object to.

Which is why I suggested adding an interface to request updates to gfns (by marking them write_dm), rather than abusing the io range interface.

And it's the assertion that use of write_dm will only be relevant to gfns, and that all such notifications only need go to a single ioreq server, that I have a problem with. Whilst the use of io ranges to track gfn updates is, I agree, not ideal I think the overloading of write_dm is not a step in the right direction.

So there are two questions here.

First of all, I certainly think that the *interface* should be able to be transparently extended to support multiple ioreq servers being able to track gfns. My suggestion was to add a hypercall that allows an ioreq server to say, "Please send modifications to gfn N to ioreq server X"; and that for the time being, only allow one such X to exist at a time per domain. That is, if ioreq server Y makes such a call after ioreq server X has done so, return -EBUSY. That way we can add support when we need it.

In fact, you probably already have a problem with two ioreq servers, because (if I recall correctly) you don't know for sure when a page has stopped being used as a GPU pagetable. Consider the following scenario:
1. Two devices, served by ioreq servers 1 and 2.
2. driver for device served by ioreq server 1 allocates a page, uses it as a pagetable. ioreq server 1 adds that pfn to the ranges it's watching.
3. driver frees page back to guest OS; but ioreq server 1 doesn't know so it doesn't release the range
4. driver for device served by ioreq server 2 allocates a page, which happens to be the same one used before, and uses it as a pagetable. ioreq server 1 tries to add that pfn to the ranges it's watching.

Now you have an "overlap in the range" between the two ioreq servers. What do you do?

Regarding using write_dm for actual device memory ranges: Do you have any concrete scenarios in mind where you think this will be used?

Fundamentally, write_dm looks to me like it's about tracking gfns -- i.e., things backed by guest RAM -- not IO ranges. As such, it should have an interface and an implementation that reflects that.

-George

author
#10 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Thanks a lot, George.

Quoted 84 lines · George Dunlap
Quoted 72 lines · Paul Durrant
Quoted 72 lines

-----Original Message-----
From: George Dunlap [mailto:[email protected]]
Sent: 06 July 2015 14:28
To: Paul Durrant; George Dunlap
Cc: Yu Zhang; [email protected]; Keir (Xen.org); Jan Beulich; Andrew Cooper; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 6 lines · Paul Durrant
Quoted 6 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:50
To: Paul Durrant
Cc: Yu Zhang; [email protected]; Keir (Xen.org); Jan Beulich;

Andrew

Quoted 2 lines
Quoted 2 lines

Cooper; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES

for

Quoted 10 lines
Quoted 10 lines

ioreq server

Quoted 6 lines · Paul Durrant
Quoted 6 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:36
To: Yu Zhang
Cc: [email protected]; Keir (Xen.org); Jan Beulich; Andrew

Cooper;

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Paul Durrant; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the

MAX_NR_IO_RANGES

Quoted 12 lines
Quoted 12 lines

for

Quoted 11 lines
Quoted 11 lines

ioreq server

Quoted 7 lines · Yu Zhang

MAX_NR_IO_RANGES is used by ioreq server as the maximum number of discrete ranges to be tracked. This patch changes its value to 8k, so that more ranges can be tracked on next generation of Intel platforms in XenGT. Future patches can extend the limit to be toolstack tunable, and MAX_NR_IO_RANGES can serve as a default limit.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 1 line

I said this at the Hackathon, and I'll say it here: I think this is the wrong approach.

The problem here is not that you don't have enough memory ranges.

The

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

problem is that you are not tracking memory ranges, but individual pages.

You need to make a new interface that allows you to tag individual gfns as p2m_mmio_write_dm, and then allow one ioreq server to get notifications for all such writes.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

I think that is conflating things. It's quite conceivable that more than one

ioreq server will handle write_dm pages. If we had enough types to have two page types per server then I'd agree with you, but we don't.

What's conflating things is using an interface designed for *device memory ranges* to instead *track writes to gfns*.

What's the difference? Are you asserting that all device memory ranges

have read side effects and therefore write_dm is not a reasonable optimization to use? I would not want to make that assertion.

Quoted 8 lines
Quoted 6 lines

Using write_dm is not the problem; it's having thousands of memory "ranges" of 4k each that I object to.

Which is why I suggested adding an interface to request updates to gfns (by marking them write_dm), rather than abusing the io range interface.

And it's the assertion that use of write_dm will only be relevant to gfns, and that all such notifications only need go to a single ioreq server, that I have a problem with. Whilst the use of io ranges to track gfn updates is, I agree, not ideal I think the overloading of write_dm is not a step in the right direction.

So there are two questions here.

Quoted 9 lines

First of all, I certainly think that the *interface* should be able to be transparently extended to support multiple ioreq servers being able to track gfns. My suggestion was to add a hypercall that allows an ioreq server to say, "Please send modifications to gfn N to ioreq server X"; and that for the time being, only allow one such X to exist at a time per domain. That is, if ioreq server Y makes such a call after ioreq server X has done so, return -EBUSY. That way we can add support when we need it.

Well, I also agree the current implementation is probably not optimal. And yes, it seems promiscuous( hope I did not use the wrong word :) ) to mix the device I/O ranges and the guest memory. But, forwarding an ioreq to backend driver, just by an p2m type? Although it would be easy for XenGT to take this approach, I agree with Paul that this would weaken the functionality of ioreq server. Besides, is it appropriate for a p2m type to be used this way? It seems strange for me.

Quoted 2 lines

In fact, you probably already have a problem with two ioreq servers, because (if I recall correctly) you don't know for sure when a page

Fortunately, we do, and these unmapped page tables will be removed from the rangeset of ioreq server. So the following scenario won't happen. :)

Quoted 15 lines

has stopped being used as a GPU pagetable. Consider the following scenario:
1. Two devices, served by ioreq servers 1 and 2.
2. driver for device served by ioreq server 1 allocates a page, uses it as a pagetable. ioreq server 1 adds that pfn to the ranges it's watching.
3. driver frees page back to guest OS; but ioreq server 1 doesn't know so it doesn't release the range
4. driver for device served by ioreq server 2 allocates a page, which happens to be the same one used before, and uses it as a pagetable. ioreq server 1 tries to add that pfn to the ranges it's watching.

Now you have an "overlap in the range" between the two ioreq servers. What do you do?

Quoted 7 lines

Regarding using write_dm for actual device memory ranges: Do you have any concrete scenarios in mind where you think this will be used?

Fundamentally, write_dm looks to me like it's about tracking gfns -- i.e., things backed by guest RAM -- not IO ranges. As such, it should have an interface and an implementation that reflects that.

Here, I guess your major concern about the difference between tracking
gfns and I/O ranges is that the gfns are scattered? And yes, this is why
we need more ranges inside a rangeset. Here the new value of the limit, 8K, is a practical one for XenGT. In the future, we can either provide other approaches to configure the maximum ranges inside an ioreq server,
or provide some xenheap allocation management routines. Is this OK?

I thought we had successfully convinced you in hackathon. And seems I'm wrong. Anyway, your advices are very appreciated. :)

Quoted 2 lines

-George

B.R.
Yu

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#11 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 166 lines

-----Original Message-----
From: Yu, Zhang [mailto:[email protected]]
Sent: 07 July 2015 09:16
To: George Dunlap; Paul Durrant
Cc: Kevin Tian; Keir (Xen.org); Andrew Cooper; George Dunlap; xen- [email protected]; [email protected]; Jan Beulich
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Thanks a lot, George.

Quoted 1 line · George Dunlap

On Mon, Jul 6, 2015 at 2:33 PM, Paul Durrant <[email protected]>

Quoted 5 lines · wrote:
Quoted 5 lines
Quoted 5 lines

-----Original Message-----
From: George Dunlap [mailto:[email protected]]
Sent: 06 July 2015 14:28
To: Paul Durrant; George Dunlap
Cc: Yu Zhang; [email protected]; Keir (Xen.org); Jan Beulich;

Andrew

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Cooper; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the

MAX_NR_IO_RANGES for

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

ioreq server

Quoted 6 lines · Paul Durrant
Quoted 6 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of George Dunlap
Sent: 06 July 2015 13:50
To: Paul Durrant
Cc: Yu Zhang; [email protected]; Keir (Xen.org); Jan Beulich;

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Andrew

Quoted 2 lines
Quoted 2 lines

Cooper; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the

MAX_NR_IO_RANGES

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

for

Quoted 3 lines
Quoted 3 lines

ioreq server

On Mon, Jul 6, 2015 at 1:38 PM, Paul Durrant

<[email protected]>

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines · wrote:
Quoted 2 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf

Of

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

George Dunlap
Sent: 06 July 2015 13:36
To: Yu Zhang
Cc: [email protected]; Keir (Xen.org); Jan Beulich; Andrew

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Cooper;

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Paul Durrant; Kevin Tian; [email protected]
Subject: Re: [Xen-devel] [PATCH v2 1/2] Resize the

MAX_NR_IO_RANGES

Quoted 4 lines
Quoted 4 lines

for

Quoted 3 lines
Quoted 3 lines

ioreq server

On Mon, Jul 6, 2015 at 7:25 AM, Yu Zhang

<[email protected]>

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines · wrote:

MAX_NR_IO_RANGES is used by ioreq server as the maximum number of discrete ranges to be tracked. This patch changes its value to 8k, so that more ranges can be tracked on next generation of Intel platforms in XenGT. Future patches can extend the limit to be toolstack tunable, and

MAX_NR_IO_RANGES

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

can serve as a default limit.

I said this at the Hackathon, and I'll say it here: I think this is the wrong approach.

The problem here is not that you don't have enough memory

ranges.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

The

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

problem is that you are not tracking memory ranges, but individual pages.

You need to make a new interface that allows you to tag individual gfns as p2m_mmio_write_dm, and then allow one ioreq server to

get

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

notifications for all such writes.

I think that is conflating things. It's quite conceivable that more than

one

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

ioreq server will handle write_dm pages. If we had enough types to

have

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

two page types per server then I'd agree with you, but we don't.

What's conflating things is using an interface designed for *device memory ranges* to instead *track writes to gfns*.

What's the difference? Are you asserting that all device memory ranges

have read side effects and therefore write_dm is not a reasonable optimization to use? I would not want to make that assertion.

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

Using write_dm is not the problem; it's having thousands of memory "ranges" of 4k each that I object to.

Which is why I suggested adding an interface to request updates to gfns (by marking them write_dm), rather than abusing the io range interface.

And it's the assertion that use of write_dm will only be relevant to gfns,

and that all such notifications only need go to a single ioreq server, that I have a problem with. Whilst the use of io ranges to track gfn updates is, I agree, not ideal I think the overloading of write_dm is not a step in the right direction.

Quoted 12 lines

So there are two questions here.

First of all, I certainly think that the *interface* should be able to be transparently extended to support multiple ioreq servers being able to track gfns. My suggestion was to add a hypercall that allows an ioreq server to say, "Please send modifications to gfn N to ioreq server X"; and that for the time being, only allow one such X to exist at a time per domain. That is, if ioreq server Y makes such a call after ioreq server X has done so, return -EBUSY. That way we can add support when we need it.

Well, I also agree the current implementation is probably not optimal. And yes, it seems promiscuous( hope I did not use the wrong word :) ) to mix the device I/O ranges and the guest memory. But, forwarding an ioreq to backend driver, just by an p2m type? Although it would be easy for XenGT to take this approach, I agree with Paul that this would weaken the functionality of ioreq server. Besides, is it appropriate for a p2m type to be used this way? It seems strange for me.

Quoted 2 lines

In fact, you probably already have a problem with two ioreq servers, because (if I recall correctly) you don't know for sure when a page

Fortunately, we do, and these unmapped page tables will be removed from the rangeset of ioreq server. So the following scenario won't happen. :)

Quoted 15 lines

has stopped being used as a GPU pagetable. Consider the following scenario:
1. Two devices, served by ioreq servers 1 and 2.
2. driver for device served by ioreq server 1 allocates a page, uses it as a pagetable. ioreq server 1 adds that pfn to the ranges it's watching.
3. driver frees page back to guest OS; but ioreq server 1 doesn't know so it doesn't release the range
4. driver for device served by ioreq server 2 allocates a page, which happens to be the same one used before, and uses it as a pagetable. ioreq server 1 tries to add that pfn to the ranges it's watching.

Now you have an "overlap in the range" between the two ioreq servers. What do you do?

Quoted 7 lines

Regarding using write_dm for actual device memory ranges: Do you have any concrete scenarios in mind where you think this will be used?

Fundamentally, write_dm looks to me like it's about tracking gfns -- i.e., things backed by guest RAM -- not IO ranges. As such, it should have an interface and an implementation that reflects that.

Here, I guess your major concern about the difference between tracking gfns and I/O ranges is that the gfns are scattered? And yes, this is why we need more ranges inside a rangeset. Here the new value of the limit, 8K, is a practical one for XenGT. In the future, we can either provide other approaches to configure the maximum ranges inside an ioreq server, or provide some xenheap allocation management routines. Is this OK?

Quoted 3 lines

I thought we had successfully convinced you in hackathon. And seems I'm wrong. Anyway, your advices are very appreciated. :)

George,

I wonder, would it be sufficient - at this stage - to add a new mapping sub-op to the HVM op to distinguish mapping of mapping gfns vs. MMIO ranges. That way we could use the same implementation underneath for now (using the rb_rangeset, which I think stands on its own merits for MMIO ranges anyway) but allow them to diverge later... perhaps using a new P2T (page-to-type) table, which I believe may become necessary as Intel reclaims bits for h/w use and thus squeezes our existing number of supported page types.

Paul

Quoted 11 lines
Quoted 2 lines

-George

B.R.
Yu

Quoted 6 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#12 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 07.07.15 at 11:23, <[email protected]> wrote:

I wonder, would it be sufficient - at this stage - to add a new mapping sub-op to the HVM op to distinguish mapping of mapping gfns vs. MMIO ranges. That way we could use the same implementation underneath for now (using the rb_rangeset, which I think stands on its own merits for MMIO ranges anyway)

Which would be (taking into account the good description of the differences between RAM and MMIO pages given by George yesterday [I think])? I continue to not be convinced we need this new rangeset type (the more that it's name seems wrong, since - as said by George - we're unlikely to deal with ranges here).

Jan

Quoted 5 lines

but allow them to diverge later... perhaps using a new P2T (page-to-type) table, which I believe may become necessary as Intel reclaims bits for h/w use and thus squeezes our existing number of supported page types.

Paul

#13 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 17 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 07 July 2015 13:53
To: Paul Durrant
Cc: Andrew Cooper; George Dunlap; Kevin Tian; [email protected]; Zhang Yu; [email protected]; Keir (Xen.org)
Subject: RE: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 07.07.15 at 11:23, <[email protected]> wrote:

I wonder, would it be sufficient - at this stage - to add a new mapping sub-

op

Quoted 1 line

to the HVM op to distinguish mapping of mapping gfns vs. MMIO ranges.

That

Quoted 1 line

way we could use the same implementation underneath for now (using

the

Quoted 1 line

rb_rangeset, which I think stands on its own merits for MMIO ranges

Quoted 9 lines

anyway)

Which would be (taking into account the good description of the differences between RAM and MMIO pages given by George yesterday [I think])? I continue to not be convinced we need this new rangeset type (the more that it's name seems wrong, since - as said by George - we're unlikely to deal with ranges here).

I don't see that implementing rangesets on top of rb tree is a problem. IMO it's a useful optimization in its own right since it takes something that's currently O(n) and makes it O(log n) using an rb tree implementation that's already there. In fact, perhaps we just make the current rangeset implementation use rb trees underneath, then there's no need for the extra API.

Paul

Quoted 8 lines

Jan

Quoted 5 lines

but allow them to diverge later... perhaps using a new P2T (page-to-type) table, which I believe may become necessary as Intel reclaims bits for h/w use and thus squeezes our existing number of supported page types.

Paul

#14 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 28 lines
Quoted 18 lines
Quoted 1 line · On 07.07.15 at 15:11, <[email protected]> wrote:

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 07 July 2015 13:53
To: Paul Durrant
Cc: Andrew Cooper; George Dunlap; Kevin Tian; [email protected]; Zhang Yu; [email protected]; Keir (Xen.org)
Subject: RE: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 07.07.15 at 11:23, <[email protected]> wrote:

I wonder, would it be sufficient - at this stage - to add a new mapping sub-

op

Quoted 1 line

to the HVM op to distinguish mapping of mapping gfns vs. MMIO ranges.

That

Quoted 1 line

way we could use the same implementation underneath for now (using

the

Quoted 1 line

rb_rangeset, which I think stands on its own merits for MMIO ranges

Quoted 9 lines

anyway)

Which would be (taking into account the good description of the differences between RAM and MMIO pages given by George yesterday [I think])? I continue to not be convinced we need this new rangeset type (the more that it's name seems wrong, since - as said by George - we're unlikely to deal with ranges here).

Quoted 6 lines

I don't see that implementing rangesets on top of rb tree is a problem. IMO it's a useful optimization in its own right since it takes something that's currently O(n) and makes it O(log n) using an rb tree implementation that's already there. In fact, perhaps we just make the current rangeset implementation use rb trees underneath, then there's no need for the extra API.

I wouldn't mind such an overall change (provided it doesn't introduce new issues), but I'm not convinced of having two rangeset implementations, and I don't see the lookup speed as an issue with the uses we have for rangesets now. The arguments for bumping the number of ranges, which would possibly affect lookup in a negative way, haven't been convincing to me so far (and XenGT isn't going to make 4.6 anyway).

Jan

author
#15 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Hi Jan,

Quoted 35 lines · Jan Beulich
Quoted 28 lines
Quoted 18 lines
Quoted 1 line · On 07.07.15 at 15:11, <[email protected]> wrote:

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 07 July 2015 13:53
To: Paul Durrant
Cc: Andrew Cooper; George Dunlap; Kevin Tian; [email protected]; Zhang Yu; [email protected]; Keir (Xen.org)
Subject: RE: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 07.07.15 at 11:23, <[email protected]> wrote:

I wonder, would it be sufficient - at this stage - to add a new mapping sub-

op

Quoted 1 line

to the HVM op to distinguish mapping of mapping gfns vs. MMIO ranges.

That

Quoted 1 line

way we could use the same implementation underneath for now (using

the

Quoted 1 line

rb_rangeset, which I think stands on its own merits for MMIO ranges

Quoted 9 lines

anyway)

Which would be (taking into account the good description of the differences between RAM and MMIO pages given by George yesterday [I think])? I continue to not be convinced we need this new rangeset type (the more that it's name seems wrong, since - as said by George - we're unlikely to deal with ranges here).

Quoted 6 lines

I don't see that implementing rangesets on top of rb tree is a problem. IMO it's a useful optimization in its own right since it takes something that's currently O(n) and makes it O(log n) using an rb tree implementation that's already there. In fact, perhaps we just make the current rangeset implementation use rb trees underneath, then there's no need for the extra API.

Quoted 9 lines

I wouldn't mind such an overall change (provided it doesn't introduce new issues), but I'm not convinced of having two rangeset implementations, and I don't see the lookup speed as an issue with the uses we have for rangesets now. The arguments for bumping the number of ranges, which would possibly affect lookup in a negative way, haven't been convincing to me so far (and XenGT isn't going to make 4.6 anyway).

I know that George and you have concerns about the differences between MMIO and guest page tables, but I do not quite understand why. :)

Althogh the granularity of the write-protected memory is 4K in our case, the trapped address is still a guest physical address, not a guest page frame number. We can see the range as an 4K sized one, right? Besides, in many cases, the guest graphic page tables are continuous and the size of a range inside ioreq server is more than 4k. As you can see, the existing code already tracks the guest graphic page tables by rangeset, and the difference here is that there would be more page tables we need to take care of for BDW. Changing the upper limit of the number of rangeset inside an ioreq server does not necessarily mean there would be so many.

About the rb_rangeset I introduced, it is only for XenGT case, because only in such cases will a more efficient data structure be necessary - maybe in the future there would be more requirements to this type.

Yes, XenGT may not catch up the 4.6. And thanks for your frankness. :) But I'll still be very appreciated if you can give me some advices and directions to go.

B.R.
Yu

Quoted 4 lines

Jan

#16 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.07.15 at 16:30, <[email protected]> wrote:

I know that George and you have concerns about the differences between MMIO and guest page tables, but I do not quite understand why. :)

But you read George's very nice description of the differences? I ask because if you did, I don't see why you re-raise the question above.

Jan

author
#17 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 9 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.07.15 at 16:30, <[email protected]> wrote:

I know that George and you have concerns about the differences between MMIO and guest page tables, but I do not quite understand why. :)

But you read George's very nice description of the differences? I ask because if you did, I don't see why you re-raise the question above.

Well, yes. I guess you mean this statement:
"the former is one or two actual ranges of a significant size; the latter are (apparently) thousands of ranges of one page each."? But I do not understand why this is abusing the io range interface. Does the number matters so much? :)

B.R.
Yu

Quoted 9 lines

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#18 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 07.07.15 at 16:49, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.07.15 at 16:30, <[email protected]> wrote:

I know that George and you have concerns about the differences between MMIO and guest page tables, but I do not quite understand why. :)

But you read George's very nice description of the differences? I ask because if you did, I don't see why you re-raise the question above.

Quoted 5 lines

Well, yes. I guess you mean this statement:
"the former is one or two actual ranges of a significant size; the latter are (apparently) thousands of ranges of one page each."? But I do not understand why this is abusing the io range interface. Does the number matters so much? :)

Yes, we specifically set it that low so misbehaving tool stacks (perhaps de-privileged) can't cause the hypervisor to allocate undue amounts of memory for tracking these ranges. This concern, btw, applies as much to the rb-rangesets.

Plus the number you bump MAX_NR_IO_RANGES to is - as I understood it - obtained phenomenologically, i.e. there's no reason not to assume that some bigger graphics card may need this to be further bumped. The current count is arbitrary too, but limiting guests only in so far as there can't be more than so many (possibly huge) MMIO ranges on the complete set of devices passed through to it.

And finally, the I/O ranges are called I/O ranges because they are intended to cover I/O memory. RAM clearly isn't I/O memory, even if it may be accessed directly by devices.

Jan

#20 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

In reply to Jan Beulich
Quoted 49 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 07 July 2015 15:04
To: Paul Durrant
Cc: Andrew Cooper; George Dunlap; Kevin Tian; [email protected]; Zhang Yu; [email protected]; Keir (Xen.org)
Subject: RE: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 6 lines
Quoted 6 lines
Quoted 1 line · On 07.07.15 at 15:11, <[email protected]> wrote:

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 07 July 2015 13:53
To: Paul Durrant
Cc: Andrew Cooper; George Dunlap; Kevin Tian; [email protected];

Zhang

Quoted 2 lines
Quoted 2 lines

Yu; [email protected]; Keir (Xen.org)
Subject: RE: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES

for

Quoted 4 lines
Quoted 4 lines

ioreq server

Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 07.07.15 at 11:23, <[email protected]> wrote:

I wonder, would it be sufficient - at this stage - to add a new mapping

sub-

Quoted 2 lines
Quoted 2 lines

op

Quoted 1 line

to the HVM op to distinguish mapping of mapping gfns vs. MMIO

ranges.

Quoted 14 lines
Quoted 4 lines

That

Quoted 1 line

way we could use the same implementation underneath for now (using

the

Quoted 1 line

rb_rangeset, which I think stands on its own merits for MMIO ranges

Quoted 9 lines

anyway)

Which would be (taking into account the good description of the differences between RAM and MMIO pages given by George yesterday [I think])? I continue to not be convinced we need this new rangeset type (the more that it's name seems wrong, since - as said by George - we're unlikely to deal with ranges here).

Quoted 5 lines

I don't see that implementing rangesets on top of rb tree is a problem. IMO it's a useful optimization in its own right since it takes something that's currently O(n) and makes it O(log n) using an rb tree implementation that's already there. In fact, perhaps we just make the current rangeset implementation use rb trees underneath, then there's no need for the

extra

Quoted 1 line

API.

Quoted 9 lines

I wouldn't mind such an overall change (provided it doesn't introduce new issues), but I'm not convinced of having two rangeset implementations, and I don't see the lookup speed as an issue with the uses we have for rangesets now. The arguments for bumping the number of ranges, which would possibly affect lookup in a negative way, haven't been convincing to me so far (and XenGT isn't going to make 4.6 anyway).

I don't think that the Xan parts of XenGT are that far off. I had a list of 3 items:

- 16 byte I/O brokenness, which should be fixed now
- Basic PV-IOMMU implementation, which I think Malcolm should be posting very soon
- Shadow GTT emulation (which is what we're looking at here)

I had a chat with George earlier and wondered whether we might approach things this way:

- Add a new sub op to HVMOP_[un]map_io_range_to_ioreq_server or a new HVM_[un]map_gfn_to_ioreq_server
- Make rb_rangeset the default rangeset implementation (since I believe it can only be an improvement even if it makes no significant difference for small numbers of ranges)
- Use a common implementation for MMIO ranges and GFN ranges *for now* (which does mean increasing the limit) to allow us to be functionally complete for 4.6
- Follow up (post-4.6) with a different ioreq server redirection implementation for mmio-dm and mmio-dm-write pages, possibly based on claiming a range of page types for emulator use, to optimize shadow GTT implementation.

Does that sound plausible?

Paul

Quoted 1 line

Jan

#21 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 07.07.15 at 17:12, <[email protected]> wrote:

I don't think that the Xan parts of XenGT are that far off. I had a list of 3 items:

- 16 byte I/O brokenness, which should be fixed now
- Basic PV-IOMMU implementation, which I think Malcolm should be posting very soon

No matter how soon Malcolm would post that, unless it is in a shape to go in without any revisions, it will - afaict - miss 4.6 (freezing at the end of the week). I can't even guarantee that your HVM emulation updates will have gone in by then, but I very much hope so.

Quoted 17 lines

- Shadow GTT emulation (which is what we're looking at here)

I had a chat with George earlier and wondered whether we might approach things this way:

- Add a new sub op to HVMOP_[un]map_io_range_to_ioreq_server or a new HVM_[un]map_gfn_to_ioreq_server
- Make rb_rangeset the default rangeset implementation (since I believe it can only be an improvement even if it makes no significant difference for small numbers of ranges)
- Use a common implementation for MMIO ranges and GFN ranges *for now* (which does mean increasing the limit) to allow us to be functionally complete for 4.6
- Follow up (post-4.6) with a different ioreq server redirection implementation for mmio-dm and mmio-dm-write pages, possibly based on claiming a range of page types for emulator use, to optimize shadow GTT implementation.

Quoted 1 line

Does that sound plausible?

Yes, except that I think all of this will be post-4.6.

Jan

#22 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 40 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 07 July 2015 16:27
To: Paul Durrant
Cc: Andrew Cooper; George Dunlap; Kevin Tian; [email protected]; Zhang Yu; [email protected]; Keir (Xen.org)
Subject: RE: [Xen-devel] [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 07.07.15 at 17:12, <[email protected]> wrote:

I don't think that the Xan parts of XenGT are that far off. I had a list of 3 items:

- 16 byte I/O brokenness, which should be fixed now
- Basic PV-IOMMU implementation, which I think Malcolm should be

posting very soon

No matter how soon Malcolm would post that, unless it is in a shape to go in without any revisions, it will - afaict - miss 4.6 (freezing at the end of the week). I can't even guarantee that your HVM emulation updates will have gone in by then, but I very much hope so.

Quoted 6 lines

- Shadow GTT emulation (which is what we're looking at here)

I had a chat with George earlier and wondered whether we might approach things this way:

- Add a new sub op to HVMOP_[un]map_io_range_to_ioreq_server or a

new

Quoted 5 lines

HVM_[un]map_gfn_to_ioreq_server
- Make rb_rangeset the default rangeset implementation (since I believe it can only be an improvement even if it makes no significant difference for small numbers of ranges)
- Use a common implementation for MMIO ranges and GFN ranges *for

now* (which

Quoted 4 lines

does mean increasing the limit) to allow us to be functionally complete for 4.6
- Follow up (post-4.6) with a different ioreq server redirection implementation for mmio-dm and mmio-dm-write pages, possibly based

Quoted 8 lines

on claiming a

Quoted 1 line

range of page types for emulator use, to optimize shadow GTT

implementation.

Quoted 2 lines

Does that sound plausible?

Yes, except that I think all of this will be post-4.6.

Ok, if we miss 4.6 then so be it, but we'll go with that plan and live in hope ;-)

Paul

Quoted 1 line

Jan

author
#19 lore raw

Re: [PATCH v2 1/2] Resize the MAX_NR_IO_RANGES for ioreq server

In reply to Jan Beulich
Quoted 18 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 07.07.15 at 16:49, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 07.07.15 at 16:30, <[email protected]> wrote:

I know that George and you have concerns about the differences between MMIO and guest page tables, but I do not quite understand why. :)

But you read George's very nice description of the differences? I ask because if you did, I don't see why you re-raise the question above.

Quoted 5 lines

Well, yes. I guess you mean this statement:
"the former is one or two actual ranges of a significant size; the latter are (apparently) thousands of ranges of one page each."? But I do not understand why this is abusing the io range interface. Does the number matters so much? :)

Quoted 5 lines

Yes, we specifically set it that low so misbehaving tool stacks (perhaps de-privileged) can't cause the hypervisor to allocate undue amounts of memory for tracking these ranges. This concern, btw, applies as much to the rb-rangesets.

Thanks for your explanation, Jan. : )
In fact, I have considered to add another patch to set this limit as toolstack tunable.
One problem I encountered is that how to guarantee the validity of the configured value - shall not over-consume the xen heap. But I do agree there definitely should be more amendment patches.

B.R.
Yu

Quoted 21 lines

Plus the number you bump MAX_NR_IO_RANGES to is - as I understood it - obtained phenomenologically, i.e. there's no reason not to assume that some bigger graphics card may need this to be further bumped. The current count is arbitrary too, but limiting guests only in so far as there can't be more than so many (possibly huge) MMIO ranges on the complete set of devices passed through to it.

And finally, the I/O ranges are called I/O ranges because they are intended to cover I/O memory. RAM clearly isn't I/O memory, even if it may be accessed directly by devices.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel