Skip to contentSkip to conversation

xen/common: Constify the parameter of _spin_is_locked()

PATCH In review Julien Grall 3 participants 4 messages Jan 27, 2023 – Jan 30, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/common: Constify the parameter of _spin_is_locked()

From: Julien Grall <[email protected]>

The lock is not meant to be modified by _spin_is_locked(). So constify it.

This is helpful to be able to assert the locked is taken when the underlying structure is const.

---
 xen/common/spinlock.c      | 2 +-
 xen/include/xen/spinlock.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
xen/common/spinlock.c +1 -1
index 84996c3fbc1f..a15f0a2eb667 100644
@@ -368,7 +368,7 @@ void _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags)
     local_irq_restore(flags);
 }
 
-int _spin_is_locked(spinlock_t *lock)
+int _spin_is_locked(const spinlock_t *lock)
 {
     /*
      * Recursive locks may be locked by another CPU, yet we return
xen/include/xen/spinlock.h +1 -1
index 2fa6ba36548e..ca40c71c88f9 100644
@@ -185,7 +185,7 @@ void _spin_unlock(spinlock_t *lock);
 void _spin_unlock_irq(spinlock_t *lock);
 void _spin_unlock_irqrestore(spinlock_t *lock, unsigned long flags);
 
-int _spin_is_locked(spinlock_t *lock);
+int _spin_is_locked(const spinlock_t *lock);
 int _spin_trylock(spinlock_t *lock);
 void _spin_barrier(spinlock_t *lock);
 
Signature · 1 line
2.38.1
Reviewed-by Tested-by on v1 1/1
#1 lore raw

Hi Julien,

Quoted 9 lines

-----Original Message-----
Subject: [PATCH] xen/common: Constify the parameter of _spin_is_locked()

From: Julien Grall <[email protected]>

The lock is not meant to be modified by _spin_is_locked(). So constify it.

This is helpful to be able to assert the locked is taken when the

Nit: s/locked/lock/
This definitely can be fixed on commit.

Quoted 3 lines

underlying structure is const.

I tried to test this patch on FVP (both Arm32 and Arm64) to play safe. This patch is good (as expected of course :)), so:

Kind regards,
Henry

Reviewed-by on v1 1/1
#2 lore raw
In reply to Julien Grall
Quoted 9 lines · Julien Grall

From: Julien Grall <[email protected]>

The lock is not meant to be modified by _spin_is_locked(). So constify it.

This is helpful to be able to assert the locked is taken when the underlying structure is const.

But: Could I talk you into doing the same for _rw_is{,_write}_locked() for consistency?

Jan

#3 lore raw
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Julien Grall

From: Julien Grall <[email protected]>

The lock is not meant to be modified by _spin_is_locked(). So constify it.

This is helpful to be able to assert the locked is taken when the underlying structure is const.

Quoted 6 lines
Quoted 1 line

But: Could I talk you into doing the same for _rw_is{,_write}_locked() for consistency?

Sure. Although, I would prefer to do it in a separate patch.

Cheers,

Signature · 1 line
Julien Grall