xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Keir Fraser <keir.xen@gmail.com>
To: Tim Deegan <tim@xen.org>
Cc: Keir Fraser <keir@xen.org>,
	Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <Ian.Campbell@eu.citrix.com>,
	Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] switch rangeset's lock to rwlock
Date: Tue, 30 Sep 2014 21:53:38 +0100	[thread overview]
Message-ID: <542B1852.9070904@gmail.com> (raw)
In-Reply-To: <20140930120149.GA30119@deinos.phlegethon.org>


[-- Attachment #1.1: Type: text/plain, Size: 20373 bytes --]

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?

I don't mind using a rwlock here though.
Acked-by: Keir Fraser <keir@xen.org>

  -- Keir
> Tim Deegan <mailto:tim@xen.org>
> 30 September 2014 13:01
>
> If Konrad's happy I am too. :)
> Acked-by: Tim Deegan <tim@xen.org>
>
> Tim.
>
> Jan Beulich <mailto:JBeulich@suse.com>
> 30 September 2014 09:50
>>>> On 19.09.14 at 18:32,<konrad.wilk@oracle.com>  wrote:
>> On Fri, Sep 12, 2014 at 01:55:07PM +0100, Jan Beulich wrote:
>>> 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<konrad.wilk@oracle.com>
>>
>> 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
>
>>> Signed-off-by: Jan Beulich<jbeulich@suse.com>
>>> ---
>>> With the widened use of rangesets I'd like to re-suggest this change
>>> which I had posted already a couple of years back.
>>>
>>> --- a/xen/common/rangeset.c
>>> +++ b/xen/common/rangeset.c
>>> @@ -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, s
>>>
>>>       if ( 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<jbeulich@suse.com>
>>> ---
>>> With the widened use of rangesets I'd like to re-suggest this change
>>> which I had posted already a couple of years back.
>>>
>>> --- a/xen/common/rangeset.c
>>> +++ b/xen/common/rangeset.c
>>> @@ -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, s
>>>
>>>       if ( 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
>>> Xen-devel@lists.xen.org
>>> http://lists.xen.org/xen-devel
>
>
> Konrad Rzeszutek Wilk <mailto:konrad.wilk@oracle.com>
> 19 September 2014 17:32
> On Fri, Sep 12, 2014 at 01:55:07PM +0100, Jan Beulich wrote:
>> 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<konrad.wilk@oracle.com>
>
> I am comfortable with this going to Xen 4.5.
>
>> Signed-off-by: Jan Beulich<jbeulich@suse.com>
>> ---
>> With the widened use of rangesets I'd like to re-suggest this change
>> which I had posted already a couple of years back.
>>
>> --- a/xen/common/rangeset.c
>> +++ b/xen/common/rangeset.c
>> @@ -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, s
>>
>>       if ( 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<jbeulich@suse.com>
>> ---
>> With the widened use of rangesets I'd like to re-suggest this change
>> which I had posted already a couple of years back.
>>
>> --- a/xen/common/rangeset.c
>> +++ b/xen/common/rangeset.c
>> @@ -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, s
>>
>>       if ( 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
>> Xen-devel@lists.xen.org
>> http://lists.xen.org/xen-devel
>
> Jan Beulich <mailto:JBeulich@suse.com>
> 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 <jbeulich@suse.com>
> ---
> With the widened use of rangesets I'd like to re-suggest this change
> which I had posted already a couple of years back.
>
> --- a/xen/common/rangeset.c
> +++ b/xen/common/rangeset.c
> @@ -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, s
>
> if ( 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(
>
>
>

[-- Attachment #1.2.1: Type: text/html, Size: 26859 bytes --]

[-- Attachment #1.2.2: compose-unknown-contact.jpg --]
[-- Type: image/jpeg, Size: 770 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2014-09-30 20:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-12 12:55 [PATCH] switch rangeset's lock to rwlock Jan Beulich
2014-09-18 10:43 ` Tim Deegan
2014-09-18 12:15   ` Jan Beulich
2014-09-18 13:02     ` Tim Deegan
2014-09-18 13:32       ` Jan Beulich
2014-09-18 14:52         ` Paul Durrant
2014-09-19 16:33         ` Konrad Rzeszutek Wilk
2014-09-22  9:42         ` Ian Campbell
2014-09-22 10:34           ` Jan Beulich
2014-09-19 16:32 ` Konrad Rzeszutek Wilk
2014-09-30  8:50   ` Jan Beulich
2014-09-30 12:01     ` Tim Deegan
2014-09-30 20:53       ` Keir Fraser [this message]
2014-10-01  8:57         ` Jan Beulich
2014-10-01  9:31           ` Keir Fraser
  -- strict thread matches above, loose matches on Subject: below --
2011-03-25 16:49 Jan Beulich
2011-03-25 17:08 ` Keir Fraser
2011-03-25 17:52   ` Dan Magenheimer
2011-03-25 20:52     ` Keir Fraser
2011-03-30 22:44       ` Jeremy Fitzhardinge
2011-03-28  8:23   ` Jan Beulich
2011-03-28  8:54     ` Keir Fraser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=542B1852.9070904@gmail.com \
    --to=keir.xen@gmail.com \
    --cc=Ian.Campbell@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.org \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).