x86: fix off-by-one in nr_irqs_gsi calculation
PATCH 1/1 x86: fix off-by-one in nr_irqs_gsi calculation
highest_gsi() returns the last valid GSI, not a count.
xen/arch/x86/io_apic.c +3 -1
@@ -2531,7 +2531,9 @@ void __init init_ioapic_mappings(void) } } - nr_irqs_gsi =max (nr_irqs_gsi,highest_gsi ()); + i =highest_gsi (); +if ( i >= nr_irqs_gsi ) + nr_irqs_gsi = i +1 ;if ( max_gsi_irqs ==0 ) max_gsi_irqs = nr_irqs ? nr_irqs /8 :PAGE_SIZE ;
x86: fix off-by-one in nr_irqs_gsi calculation
highest_gsi() returns the last valid GSI, not a count.
xen/arch/x86/io_apic.c +3 -1
@@ -2531,7 +2531,9 @@ void __init init_ioapic_mappings(void) } } - nr_irqs_gsi =max (nr_irqs_gsi,highest_gsi ()); + i =highest_gsi (); +if ( i >= nr_irqs_gsi ) + nr_irqs_gsi = i +1 ;if ( max_gsi_irqs ==0 ) max_gsi_irqs = nr_irqs ? nr_irqs /8 :PAGE_SIZE ;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 3 lines · Jan Beulich
highest_gsi()returns the last valid GSI, not a count.Signed-off-by Jan Beulich <[email protected]>
Why not "nr_irqs_gsi = max(nr_irqs_gsi, highest_gsi()+1)"?
Quoted 20 lines
xen/arch/x86/io_apic.c +3
-1@@ -2531,7 +2531,9 @@ void __init init_ioapic_mappings(void) } } - nr_irqs_gsi =max (nr_irqs_gsi,highest_gsi ()); + i =highest_gsi (); +if ( i >= nr_irqs_gsi ) + nr_irqs_gsi = i +1 ;if ( max_gsi_irqs ==0 ) max_gsi_irqs = nr_irqs ? nr_irqs /8 :PAGE_SIZE ;_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 8 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 3 lines · Jan Beulich
highest_gsi()returns the last valid GSI, not a count.Signed-off-by Jan Beulich <[email protected]>Why not "
nr_irqs_gsi=max(nr_irqs_gsi, highest_gsi()+1)"?
While I think x = max(y, z) is fine, I generally find x = max(x, y) pretty useless - what's the point of assigning a value to itself? This is __init code, so code size considerations probably don't matter, but I'd still like to not encourage inefficient code like this to be used elsewhere by giving a bad example...
Jan
Quoted 20 lines
Quoted 20 lines
xen/arch/x86/io_apic.c +3
-1@@ -2531,7 +2531,9 @@ void __init init_ioapic_mappings(void) } } - nr_irqs_gsi =max (nr_irqs_gsi,highest_gsi ()); + i =highest_gsi (); +if ( i >= nr_irqs_gsi ) + nr_irqs_gsi = i +1 ;if ( max_gsi_irqs ==0 ) max_gsi_irqs = nr_irqs ? nr_irqs /8 :PAGE_SIZE ;_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 7 lines · Jan Beulich
Quoted 7 lines
Quoted 1 line
Quoted 1 line · Keir Fraser
Quoted 3 lines · Jan Beulich
highest_gsi()returns the last valid GSI, not a count.Signed-off-by Jan Beulich <[email protected]>
Quoted 7 lines
Quoted 1 line
Why not "
nr_irqs_gsi=max(nr_irqs_gsi, highest_gsi()+1)"?While I think x =
max(y, z)is fine, I generally find x =max(x, y)pretty useless - what's the point of assigning a value to itself? This is__initcode, so code size considerations probably don't matter, but I'd still like to not encourage inefficient code like this to be used elsewhere by giving a bad example...
I think the code is clearer with max(). An even stronger argument is that it makes the intent of the patch much more obvious too. I think you should leave the max() construct in place in this patch.
-- Keir
Quoted 25 lines
Jan
Quoted 20 lines
Quoted 20 lines
xen/arch/x86/io_apic.c +3
-1@@ -2531,7 +2531,9 @@ void __init init_ioapic_mappings(void) } } - nr_irqs_gsi =max (nr_irqs_gsi,highest_gsi ()); + i =highest_gsi (); +if ( i >= nr_irqs_gsi ) + nr_irqs_gsi = i +1 ;if ( max_gsi_irqs ==0 ) max_gsi_irqs = nr_irqs ? nr_irqs /8 :PAGE_SIZE ;_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel