Commit 0d437906f6dca6167b37c8e1f6f6ec395bde6230
Committed by
Martin K. Petersen
1 parent
4ae61c68f7
scsi: core: scsi_io_completion hints on fastpath
Add likely() and unlikely() hints to conditionals on or near the fastpath. Signed-off-by: Douglas Gilbert <dgilbert@interlog.com> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Showing 1 changed file with 9 additions and 9 deletions Side-by-side Diff
drivers/scsi/scsi_lib.c
... | ... | @@ -1042,17 +1042,17 @@ |
1042 | 1042 | struct request *req = cmd->request; |
1043 | 1043 | blk_status_t blk_stat = BLK_STS_OK; |
1044 | 1044 | |
1045 | - if (result) /* does not necessarily mean there is an error */ | |
1045 | + if (unlikely(result)) /* a nz result may or may not be an error */ | |
1046 | 1046 | result = scsi_io_completion_nz_result(cmd, result, &blk_stat); |
1047 | 1047 | |
1048 | - if (blk_rq_is_passthrough(req)) { | |
1048 | + if (unlikely(blk_rq_is_passthrough(req))) { | |
1049 | 1049 | /* |
1050 | 1050 | * scsi_result_to_blk_status may have reset the host_byte |
1051 | 1051 | */ |
1052 | 1052 | scsi_req(req)->result = cmd->result; |
1053 | 1053 | scsi_req(req)->resid_len = scsi_get_resid(cmd); |
1054 | 1054 | |
1055 | - if (scsi_bidi_cmnd(cmd)) { | |
1055 | + if (unlikely(scsi_bidi_cmnd(cmd))) { | |
1056 | 1056 | /* |
1057 | 1057 | * Bidi commands Must be complete as a whole, |
1058 | 1058 | * both sides at once. |
... | ... | @@ -1065,7 +1065,7 @@ |
1065 | 1065 | } |
1066 | 1066 | } |
1067 | 1067 | |
1068 | - /* no bidi support for !blk_rq_is_passthrough yet */ | |
1068 | + /* no bidi support yet, other than in pass-through */ | |
1069 | 1069 | BUG_ON(blk_bidi_rq(req)); |
1070 | 1070 | |
1071 | 1071 | /* |
1072 | 1072 | |
... | ... | @@ -1081,13 +1081,13 @@ |
1081 | 1081 | * handle. Failed, zero length commands always need to drop down |
1082 | 1082 | * to retry code. Fast path should return in this block. |
1083 | 1083 | */ |
1084 | - if (blk_rq_bytes(req) > 0 || blk_stat == BLK_STS_OK) { | |
1085 | - if (!scsi_end_request(req, blk_stat, good_bytes, 0)) | |
1084 | + if (likely(blk_rq_bytes(req) > 0 || blk_stat == BLK_STS_OK)) { | |
1085 | + if (likely(!scsi_end_request(req, blk_stat, good_bytes, 0))) | |
1086 | 1086 | return; /* no bytes remaining */ |
1087 | 1087 | } |
1088 | 1088 | |
1089 | - /* Kill remainder if no retries. */ | |
1090 | - if (blk_stat && scsi_noretry_cmd(cmd)) { | |
1089 | + /* Kill remainder if no retries. */ | |
1090 | + if (unlikely(blk_stat && scsi_noretry_cmd(cmd))) { | |
1091 | 1091 | if (scsi_end_request(req, blk_stat, blk_rq_bytes(req), 0)) |
1092 | 1092 | BUG(); |
1093 | 1093 | return; |
... | ... | @@ -1097,7 +1097,7 @@ |
1097 | 1097 | * If there had been no error, but we have leftover bytes in the |
1098 | 1098 | * requeues just queue the command up again. |
1099 | 1099 | */ |
1100 | - if (result == 0) | |
1100 | + if (likely(result == 0)) | |
1101 | 1101 | scsi_io_completion_reprep(cmd, q); |
1102 | 1102 | else |
1103 | 1103 | scsi_io_completion_action(cmd, result); |