switch rangeset's lock to rwlock
PATCH 1/1 switch rangeset's lock to rwlock
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.
xen/common/rangeset.c +20 -20
@@ -28,7 +28,7 @@ struct rangeset {/* Number of ranges that can be allocated */ long nr_ranges; -spinlock_t lock; +rwlock_t lock;/* Pretty-printing name. */ char name[32 ];
@@ -120,7 +120,7 @@ int rangeset_add_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);
@@ -176,7 +176,7 @@ int rangeset_add_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }
@@ -188,7 +188,7 @@ int rangeset_remove_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);
@@ -244,7 +244,7 @@ int rangeset_remove_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }
@@ -256,10 +256,10 @@ int rangeset_contains_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, s); contains = (x && (x->e >= e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return contains; }
@@ -272,10 +272,10 @@ int rangeset_overlaps_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, e); overlaps = (x && (s <= x->e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return overlaps; }
@@ -287,13 +287,13 @@ int rangeset_report_ranges(struct range *x;int rc =0 ; -spin_lock (&r->lock); +read_lock (&r->lock);for ( x =find_range (r, s); x && (x->s <= e) && !rc; x =next_range (r, x) )if ( x->e >= s ) rc =cb (max (x->s, s),min (x->e, e), ctxt); -spin_unlock (&r->lock); +read_unlock (&r->lock);return rc; }
@@ -331,7 +331,7 @@ struct rangeset *rangeset_new(if ( r ==NULL )return NULL ; -spin_lock_init (&r->lock); +rwlock_init (&r->lock);INIT_LIST_HEAD (&r->range_list); r->nr_ranges =-1 ;
@@ -414,21 +414,21 @@ void rangeset_swap(struct rangeset *a, sif ( a < b ) { -spin_lock (&a->lock); -spin_lock (&b->lock); +write_lock (&a->lock); +write_lock (&b->lock); }else { -spin_lock (&b->lock); -spin_lock (&a->lock); +write_lock (&b->lock); +write_lock (&a->lock); }list_splice_init (&a->range_list, &tmp);list_splice_init (&b->range_list, &a->range_list);list_splice (&tmp, &b->range_list); -spin_unlock (&a->lock); -spin_unlock (&b->lock); +write_unlock (&a->lock); +write_unlock (&b->lock); }/*****************************
@@ -446,7 +446,7 @@ void rangeset_printk(int nr_printed =0 ;struct range *x; -spin_lock (&r->lock); +read_lock (&r->lock);printk ("%-10s {" , r->name);
@@ -465,7 +465,7 @@ void rangeset_printk(printk (" }" ); -spin_unlock (&r->lock); +read_unlock (&r->lock); } void rangeset_domain_printk(
switch rangeset's lock to rwlock
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.
xen/common/rangeset.c +20 -20
@@ -28,7 +28,7 @@ struct rangeset {/* Number of ranges that can be allocated */ long nr_ranges; -spinlock_t lock; +rwlock_t lock;/* Pretty-printing name. */ char name[32 ];
@@ -120,7 +120,7 @@ int rangeset_add_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);
@@ -176,7 +176,7 @@ int rangeset_add_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }
@@ -188,7 +188,7 @@ int rangeset_remove_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);
@@ -244,7 +244,7 @@ int rangeset_remove_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }
@@ -256,10 +256,10 @@ int rangeset_contains_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, s); contains = (x && (x->e >= e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return contains; }
@@ -272,10 +272,10 @@ int rangeset_overlaps_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, e); overlaps = (x && (s <= x->e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return overlaps; }
@@ -287,13 +287,13 @@ int rangeset_report_ranges(struct range *x;int rc =0 ; -spin_lock (&r->lock); +read_lock (&r->lock);for ( x =find_range (r, s); x && (x->s <= e) && !rc; x =next_range (r, x) )if ( x->e >= s ) rc =cb (max (x->s, s),min (x->e, e), ctxt); -spin_unlock (&r->lock); +read_unlock (&r->lock);return rc; }
@@ -331,7 +331,7 @@ struct rangeset *rangeset_new(if ( r ==NULL )return NULL ; -spin_lock_init (&r->lock); +rwlock_init (&r->lock);INIT_LIST_HEAD (&r->range_list); r->nr_ranges =-1 ;
@@ -414,21 +414,21 @@ void rangeset_swap(struct rangeset *a, sif ( a < b ) { -spin_lock (&a->lock); -spin_lock (&b->lock); +write_lock (&a->lock); +write_lock (&b->lock); }else { -spin_lock (&b->lock); -spin_lock (&a->lock); +write_lock (&b->lock); +write_lock (&a->lock); }list_splice_init (&a->range_list, &tmp);list_splice_init (&b->range_list, &a->range_list);list_splice (&tmp, &b->range_list); -spin_unlock (&a->lock); -spin_unlock (&b->lock); +write_unlock (&a->lock); +write_unlock (&b->lock); }/*****************************
@@ -446,7 +446,7 @@ void rangeset_printk(int nr_printed =0 ;struct range *x; -spin_lock (&r->lock); +read_lock (&r->lock);printk ("%-10s {" , r->name);
@@ -465,7 +465,7 @@ void rangeset_printk(printk (" }" ); -spin_unlock (&r->lock); +read_unlock (&r->lock); } void rangeset_domain_printk(
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 7 lines · Jan Beulich
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Signed-off-by Jan Beulich <[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.
Is this addressing an actual (measured) problem or just seems like a good idea? If the latter maybe keep it until after 4.5?
Tim.
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 18.09.14 at 12:43, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Jan Beulich <[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.Is this addressing an actual (measured) problem or just seems like a good idea? If the latter maybe keep it until after 4.5?
The latter. And yes, I have no problem keeping it until after 4.5, it's just that the multi-ioreq-server's extended use of rangesets (as said elsewhere) would seem to make this a reasonable fit for 4.5.
Jan
Quoted 10 lines · Jan Beulich
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 18.09.14 at 12:43, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Signed-off-by Jan Beulich <[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.
Quoted 7 lines
Quoted 2 lines
Is this addressing an actual (measured) problem or just seems like a good idea? If the latter maybe keep it until after 4.5?
The latter. And yes, I have no problem keeping it until after 4.5, it's just that the multi-ioreq-server's extended use of rangesets (as said elsewhere) would seem to make this a reasonable fit for 4.5.
Well, I think it's a question for the release manager, then. :)
I wouldn't be inclined to tinker with them unless we had a measurement justifying the change. After all, the rangeset operations are not long-running ones and we'd be adding some overhead.
Tim.
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 18.09.14 at 15:02, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 18.09.14 at 12:43, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Signed-off-by Jan Beulich <[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.Is this addressing an actual (measured) problem or just seems like a good idea? If the latter maybe keep it until after 4.5?
Quoted 6 lines
Quoted 4 lines
The latter. And yes, I have no problem keeping it until after 4.5, it's just that the multi-ioreq-server's extended use of rangesets (as said elsewhere) would seem to make this a reasonable fit for 4.5.
Well, I think it's a question for the release manager, then. :)
Konrad?
Quoted 3 lines
I wouldn't be inclined to tinker with them unless we had a measurement justifying the change. After all, the rangeset operations are not long-running ones and we'd be adding some overhead.
Well, that's a pretty weak argument: The vHPET lock doesn't protect long running operations either, yet its conversion to rwlock did yield a significant improvement. But yes, unless rangesets participate in something that may get used heavily by a guest, changing the lock kind would likely not have a significant effect. Otoh figuring out that lock contention is a problem involves a non- eglectible amount of work, preemption of which seems at least desirable.
In fact, in the latest runs with those many-vCPU Windows guests I see signs of contention even on vpt's pl_time_lock (8 out of 64 vCPU-s racing for it).
Jan
Quoted 36 lines
-----Original Message-----
From: [email protected] [mailto:xen-devel- [email protected]] On Behalf Of Jan Beulich
Sent: 18 September 2014 14:33
To: Konrad Rzeszutek Wilk; Tim (Xen.org)
Cc: Ian Campbell; xen-devel; Keir (Xen.org); Ian Jackson
Subject: Re: [Xen-devel] [PATCH] switch rangeset's lock to rwlockQuoted 15 lines
Quoted 1 line
Quoted 1 line · On 18.09.14 at 15:02, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 18.09.14 at 12:43, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Signed-off-by Jan Beulich <[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.Is this addressing an actual (measured) problem or just seems like a good idea? If the latter maybe keep it until after 4.5?
Quoted 6 lines
Quoted 4 lines
The latter. And yes, I have no problem keeping it until after 4.5, it's just that the multi-ioreq-server's extended use of rangesets (as said elsewhere) would seem to make this a reasonable fit for 4.5.
Well, I think it's a question for the release manager, then. :)
Konrad?
Quoted 3 lines
I wouldn't be inclined to tinker with them unless we had a measurement justifying the change. After all, the rangeset operations are not long-running ones and we'd be adding some overhead.
Quoted 5 lines
Well, that's a pretty weak argument: The vHPET lock doesn't protect long running operations either, yet its conversion to rwlock did yield a significant improvement. But yes, unless rangesets participate in something that may get used heavily by a guest, changing the lock kind would likely not have a significant effect.
The ioreq server code uses rangesets so multiple vcpus all hitting an aperture registered by an ioreq server could contend.
Paul
Quoted 15 lines
Otoh figuring out that lock contention is a problem involves a non- eglectible amount of work, preemption of which seems at least desirable.
In fact, in the latest runs with those many-vCPU Windows guests I see signs of contention even on vpt's
pl_time_lock(8 out of 64 vCPU-s racing for it).Jan
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 15 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 18.09.14 at 15:02, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 18.09.14 at 12:43, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Signed-off-by Jan Beulich <[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.Is this addressing an actual (measured) problem or just seems like a good idea? If the latter maybe keep it until after 4.5?
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
The latter. And yes, I have no problem keeping it until after 4.5, it's just that the multi-ioreq-server's extended use of rangesets (as said elsewhere) would seem to make this a reasonable fit for 4.5.
Well, I think it's a question for the release manager, then. :)
Konrad?
I am comfortable with it. Responded with an Reviewed-by on the patch itself and Ack for Xen 4.5.
Quoted 24 lines · Jan Beulich
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 18.09.14 at 15:02, <[email protected]> wrote:
Quoted 13 lines · Jan Beulich
Quoted 12 lines
Quoted 1 line
Quoted 1 line · On 18.09.14 at 12:43, <[email protected]> wrote:
Quoted 7 lines · Jan Beulich
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Signed-off-by Jan Beulich <[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.Is this addressing an actual (measured) problem or just seems like a good idea? If the latter maybe keep it until after 4.5?
Quoted 6 lines
Quoted 4 lines
The latter. And yes, I have no problem keeping it until after 4.5, it's just that the multi-ioreq-server's extended use of rangesets (as said elsewhere) would seem to make this a reasonable fit for 4.5.
Well, I think it's a question for the release manager, then. :)
Konrad?
Quoted 7 lines
Quoted 3 lines
I wouldn't be inclined to tinker with them unless we had a measurement justifying the change. After all, the rangeset operations are not long-running ones and we'd be adding some overhead.
Well, that's a pretty weak argument: The vHPET lock doesn't protect long running operations either, yet its conversion to rwlock did yield a significant improvement.
That implies the measurement Tim is asking about...
Quoted 10 lines
But yes, unless rangesets
participate in something that may get used heavily by a guest, changing the lock kind would likely not have a significant effect. Otoh figuring out that lock contention is a problem involves a non- eglectible amount of work, preemption of which seems at least desirable.In fact, in the latest runs with those many-vCPU Windows guests I see signs of contention even on vpt's
pl_time_lock(8 out of 64 vCPU-s racing for it).
... as does this, but that isn't affected by this change, is it?
I suppose constructing a test for the rangeset getting hit by e.g. the ioreq server would be tricky to do unless you happen to already have a disaggregated qemu setup (which I suppose you don't).
What are the potential negative affects if our gut feeling about the accesses patterns of the rangesets are wrong? Is the rwlock potentially slower than the existing lock for the read or uncontended or some other case?
Ian.
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 22.09.14 at 11:42, <[email protected]> wrote:
Quoted 8 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 18.09.14 at 15:02, <[email protected]> wrote:
I wouldn't be inclined to tinker with them unless we had a measurement justifying the change. After all, the rangeset operations are not long-running ones and we'd be adding some overhead.
Well, that's a pretty weak argument: The vHPET lock doesn't protect long running operations either, yet its conversion to rwlock did yield a significant improvement.
That implies the measurement Tim is asking about...
Quoted 7 lines
But yes, unless rangesets
participate in something that may get used heavily by a guest, changing the lock kind would likely not have a significant effect. Otoh figuring out that lock contention is a problem involves a non- eglectible amount of work, preemption of which seems at least desirable.
Quoted 5 lines
Quoted 3 lines
In fact, in the latest runs with those many-vCPU Windows guests I see signs of contention even on vpt's
pl_time_lock(8 out of 64 vCPU-s racing for it).... as does this, but that isn't affected by this change, is it?
No, it was merely another statement towards a locked region being short running not being an argument for there not being potential (severe) contention.
Quoted 3 lines
I suppose constructing a test for the rangeset getting hit by e.g. the ioreq server would be tricky to do unless you happen to already have a disaggregated qemu setup (which I suppose you don't).
Correct.
Quoted 4 lines
What are the potential negative affects if our gut feeling about the accesses patterns of the rangesets are wrong? Is the rwlock potentially slower than the existing lock for the read or uncontended or some other case?
The only downside is that the raw lock structure is 4 bytes instead of 2 for the simply spin lock.
Jan
Quoted 3 lines · Jan Beulich
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
I am comfortable with this going to Xen 4.5.
Quoted 312 lines
Signed-off-by Jan Beulich <[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.xen/common/rangeset.c +20
-20@@ -28,7 +28,7 @@ struct rangeset {/* Number of ranges that can be allocated */ long nr_ranges; -spinlock_t lock; +rwlock_t lock;/* Pretty-printing name. */ char name[32 ];@@ -120,7 +120,7 @@ int rangeset_add_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -176,7 +176,7 @@ int rangeset_add_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -188,7 +188,7 @@ int rangeset_remove_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -244,7 +244,7 @@ int rangeset_remove_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -256,10 +256,10 @@ int rangeset_contains_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, s); contains = (x && (x->e >= e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return contains; }@@ -272,10 +272,10 @@ int rangeset_overlaps_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, e); overlaps = (x && (s <= x->e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return overlaps; }@@ -287,13 +287,13 @@ int rangeset_report_ranges(struct range *x;int rc =0 ; -spin_lock (&r->lock); +read_lock (&r->lock);for ( x =find_range (r, s); x && (x->s <= e) && !rc; x =next_range (r, x) )if ( x->e >= s ) rc =cb (max (x->s, s),min (x->e, e), ctxt); -spin_unlock (&r->lock); +read_unlock (&r->lock);return rc; }@@ -331,7 +331,7 @@ struct rangeset *rangeset_new(if ( r ==NULL )return NULL ; -spin_lock_init (&r->lock); +rwlock_init (&r->lock);INIT_LIST_HEAD (&r->range_list); r->nr_ranges =-1 ;@@ -414,21 +414,21 @@ void rangeset_swap(struct rangeset *a, sif ( a < b ) { -spin_lock (&a->lock); -spin_lock (&b->lock); +write_lock (&a->lock); +write_lock (&b->lock); }else { -spin_lock (&b->lock); -spin_lock (&a->lock); +write_lock (&b->lock); +write_lock (&a->lock); }list_splice_init (&a->range_list, &tmp);list_splice_init (&b->range_list, &a->range_list);list_splice (&tmp, &b->range_list); -spin_unlock (&a->lock); -spin_unlock (&b->lock); +write_unlock (&a->lock); +write_unlock (&b->lock); }/***************************** @@ -446,7 +446,7 @@ void rangeset_printk(int nr_printed =0 ;struct range *x; -spin_lock (&r->lock); +read_lock (&r->lock);printk ("%-10s {" , r->name);@@ -465,7 +465,7 @@ void rangeset_printk(printk (" }" ); -spin_unlock (&r->lock); +read_unlock (&r->lock); } void rangeset_domain_printk(switch rangeset's lock to rwlock
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Signed-off-by Jan Beulich <[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.xen/common/rangeset.c +20
-20@@ -28,7 +28,7 @@ struct rangeset {/* Number of ranges that can be allocated */ long nr_ranges; -spinlock_t lock; +rwlock_t lock;/* Pretty-printing name. */ char name[32 ];@@ -120,7 +120,7 @@ int rangeset_add_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -176,7 +176,7 @@ int rangeset_add_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -188,7 +188,7 @@ int rangeset_remove_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -244,7 +244,7 @@ int rangeset_remove_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -256,10 +256,10 @@ int rangeset_contains_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, s); contains = (x && (x->e >= e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return contains; }@@ -272,10 +272,10 @@ int rangeset_overlaps_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, e); overlaps = (x && (s <= x->e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return overlaps; }@@ -287,13 +287,13 @@ int rangeset_report_ranges(struct range *x;int rc =0 ; -spin_lock (&r->lock); +read_lock (&r->lock);for ( x =find_range (r, s); x && (x->s <= e) && !rc; x =next_range (r, x) )if ( x->e >= s ) rc =cb (max (x->s, s),min (x->e, e), ctxt); -spin_unlock (&r->lock); +read_unlock (&r->lock);return rc; }@@ -331,7 +331,7 @@ struct rangeset *rangeset_new(if ( r ==NULL )return NULL ; -spin_lock_init (&r->lock); +rwlock_init (&r->lock);INIT_LIST_HEAD (&r->range_list); r->nr_ranges =-1 ;@@ -414,21 +414,21 @@ void rangeset_swap(struct rangeset *a, sif ( a < b ) { -spin_lock (&a->lock); -spin_lock (&b->lock); +write_lock (&a->lock); +write_lock (&b->lock); }else { -spin_lock (&b->lock); -spin_lock (&a->lock); +write_lock (&b->lock); +write_lock (&a->lock); }list_splice_init (&a->range_list, &tmp);list_splice_init (&b->range_list, &a->range_list);list_splice (&tmp, &b->range_list); -spin_unlock (&a->lock); -spin_unlock (&b->lock); +write_unlock (&a->lock); +write_unlock (&b->lock); }/***************************** @@ -446,7 +446,7 @@ void rangeset_printk(int nr_printed =0 ;struct range *x; -spin_lock (&r->lock); +read_lock (&r->lock);printk ("%-10s {" , r->name);@@ -465,7 +465,7 @@ void rangeset_printk(printk (" }" ); -spin_unlock (&r->lock); +read_unlock (&r->lock); } void rangeset_domain_printk(_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 19.09.14 at 18:32, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Reviewed-by Konrad Rzeszutek Wilk <[email protected]>I am comfortable with this going to Xen 4.5.
Anyone of you wanting to ack this then, or should I nevertheless postpone it until after 4.5?
Jan
Quoted 312 lines
Quoted 312 lines
Signed-off-by Jan Beulich <[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.xen/common/rangeset.c +20
-20@@ -28,7 +28,7 @@ struct rangeset {/* Number of ranges that can be allocated */ long nr_ranges; -spinlock_t lock; +rwlock_t lock;/* Pretty-printing name. */ char name[32 ];@@ -120,7 +120,7 @@ int rangeset_add_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -176,7 +176,7 @@ int rangeset_add_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -188,7 +188,7 @@ int rangeset_remove_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -244,7 +244,7 @@ int rangeset_remove_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -256,10 +256,10 @@ int rangeset_contains_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, s); contains = (x && (x->e >= e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return contains; }@@ -272,10 +272,10 @@ int rangeset_overlaps_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, e); overlaps = (x && (s <= x->e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return overlaps; }@@ -287,13 +287,13 @@ int rangeset_report_ranges(struct range *x;int rc =0 ; -spin_lock (&r->lock); +read_lock (&r->lock);for ( x =find_range (r, s); x && (x->s <= e) && !rc; x =next_range (r, x) )if ( x->e >= s ) rc =cb (max (x->s, s),min (x->e, e), ctxt); -spin_unlock (&r->lock); +read_unlock (&r->lock);return rc; }@@ -331,7 +331,7 @@ struct rangeset *rangeset_new(if ( r ==NULL )return NULL ; -spin_lock_init (&r->lock); +rwlock_init (&r->lock);INIT_LIST_HEAD (&r->range_list); r->nr_ranges =-1 ;@@ -414,21 +414,21 @@ void rangeset_swap(struct rangeset *a, sif ( a < b ) { -spin_lock (&a->lock); -spin_lock (&b->lock); +write_lock (&a->lock); +write_lock (&b->lock); }else { -spin_lock (&b->lock); -spin_lock (&a->lock); +write_lock (&b->lock); +write_lock (&a->lock); }list_splice_init (&a->range_list, &tmp);list_splice_init (&b->range_list, &a->range_list);list_splice (&tmp, &b->range_list); -spin_unlock (&a->lock); -spin_unlock (&b->lock); +write_unlock (&a->lock); +write_unlock (&b->lock); }/***************************** @@ -446,7 +446,7 @@ void rangeset_printk(int nr_printed =0 ;struct range *x; -spin_lock (&r->lock); +read_lock (&r->lock);printk ("%-10s {" , r->name);@@ -465,7 +465,7 @@ void rangeset_printk(printk (" }" ); -spin_unlock (&r->lock); +read_unlock (&r->lock); } void rangeset_domain_printk(switch rangeset's lock to rwlock
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Signed-off-by Jan Beulich <[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.xen/common/rangeset.c +20
-20@@ -28,7 +28,7 @@ struct rangeset {/* Number of ranges that can be allocated */ long nr_ranges; -spinlock_t lock; +rwlock_t lock;/* Pretty-printing name. */ char name[32 ];@@ -120,7 +120,7 @@ int rangeset_add_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -176,7 +176,7 @@ int rangeset_add_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -188,7 +188,7 @@ int rangeset_remove_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -244,7 +244,7 @@ int rangeset_remove_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -256,10 +256,10 @@ int rangeset_contains_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, s); contains = (x && (x->e >= e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return contains; }@@ -272,10 +272,10 @@ int rangeset_overlaps_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, e); overlaps = (x && (s <= x->e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return overlaps; }@@ -287,13 +287,13 @@ int rangeset_report_ranges(struct range *x;int rc =0 ; -spin_lock (&r->lock); +read_lock (&r->lock);for ( x =find_range (r, s); x && (x->s <= e) && !rc; x =next_range (r, x) )if ( x->e >= s ) rc =cb (max (x->s, s),min (x->e, e), ctxt); -spin_unlock (&r->lock); +read_unlock (&r->lock);return rc; }@@ -331,7 +331,7 @@ struct rangeset *rangeset_new(if ( r ==NULL )return NULL ; -spin_lock_init (&r->lock); +rwlock_init (&r->lock);INIT_LIST_HEAD (&r->range_list); r->nr_ranges =-1 ;@@ -414,21 +414,21 @@ void rangeset_swap(struct rangeset *a, sif ( a < b ) { -spin_lock (&a->lock); -spin_lock (&b->lock); +write_lock (&a->lock); +write_lock (&b->lock); }else { -spin_lock (&b->lock); -spin_lock (&a->lock); +write_lock (&b->lock); +write_lock (&a->lock); }list_splice_init (&a->range_list, &tmp);list_splice_init (&b->range_list, &a->range_list);list_splice (&tmp, &b->range_list); -spin_unlock (&a->lock); -spin_unlock (&b->lock); +write_unlock (&a->lock); +write_unlock (&b->lock); }/***************************** @@ -446,7 +446,7 @@ void rangeset_printk(int nr_printed =0 ;struct range *x; -spin_lock (&r->lock); +read_lock (&r->lock);printk ("%-10s {" , r->name);@@ -465,7 +465,7 @@ void rangeset_printk(printk (" }" ); -spin_unlock (&r->lock); +read_unlock (&r->lock); } void rangeset_domain_printk(_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Tim Deegan
Acked-byQuoted 6 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 19.09.14 at 18:32, <[email protected]> wrote:
Quoted 3 lines · Jan Beulich
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Quoted 6 lines
Quoted 3 lines
Reviewed-by Konrad Rzeszutek Wilk <[email protected]>I am comfortable with this going to Xen 4.5.
Anyone of you wanting to ack this then, or should I nevertheless postpone it until after 4.5?
If Konrad's happy I am too. :)
Tim.
Keir Fraser
Acked-byDo the searches ever get long enough that a read lock helps? If any of the rangesets is getting large and making the searches slow then it would be quite easy to switch from linked list to red-black tree?
I don't mind using a rwlock here though.
-- Keir
Quoted 813 lines
Tim Deegan <mailto:[email protected]>
30 September 2014 13:01If Konrad's happy I am too. :)
Acked-by Tim Deegan <[email protected]>Tim.
Jan Beulich <mailto:[email protected]>
30 September 2014 09:50Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 19.09.14 at 18:32,<[email protected]> wrote:
Quoted 3 lines · Jan Beulich
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Reviewed-by Konrad Rzeszutek Wilk<[email protected]>I am comfortable with this going to Xen 4.5.
Anyone of you wanting to ack this then, or should I nevertheless postpone it until after 4.5?
Jan
Quoted 305 lines
Quoted 305 lines
Signed-off-by Jan Beulich<[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.xen/common/rangeset.c +20
-20@@ -28,7 +28,7 @@ struct rangeset {/* Number of ranges that can be allocated */ long nr_ranges; -spinlock_t lock; +rwlock_t lock;/* Pretty-printing name. */ char name[32 ];@@ -120,7 +120,7 @@ int rangeset_add_range(ASSERT (s<= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -176,7 +176,7 @@ int rangeset_add_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -188,7 +188,7 @@ int rangeset_remove_range(ASSERT (s<= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -244,7 +244,7 @@ int rangeset_remove_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -256,10 +256,10 @@ int rangeset_contains_range(ASSERT (s<= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, s); contains = (x&& (x->e>= e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return contains; }@@ -272,10 +272,10 @@ int rangeset_overlaps_range(ASSERT (s<= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, e); overlaps = (x&& (s<= x->e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return overlaps; }@@ -287,13 +287,13 @@ int rangeset_report_ranges(struct range *x;int rc =0 ; -spin_lock (&r->lock); +read_lock (&r->lock);for ( x =find_range (r, s); x&& (x->s<= e)&& !rc; x =next_range (r, x) )if ( x->e>= s ) rc =cb (max (x->s, s),min (x->e, e), ctxt); -spin_unlock (&r->lock); +read_unlock (&r->lock);return rc; }@@ -331,7 +331,7 @@ struct rangeset *rangeset_new(if ( r ==NULL )return NULL ; -spin_lock_init (&r->lock); +rwlock_init (&r->lock);INIT_LIST_HEAD (&r->range_list); r->nr_ranges =-1 ;@@ -414,21 +414,21 @@ void rangeset_swap(struct rangeset *a, sif ( a< b ) { -spin_lock (&a->lock); -spin_lock (&b->lock); +write_lock (&a->lock); +write_lock (&b->lock); }else { -spin_lock (&b->lock); -spin_lock (&a->lock); +write_lock (&b->lock); +write_lock (&a->lock); }list_splice_init (&a->range_list,&tmp);list_splice_init (&b->range_list,&a->range_list);list_splice (&tmp,&b->range_list); -spin_unlock (&a->lock); -spin_unlock (&b->lock); +write_unlock (&a->lock); +write_unlock (&b->lock); }/***************************** @@ -446,7 +446,7 @@ void rangeset_printk(int nr_printed =0 ;struct range *x; -spin_lock (&r->lock); +read_lock (&r->lock);printk ("%-10s {" , r->name);@@ -465,7 +465,7 @@ void rangeset_printk(printk (" }" ); -spin_unlock (&r->lock); +read_unlock (&r->lock); } void rangeset_domain_printk(switch rangeset's lock to rwlock
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Signed-off-by Jan Beulich<[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.xen/common/rangeset.c +20
-20@@ -28,7 +28,7 @@ struct rangeset {/* Number of ranges that can be allocated */ long nr_ranges; -spinlock_t lock; +rwlock_t lock;/* Pretty-printing name. */ char name[32 ];@@ -120,7 +120,7 @@ int rangeset_add_range(ASSERT (s<= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -176,7 +176,7 @@ int rangeset_add_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -188,7 +188,7 @@ int rangeset_remove_range(ASSERT (s<= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -244,7 +244,7 @@ int rangeset_remove_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -256,10 +256,10 @@ int rangeset_contains_range(ASSERT (s<= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, s); contains = (x&& (x->e>= e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return contains; }@@ -272,10 +272,10 @@ int rangeset_overlaps_range(ASSERT (s<= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, e); overlaps = (x&& (s<= x->e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return overlaps; }@@ -287,13 +287,13 @@ int rangeset_report_ranges(struct range *x;int rc =0 ; -spin_lock (&r->lock); +read_lock (&r->lock);for ( x =find_range (r, s); x&& (x->s<= e)&& !rc; x =next_range (r, x) )if ( x->e>= s ) rc =cb (max (x->s, s),min (x->e, e), ctxt); -spin_unlock (&r->lock); +read_unlock (&r->lock);return rc; }@@ -331,7 +331,7 @@ struct rangeset *rangeset_new(if ( r ==NULL )return NULL ; -spin_lock_init (&r->lock); +rwlock_init (&r->lock);INIT_LIST_HEAD (&r->range_list); r->nr_ranges =-1 ;@@ -414,21 +414,21 @@ void rangeset_swap(struct rangeset *a, sif ( a< b ) { -spin_lock (&a->lock); -spin_lock (&b->lock); +write_lock (&a->lock); +write_lock (&b->lock); }else { -spin_lock (&b->lock); -spin_lock (&a->lock); +write_lock (&b->lock); +write_lock (&a->lock); }list_splice_init (&a->range_list,&tmp);list_splice_init (&b->range_list,&a->range_list);list_splice (&tmp,&b->range_list); -spin_unlock (&a->lock); -spin_unlock (&b->lock); +write_unlock (&a->lock); +write_unlock (&b->lock); }/***************************** @@ -446,7 +446,7 @@ void rangeset_printk(int nr_printed =0 ;struct range *x; -spin_lock (&r->lock); +read_lock (&r->lock);printk ("%-10s {" , r->name);@@ -465,7 +465,7 @@ void rangeset_printk(printk (" }" ); -spin_unlock (&r->lock); +read_unlock (&r->lock); }Quoted 5 lines
Quoted 5 lines
xen/common/rangeset.c +0
-0void rangeset_domain_printk(_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-develKonrad Rzeszutek Wilk <mailto:[email protected]> 19 September 2014 17:32
Quoted 3 lines · Jan Beulich
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Reviewed-by Konrad Rzeszutek Wilk<[email protected]>I am comfortable with this going to Xen 4.5.
Quoted 308 lines
Signed-off-by Jan Beulich<[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.xen/common/rangeset.c +20
-20@@ -28,7 +28,7 @@ struct rangeset {/* Number of ranges that can be allocated */ long nr_ranges; -spinlock_t lock; +rwlock_t lock;/* Pretty-printing name. */ char name[32 ];@@ -120,7 +120,7 @@ int rangeset_add_range(ASSERT (s<= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -176,7 +176,7 @@ int rangeset_add_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -188,7 +188,7 @@ int rangeset_remove_range(ASSERT (s<= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -244,7 +244,7 @@ int rangeset_remove_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -256,10 +256,10 @@ int rangeset_contains_range(ASSERT (s<= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, s); contains = (x&& (x->e>= e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return contains; }@@ -272,10 +272,10 @@ int rangeset_overlaps_range(ASSERT (s<= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, e); overlaps = (x&& (s<= x->e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return overlaps; }@@ -287,13 +287,13 @@ int rangeset_report_ranges(struct range *x;int rc =0 ; -spin_lock (&r->lock); +read_lock (&r->lock);for ( x =find_range (r, s); x&& (x->s<= e)&& !rc; x =next_range (r, x) )if ( x->e>= s ) rc =cb (max (x->s, s),min (x->e, e), ctxt); -spin_unlock (&r->lock); +read_unlock (&r->lock);return rc; }@@ -331,7 +331,7 @@ struct rangeset *rangeset_new(if ( r ==NULL )return NULL ; -spin_lock_init (&r->lock); +rwlock_init (&r->lock);INIT_LIST_HEAD (&r->range_list); r->nr_ranges =-1 ;@@ -414,21 +414,21 @@ void rangeset_swap(struct rangeset *a, sif ( a< b ) { -spin_lock (&a->lock); -spin_lock (&b->lock); +write_lock (&a->lock); +write_lock (&b->lock); }else { -spin_lock (&b->lock); -spin_lock (&a->lock); +write_lock (&b->lock); +write_lock (&a->lock); }list_splice_init (&a->range_list,&tmp);list_splice_init (&b->range_list,&a->range_list);list_splice (&tmp,&b->range_list); -spin_unlock (&a->lock); -spin_unlock (&b->lock); +write_unlock (&a->lock); +write_unlock (&b->lock); }/***************************** @@ -446,7 +446,7 @@ void rangeset_printk(int nr_printed =0 ;struct range *x; -spin_lock (&r->lock); +read_lock (&r->lock);printk ("%-10s {" , r->name);@@ -465,7 +465,7 @@ void rangeset_printk(printk (" }" ); -spin_unlock (&r->lock); +read_unlock (&r->lock); } void rangeset_domain_printk(switch rangeset's lock to rwlock
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.
Signed-off-by Jan Beulich<[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.xen/common/rangeset.c +20
-20@@ -28,7 +28,7 @@ struct rangeset {/* Number of ranges that can be allocated */ long nr_ranges; -spinlock_t lock; +rwlock_t lock;/* Pretty-printing name. */ char name[32 ];@@ -120,7 +120,7 @@ int rangeset_add_range(ASSERT (s<= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -176,7 +176,7 @@ int rangeset_add_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -188,7 +188,7 @@ int rangeset_remove_range(ASSERT (s<= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -244,7 +244,7 @@ int rangeset_remove_range( } out: -spin_unlock (&r->lock); +write_unlock (&r->lock);return rc; }@@ -256,10 +256,10 @@ int rangeset_contains_range(ASSERT (s<= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, s); contains = (x&& (x->e>= e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return contains; }@@ -272,10 +272,10 @@ int rangeset_overlaps_range(ASSERT (s<= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, e); overlaps = (x&& (s<= x->e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return overlaps; }@@ -287,13 +287,13 @@ int rangeset_report_ranges(struct range *x;int rc =0 ; -spin_lock (&r->lock); +read_lock (&r->lock);for ( x =find_range (r, s); x&& (x->s<= e)&& !rc; x =next_range (r, x) )if ( x->e>= s ) rc =cb (max (x->s, s),min (x->e, e), ctxt); -spin_unlock (&r->lock); +read_unlock (&r->lock);return rc; }@@ -331,7 +331,7 @@ struct rangeset *rangeset_new(if ( r ==NULL )return NULL ; -spin_lock_init (&r->lock); +rwlock_init (&r->lock);INIT_LIST_HEAD (&r->range_list); r->nr_ranges =-1 ;@@ -414,21 +414,21 @@ void rangeset_swap(struct rangeset *a, sif ( a< b ) { -spin_lock (&a->lock); -spin_lock (&b->lock); +write_lock (&a->lock); +write_lock (&b->lock); }else { -spin_lock (&b->lock); -spin_lock (&a->lock); +write_lock (&b->lock); +write_lock (&a->lock); }list_splice_init (&a->range_list,&tmp);list_splice_init (&b->range_list,&a->range_list);list_splice (&tmp,&b->range_list); -spin_unlock (&a->lock); -spin_unlock (&b->lock); +write_unlock (&a->lock); +write_unlock (&b->lock); }/***************************** @@ -446,7 +446,7 @@ void rangeset_printk(int nr_printed =0 ;struct range *x; -spin_lock (&r->lock); +read_lock (&r->lock);printk ("%-10s {" , r->name);@@ -465,7 +465,7 @@ void rangeset_printk(printk (" }" ); -spin_unlock (&r->lock); +read_unlock (&r->lock); } void rangeset_domain_printk(Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-develJan Beulich <mailto:[email protected]>
12 September 2014 13:55
As a general library routine, it should behave as efficiently as possible, even if at present no significant contention is known here.Signed-off-by Jan Beulich <[email protected]>---
With the widened use of rangesets I'd like to re-suggest this change which I had posted already a couple of years back.xen/common/rangeset.c +2
-2@@ -28,7 +28,7 @@ struct rangeset {/* Number of ranges that can be allocated */ long nr_ranges; -spinlock_t lock; +rwlock_t lock;/* Pretty-printing name. */ char name[32 ];@@ -120,7 +120,7 @@ int rangeset_add_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -176,7 +176,7 @@ int rangeset_add_range( }out:
-spin_unlock(&r->lock);
+write_unlock(&r->lock);
return rc;
}xen/common/rangeset.c +1
-1@@ -188,7 +188,7 @@ int rangeset_remove_range(ASSERT (s <= e); -spin_lock (&r->lock); +write_lock (&r->lock); x =find_range (r, s); y =find_range (r, e);@@ -244,7 +244,7 @@ int rangeset_remove_range( }out:
-spin_unlock(&r->lock);
+write_unlock(&r->lock);
return rc;
}xen/common/rangeset.c +9
-9@@ -256,10 +256,10 @@ int rangeset_contains_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, s); contains = (x && (x->e >= e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return contains; }@@ -272,10 +272,10 @@ int rangeset_overlaps_range(ASSERT (s <= e); -spin_lock (&r->lock); +read_lock (&r->lock); x =find_range (r, e); overlaps = (x && (s <= x->e)); -spin_unlock (&r->lock); +read_unlock (&r->lock);return overlaps; }@@ -287,13 +287,13 @@ int rangeset_report_ranges(struct range *x;int rc =0 ; -spin_lock (&r->lock); +read_lock (&r->lock);for ( x =find_range (r, s); x && (x->s <= e) && !rc; x =next_range (r, x) )if ( x->e >= s ) rc =cb (max (x->s, s),min (x->e, e), ctxt); -spin_unlock (&r->lock); +read_unlock (&r->lock);return rc; }@@ -331,7 +331,7 @@ struct rangeset *rangeset_new(if ( r ==NULL )return NULL ; -spin_lock_init (&r->lock); +rwlock_init (&r->lock);INIT_LIST_HEAD (&r->range_list); r->nr_ranges =-1 ;@@ -414,21 +414,21 @@ void rangeset_swap(struct rangeset *a, sif ( a < b ) { -spin_lock (&a->lock); -spin_lock (&b->lock); +write_lock (&a->lock); +write_lock (&b->lock); }else
{
-spin_lock(&b->lock);
-spin_lock(&a->lock);
+write_lock(&b->lock);
+write_lock(&a->lock);
}
list_splice_init(&a->range_list, &tmp);list_splice_init(&b->range_list, &a->range_list);list_splice(&tmp, &b->range_list);-
spin_unlock(&a->lock);
-spin_unlock(&b->lock);
+write_unlock(&a->lock);
+write_unlock(&b->lock);
}/*****************************
xen/common/rangeset.c +2
-2@@ -446,7 +446,7 @@ void rangeset_printk(int nr_printed =0 ;struct range *x; -spin_lock (&r->lock); +read_lock (&r->lock);printk ("%-10s {" , r->name);@@ -465,7 +465,7 @@ void rangeset_printk(printk (" }" ); -spin_unlock (&r->lock); +read_unlock (&r->lock); }
Quoted 4 lines
void rangeset_domain_printk(
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 30.09.14 at 22:53, <[email protected]> wrote:
Do the searches ever get long enough that a read lock helps? If any of the rangesets is getting large and making the searches slow then it would be quite easy to switch from linked list to red-black tree?
As noted elsewhere, even very brief locking periods can cause convoys for many-vCPU guests. One case where we observe this is hvm_get_guest_time_fixed() (without clear route for mitigation as converting to rw lock is not an option here, and I didn't get around to try out whether eliminating the lock altogether in favor of atomic CPU operations would make this any better).
Jan
Quoted 5 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 30.09.14 at 22:53,<[email protected]> wrote:
Do the searches ever get long enough that a read lock helps? If any of the rangesets is getting large and making the searches slow then it would be quite easy to switch from linked list to red-black tree?
Quoted 7 lines
As noted elsewhere, even very brief locking periods can cause convoys for many-vCPU guests. One case where we observe this is
hvm_get_guest_time_fixed()(without clear route for mitigation as converting to rw lock is not an option here, and I didn't get around to try out whether eliminating the lock altogether in favor of atomic CPU operations would make this any better).
Given how rarely most of these rangesets get updated, it would be nice to let the guest itself have lock-free access at the expense of having to pause it to make modifications. Although, does a guest ever modify any of its own rangesets? I'm not sure that ever happens.
-- Keir
Quoted 2 lines
Jan