[RFC v5 1/3] rcu: introduce rcu_read_is_locked()

Chuang Xu posted 3 patches 3 years ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>, David Hildenbrand <david@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Juan Quintela <quintela@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>
There is a newer version of this series
[RFC v5 1/3] rcu: introduce rcu_read_is_locked()
Posted by Chuang Xu 3 years ago
add rcu_read_is_locked() to detect holding of rcu lock.

Signed-off-by: Chuang Xu <xuchuangxclwt@bytedance.com>
---
 include/qemu/rcu.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/qemu/rcu.h b/include/qemu/rcu.h
index b063c6fde8..719916d9d3 100644
--- a/include/qemu/rcu.h
+++ b/include/qemu/rcu.h
@@ -119,6 +119,13 @@ static inline void rcu_read_unlock(void)
     }
 }
 
+static inline bool rcu_read_is_locked(void)
+{
+    struct rcu_reader_data *p_rcu_reader = get_ptr_rcu_reader();
+
+    return p_rcu_reader->depth > 0;
+}
+
 extern void synchronize_rcu(void);
 
 /*
-- 
2.20.1
Re: [RFC v5 1/3] rcu: introduce rcu_read_is_locked()
Posted by Juan Quintela 3 years ago
Chuang Xu <xuchuangxclwt@bytedance.com> wrote:
> add rcu_read_is_locked() to detect holding of rcu lock.
>
> Signed-off-by: Chuang Xu <xuchuangxclwt@bytedance.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

Althought I think that petting a review from Paolo or anyone that knows
more than RCU could be a good idea.

> ---
>  include/qemu/rcu.h | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/include/qemu/rcu.h b/include/qemu/rcu.h
> index b063c6fde8..719916d9d3 100644
> --- a/include/qemu/rcu.h
> +++ b/include/qemu/rcu.h
> @@ -119,6 +119,13 @@ static inline void rcu_read_unlock(void)
>      }
>  }
>  
> +static inline bool rcu_read_is_locked(void)
> +{
> +    struct rcu_reader_data *p_rcu_reader = get_ptr_rcu_reader();
> +
> +    return p_rcu_reader->depth > 0;
> +}
> +
>  extern void synchronize_rcu(void);
>  
>  /*
Re: [RFC v5 1/3] rcu: introduce rcu_read_is_locked()
Posted by Chuang Xu 2 years, 12 months ago
Hi, Paolo!

On 2023/2/2 下午6:59, Juan Quintela wrote:
> Chuang Xu <xuchuangxclwt@bytedance.com> wrote:
>> add rcu_read_is_locked() to detect holding of rcu lock.
>>
>> Signed-off-by: Chuang Xu <xuchuangxclwt@bytedance.com>
> Reviewed-by: Juan Quintela <quintela@redhat.com>
>
> Althought I think that petting a review from Paolo or anyone that knows
> more than RCU could be a good idea.
>
>> ---
>>   include/qemu/rcu.h | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/include/qemu/rcu.h b/include/qemu/rcu.h
>> index b063c6fde8..719916d9d3 100644
>> --- a/include/qemu/rcu.h
>> +++ b/include/qemu/rcu.h
>> @@ -119,6 +119,13 @@ static inline void rcu_read_unlock(void)
>>       }
>>   }
>>   
>> +static inline bool rcu_read_is_locked(void)
>> +{
>> +    struct rcu_reader_data *p_rcu_reader = get_ptr_rcu_reader();
>> +
>> +    return p_rcu_reader->depth > 0;
>> +}
>> +
>>   extern void synchronize_rcu(void);
>>   
>>   /*

Do you have any more suggestions about patch1?

Looking forward to your reply.

Thanks!