From patchwork Thu Jul 12 17:35:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Gilbert X-Patchwork-Id: 10522079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 76E72602C8 for ; Thu, 12 Jul 2018 17:35:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58B6821327 for ; Thu, 12 Jul 2018 17:35:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B1B629B76; Thu, 12 Jul 2018 17:35:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BADA821327 for ; Thu, 12 Jul 2018 17:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726463AbeGLRq0 (ORCPT ); Thu, 12 Jul 2018 13:46:26 -0400 Received: from smtp.infotech.no ([82.134.31.41]:54121 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725967AbeGLRq0 (ORCPT ); Thu, 12 Jul 2018 13:46:26 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id 58E5F20423B; Thu, 12 Jul 2018 19:35:51 +0200 (CEST) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id n+c4Y5lbmgif; Thu, 12 Jul 2018 19:35:45 +0200 (CEST) Received: from xtwo70.bingwo.ca (host-45-58-196-245.dyn.295.ca [45.58.196.245]) by smtp.infotech.no (Postfix) with ESMTPA id 6B38520418C; Thu, 12 Jul 2018 19:35:43 +0200 (CEST) From: Douglas Gilbert To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, hare@suse.de, bart.vanassche@wdc.com, jthumshirn@suse.de, ming.lei@redhat.com Subject: [PATCH] scsi_debug: skip long delays when ndelay small Date: Thu, 12 Jul 2018 13:35:42 -0400 Message-Id: <20180712173542.8773-1-dgilbert@interlog.com> X-Mailer: git-send-email 2.17.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A test program's runtime became impractically long since any non zero ndelay (e.g. 1 nanosec) caused Start Stop Unit to delay over 8 magnitudes greater than other commands. This patch skips long delays (on Start Stop Unit and Synchronize Cache) if ndelay is less than or equal to 10 microsecs. Signed-off-by: Douglas Gilbert --- This patch is against MKP's 4.19/scsi-queue branch. Re-arrange if condition so least likely is first part of && . drivers/scsi/scsi_debug.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 24d7496cd9e2..4dda192b8fba 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -5790,11 +5790,13 @@ static int scsi_debug_queuecommand(struct Scsi_Host *shost, fini: if (F_DELAY_OVERR & flags) return schedule_resp(scp, devip, errsts, pfp, 0, 0); - else if ((sdebug_jdelay || sdebug_ndelay) && (flags & F_LONG_DELAY)) { + else if ((flags & F_LONG_DELAY) && (sdebug_jdelay > 0 || + sdebug_ndelay > 10000)) { /* - * If any delay is active, for F_SSU_DELAY want at least 1 - * second and if sdebug_jdelay>0 want a long delay of that - * many seconds; for F_SYNC_DELAY want 1/20 of that. + * Skip long delays if ndelay <= 10 microseconds. Otherwise + * for Start Stop Unit (SSU) want at least 1 second delay and + * if sdebug_jdelay>1 want a long delay of that many seconds. + * For Synchronize Cache want 1/20 of SSU's delay. */ int jdelay = (sdebug_jdelay < 2) ? 1 : sdebug_jdelay; int denom = (flags & F_SYNC_DELAY) ? 20 : 1;