Refactor ioreq server for better performance.
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.
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
PATCH 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
@@ -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 8192struct hvm_ioreq_server {struct list_head list_entry;
Signature · 1 line
1.9.1
PATCH 2/2 Add new data structure to track ranges.
In reply to Yu ZhangThis 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
@@ -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
@@ -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
@@ -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
@@ -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
Oh, I forgot the version number and change history. This patchset should be version 2.
The change history should be:
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;
Sorry, my fault. Could I add this change history in next version, or should I resend the version 2? :)
Thanks
Yu
Quoted 30 lines · Yu Zhang
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_RANGESis 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.Yu Zhang (2):
Resize theMAX_NR_IO_RANGESfor 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.ccreate mode 100644xen/include/xen/rb_rangeset.h
A new patchset with v2 prefix and change log was just sent out. So please ignore this thread, and sorry for the inconvenience. :)
Yu
Quoted 57 lines · Zhang
Oh, I forgot the version number and change history. This patchset should be version 2.
The change history should be:
1> Split the original patch into 2;
2> Take Paul Durrant’s comments:
a> Add a name member in the structrb_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;Sorry, my fault. Could I add this change history in next version, or should I resend the version 2? :)
Thanks
YuQuoted 28 lines · Yu Zhang
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_RANGESis 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.Yu Zhang (2):
Resize theMAX_NR_IO_RANGESfor 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(-)Quoted 3 lines
create mode 100644
xen/common/rb_rangeset.ccreate mode 100644xen/include/xen/rb_rangeset.h_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel