KVM: s390: gmap: use assign_bit() where applicable
PATCH 1/1 KVM: s390: gmap: use assign_bit() where applicable
From: Peng Fan <[email protected]>
Convert open-coded if/else with set_bit/clear_bit to the assign_bit API.
--- arch/s390/kvm/gmap/gmap.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
arch/s390/kvm/gmap/gmap.c +5 -12
@@ -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);
Signature · 1 line
2.51.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines
From: Peng Fan <[email protected]>
Convert open-coded if/else with set_bit/clear_bit to the
assign_bitAPI.Signed-off-by Peng Fan <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Heiko Carstens
maintainerQuoted 8 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Convert open-coded if/else with set_bit/clear_bit to the
assign_bitAPI.Signed-off-by Peng Fan <[email protected]>--- arch/s390/kvm/gmap/gmap.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
...
arch/s390/kvm/gmap/gmap.c static void gmap_add_child(struct gmap *parent, struct gmap *child) · line 99
Quoted 13 lines
arch/s390/kvm/gmap/gmap.c +4
-8-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.
Christian Borntraeger
maintainerAm 20.09.26 um 18:18 schrieb Heiko Carstens:
Quoted 17 lines · Peng Fan (OSS)
Quoted 8 lines
From: Peng Fan <[email protected]>
Convert open-coded if/else with set_bit/clear_bit to the
assign_bitAPI.Signed-off-by Peng Fan <[email protected]>--- arch/s390/kvm/gmap/gmap.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)...
Quoted 7 lines
arch/s390/kvm/gmap/gmap.c +2
-4-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));
Quoted 8 lines
arch/s390/kvm/gmap/gmap.c static void gmap_add_child(struct gmap *parent, struct gmap *child) · line 99
Quoted 6 lines
arch/s390/kvm/gmap/gmap.c +2
-4-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.
Quoted 28 lines · Christian Borntraeger
Am 20.09.26 um 18:18 schrieb Heiko Carstens:
Quoted 10 lines · Peng Fan (OSS)
Quoted 8 lines
From: Peng Fan <[email protected]>
Convert open-coded if/else with set_bit/clear_bit to the
assign_bitAPI.Signed-off-by Peng Fan <[email protected]>--- arch/s390/kvm/gmap/gmap.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)...
Quoted 14 lines
arch/s390/kvm/gmap/gmap.c static void gmap_add_child(struct gmap *parent, struct gmap *child) · line 99
Quoted 12 lines
arch/s390/kvm/gmap/gmap.c +4
-8-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.
Quoted 1 line
I agree, this is not a good use for the
assign_bithelper.
No problem. Let's drop the patch.
Thanks,
Peng