Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/qdio: optimize state inspection of HW-owned SBALs

When get_buf_states() gets called with count > 1, it scans the
corresponding number of SBAL states until it encounters a mismatch.

But when these SBALs are in a HW-owned state, the callers don't actually
care _how many_ such SBALs are on the queue. If we can't process the
first SBAL, we can't process any of the following SBALs either. So when
the first SBAL is HW-owned, skip the scan of the remaining SBALs and
thus save some CPU time.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Julian Wiedmann and committed by
Martin Schwidefsky
a698e137 5a19d670

+9 -2
+9 -2
drivers/s390/cio/qdio_main.c
··· 205 205 int auto_ack, int merge_pending) 206 206 { 207 207 unsigned char __state = 0; 208 - int i; 208 + int i = 1; 209 209 210 210 if (is_qebsm(q)) 211 211 return qdio_do_eqbs(q, state, bufnr, count, auto_ack); 212 212 213 213 /* get initial state: */ 214 214 __state = q->slsb.val[bufnr]; 215 + 216 + /* Bail out early if there is no work on the queue: */ 217 + if (__state & SLSB_OWNER_CU) 218 + goto out; 219 + 215 220 if (merge_pending && __state == SLSB_P_OUTPUT_PENDING) 216 221 __state = SLSB_P_OUTPUT_EMPTY; 217 222 218 - for (i = 1; i < count; i++) { 223 + for (; i < count; i++) { 219 224 bufnr = next_buf(bufnr); 220 225 221 226 /* merge PENDING into EMPTY: */ ··· 233 228 if (q->slsb.val[bufnr] != __state) 234 229 break; 235 230 } 231 + 232 + out: 236 233 *state = __state; 237 234 return i; 238 235 }