mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] KVM: s390: gmap: use assign_bit() where applicable
@ 2026-09-20  2:26 Peng Fan (OSS)
  2026-09-20 16:18 ` Heiko Carstens
  0 siblings, 1 reply; 4+ messages in thread
From: Peng Fan (OSS) @ 2026-09-20  2:26 UTC (permalink / raw)
  To: Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
	David Hildenbrand, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Sven Schnelle, Steffen Eiden,
	Christoph Schlameuss
  Cc: linux-kernel, Peng Fan, kvm, linux-s390

From: Peng Fan <peng.fan@nxp.com>

Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 arch/s390/kvm/gmap/gmap.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/arch/s390/kvm/gmap/gmap.c b/arch/s390/kvm/gmap/gmap.c
index 3f3fa864cc36..89a5ed4ac440 100644
--- a/arch/s390/kvm/gmap/gmap.c
+++ b/arch/s390/kvm/gmap/gmap.c
@@ -90,20 +90,13 @@ static void gmap_add_child(struct gmap *parent, struct gmap *child)
 
 	child->parent = parent;
 
-	if (is_ucontrol(parent))
-		set_bit(GMAP_FLAG_IS_UCONTROL, &child->flags);
-	else
-		clear_bit(GMAP_FLAG_IS_UCONTROL, &child->flags);
+	assign_bit(GMAP_FLAG_IS_UCONTROL, &child->flags, is_ucontrol(parent));
 
-	if (test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &parent->flags))
-		set_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &child->flags);
-	else
-		clear_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &child->flags);
+	assign_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &child->flags,
+		   test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &parent->flags));
 
-	if (test_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &parent->flags))
-		set_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags);
-	else
-		clear_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags);
+	assign_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags,
+		   test_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &parent->flags));
 
 	if (kvm_is_ucontrol(parent->kvm))
 		clear_bit(GMAP_FLAG_OWNS_PAGETABLES, &child->flags);
-- 
2.51.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: s390: gmap: use assign_bit() where applicable
  2026-09-20  2:26 [PATCH] KVM: s390: gmap: use assign_bit() where applicable Peng Fan (OSS)
@ 2026-09-20 16:18 ` Heiko Carstens
  2026-09-21  7:06   ` Christian Borntraeger
  0 siblings, 1 reply; 4+ messages in thread
From: Heiko Carstens @ 2026-09-20 16:18 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
	David Hildenbrand, Vasily Gorbik, Alexander Gordeev,
	Sven Schnelle, Steffen Eiden, Christoph Schlameuss, linux-kernel,
	Peng Fan, kvm, linux-s390

On Sun, Sep 20, 2026 at 10:26:25AM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  arch/s390/kvm/gmap/gmap.c | 17 +++++------------
>  1 file changed, 5 insertions(+), 12 deletions(-)
...
> -	if (test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &parent->flags))
> -		set_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &child->flags);
> -	else
> -		clear_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &child->flags);
> +	assign_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &child->flags,
> +		   test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &parent->flags));
>  
> -	if (test_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &parent->flags))
> -		set_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags);
> -	else
> -		clear_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags);
> +	assign_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags,
> +		   test_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &parent->flags));

This turns something which was easily readable into an unreadable mess.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: s390: gmap: use assign_bit() where applicable
  2026-09-20 16:18 ` Heiko Carstens
@ 2026-09-21  7:06   ` Christian Borntraeger
  2026-09-21  7:17     ` Peng Fan
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Borntraeger @ 2026-09-21  7:06 UTC (permalink / raw)
  To: Heiko Carstens, Peng Fan (OSS)
  Cc: Janosch Frank, Claudio Imbrenda, David Hildenbrand,
	Vasily Gorbik, Alexander Gordeev, Sven Schnelle, Steffen Eiden,
	Christoph Schlameuss, linux-kernel, Peng Fan, kvm, linux-s390



Am 20.09.26 um 18:18 schrieb Heiko Carstens:
> On Sun, Sep 20, 2026 at 10:26:25AM +0800, Peng Fan (OSS) wrote:
>> From: Peng Fan <peng.fan@nxp.com>
>>
>> Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.
>>
>> Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> ---
>>   arch/s390/kvm/gmap/gmap.c | 17 +++++------------
>>   1 file changed, 5 insertions(+), 12 deletions(-)
> ...
>> -	if (test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &parent->flags))
>> -		set_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &child->flags);
>> -	else
>> -		clear_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &child->flags);
>> +	assign_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &child->flags,
>> +		   test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &parent->flags));
>>   
>> -	if (test_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &parent->flags))
>> -		set_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags);
>> -	else
>> -		clear_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags);
>> +	assign_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags,
>> +		   test_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &parent->flags));
> 
> This turns something which was easily readable into an unreadable mess.

I agree, this is not a good use for the assign_bit helper.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] KVM: s390: gmap: use assign_bit() where applicable
  2026-09-21  7:06   ` Christian Borntraeger
@ 2026-09-21  7:17     ` Peng Fan
  0 siblings, 0 replies; 4+ messages in thread
From: Peng Fan @ 2026-09-21  7:17 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Heiko Carstens, Janosch Frank, Claudio Imbrenda,
	David Hildenbrand, Vasily Gorbik, Alexander Gordeev,
	Sven Schnelle, Steffen Eiden, Christoph Schlameuss, linux-kernel,
	Peng Fan, kvm, linux-s390

On Mon, Sep 21, 2026 at 09:06:26AM +0200, Christian Borntraeger wrote:
>
>
>Am 20.09.26 um 18:18 schrieb Heiko Carstens:
>> On Sun, Sep 20, 2026 at 10:26:25AM +0800, Peng Fan (OSS) wrote:
>> > From: Peng Fan <peng.fan@nxp.com>
>> > 
>> > Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.
>> > 
>> > Signed-off-by: Peng Fan <peng.fan@nxp.com>
>> > ---
>> >   arch/s390/kvm/gmap/gmap.c | 17 +++++------------
>> >   1 file changed, 5 insertions(+), 12 deletions(-)
>> ...
>> > -	if (test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &parent->flags))
>> > -		set_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &child->flags);
>> > -	else
>> > -		clear_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &child->flags);
>> > +	assign_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &child->flags,
>> > +		   test_bit(GMAP_FLAG_ALLOW_HPAGE_1M, &parent->flags));
>> > -	if (test_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &parent->flags))
>> > -		set_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags);
>> > -	else
>> > -		clear_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags);
>> > +	assign_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &child->flags,
>> > +		   test_bit(GMAP_FLAG_ALLOW_HPAGE_2G, &parent->flags));
>> 
>> This turns something which was easily readable into an unreadable mess.
>
>I agree, this is not a good use for the assign_bit helper.

No problem. Let's drop the patch.

Thanks,
Peng

>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-09-21  7:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-20  2:26 [PATCH] KVM: s390: gmap: use assign_bit() where applicable Peng Fan (OSS)
2026-09-20 16:18 ` Heiko Carstens
2026-09-21  7:06   ` Christian Borntraeger
2026-09-21  7:17     ` Peng Fan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®