* [Qemu-devel] [PATCH] rfifolock: no need to get thread identifier when nesting
@ 2016-05-10 9:16 Changlong Xie
2016-05-10 9:38 ` Denis V. Lunev
0 siblings, 1 reply; 3+ messages in thread
From: Changlong Xie @ 2016-05-10 9:16 UTC (permalink / raw)
To: qemu devel, Stefan Hajnoczi; +Cc: Wen Congyang, Changlong Xie
Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
---
util/rfifolock.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/util/rfifolock.c b/util/rfifolock.c
index c22f5fe..f406cc1 100644
--- a/util/rfifolock.c
+++ b/util/rfifolock.c
@@ -50,6 +50,7 @@ void rfifolock_lock(RFifoLock *r)
if (r->nesting > 0 && qemu_thread_is_self(&r->owner_thread)) {
r->tail--; /* put ticket back, we're nesting */
+ goto out;
} else {
while (ticket != r->head) {
/* Invoke optional contention callback */
@@ -61,6 +62,7 @@ void rfifolock_lock(RFifoLock *r)
}
qemu_thread_get_self(&r->owner_thread);
+out:
r->nesting++;
qemu_mutex_unlock(&r->lock);
}
--
1.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] rfifolock: no need to get thread identifier when nesting
2016-05-10 9:16 [Qemu-devel] [PATCH] rfifolock: no need to get thread identifier when nesting Changlong Xie
@ 2016-05-10 9:38 ` Denis V. Lunev
2016-05-10 9:54 ` Changlong Xie
0 siblings, 1 reply; 3+ messages in thread
From: Denis V. Lunev @ 2016-05-10 9:38 UTC (permalink / raw)
To: Changlong Xie, qemu devel, Stefan Hajnoczi
On 05/10/2016 12:16 PM, Changlong Xie wrote:
> Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
> ---
> util/rfifolock.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/util/rfifolock.c b/util/rfifolock.c
> index c22f5fe..f406cc1 100644
> --- a/util/rfifolock.c
> +++ b/util/rfifolock.c
> @@ -50,6 +50,7 @@ void rfifolock_lock(RFifoLock *r)
>
> if (r->nesting > 0 && qemu_thread_is_self(&r->owner_thread)) {
> r->tail--; /* put ticket back, we're nesting */
> + goto out;
> } else {
> while (ticket != r->head) {
> /* Invoke optional contention callback */
> @@ -61,6 +62,7 @@ void rfifolock_lock(RFifoLock *r)
> }
>
> qemu_thread_get_self(&r->owner_thread);
> +out:
> r->nesting++;
> qemu_mutex_unlock(&r->lock);
> }
it would be better to put
qemu_thread_get_self(&r->owner_thread);
2 lines up and avoid unnecessary goto
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] rfifolock: no need to get thread identifier when nesting
2016-05-10 9:38 ` Denis V. Lunev
@ 2016-05-10 9:54 ` Changlong Xie
0 siblings, 0 replies; 3+ messages in thread
From: Changlong Xie @ 2016-05-10 9:54 UTC (permalink / raw)
To: Denis V. Lunev, qemu devel, Stefan Hajnoczi
On 05/10/2016 05:38 PM, Denis V. Lunev wrote:
> On 05/10/2016 12:16 PM, Changlong Xie wrote:
>> Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
>> ---
>> util/rfifolock.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/util/rfifolock.c b/util/rfifolock.c
>> index c22f5fe..f406cc1 100644
>> --- a/util/rfifolock.c
>> +++ b/util/rfifolock.c
>> @@ -50,6 +50,7 @@ void rfifolock_lock(RFifoLock *r)
>> if (r->nesting > 0 && qemu_thread_is_self(&r->owner_thread)) {
>> r->tail--; /* put ticket back, we're nesting */
>> + goto out;
>> } else {
>> while (ticket != r->head) {
>> /* Invoke optional contention callback */
>> @@ -61,6 +62,7 @@ void rfifolock_lock(RFifoLock *r)
>> }
>> qemu_thread_get_self(&r->owner_thread);
>> +out:
>> r->nesting++;
>> qemu_mutex_unlock(&r->lock);
>> }
> it would be better to put
> qemu_thread_get_self(&r->owner_thread);
> 2 lines up and avoid unnecessary goto
Yes, it's a better choice, will send out v2
Thanks
-Xie
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-05-10 9:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-10 9:16 [Qemu-devel] [PATCH] rfifolock: no need to get thread identifier when nesting Changlong Xie
2016-05-10 9:38 ` Denis V. Lunev
2016-05-10 9:54 ` Changlong Xie
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).