drivers/s390/scsi/zcsp_fc.c: Use prandom_u32_max() for backoff
Subsystems (3)
RFC PATCH 27/50 drivers/s390/scsi/zcsp_fc.c: Use prandom_u32_max() for backoff
We don't need crypto-grade random numbers for randomized backoffs.
(We could skip the if() if we wanted to rely on the undocumented fact that prandom_u32_max(0) always returns 0. That would be a net time saving it port_scan_backoff == 0 is rare; if it's common, the if() is false often enough to pay for itself. Not sure which applies here.)
--- drivers/s390/scsi/zfcp_fc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/scsi/zfcp_fc.c +1 -1
@@ -48,7 +48,7 @@ unsigned int zfcp_fc_port_scan_backoff(void) {if (!port_scan_backoff)return 0 ; -return get_random_int () % port_scan_backoff; +return prandom_u32_max (port_scan_backoff); }static void zfcp_fc_port_scan_time (struct zfcp_adapter *adapter)
Signature · 1 line
2.26.0
Quoted 7 lines · George Spelvin
We don't need crypto-grade random numbers for randomized backoffs.
(We could skip the
if()if we wanted to rely on the undocumented fact thatprandom_u32_max(0)always returns 0. That would be a net time saving itport_scan_backoff== 0 is rare; if it's common, theif()is false often enough to pay for itself. Not sure which applies here.)
Quoted 8 lines
Signed-off-by George Spelvin <[email protected]>Cc Heiko Carstens <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Christian Borntraeger <[email protected]>--- drivers/s390/scsi/zfcp_fc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Hello George,
it would be nice, if you could address the mails to the driver-maintainers (scripts/get_maintainer.pl drivers/s390/scsi/zfcp_fc.c will tell you that this is me and Steffen); I'd certainly have noticed it earlier then :-).
drivers/s390/scsi/zfcp_fc.c unsigned int zfcp_fc_port_scan_backoff(void) · line 51
Quoted 11 lines
drivers/s390/scsi/zfcp_fc.c +1
-1@@ -48,7 +48,7 @@ unsigned int zfcp_fc_port_scan_backoff(void) {if (!port_scan_backoff)return 0 ; -return get_random_int () % port_scan_backoff; +return prandom_u32_max (port_scan_backoff);
I think the change is fine. You are right, we don't need a crypto nonce here.
I think I'd let the zero-check stand as is, because the internal behaviour of prandom_u32_max() is, as you say, undocumented. This is not a performance critical code-path for us anyway.
Quoted 6 lines
drivers/s390/scsi/zfcp_fc.c +0
-0}static void zfcp_fc_port_scan_time (struct zfcp_adapter *adapter)Signature · 1 line
2.26.0
Steffen, do you have any objections? Otherwise I can queue this up - minus the somewhat mangled subject - for when we send something next time.
Signature · 4 lines
Best Regards, Benjamin Block / Linux on IBM Z Kernel Development / IBM Systems IBM Deutschland Research & Development GmbH / https://www.ibm.com/privacy Vorsitz. AufsR.: Gregor Pillen / Gesch�ftsf�hrung: Dirk Wittkopp Sitz der Gesellschaft: B�blingen / Registergericht: AmtsG Stuttgart, HRB 243294
Steffen Maier
Reviewed-byQuoted 25 lines · Benjamin Block
Quoted 7 lines · George Spelvin
We don't need crypto-grade random numbers for randomized backoffs.
(We could skip the
if()if we wanted to rely on the undocumented fact thatprandom_u32_max(0)always returns 0. That would be a net time saving itport_scan_backoff== 0 is rare; if it's common, theif()is false often enough to pay for itself. Not sure which applies here.)Quoted 8 lines
Signed-off-by George Spelvin <[email protected]>Cc Heiko Carstens <[email protected]>Cc Vasily Gorbik <[email protected]>Cc Christian Borntraeger <[email protected]>--- drivers/s390/scsi/zfcp_fc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Hello George,
it would be nice, if you could address the mails to the driver-maintainers (
scripts/get_maintainer.pl drivers/s390/scsi/zfcp_fc.cwill tell you that this is me and Steffen); I'd certainly have noticed it earlier then :-).Quoted 1 line
Quoted 10 lines
drivers/s390/scsi/zfcp_fc.c unsigned int zfcp_fc_port_scan_backoff(void) · line 51
Quoted 10 lines
drivers/s390/scsi/zfcp_fc.c +1
-1@@ -48,7 +48,7 @@ unsigned int zfcp_fc_port_scan_backoff(void) {if (!port_scan_backoff)return 0 ; -return get_random_int () % port_scan_backoff; +return prandom_u32_max (port_scan_backoff);
Quoted 7 lines
I think the change is fine. You are right, we don't need a crypto nonce here.
I think I'd let the zero-check stand as is, because the internal behaviour of
prandom_u32_max()is, as you say, undocumented. This is not a performance critical code-path for us anyway.
yes, let's keep the extra check as it's intentional and documented user interface for zfcp, so better be explicit
Quoted 11 lines
Quoted 7 lines
drivers/s390/scsi/zfcp_fc.c +0
-0}static void zfcp_fc_port_scan_time (struct zfcp_adapter *adapter)Signature · 1 line
2.26.0Steffen, do you have any objections? Otherwise I can queue this up - minus the somewhat mangled subject - for when we send something next time.
Signature · 11 lines
Mit freundlichen Gruessen / Kind regards Steffen Maier Linux on IBM Z Development https://www.ibm.com/privacy/us/en/ IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Matthias Hartmann Geschaeftsfuehrung: Dirk Wittkopp Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
Quoted 4 lines · Benjamin Block
it would be nice, if you could address the mails to the driver-maintainers (
scripts/get_maintainer.pl drivers/s390/scsi/zfcp_fc.cwill tell you that this is me and Steffen); I'd certainly have noticed it earlier then :-).
How the $%$# did I mess that up? I know choosing recipients for this series was mostly manual, becase it didn't fit the usual pattern of the entire series going to everyone affectrd by any part of it.
And then there waqs a whole lot of shuffling things into a logical order and grouping.
But I checked MAINTAINERS originally, I really did. :-(
Quoted 15 lines · George Spelvin
drivers/s390/scsi/zfcp_fc.c unsigned int zfcp_fc_port_scan_backoff(void) · line 51
Quoted 10 lines
drivers/s390/scsi/zfcp_fc.c +1
-1@@ -48,7 +48,7 @@ unsigned int zfcp_fc_port_scan_backoff(void) {if (!port_scan_backoff)return 0 ; -return get_random_int () % port_scan_backoff; +return prandom_u32_max (port_scan_backoff);I think the change is fine. You are right, we don't need a crypto nonce here.
Quoted 3 lines
I think I'd let the zero-check stand as is, because the internal behaviour of
prandom_u32_max()is, as you say, undocumented. This is not a performance critical code-path for us anyway.
I agree. Sorry, that comment in the commit message was a bit of a "not to self" that I didn't clean up. Feel free to rm it when queueing if you like.
Quoted 2 lines
Steffen, do you have any objections? Otherwise I can queue this up - minus the somewhat mangled subject - for when we send something next time.
Thank you, I'll put it in my "accepted" pile.