diff mbox series

[v2,06/12] KVM: s390: add function unlink_gib_alert_list()

Message ID 20181119172536.52649-7-mimu@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series KVM: s390: make use of the GIB | expand

Commit Message

Michael Mueller Nov. 19, 2018, 5:25 p.m. UTC
The function atomically returns the address of the first
GISA of this list and stores a zero address in the origin
list field of the GIB instead.

The GIB alert list contains all GISAs that have pending
adapter interruptions.

Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
---
 arch/s390/kvm/interrupt.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Heiko Carstens Nov. 19, 2018, 7:47 p.m. UTC | #1
On Mon, Nov 19, 2018 at 06:25:30PM +0100, Michael Mueller wrote:
> The function atomically returns the address of the first
> GISA of this list and stores a zero address in the origin
> list field of the GIB instead.
> 
> The GIB alert list contains all GISAs that have pending
> adapter interruptions.
> 
> Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
> Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
...
> +static struct kvm_s390_gisa __maybe_unused *unlink_gib_alert_list(void)
> +{
> +	u32 gisa;
> +
> +	if (!gib)
> +		return NULL;
> +

...

> +	do {
> +		gisa = READ_ONCE(gib->alert_list_origin);
> +	} while (cmpxchg(&gib->alert_list_origin, gisa, 0) != gisa);
> +
> +	return (void *)(u64) gisa;
> +}

Please make this shorter:

	return (void *)(u64) xchg(&gib->alert_list_origin, gisa, 0);
Michael Mueller Nov. 20, 2018, 8:25 a.m. UTC | #2
On 19.11.18 20:47, Heiko Carstens wrote:
> On Mon, Nov 19, 2018 at 06:25:30PM +0100, Michael Mueller wrote:
>> The function atomically returns the address of the first
>> GISA of this list and stores a zero address in the origin
>> list field of the GIB instead.
>>
>> The GIB alert list contains all GISAs that have pending
>> adapter interruptions.
>>
>> Signed-off-by: Michael Mueller <mimu@linux.ibm.com>
>> Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
> ...
>> +static struct kvm_s390_gisa __maybe_unused *unlink_gib_alert_list(void)
>> +{
>> +	u32 gisa;
>> +
>> +	if (!gib)
>> +		return NULL;
>> +
> 
> ...
> 
>> +	do {
>> +		gisa = READ_ONCE(gib->alert_list_origin);
>> +	} while (cmpxchg(&gib->alert_list_origin, gisa, 0) != gisa);
>> +
>> +	return (void *)(u64) gisa;
>> +}
> 
> Please make this shorter:
> 
> 	return (void *)(u64) xchg(&gib->alert_list_origin, gisa, 0);
> 

Unbelievable... just one macro further down. Thanks for pointing me to.
diff mbox series

Patch

diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index 56d431508435..fc9eae499319 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -2882,6 +2882,20 @@  int kvm_s390_get_irq_state(struct kvm_vcpu *vcpu, __u8 __user *buf, int len)
 	return n;
 }
 
+static struct kvm_s390_gisa __maybe_unused *unlink_gib_alert_list(void)
+{
+	u32 gisa;
+
+	if (!gib)
+		return NULL;
+
+	do {
+		gisa = READ_ONCE(gib->alert_list_origin);
+	} while (cmpxchg(&gib->alert_list_origin, gisa, 0) != gisa);
+
+	return (void *)(u64) gisa;
+}
+
 static void nullify_gisa(struct kvm_s390_gisa *gisa)
 {
 	memset(gisa, 0, sizeof(struct kvm_s390_gisa));