* [PATCH] xen/common: rwlock: Constify the parameter of _rw_is{,_write}_locked()
@ 2023-01-30 18:28 Julien Grall
2023-01-31 9:34 ` Jan Beulich
0 siblings, 1 reply; 5+ messages in thread
From: Julien Grall @ 2023-01-30 18:28 UTC (permalink / raw)
To: xen-devel
Cc: julien, Julien Grall, Andrew Cooper, George Dunlap, Jan Beulich,
Stefano Stabellini, Wei Liu
From: Julien Grall <jgrall@amazon.com>
The lock is not meant to be modified by _rw_is{,_write}_locked(). So
constify it.
This is helpful to be able to assert if the lock is taken when the
underlying structure is const.
Signed-off-by: Julien Grall <jgrall@amazon.com>
---
xen/include/xen/rwlock.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/xen/include/xen/rwlock.h b/xen/include/xen/rwlock.h
index b8d52a5aa939..e0d2b41c5c7e 100644
--- a/xen/include/xen/rwlock.h
+++ b/xen/include/xen/rwlock.h
@@ -149,7 +149,7 @@ static inline void _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
local_irq_restore(flags);
}
-static inline int _rw_is_locked(rwlock_t *lock)
+static inline int _rw_is_locked(const rwlock_t *lock)
{
return atomic_read(&lock->cnts);
}
@@ -254,7 +254,7 @@ static inline void _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
local_irq_restore(flags);
}
-static inline int _rw_is_write_locked(rwlock_t *lock)
+static inline int _rw_is_write_locked(const rwlock_t *lock)
{
return (atomic_read(&lock->cnts) & _QW_WMASK) == _QW_LOCKED;
}
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] xen/common: rwlock: Constify the parameter of _rw_is{,_write}_locked()
2023-01-30 18:28 [PATCH] xen/common: rwlock: Constify the parameter of _rw_is{,_write}_locked() Julien Grall
@ 2023-01-31 9:34 ` Jan Beulich
2023-01-31 21:34 ` Julien Grall
0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2023-01-31 9:34 UTC (permalink / raw)
To: Julien Grall
Cc: Julien Grall, Andrew Cooper, George Dunlap, Stefano Stabellini,
Wei Liu, xen-devel
On 30.01.2023 19:28, Julien Grall wrote:
> From: Julien Grall <jgrall@amazon.com>
>
> The lock is not meant to be modified by _rw_is{,_write}_locked(). So
> constify it.
>
> This is helpful to be able to assert if the lock is taken when the
> underlying structure is const.
>
> Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
(maybe also Requested-by)
Thanks for doing this on top of the spinlock change.
Jan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xen/common: rwlock: Constify the parameter of _rw_is{,_write}_locked()
2023-01-31 9:34 ` Jan Beulich
@ 2023-01-31 21:34 ` Julien Grall
0 siblings, 0 replies; 5+ messages in thread
From: Julien Grall @ 2023-01-31 21:34 UTC (permalink / raw)
To: Jan Beulich
Cc: Julien Grall, Andrew Cooper, George Dunlap, Stefano Stabellini,
Wei Liu, xen-devel
Hi Jan,
On 31/01/2023 09:34, Jan Beulich wrote:
> On 30.01.2023 19:28, Julien Grall wrote:
>> From: Julien Grall <jgrall@amazon.com>
>>
>> The lock is not meant to be modified by _rw_is{,_write}_locked(). So
>> constify it.
>>
>> This is helpful to be able to assert if the lock is taken when the
>> underlying structure is const.
>>
>> Signed-off-by: Julien Grall <jgrall@amazon.com>
>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> (maybe also Requested-by)
I will add a requested-by while committing (waiting for a push before
doing it).
Cheers,
--
Julien Grall
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xen/common: rwlock: Constify the parameter of _rw_is{,_write}_locked()
2023-01-30 18:28 Julien Grall
@ 2023-01-30 18:29 ` Julien Grall
0 siblings, 0 replies; 5+ messages in thread
From: Julien Grall @ 2023-01-30 18:29 UTC (permalink / raw)
To: xen-devel; +Cc: Julien Grall
Hi,
I forgot to CC the maintainers. Please ignore this version.
Cheers,
On 30/01/2023 18:28, Julien Grall wrote:
> From: Julien Grall <jgrall@amazon.com>
>
> The lock is not meant to be modified by _rw_is{,_write}_locked(). So
> constify it.
>
> This is helpful to be able to assert if the lock is taken when the
> underlying structure is const.
>
> Signed-off-by: Julien Grall <jgrall@amazon.com>
> ---
> xen/include/xen/rwlock.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/xen/include/xen/rwlock.h b/xen/include/xen/rwlock.h
> index b8d52a5aa939..e0d2b41c5c7e 100644
> --- a/xen/include/xen/rwlock.h
> +++ b/xen/include/xen/rwlock.h
> @@ -149,7 +149,7 @@ static inline void _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
> local_irq_restore(flags);
> }
>
> -static inline int _rw_is_locked(rwlock_t *lock)
> +static inline int _rw_is_locked(const rwlock_t *lock)
> {
> return atomic_read(&lock->cnts);
> }
> @@ -254,7 +254,7 @@ static inline void _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
> local_irq_restore(flags);
> }
>
> -static inline int _rw_is_write_locked(rwlock_t *lock)
> +static inline int _rw_is_write_locked(const rwlock_t *lock)
> {
> return (atomic_read(&lock->cnts) & _QW_WMASK) == _QW_LOCKED;
> }
--
Julien Grall
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] xen/common: rwlock: Constify the parameter of _rw_is{,_write}_locked()
@ 2023-01-30 18:28 Julien Grall
2023-01-30 18:29 ` Julien Grall
0 siblings, 1 reply; 5+ messages in thread
From: Julien Grall @ 2023-01-30 18:28 UTC (permalink / raw)
To: xen-devel; +Cc: julien, Julien Grall
From: Julien Grall <jgrall@amazon.com>
The lock is not meant to be modified by _rw_is{,_write}_locked(). So
constify it.
This is helpful to be able to assert if the lock is taken when the
underlying structure is const.
Signed-off-by: Julien Grall <jgrall@amazon.com>
---
xen/include/xen/rwlock.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/xen/include/xen/rwlock.h b/xen/include/xen/rwlock.h
index b8d52a5aa939..e0d2b41c5c7e 100644
--- a/xen/include/xen/rwlock.h
+++ b/xen/include/xen/rwlock.h
@@ -149,7 +149,7 @@ static inline void _read_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
local_irq_restore(flags);
}
-static inline int _rw_is_locked(rwlock_t *lock)
+static inline int _rw_is_locked(const rwlock_t *lock)
{
return atomic_read(&lock->cnts);
}
@@ -254,7 +254,7 @@ static inline void _write_unlock_irqrestore(rwlock_t *lock, unsigned long flags)
local_irq_restore(flags);
}
-static inline int _rw_is_write_locked(rwlock_t *lock)
+static inline int _rw_is_write_locked(const rwlock_t *lock)
{
return (atomic_read(&lock->cnts) & _QW_WMASK) == _QW_LOCKED;
}
--
2.38.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-31 21:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-30 18:28 [PATCH] xen/common: rwlock: Constify the parameter of _rw_is{,_write}_locked() Julien Grall
2023-01-31 9:34 ` Jan Beulich
2023-01-31 21:34 ` Julien Grall
-- strict thread matches above, loose matches on Subject: below --
2023-01-30 18:28 Julien Grall
2023-01-30 18:29 ` Julien Grall
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.